documentation.d.ts 3.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573
  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 http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see http://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 http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see http://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. }
  1054. declare module BABYLON {
  1055. /**
  1056. * This represents the required contract to create a new type of texture loader.
  1057. */
  1058. export interface IInternalTextureLoader {
  1059. /**
  1060. * Defines wether the loader supports cascade loading the different faces.
  1061. */
  1062. supportCascades: boolean;
  1063. /**
  1064. * This returns if the loader support the current file information.
  1065. * @param extension defines the file extension of the file being loaded
  1066. * @returns true if the loader can load the specified file
  1067. */
  1068. canLoad(extension: string): boolean;
  1069. /**
  1070. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1071. * @param data contains the texture data
  1072. * @param texture defines the BabylonJS internal texture
  1073. * @param createPolynomials will be true if polynomials have been requested
  1074. * @param onLoad defines the callback to trigger once the texture is ready
  1075. * @param onError defines the callback to trigger in case of error
  1076. */
  1077. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1078. /**
  1079. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1080. * @param data contains the texture data
  1081. * @param texture defines the BabylonJS internal texture
  1082. * @param callback defines the method to call once ready to upload
  1083. */
  1084. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1085. }
  1086. }
  1087. declare module BABYLON {
  1088. /**
  1089. * Class used to store and describe the pipeline context associated with an effect
  1090. */
  1091. export interface IPipelineContext {
  1092. /**
  1093. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1094. */
  1095. isAsync: boolean;
  1096. /**
  1097. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1098. */
  1099. isReady: boolean;
  1100. /** @hidden */
  1101. _getVertexShaderCode(): string | null;
  1102. /** @hidden */
  1103. _getFragmentShaderCode(): string | null;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module BABYLON {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module BABYLON {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module BABYLON {
  1143. /** @hidden */
  1144. export interface ProcessingOptions {
  1145. defines: string[];
  1146. indexParameters: any;
  1147. isFragment: boolean;
  1148. shouldUseHighPrecisionShader: boolean;
  1149. supportsUniformBuffers: boolean;
  1150. shadersRepository: string;
  1151. includesShadersStore: {
  1152. [key: string]: string;
  1153. };
  1154. processor?: IShaderProcessor;
  1155. version: string;
  1156. platformName: string;
  1157. lookForClosingBracketForUniformBuffer?: boolean;
  1158. }
  1159. }
  1160. declare module BABYLON {
  1161. /** @hidden */
  1162. export class ShaderCodeNode {
  1163. line: string;
  1164. children: ShaderCodeNode[];
  1165. additionalDefineKey?: string;
  1166. additionalDefineValue?: string;
  1167. isValid(preprocessors: {
  1168. [key: string]: string;
  1169. }): boolean;
  1170. process(preprocessors: {
  1171. [key: string]: string;
  1172. }, options: ProcessingOptions): string;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export class ShaderCodeCursor {
  1178. private _lines;
  1179. lineIndex: number;
  1180. get currentLine(): string;
  1181. get canRead(): boolean;
  1182. set lines(value: string[]);
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1188. process(preprocessors: {
  1189. [key: string]: string;
  1190. }, options: ProcessingOptions): string;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderDefineExpression {
  1196. isTrue(preprocessors: {
  1197. [key: string]: string;
  1198. }): boolean;
  1199. private static _OperatorPriority;
  1200. private static _Stack;
  1201. static postfixToInfix(postfix: string[]): string;
  1202. static infixToPostfix(infix: string): string[];
  1203. }
  1204. }
  1205. declare module BABYLON {
  1206. /** @hidden */
  1207. export class ShaderCodeTestNode extends ShaderCodeNode {
  1208. testExpression: ShaderDefineExpression;
  1209. isValid(preprocessors: {
  1210. [key: string]: string;
  1211. }): boolean;
  1212. }
  1213. }
  1214. declare module BABYLON {
  1215. /** @hidden */
  1216. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1217. define: string;
  1218. not: boolean;
  1219. constructor(define: string, not?: boolean);
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1238. leftOperand: ShaderDefineExpression;
  1239. rightOperand: ShaderDefineExpression;
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /** @hidden */
  1247. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1248. define: string;
  1249. operand: string;
  1250. testValue: string;
  1251. constructor(define: string, operand: string, testValue: string);
  1252. isTrue(preprocessors: {
  1253. [key: string]: string;
  1254. }): boolean;
  1255. }
  1256. }
  1257. declare module BABYLON {
  1258. /**
  1259. * Class used to enable access to offline support
  1260. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1261. */
  1262. export interface IOfflineProvider {
  1263. /**
  1264. * Gets a boolean indicating if scene must be saved in the database
  1265. */
  1266. enableSceneOffline: boolean;
  1267. /**
  1268. * Gets a boolean indicating if textures must be saved in the database
  1269. */
  1270. enableTexturesOffline: boolean;
  1271. /**
  1272. * Open the offline support and make it available
  1273. * @param successCallback defines the callback to call on success
  1274. * @param errorCallback defines the callback to call on error
  1275. */
  1276. open(successCallback: () => void, errorCallback: () => void): void;
  1277. /**
  1278. * Loads an image from the offline support
  1279. * @param url defines the url to load from
  1280. * @param image defines the target DOM image
  1281. */
  1282. loadImage(url: string, image: HTMLImageElement): void;
  1283. /**
  1284. * Loads a file from offline support
  1285. * @param url defines the URL to load from
  1286. * @param sceneLoaded defines a callback to call on success
  1287. * @param progressCallBack defines a callback to call when progress changed
  1288. * @param errorCallback defines a callback to call on error
  1289. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1290. */
  1291. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1292. }
  1293. }
  1294. declare module BABYLON {
  1295. /**
  1296. * Class used to help managing file picking and drag'n'drop
  1297. * File Storage
  1298. */
  1299. export class FilesInputStore {
  1300. /**
  1301. * List of files ready to be loaded
  1302. */
  1303. static FilesToLoad: {
  1304. [key: string]: File;
  1305. };
  1306. }
  1307. }
  1308. declare module BABYLON {
  1309. /**
  1310. * Class used to define a retry strategy when error happens while loading assets
  1311. */
  1312. export class RetryStrategy {
  1313. /**
  1314. * Function used to defines an exponential back off strategy
  1315. * @param maxRetries defines the maximum number of retries (3 by default)
  1316. * @param baseInterval defines the interval between retries
  1317. * @returns the strategy function to use
  1318. */
  1319. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1320. }
  1321. }
  1322. declare module BABYLON {
  1323. /**
  1324. * @ignore
  1325. * Application error to support additional information when loading a file
  1326. */
  1327. export abstract class BaseError extends Error {
  1328. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1329. }
  1330. }
  1331. declare module BABYLON {
  1332. /** @ignore */
  1333. export class LoadFileError extends BaseError {
  1334. request?: WebRequest;
  1335. file?: File;
  1336. /**
  1337. * Creates a new LoadFileError
  1338. * @param message defines the message of the error
  1339. * @param request defines the optional web request
  1340. * @param file defines the optional file
  1341. */
  1342. constructor(message: string, object?: WebRequest | File);
  1343. }
  1344. /** @ignore */
  1345. export class RequestFileError extends BaseError {
  1346. request: WebRequest;
  1347. /**
  1348. * Creates a new LoadFileError
  1349. * @param message defines the message of the error
  1350. * @param request defines the optional web request
  1351. */
  1352. constructor(message: string, request: WebRequest);
  1353. }
  1354. /** @ignore */
  1355. export class ReadFileError extends BaseError {
  1356. file: File;
  1357. /**
  1358. * Creates a new ReadFileError
  1359. * @param message defines the message of the error
  1360. * @param file defines the optional file
  1361. */
  1362. constructor(message: string, file: File);
  1363. }
  1364. /**
  1365. * @hidden
  1366. */
  1367. export class FileTools {
  1368. /**
  1369. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1370. */
  1371. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1372. /**
  1373. * Gets or sets the base URL to use to load assets
  1374. */
  1375. static BaseUrl: string;
  1376. /**
  1377. * Default behaviour for cors in the application.
  1378. * It can be a string if the expected behavior is identical in the entire app.
  1379. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1380. */
  1381. static CorsBehavior: string | ((url: string | string[]) => string);
  1382. /**
  1383. * Gets or sets a function used to pre-process url before using them to load assets
  1384. */
  1385. static PreprocessUrl: (url: string) => string;
  1386. /**
  1387. * Removes unwanted characters from an url
  1388. * @param url defines the url to clean
  1389. * @returns the cleaned url
  1390. */
  1391. private static _CleanUrl;
  1392. /**
  1393. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1394. * @param url define the url we are trying
  1395. * @param element define the dom element where to configure the cors policy
  1396. */
  1397. static SetCorsBehavior(url: string | string[], element: {
  1398. crossOrigin: string | null;
  1399. }): void;
  1400. /**
  1401. * Loads an image as an HTMLImageElement.
  1402. * @param input url string, ArrayBuffer, or Blob to load
  1403. * @param onLoad callback called when the image successfully loads
  1404. * @param onError callback called when the image fails to load
  1405. * @param offlineProvider offline provider for caching
  1406. * @param mimeType optional mime type
  1407. * @returns the HTMLImageElement of the loaded image
  1408. */
  1409. 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>;
  1410. /**
  1411. * Reads a file from a File object
  1412. * @param file defines the file to load
  1413. * @param onSuccess defines the callback to call when data is loaded
  1414. * @param onProgress defines the callback to call during loading process
  1415. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1416. * @param onError defines the callback to call when an error occurs
  1417. * @returns a file request object
  1418. */
  1419. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1420. /**
  1421. * Loads a file from a url
  1422. * @param url url to load
  1423. * @param onSuccess callback called when the file successfully loads
  1424. * @param onProgress callback called while file is loading (if the server supports this mode)
  1425. * @param offlineProvider defines the offline provider for caching
  1426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @returns a file request object
  1429. */
  1430. 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;
  1431. /**
  1432. * Loads a file
  1433. * @param url url to load
  1434. * @param onSuccess callback called when the file successfully loads
  1435. * @param onProgress callback called while file is loading (if the server supports this mode)
  1436. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1437. * @param onError callback called when the file fails to load
  1438. * @param onOpened callback called when the web request is opened
  1439. * @returns a file request object
  1440. */
  1441. 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;
  1442. /**
  1443. * Checks if the loaded document was accessed via `file:`-Protocol.
  1444. * @returns boolean
  1445. */
  1446. static IsFileURL(): boolean;
  1447. }
  1448. }
  1449. declare module BABYLON {
  1450. /** @hidden */
  1451. export class ShaderProcessor {
  1452. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1453. private static _ProcessPrecision;
  1454. private static _ExtractOperation;
  1455. private static _BuildSubExpression;
  1456. private static _BuildExpression;
  1457. private static _MoveCursorWithinIf;
  1458. private static _MoveCursor;
  1459. private static _EvaluatePreProcessors;
  1460. private static _PreparePreProcessors;
  1461. private static _ProcessShaderConversion;
  1462. private static _ProcessIncludes;
  1463. /**
  1464. * Loads a file from a url
  1465. * @param url url to load
  1466. * @param onSuccess callback called when the file successfully loads
  1467. * @param onProgress callback called while file is loading (if the server supports this mode)
  1468. * @param offlineProvider defines the offline provider for caching
  1469. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1470. * @param onError callback called when the file fails to load
  1471. * @returns a file request object
  1472. * @hidden
  1473. */
  1474. 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;
  1475. }
  1476. }
  1477. declare module BABYLON {
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module BABYLON {
  1545. /**
  1546. * Interface used to define common properties for effect fallbacks
  1547. */
  1548. export interface IEffectFallbacks {
  1549. /**
  1550. * Removes the defines that should be removed when falling back.
  1551. * @param currentDefines defines the current define statements for the shader.
  1552. * @param effect defines the current effect we try to compile
  1553. * @returns The resulting defines with defines of the current rank removed.
  1554. */
  1555. reduce(currentDefines: string, effect: Effect): string;
  1556. /**
  1557. * Removes the fallback from the bound mesh.
  1558. */
  1559. unBindMesh(): void;
  1560. /**
  1561. * Checks to see if more fallbacks are still availible.
  1562. */
  1563. hasMoreFallbacks: boolean;
  1564. }
  1565. }
  1566. declare module BABYLON {
  1567. /**
  1568. * Class used to evalaute queries containing `and` and `or` operators
  1569. */
  1570. export class AndOrNotEvaluator {
  1571. /**
  1572. * Evaluate a query
  1573. * @param query defines the query to evaluate
  1574. * @param evaluateCallback defines the callback used to filter result
  1575. * @returns true if the query matches
  1576. */
  1577. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1578. private static _HandleParenthesisContent;
  1579. private static _SimplifyNegation;
  1580. }
  1581. }
  1582. declare module BABYLON {
  1583. /**
  1584. * Class used to store custom tags
  1585. */
  1586. export class Tags {
  1587. /**
  1588. * Adds support for tags on the given object
  1589. * @param obj defines the object to use
  1590. */
  1591. static EnableFor(obj: any): void;
  1592. /**
  1593. * Removes tags support
  1594. * @param obj defines the object to use
  1595. */
  1596. static DisableFor(obj: any): void;
  1597. /**
  1598. * Gets a boolean indicating if the given object has tags
  1599. * @param obj defines the object to use
  1600. * @returns a boolean
  1601. */
  1602. static HasTags(obj: any): boolean;
  1603. /**
  1604. * Gets the tags available on a given object
  1605. * @param obj defines the object to use
  1606. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1607. * @returns the tags
  1608. */
  1609. static GetTags(obj: any, asString?: boolean): any;
  1610. /**
  1611. * Adds tags to an object
  1612. * @param obj defines the object to use
  1613. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1614. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1615. */
  1616. static AddTagsTo(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _AddTagTo(obj: any, tag: string): void;
  1621. /**
  1622. * Removes specific tags from a specific object
  1623. * @param obj defines the object to use
  1624. * @param tagsString defines the tags to remove
  1625. */
  1626. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1627. /**
  1628. * @hidden
  1629. */
  1630. static _RemoveTagFrom(obj: any, tag: string): void;
  1631. /**
  1632. * Defines if tags hosted on an object match a given query
  1633. * @param obj defines the object to use
  1634. * @param tagsQuery defines the tag query
  1635. * @returns a boolean
  1636. */
  1637. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1638. }
  1639. }
  1640. declare module BABYLON {
  1641. /**
  1642. * Scalar computation library
  1643. */
  1644. export class Scalar {
  1645. /**
  1646. * Two pi constants convenient for computation.
  1647. */
  1648. static TwoPi: number;
  1649. /**
  1650. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1651. * @param a number
  1652. * @param b number
  1653. * @param epsilon (default = 1.401298E-45)
  1654. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1655. */
  1656. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1657. /**
  1658. * Returns a string : the upper case translation of the number i to hexadecimal.
  1659. * @param i number
  1660. * @returns the upper case translation of the number i to hexadecimal.
  1661. */
  1662. static ToHex(i: number): string;
  1663. /**
  1664. * Returns -1 if value is negative and +1 is value is positive.
  1665. * @param value the value
  1666. * @returns the value itself if it's equal to zero.
  1667. */
  1668. static Sign(value: number): number;
  1669. /**
  1670. * Returns the value itself if it's between min and max.
  1671. * Returns min if the value is lower than min.
  1672. * Returns max if the value is greater than max.
  1673. * @param value the value to clmap
  1674. * @param min the min value to clamp to (default: 0)
  1675. * @param max the max value to clamp to (default: 1)
  1676. * @returns the clamped value
  1677. */
  1678. static Clamp(value: number, min?: number, max?: number): number;
  1679. /**
  1680. * the log2 of value.
  1681. * @param value the value to compute log2 of
  1682. * @returns the log2 of value.
  1683. */
  1684. static Log2(value: number): number;
  1685. /**
  1686. * Loops the value, so that it is never larger than length and never smaller than 0.
  1687. *
  1688. * This is similar to the modulo operator but it works with floating point numbers.
  1689. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1690. * With t = 5 and length = 2.5, the result would be 0.0.
  1691. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1692. * @param value the value
  1693. * @param length the length
  1694. * @returns the looped value
  1695. */
  1696. static Repeat(value: number, length: number): number;
  1697. /**
  1698. * Normalize the value between 0.0 and 1.0 using min and max values
  1699. * @param value value to normalize
  1700. * @param min max to normalize between
  1701. * @param max min to normalize between
  1702. * @returns the normalized value
  1703. */
  1704. static Normalize(value: number, min: number, max: number): number;
  1705. /**
  1706. * Denormalize the value from 0.0 and 1.0 using min and max values
  1707. * @param normalized value to denormalize
  1708. * @param min max to denormalize between
  1709. * @param max min to denormalize between
  1710. * @returns the denormalized value
  1711. */
  1712. static Denormalize(normalized: number, min: number, max: number): number;
  1713. /**
  1714. * Calculates the shortest difference between two given angles given in degrees.
  1715. * @param current current angle in degrees
  1716. * @param target target angle in degrees
  1717. * @returns the delta
  1718. */
  1719. static DeltaAngle(current: number, target: number): number;
  1720. /**
  1721. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1722. * @param tx value
  1723. * @param length length
  1724. * @returns The returned value will move back and forth between 0 and length
  1725. */
  1726. static PingPong(tx: number, length: number): number;
  1727. /**
  1728. * Interpolates between min and max with smoothing at the limits.
  1729. *
  1730. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1731. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1732. * @param from from
  1733. * @param to to
  1734. * @param tx value
  1735. * @returns the smooth stepped value
  1736. */
  1737. static SmoothStep(from: number, to: number, tx: number): number;
  1738. /**
  1739. * Moves a value current towards target.
  1740. *
  1741. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1742. * Negative values of maxDelta pushes the value away from target.
  1743. * @param current current value
  1744. * @param target target value
  1745. * @param maxDelta max distance to move
  1746. * @returns resulting value
  1747. */
  1748. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1749. /**
  1750. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1751. *
  1752. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1753. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1754. * @param current current value
  1755. * @param target target value
  1756. * @param maxDelta max distance to move
  1757. * @returns resulting angle
  1758. */
  1759. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1760. /**
  1761. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1762. * @param start start value
  1763. * @param end target value
  1764. * @param amount amount to lerp between
  1765. * @returns the lerped value
  1766. */
  1767. static Lerp(start: number, end: number, amount: number): number;
  1768. /**
  1769. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1771. * @param start start value
  1772. * @param end target value
  1773. * @param amount amount to lerp between
  1774. * @returns the lerped value
  1775. */
  1776. static LerpAngle(start: number, end: number, amount: number): number;
  1777. /**
  1778. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1779. * @param a start value
  1780. * @param b target value
  1781. * @param value value between a and b
  1782. * @returns the inverseLerp value
  1783. */
  1784. static InverseLerp(a: number, b: number, value: number): number;
  1785. /**
  1786. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1787. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1788. * @param value1 spline value
  1789. * @param tangent1 spline value
  1790. * @param value2 spline value
  1791. * @param tangent2 spline value
  1792. * @param amount input value
  1793. * @returns hermite result
  1794. */
  1795. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1796. /**
  1797. * Returns a random float number between and min and max values
  1798. * @param min min value of random
  1799. * @param max max value of random
  1800. * @returns random value
  1801. */
  1802. static RandomRange(min: number, max: number): number;
  1803. /**
  1804. * This function returns percentage of a number in a given range.
  1805. *
  1806. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1807. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1808. * @param number to convert to percentage
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the percentage
  1812. */
  1813. static RangeToPercent(number: number, min: number, max: number): number;
  1814. /**
  1815. * This function returns number that corresponds to the percentage in a given range.
  1816. *
  1817. * PercentToRange(0.34,0,100) will return 34.
  1818. * @param percent to convert to number
  1819. * @param min min range
  1820. * @param max max range
  1821. * @returns the number
  1822. */
  1823. static PercentToRange(percent: number, min: number, max: number): number;
  1824. /**
  1825. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1826. * @param angle The angle to normalize in radian.
  1827. * @return The converted angle.
  1828. */
  1829. static NormalizeRadians(angle: number): number;
  1830. }
  1831. }
  1832. declare module BABYLON {
  1833. /**
  1834. * Constant used to convert a value to gamma space
  1835. * @ignorenaming
  1836. */
  1837. export const ToGammaSpace: number;
  1838. /**
  1839. * Constant used to convert a value to linear space
  1840. * @ignorenaming
  1841. */
  1842. export const ToLinearSpace = 2.2;
  1843. /**
  1844. * Constant used to define the minimal number value in Babylon.js
  1845. * @ignorenaming
  1846. */
  1847. let Epsilon: number;
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Class used to represent a viewport on screen
  1852. */
  1853. export class Viewport {
  1854. /** viewport left coordinate */
  1855. x: number;
  1856. /** viewport top coordinate */
  1857. y: number;
  1858. /**viewport width */
  1859. width: number;
  1860. /** viewport height */
  1861. height: number;
  1862. /**
  1863. * Creates a Viewport object located at (x, y) and sized (width, height)
  1864. * @param x defines viewport left coordinate
  1865. * @param y defines viewport top coordinate
  1866. * @param width defines the viewport width
  1867. * @param height defines the viewport height
  1868. */
  1869. constructor(
  1870. /** viewport left coordinate */
  1871. x: number,
  1872. /** viewport top coordinate */
  1873. y: number,
  1874. /**viewport width */
  1875. width: number,
  1876. /** viewport height */
  1877. height: number);
  1878. /**
  1879. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1880. * @param renderWidth defines the rendering width
  1881. * @param renderHeight defines the rendering height
  1882. * @returns a new Viewport
  1883. */
  1884. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1885. /**
  1886. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1887. * @param renderWidth defines the rendering width
  1888. * @param renderHeight defines the rendering height
  1889. * @param ref defines the target viewport
  1890. * @returns the current viewport
  1891. */
  1892. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1893. /**
  1894. * Returns a new Viewport copied from the current one
  1895. * @returns a new Viewport
  1896. */
  1897. clone(): Viewport;
  1898. }
  1899. }
  1900. declare module BABYLON {
  1901. /**
  1902. * Class containing a set of static utilities functions for arrays.
  1903. */
  1904. export class ArrayTools {
  1905. /**
  1906. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1907. * @param size the number of element to construct and put in the array
  1908. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1909. * @returns a new array filled with new objects
  1910. */
  1911. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1912. }
  1913. }
  1914. declare module BABYLON {
  1915. /**
  1916. * Represents a plane by the equation ax + by + cz + d = 0
  1917. */
  1918. export class Plane {
  1919. private static _TmpMatrix;
  1920. /**
  1921. * Normal of the plane (a,b,c)
  1922. */
  1923. normal: Vector3;
  1924. /**
  1925. * d component of the plane
  1926. */
  1927. d: number;
  1928. /**
  1929. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1930. * @param a a component of the plane
  1931. * @param b b component of the plane
  1932. * @param c c component of the plane
  1933. * @param d d component of the plane
  1934. */
  1935. constructor(a: number, b: number, c: number, d: number);
  1936. /**
  1937. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1938. */
  1939. asArray(): number[];
  1940. /**
  1941. * @returns a new plane copied from the current Plane.
  1942. */
  1943. clone(): Plane;
  1944. /**
  1945. * @returns the string "Plane".
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * @returns the Plane hash code.
  1950. */
  1951. getHashCode(): number;
  1952. /**
  1953. * Normalize the current Plane in place.
  1954. * @returns the updated Plane.
  1955. */
  1956. normalize(): Plane;
  1957. /**
  1958. * Applies a transformation the plane and returns the result
  1959. * @param transformation the transformation matrix to be applied to the plane
  1960. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1961. */
  1962. transform(transformation: DeepImmutable<Matrix>): Plane;
  1963. /**
  1964. * Compute the dot product between the point and the plane normal
  1965. * @param point point to calculate the dot product with
  1966. * @returns the dot product (float) of the point coordinates and the plane normal.
  1967. */
  1968. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1969. /**
  1970. * Updates the current Plane from the plane defined by the three given points.
  1971. * @param point1 one of the points used to contruct the plane
  1972. * @param point2 one of the points used to contruct the plane
  1973. * @param point3 one of the points used to contruct the plane
  1974. * @returns the updated Plane.
  1975. */
  1976. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1977. /**
  1978. * Checks if the plane is facing a given direction
  1979. * @param direction the direction to check if the plane is facing
  1980. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1981. * @returns True is the vector "direction" is the same side than the plane normal.
  1982. */
  1983. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1984. /**
  1985. * Calculates the distance to a point
  1986. * @param point point to calculate distance to
  1987. * @returns the signed distance (float) from the given point to the Plane.
  1988. */
  1989. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1990. /**
  1991. * Creates a plane from an array
  1992. * @param array the array to create a plane from
  1993. * @returns a new Plane from the given array.
  1994. */
  1995. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1996. /**
  1997. * Creates a plane from three points
  1998. * @param point1 point used to create the plane
  1999. * @param point2 point used to create the plane
  2000. * @param point3 point used to create the plane
  2001. * @returns a new Plane defined by the three given points.
  2002. */
  2003. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Creates a plane from an origin point and a normal
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @returns a new Plane the normal vector to this plane at the given origin point.
  2009. * Note : the vector "normal" is updated because normalized.
  2010. */
  2011. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2012. /**
  2013. * Calculates the distance from a plane and a point
  2014. * @param origin origin of the plane to be constructed
  2015. * @param normal normal of the plane to be constructed
  2016. * @param point point to calculate distance to
  2017. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2018. */
  2019. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2020. }
  2021. }
  2022. declare module BABYLON {
  2023. /**
  2024. * Class representing a vector containing 2 coordinates
  2025. */
  2026. export class Vector2 {
  2027. /** defines the first coordinate */
  2028. x: number;
  2029. /** defines the second coordinate */
  2030. y: number;
  2031. /**
  2032. * Creates a new Vector2 from the given x and y coordinates
  2033. * @param x defines the first coordinate
  2034. * @param y defines the second coordinate
  2035. */
  2036. constructor(
  2037. /** defines the first coordinate */
  2038. x?: number,
  2039. /** defines the second coordinate */
  2040. y?: number);
  2041. /**
  2042. * Gets a string with the Vector2 coordinates
  2043. * @returns a string with the Vector2 coordinates
  2044. */
  2045. toString(): string;
  2046. /**
  2047. * Gets class name
  2048. * @returns the string "Vector2"
  2049. */
  2050. getClassName(): string;
  2051. /**
  2052. * Gets current vector hash code
  2053. * @returns the Vector2 hash code as a number
  2054. */
  2055. getHashCode(): number;
  2056. /**
  2057. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2058. * @param array defines the source array
  2059. * @param index defines the offset in source array
  2060. * @returns the current Vector2
  2061. */
  2062. toArray(array: FloatArray, index?: number): Vector2;
  2063. /**
  2064. * Copy the current vector to an array
  2065. * @returns a new array with 2 elements: the Vector2 coordinates.
  2066. */
  2067. asArray(): number[];
  2068. /**
  2069. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2070. * @param source defines the source Vector2
  2071. * @returns the current updated Vector2
  2072. */
  2073. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Sets the Vector2 coordinates with the given floats
  2076. * @param x defines the first coordinate
  2077. * @param y defines the second coordinate
  2078. * @returns the current updated Vector2
  2079. */
  2080. copyFromFloats(x: number, y: number): Vector2;
  2081. /**
  2082. * Sets the Vector2 coordinates with the given floats
  2083. * @param x defines the first coordinate
  2084. * @param y defines the second coordinate
  2085. * @returns the current updated Vector2
  2086. */
  2087. set(x: number, y: number): Vector2;
  2088. /**
  2089. * Add another vector with the current one
  2090. * @param otherVector defines the other vector
  2091. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2092. */
  2093. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2096. * @param otherVector defines the other vector
  2097. * @param result defines the target vector
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2101. /**
  2102. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2103. * @param otherVector defines the other vector
  2104. * @returns the current updated Vector2
  2105. */
  2106. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2107. /**
  2108. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2109. * @param otherVector defines the other vector
  2110. * @returns a new Vector2
  2111. */
  2112. addVector3(otherVector: Vector3): Vector2;
  2113. /**
  2114. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2115. * @param otherVector defines the other vector
  2116. * @returns a new Vector2
  2117. */
  2118. subtract(otherVector: Vector2): Vector2;
  2119. /**
  2120. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2121. * @param otherVector defines the other vector
  2122. * @param result defines the target vector
  2123. * @returns the unmodified current Vector2
  2124. */
  2125. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2126. /**
  2127. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2128. * @param otherVector defines the other vector
  2129. * @returns the current updated Vector2
  2130. */
  2131. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2132. /**
  2133. * Multiplies in place the current Vector2 coordinates by the given ones
  2134. * @param otherVector defines the other vector
  2135. * @returns the current updated Vector2
  2136. */
  2137. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2138. /**
  2139. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2140. * @param otherVector defines the other vector
  2141. * @returns a new Vector2
  2142. */
  2143. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2146. * @param otherVector defines the other vector
  2147. * @param result defines the target vector
  2148. * @returns the unmodified current Vector2
  2149. */
  2150. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2153. * @param x defines the first coordinate
  2154. * @param y defines the second coordinate
  2155. * @returns a new Vector2
  2156. */
  2157. multiplyByFloats(x: number, y: number): Vector2;
  2158. /**
  2159. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2160. * @param otherVector defines the other vector
  2161. * @returns a new Vector2
  2162. */
  2163. divide(otherVector: Vector2): Vector2;
  2164. /**
  2165. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2166. * @param otherVector defines the other vector
  2167. * @param result defines the target vector
  2168. * @returns the unmodified current Vector2
  2169. */
  2170. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2171. /**
  2172. * Divides the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Gets a new Vector2 with current Vector2 negated coordinates
  2179. * @returns a new Vector2
  2180. */
  2181. negate(): Vector2;
  2182. /**
  2183. * Negate this vector in place
  2184. * @returns this
  2185. */
  2186. negateInPlace(): Vector2;
  2187. /**
  2188. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2189. * @param result defines the Vector3 object where to store the result
  2190. * @returns the current Vector2
  2191. */
  2192. negateToRef(result: Vector2): Vector2;
  2193. /**
  2194. * Multiply the Vector2 coordinates by scale
  2195. * @param scale defines the scaling factor
  2196. * @returns the current updated Vector2
  2197. */
  2198. scaleInPlace(scale: number): Vector2;
  2199. /**
  2200. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2201. * @param scale defines the scaling factor
  2202. * @returns a new Vector2
  2203. */
  2204. scale(scale: number): Vector2;
  2205. /**
  2206. * Scale the current Vector2 values by a factor to a given Vector2
  2207. * @param scale defines the scale factor
  2208. * @param result defines the Vector2 object where to store the result
  2209. * @returns the unmodified current Vector2
  2210. */
  2211. scaleToRef(scale: number, result: Vector2): Vector2;
  2212. /**
  2213. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2214. * @param scale defines the scale factor
  2215. * @param result defines the Vector2 object where to store the result
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a boolean if two vectors are equals
  2221. * @param otherVector defines the other vector
  2222. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2223. */
  2224. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2225. /**
  2226. * Gets a boolean if two vectors are equals (using an epsilon value)
  2227. * @param otherVector defines the other vector
  2228. * @param epsilon defines the minimal distance to consider equality
  2229. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2230. */
  2231. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2232. /**
  2233. * Gets a new Vector2 from current Vector2 floored values
  2234. * @returns a new Vector2
  2235. */
  2236. floor(): Vector2;
  2237. /**
  2238. * Gets a new Vector2 from current Vector2 floored values
  2239. * @returns a new Vector2
  2240. */
  2241. fract(): Vector2;
  2242. /**
  2243. * Gets the length of the vector
  2244. * @returns the vector length (float)
  2245. */
  2246. length(): number;
  2247. /**
  2248. * Gets the vector squared length
  2249. * @returns the vector squared length (float)
  2250. */
  2251. lengthSquared(): number;
  2252. /**
  2253. * Normalize the vector
  2254. * @returns the current updated Vector2
  2255. */
  2256. normalize(): Vector2;
  2257. /**
  2258. * Gets a new Vector2 copied from the Vector2
  2259. * @returns a new Vector2
  2260. */
  2261. clone(): Vector2;
  2262. /**
  2263. * Gets a new Vector2(0, 0)
  2264. * @returns a new Vector2
  2265. */
  2266. static Zero(): Vector2;
  2267. /**
  2268. * Gets a new Vector2(1, 1)
  2269. * @returns a new Vector2
  2270. */
  2271. static One(): Vector2;
  2272. /**
  2273. * Gets a new Vector2 set from the given index element of the given array
  2274. * @param array defines the data source
  2275. * @param offset defines the offset in the data source
  2276. * @returns a new Vector2
  2277. */
  2278. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2279. /**
  2280. * Sets "result" from the given index element of the given array
  2281. * @param array defines the data source
  2282. * @param offset defines the offset in the data source
  2283. * @param result defines the target vector
  2284. */
  2285. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2286. /**
  2287. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2288. * @param value1 defines 1st point of control
  2289. * @param value2 defines 2nd point of control
  2290. * @param value3 defines 3rd point of control
  2291. * @param value4 defines 4th point of control
  2292. * @param amount defines the interpolation factor
  2293. * @returns a new Vector2
  2294. */
  2295. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2296. /**
  2297. * 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".
  2298. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2299. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2300. * @param value defines the value to clamp
  2301. * @param min defines the lower limit
  2302. * @param max defines the upper limit
  2303. * @returns a new Vector2
  2304. */
  2305. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2306. /**
  2307. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2308. * @param value1 defines the 1st control point
  2309. * @param tangent1 defines the outgoing tangent
  2310. * @param value2 defines the 2nd control point
  2311. * @param tangent2 defines the incoming tangent
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2318. * @param start defines the start vector
  2319. * @param end defines the end vector
  2320. * @param amount defines the interpolation factor
  2321. * @returns a new Vector2
  2322. */
  2323. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2324. /**
  2325. * Gets the dot product of the vector "left" and the vector "right"
  2326. * @param left defines first vector
  2327. * @param right defines second vector
  2328. * @returns the dot product (float)
  2329. */
  2330. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2331. /**
  2332. * Returns a new Vector2 equal to the normalized given vector
  2333. * @param vector defines the vector to normalize
  2334. * @returns a new Vector2
  2335. */
  2336. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2337. /**
  2338. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2339. * @param left defines 1st vector
  2340. * @param right defines 2nd vector
  2341. * @returns a new Vector2
  2342. */
  2343. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2344. /**
  2345. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2346. * @param left defines 1st vector
  2347. * @param right defines 2nd vector
  2348. * @returns a new Vector2
  2349. */
  2350. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2351. /**
  2352. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2353. * @param vector defines the vector to transform
  2354. * @param transformation defines the matrix to apply
  2355. * @returns a new Vector2
  2356. */
  2357. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2358. /**
  2359. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2360. * @param vector defines the vector to transform
  2361. * @param transformation defines the matrix to apply
  2362. * @param result defines the target vector
  2363. */
  2364. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2365. /**
  2366. * Determines if a given vector is included in a triangle
  2367. * @param p defines the vector to test
  2368. * @param p0 defines 1st triangle point
  2369. * @param p1 defines 2nd triangle point
  2370. * @param p2 defines 3rd triangle point
  2371. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2372. */
  2373. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2374. /**
  2375. * Gets the distance between the vectors "value1" and "value2"
  2376. * @param value1 defines first vector
  2377. * @param value2 defines second vector
  2378. * @returns the distance between vectors
  2379. */
  2380. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2381. /**
  2382. * Returns the squared distance between the vectors "value1" and "value2"
  2383. * @param value1 defines first vector
  2384. * @param value2 defines second vector
  2385. * @returns the squared distance between vectors
  2386. */
  2387. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2388. /**
  2389. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2390. * @param value1 defines first vector
  2391. * @param value2 defines second vector
  2392. * @returns a new Vector2
  2393. */
  2394. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2395. /**
  2396. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2397. * @param p defines the middle point
  2398. * @param segA defines one point of the segment
  2399. * @param segB defines the other point of the segment
  2400. * @returns the shortest distance
  2401. */
  2402. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2403. }
  2404. /**
  2405. * Class used to store (x,y,z) vector representation
  2406. * A Vector3 is the main object used in 3D geometry
  2407. * It can represent etiher the coordinates of a point the space, either a direction
  2408. * Reminder: js uses a left handed forward facing system
  2409. */
  2410. export class Vector3 {
  2411. /**
  2412. * Defines the first coordinates (on X axis)
  2413. */
  2414. x: number;
  2415. /**
  2416. * Defines the second coordinates (on Y axis)
  2417. */
  2418. y: number;
  2419. /**
  2420. * Defines the third coordinates (on Z axis)
  2421. */
  2422. z: number;
  2423. private static _UpReadOnly;
  2424. private static _ZeroReadOnly;
  2425. /**
  2426. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2427. * @param x defines the first coordinates (on X axis)
  2428. * @param y defines the second coordinates (on Y axis)
  2429. * @param z defines the third coordinates (on Z axis)
  2430. */
  2431. constructor(
  2432. /**
  2433. * Defines the first coordinates (on X axis)
  2434. */
  2435. x?: number,
  2436. /**
  2437. * Defines the second coordinates (on Y axis)
  2438. */
  2439. y?: number,
  2440. /**
  2441. * Defines the third coordinates (on Z axis)
  2442. */
  2443. z?: number);
  2444. /**
  2445. * Creates a string representation of the Vector3
  2446. * @returns a string with the Vector3 coordinates.
  2447. */
  2448. toString(): string;
  2449. /**
  2450. * Gets the class name
  2451. * @returns the string "Vector3"
  2452. */
  2453. getClassName(): string;
  2454. /**
  2455. * Creates the Vector3 hash code
  2456. * @returns a number which tends to be unique between Vector3 instances
  2457. */
  2458. getHashCode(): number;
  2459. /**
  2460. * Creates an array containing three elements : the coordinates of the Vector3
  2461. * @returns a new array of numbers
  2462. */
  2463. asArray(): number[];
  2464. /**
  2465. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2466. * @param array defines the destination array
  2467. * @param index defines the offset in the destination array
  2468. * @returns the current Vector3
  2469. */
  2470. toArray(array: FloatArray, index?: number): Vector3;
  2471. /**
  2472. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2473. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2474. */
  2475. toQuaternion(): Quaternion;
  2476. /**
  2477. * Adds the given vector to the current Vector3
  2478. * @param otherVector defines the second operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Adds the given coordinates to the current Vector3
  2484. * @param x defines the x coordinate of the operand
  2485. * @param y defines the y coordinate of the operand
  2486. * @param z defines the z coordinate of the operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2490. /**
  2491. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the resulting Vector3
  2494. */
  2495. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Subtract the given vector from the current Vector3
  2505. * @param otherVector defines the second operand
  2506. * @returns the current updated Vector3
  2507. */
  2508. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2509. /**
  2510. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2511. * @param otherVector defines the second operand
  2512. * @returns the resulting Vector3
  2513. */
  2514. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2515. /**
  2516. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2517. * @param otherVector defines the second operand
  2518. * @param result defines the Vector3 object where to store the result
  2519. * @returns the current Vector3
  2520. */
  2521. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2522. /**
  2523. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @returns the resulting Vector3
  2528. */
  2529. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2530. /**
  2531. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2532. * @param x defines the x coordinate of the operand
  2533. * @param y defines the y coordinate of the operand
  2534. * @param z defines the z coordinate of the operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2539. /**
  2540. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2541. * @returns a new Vector3
  2542. */
  2543. negate(): Vector3;
  2544. /**
  2545. * Negate this vector in place
  2546. * @returns this
  2547. */
  2548. negateInPlace(): Vector3;
  2549. /**
  2550. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2551. * @param result defines the Vector3 object where to store the result
  2552. * @returns the current Vector3
  2553. */
  2554. negateToRef(result: Vector3): Vector3;
  2555. /**
  2556. * Multiplies the Vector3 coordinates by the float "scale"
  2557. * @param scale defines the multiplier factor
  2558. * @returns the current updated Vector3
  2559. */
  2560. scaleInPlace(scale: number): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2563. * @param scale defines the multiplier factor
  2564. * @returns a new Vector3
  2565. */
  2566. scale(scale: number): Vector3;
  2567. /**
  2568. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2569. * @param scale defines the multiplier factor
  2570. * @param result defines the Vector3 object where to store the result
  2571. * @returns the current Vector3
  2572. */
  2573. scaleToRef(scale: number, result: Vector3): Vector3;
  2574. /**
  2575. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2576. * @param scale defines the scale factor
  2577. * @param result defines the Vector3 object where to store the result
  2578. * @returns the unmodified current Vector3
  2579. */
  2580. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2581. /**
  2582. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2583. * @param origin defines the origin of the projection ray
  2584. * @param plane defines the plane to project to
  2585. * @returns the projected vector3
  2586. */
  2587. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2588. /**
  2589. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2590. * @param origin defines the origin of the projection ray
  2591. * @param plane defines the plane to project to
  2592. * @param result defines the Vector3 where to store the result
  2593. */
  2594. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2595. /**
  2596. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2597. * @param otherVector defines the second operand
  2598. * @returns true if both vectors are equals
  2599. */
  2600. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2601. /**
  2602. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2603. * @param otherVector defines the second operand
  2604. * @param epsilon defines the minimal distance to define values as equals
  2605. * @returns true if both vectors are distant less than epsilon
  2606. */
  2607. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2608. /**
  2609. * Returns true if the current Vector3 coordinates equals the given floats
  2610. * @param x defines the x coordinate of the operand
  2611. * @param y defines the y coordinate of the operand
  2612. * @param z defines the z coordinate of the operand
  2613. * @returns true if both vectors are equals
  2614. */
  2615. equalsToFloats(x: number, y: number, z: number): boolean;
  2616. /**
  2617. * Multiplies the current Vector3 coordinates by the given ones
  2618. * @param otherVector defines the second operand
  2619. * @returns the current updated Vector3
  2620. */
  2621. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2622. /**
  2623. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2624. * @param otherVector defines the second operand
  2625. * @returns the new Vector3
  2626. */
  2627. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2628. /**
  2629. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2630. * @param otherVector defines the second operand
  2631. * @param result defines the Vector3 object where to store the result
  2632. * @returns the current Vector3
  2633. */
  2634. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2637. * @param x defines the x coordinate of the operand
  2638. * @param y defines the y coordinate of the operand
  2639. * @param z defines the z coordinate of the operand
  2640. * @returns the new Vector3
  2641. */
  2642. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2643. /**
  2644. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2645. * @param otherVector defines the second operand
  2646. * @returns the new Vector3
  2647. */
  2648. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2649. /**
  2650. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2651. * @param otherVector defines the second operand
  2652. * @param result defines the Vector3 object where to store the result
  2653. * @returns the current Vector3
  2654. */
  2655. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2656. /**
  2657. * Divides the current Vector3 coordinates by the given ones.
  2658. * @param otherVector defines the second operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. divideInPlace(otherVector: Vector3): Vector3;
  2662. /**
  2663. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2664. * @param other defines the second operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2668. /**
  2669. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2670. * @param other defines the second operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  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 current updated Vector3
  2680. */
  2681. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2684. * @param x defines the x coordinate of the operand
  2685. * @param y defines the y coordinate of the operand
  2686. * @param z defines the z coordinate of the operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2690. /**
  2691. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2692. * Check if is non uniform within a certain amount of decimal places to account for this
  2693. * @param epsilon the amount the values can differ
  2694. * @returns if the the vector is non uniform to a certain number of decimal places
  2695. */
  2696. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2697. /**
  2698. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2699. */
  2700. get isNonUniform(): boolean;
  2701. /**
  2702. * Gets a new Vector3 from current Vector3 floored values
  2703. * @returns a new Vector3
  2704. */
  2705. floor(): Vector3;
  2706. /**
  2707. * Gets a new Vector3 from current Vector3 floored values
  2708. * @returns a new Vector3
  2709. */
  2710. fract(): Vector3;
  2711. /**
  2712. * Gets the length of the Vector3
  2713. * @returns the length of the Vector3
  2714. */
  2715. length(): number;
  2716. /**
  2717. * Gets the squared length of the Vector3
  2718. * @returns squared length of the Vector3
  2719. */
  2720. lengthSquared(): number;
  2721. /**
  2722. * Normalize the current Vector3.
  2723. * Please note that this is an in place operation.
  2724. * @returns the current updated Vector3
  2725. */
  2726. normalize(): Vector3;
  2727. /**
  2728. * Reorders the x y z properties of the vector in place
  2729. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2730. * @returns the current updated vector
  2731. */
  2732. reorderInPlace(order: string): this;
  2733. /**
  2734. * Rotates the vector around 0,0,0 by a quaternion
  2735. * @param quaternion the rotation quaternion
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2740. /**
  2741. * Rotates a vector around a given point
  2742. * @param quaternion the rotation quaternion
  2743. * @param point the point to rotate around
  2744. * @param result vector to store the result
  2745. * @returns the resulting vector
  2746. */
  2747. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2748. /**
  2749. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2750. * The cross product is then orthogonal to both current and "other"
  2751. * @param other defines the right operand
  2752. * @returns the cross product
  2753. */
  2754. cross(other: Vector3): Vector3;
  2755. /**
  2756. * Normalize the current Vector3 with the given input length.
  2757. * Please note that this is an in place operation.
  2758. * @param len the length of the vector
  2759. * @returns the current updated Vector3
  2760. */
  2761. normalizeFromLength(len: number): Vector3;
  2762. /**
  2763. * Normalize the current Vector3 to a new vector
  2764. * @returns the new Vector3
  2765. */
  2766. normalizeToNew(): Vector3;
  2767. /**
  2768. * Normalize the current Vector3 to the reference
  2769. * @param reference define the Vector3 to update
  2770. * @returns the updated Vector3
  2771. */
  2772. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2773. /**
  2774. * Creates a new Vector3 copied from the current Vector3
  2775. * @returns the new Vector3
  2776. */
  2777. clone(): Vector3;
  2778. /**
  2779. * Copies the given vector coordinates to the current Vector3 ones
  2780. * @param source defines the source Vector3
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. copyFromFloats(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given floats to the current Vector3 coordinates
  2794. * @param x defines the x coordinate of the operand
  2795. * @param y defines the y coordinate of the operand
  2796. * @param z defines the z coordinate of the operand
  2797. * @returns the current updated Vector3
  2798. */
  2799. set(x: number, y: number, z: number): Vector3;
  2800. /**
  2801. * Copies the given float to the current Vector3 coordinates
  2802. * @param v defines the x, y and z coordinates of the operand
  2803. * @returns the current updated Vector3
  2804. */
  2805. setAll(v: number): Vector3;
  2806. /**
  2807. * Get the clip factor between two vectors
  2808. * @param vector0 defines the first operand
  2809. * @param vector1 defines the second operand
  2810. * @param axis defines the axis to use
  2811. * @param size defines the size along the axis
  2812. * @returns the clip factor
  2813. */
  2814. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2815. /**
  2816. * Get angle between two vectors
  2817. * @param vector0 angle between vector0 and vector1
  2818. * @param vector1 angle between vector0 and vector1
  2819. * @param normal direction of the normal
  2820. * @return the angle between vector0 and vector1
  2821. */
  2822. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2823. /**
  2824. * Returns a new Vector3 set from the index "offset" of the given array
  2825. * @param array defines the source array
  2826. * @param offset defines the offset in the source array
  2827. * @returns the new Vector3
  2828. */
  2829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2830. /**
  2831. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @returns the new Vector3
  2835. * @deprecated Please use FromArray instead.
  2836. */
  2837. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2838. /**
  2839. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2840. * @param array defines the source array
  2841. * @param offset defines the offset in the source array
  2842. * @param result defines the Vector3 where to store the result
  2843. */
  2844. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2847. * @param array defines the source array
  2848. * @param offset defines the offset in the source array
  2849. * @param result defines the Vector3 where to store the result
  2850. * @deprecated Please use FromArrayToRef instead.
  2851. */
  2852. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2853. /**
  2854. * Sets the given vector "result" with the given floats.
  2855. * @param x defines the x coordinate of the source
  2856. * @param y defines the y coordinate of the source
  2857. * @param z defines the z coordinate of the source
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2861. /**
  2862. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2863. * @returns a new empty Vector3
  2864. */
  2865. static Zero(): Vector3;
  2866. /**
  2867. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2868. * @returns a new unit Vector3
  2869. */
  2870. static One(): Vector3;
  2871. /**
  2872. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2873. * @returns a new up Vector3
  2874. */
  2875. static Up(): Vector3;
  2876. /**
  2877. * Gets a up Vector3 that must not be updated
  2878. */
  2879. static get UpReadOnly(): DeepImmutable<Vector3>;
  2880. /**
  2881. * Gets a zero Vector3 that must not be updated
  2882. */
  2883. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2884. /**
  2885. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2886. * @returns a new down Vector3
  2887. */
  2888. static Down(): Vector3;
  2889. /**
  2890. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2891. * @param rightHandedSystem is the scene right-handed (negative z)
  2892. * @returns a new forward Vector3
  2893. */
  2894. static Forward(rightHandedSystem?: boolean): Vector3;
  2895. /**
  2896. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2897. * @param rightHandedSystem is the scene right-handed (negative-z)
  2898. * @returns a new forward Vector3
  2899. */
  2900. static Backward(rightHandedSystem?: boolean): Vector3;
  2901. /**
  2902. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2903. * @returns a new right Vector3
  2904. */
  2905. static Right(): Vector3;
  2906. /**
  2907. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2908. * @returns a new left Vector3
  2909. */
  2910. static Left(): Vector3;
  2911. /**
  2912. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @returns the transformed Vector3
  2917. */
  2918. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2921. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2922. * @param vector defines the Vector3 to transform
  2923. * @param transformation defines the transformation matrix
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2929. * This method computes tranformed coordinates only, not transformed direction vectors
  2930. * @param x define the x coordinate of the source vector
  2931. * @param y define the y coordinate of the source vector
  2932. * @param z define the z coordinate of the source vector
  2933. * @param transformation defines the transformation matrix
  2934. * @param result defines the Vector3 where to store the result
  2935. */
  2936. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2937. /**
  2938. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @returns the new Vector3
  2943. */
  2944. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param vector defines the Vector3 to transform
  2949. * @param transformation defines the transformation matrix
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2955. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2956. * @param x define the x coordinate of the source vector
  2957. * @param y define the y coordinate of the source vector
  2958. * @param z define the z coordinate of the source vector
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2965. * @param value1 defines the first control point
  2966. * @param value2 defines the second control point
  2967. * @param value3 defines the third control point
  2968. * @param value4 defines the fourth control point
  2969. * @param amount defines the amount on the spline to use
  2970. * @returns the new Vector3
  2971. */
  2972. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2973. /**
  2974. * 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"
  2975. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2976. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2977. * @param value defines the current value
  2978. * @param min defines the lower range value
  2979. * @param max defines the upper range value
  2980. * @returns the new Vector3
  2981. */
  2982. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2983. /**
  2984. * 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"
  2985. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2986. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2987. * @param value defines the current value
  2988. * @param min defines the lower range value
  2989. * @param max defines the upper range value
  2990. * @param result defines the Vector3 where to store the result
  2991. */
  2992. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2993. /**
  2994. * Checks if a given vector is inside a specific range
  2995. * @param v defines the vector to test
  2996. * @param min defines the minimum range
  2997. * @param max defines the maximum range
  2998. */
  2999. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3000. /**
  3001. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3002. * @param value1 defines the first control point
  3003. * @param tangent1 defines the first tangent vector
  3004. * @param value2 defines the second control point
  3005. * @param tangent2 defines the second tangent vector
  3006. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @returns the new Vector3
  3016. */
  3017. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3018. /**
  3019. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3020. * @param start defines the start value
  3021. * @param end defines the end value
  3022. * @param amount max defines amount between both (between 0 and 1)
  3023. * @param result defines the Vector3 where to store the result
  3024. */
  3025. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3026. /**
  3027. * Returns the dot product (float) between the vectors "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the dot product
  3031. */
  3032. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3033. /**
  3034. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @returns the cross product
  3039. */
  3040. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3041. /**
  3042. * Sets the given vector "result" with the cross product of "left" and "right"
  3043. * The cross product is then orthogonal to both "left" and "right"
  3044. * @param left defines the left operand
  3045. * @param right defines the right operand
  3046. * @param result defines the Vector3 where to store the result
  3047. */
  3048. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3049. /**
  3050. * Returns a new Vector3 as the normalization of the given vector
  3051. * @param vector defines the Vector3 to normalize
  3052. * @returns the new Vector3
  3053. */
  3054. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3055. /**
  3056. * Sets the given vector "result" with the normalization of the given first vector
  3057. * @param vector defines the Vector3 to normalize
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3061. /**
  3062. * Project a Vector3 onto screen space
  3063. * @param vector defines the Vector3 to project
  3064. * @param world defines the world matrix to use
  3065. * @param transform defines the transform (view x projection) matrix to use
  3066. * @param viewport defines the screen viewport to use
  3067. * @returns the new Vector3
  3068. */
  3069. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3070. /** @hidden */
  3071. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3072. /**
  3073. * Unproject from screen space to object space
  3074. * @param source defines the screen space Vector3 to use
  3075. * @param viewportWidth defines the current width of the viewport
  3076. * @param viewportHeight defines the current height of the viewport
  3077. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3078. * @param transform defines the transform (view x projection) matrix to use
  3079. * @returns the new Vector3
  3080. */
  3081. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3082. /**
  3083. * Unproject from screen space to object space
  3084. * @param source defines the screen space Vector3 to use
  3085. * @param viewportWidth defines the current width of the viewport
  3086. * @param viewportHeight defines the current height of the viewport
  3087. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3088. * @param view defines the view matrix to use
  3089. * @param projection defines the projection matrix to use
  3090. * @returns the new Vector3
  3091. */
  3092. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3093. /**
  3094. * Unproject from screen space to object space
  3095. * @param source defines the screen space Vector3 to use
  3096. * @param viewportWidth defines the current width of the viewport
  3097. * @param viewportHeight defines the current height of the viewport
  3098. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3099. * @param view defines the view matrix to use
  3100. * @param projection defines the projection matrix to use
  3101. * @param result defines the Vector3 where to store the result
  3102. */
  3103. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3104. /**
  3105. * Unproject from screen space to object space
  3106. * @param sourceX defines the screen space x coordinate to use
  3107. * @param sourceY defines the screen space y coordinate to use
  3108. * @param sourceZ defines the screen space z coordinate to use
  3109. * @param viewportWidth defines the current width of the viewport
  3110. * @param viewportHeight defines the current height of the viewport
  3111. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3112. * @param view defines the view matrix to use
  3113. * @param projection defines the projection matrix to use
  3114. * @param result defines the Vector3 where to store the result
  3115. */
  3116. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3117. /**
  3118. * Gets the minimal coordinate values between two Vector3
  3119. * @param left defines the first operand
  3120. * @param right defines the second operand
  3121. * @returns the new Vector3
  3122. */
  3123. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3124. /**
  3125. * Gets the maximal coordinate values between two Vector3
  3126. * @param left defines the first operand
  3127. * @param right defines the second operand
  3128. * @returns the new Vector3
  3129. */
  3130. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3131. /**
  3132. * Returns the distance between the vectors "value1" and "value2"
  3133. * @param value1 defines the first operand
  3134. * @param value2 defines the second operand
  3135. * @returns the distance
  3136. */
  3137. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3138. /**
  3139. * Returns the squared distance between the vectors "value1" and "value2"
  3140. * @param value1 defines the first operand
  3141. * @param value2 defines the second operand
  3142. * @returns the squared distance
  3143. */
  3144. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3145. /**
  3146. * Returns a new Vector3 located at the center between "value1" and "value2"
  3147. * @param value1 defines the first operand
  3148. * @param value2 defines the second operand
  3149. * @returns the new Vector3
  3150. */
  3151. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3152. /**
  3153. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3154. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3155. * to something in order to rotate it from its local system to the given target system
  3156. * Note: axis1, axis2 and axis3 are normalized during this operation
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @returns a new Vector3
  3161. */
  3162. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3165. * @param axis1 defines the first axis
  3166. * @param axis2 defines the second axis
  3167. * @param axis3 defines the third axis
  3168. * @param ref defines the Vector3 where to store the result
  3169. */
  3170. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3171. }
  3172. /**
  3173. * Vector4 class created for EulerAngle class conversion to Quaternion
  3174. */
  3175. export class Vector4 {
  3176. /** x value of the vector */
  3177. x: number;
  3178. /** y value of the vector */
  3179. y: number;
  3180. /** z value of the vector */
  3181. z: number;
  3182. /** w value of the vector */
  3183. w: number;
  3184. /**
  3185. * Creates a Vector4 object from the given floats.
  3186. * @param x x value of the vector
  3187. * @param y y value of the vector
  3188. * @param z z value of the vector
  3189. * @param w w value of the vector
  3190. */
  3191. constructor(
  3192. /** x value of the vector */
  3193. x: number,
  3194. /** y value of the vector */
  3195. y: number,
  3196. /** z value of the vector */
  3197. z: number,
  3198. /** w value of the vector */
  3199. w: number);
  3200. /**
  3201. * Returns the string with the Vector4 coordinates.
  3202. * @returns a string containing all the vector values
  3203. */
  3204. toString(): string;
  3205. /**
  3206. * Returns the string "Vector4".
  3207. * @returns "Vector4"
  3208. */
  3209. getClassName(): string;
  3210. /**
  3211. * Returns the Vector4 hash code.
  3212. * @returns a unique hash code
  3213. */
  3214. getHashCode(): number;
  3215. /**
  3216. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3217. * @returns the resulting array
  3218. */
  3219. asArray(): number[];
  3220. /**
  3221. * Populates the given array from the given index with the Vector4 coordinates.
  3222. * @param array array to populate
  3223. * @param index index of the array to start at (default: 0)
  3224. * @returns the Vector4.
  3225. */
  3226. toArray(array: FloatArray, index?: number): Vector4;
  3227. /**
  3228. * Adds the given vector to the current Vector4.
  3229. * @param otherVector the vector to add
  3230. * @returns the updated Vector4.
  3231. */
  3232. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3233. /**
  3234. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3235. * @param otherVector the vector to add
  3236. * @returns the resulting vector
  3237. */
  3238. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3239. /**
  3240. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3241. * @param otherVector the vector to add
  3242. * @param result the vector to store the result
  3243. * @returns the current Vector4.
  3244. */
  3245. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3246. /**
  3247. * Subtract in place the given vector from the current Vector4.
  3248. * @param otherVector the vector to subtract
  3249. * @returns the updated Vector4.
  3250. */
  3251. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3254. * @param otherVector the vector to add
  3255. * @returns the new vector with the result
  3256. */
  3257. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3258. /**
  3259. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3260. * @param otherVector the vector to subtract
  3261. * @param result the vector to store the result
  3262. * @returns the current Vector4.
  3263. */
  3264. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3265. /**
  3266. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3267. */
  3268. /**
  3269. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3270. * @param x value to subtract
  3271. * @param y value to subtract
  3272. * @param z value to subtract
  3273. * @param w value to subtract
  3274. * @returns new vector containing the result
  3275. */
  3276. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3277. /**
  3278. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3279. * @param x value to subtract
  3280. * @param y value to subtract
  3281. * @param z value to subtract
  3282. * @param w value to subtract
  3283. * @param result the vector to store the result in
  3284. * @returns the current Vector4.
  3285. */
  3286. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3287. /**
  3288. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3289. * @returns a new vector with the negated values
  3290. */
  3291. negate(): Vector4;
  3292. /**
  3293. * Negate this vector in place
  3294. * @returns this
  3295. */
  3296. negateInPlace(): Vector4;
  3297. /**
  3298. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3299. * @param result defines the Vector3 object where to store the result
  3300. * @returns the current Vector4
  3301. */
  3302. negateToRef(result: Vector4): Vector4;
  3303. /**
  3304. * Multiplies the current Vector4 coordinates by scale (float).
  3305. * @param scale the number to scale with
  3306. * @returns the updated Vector4.
  3307. */
  3308. scaleInPlace(scale: number): Vector4;
  3309. /**
  3310. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3311. * @param scale the number to scale with
  3312. * @returns a new vector with the result
  3313. */
  3314. scale(scale: number): Vector4;
  3315. /**
  3316. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3317. * @param scale the number to scale with
  3318. * @param result a vector to store the result in
  3319. * @returns the current Vector4.
  3320. */
  3321. scaleToRef(scale: number, result: Vector4): Vector4;
  3322. /**
  3323. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3324. * @param scale defines the scale factor
  3325. * @param result defines the Vector4 object where to store the result
  3326. * @returns the unmodified current Vector4
  3327. */
  3328. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3329. /**
  3330. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3331. * @param otherVector the vector to compare against
  3332. * @returns true if they are equal
  3333. */
  3334. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3335. /**
  3336. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3337. * @param otherVector vector to compare against
  3338. * @param epsilon (Default: very small number)
  3339. * @returns true if they are equal
  3340. */
  3341. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3342. /**
  3343. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3344. * @param x x value to compare against
  3345. * @param y y value to compare against
  3346. * @param z z value to compare against
  3347. * @param w w value to compare against
  3348. * @returns true if equal
  3349. */
  3350. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3351. /**
  3352. * Multiplies in place the current Vector4 by the given one.
  3353. * @param otherVector vector to multiple with
  3354. * @returns the updated Vector4.
  3355. */
  3356. multiplyInPlace(otherVector: Vector4): Vector4;
  3357. /**
  3358. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3359. * @param otherVector vector to multiple with
  3360. * @returns resulting new vector
  3361. */
  3362. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3365. * @param otherVector vector to multiple with
  3366. * @param result vector to store the result
  3367. * @returns the current Vector4.
  3368. */
  3369. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3372. * @param x x value multiply with
  3373. * @param y y value multiply with
  3374. * @param z z value multiply with
  3375. * @param w w value multiply with
  3376. * @returns resulting new vector
  3377. */
  3378. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3379. /**
  3380. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3381. * @param otherVector vector to devide with
  3382. * @returns resulting new vector
  3383. */
  3384. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3385. /**
  3386. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3387. * @param otherVector vector to devide with
  3388. * @param result vector to store the result
  3389. * @returns the current Vector4.
  3390. */
  3391. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3392. /**
  3393. * Divides the current Vector3 coordinates by the given ones.
  3394. * @param otherVector vector to devide with
  3395. * @returns the updated Vector3.
  3396. */
  3397. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3398. /**
  3399. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3400. * @param other defines the second operand
  3401. * @returns the current updated Vector4
  3402. */
  3403. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3406. * @param other defines the second operand
  3407. * @returns the current updated Vector4
  3408. */
  3409. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3410. /**
  3411. * Gets a new Vector4 from current Vector4 floored values
  3412. * @returns a new Vector4
  3413. */
  3414. floor(): Vector4;
  3415. /**
  3416. * Gets a new Vector4 from current Vector3 floored values
  3417. * @returns a new Vector4
  3418. */
  3419. fract(): Vector4;
  3420. /**
  3421. * Returns the Vector4 length (float).
  3422. * @returns the length
  3423. */
  3424. length(): number;
  3425. /**
  3426. * Returns the Vector4 squared length (float).
  3427. * @returns the length squared
  3428. */
  3429. lengthSquared(): number;
  3430. /**
  3431. * Normalizes in place the Vector4.
  3432. * @returns the updated Vector4.
  3433. */
  3434. normalize(): Vector4;
  3435. /**
  3436. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3437. * @returns this converted to a new vector3
  3438. */
  3439. toVector3(): Vector3;
  3440. /**
  3441. * Returns a new Vector4 copied from the current one.
  3442. * @returns the new cloned vector
  3443. */
  3444. clone(): Vector4;
  3445. /**
  3446. * Updates the current Vector4 with the given one coordinates.
  3447. * @param source the source vector to copy from
  3448. * @returns the updated Vector4.
  3449. */
  3450. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3451. /**
  3452. * Updates the current Vector4 coordinates with the given floats.
  3453. * @param x float to copy from
  3454. * @param y float to copy from
  3455. * @param z float to copy from
  3456. * @param w float to copy from
  3457. * @returns the updated Vector4.
  3458. */
  3459. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3460. /**
  3461. * Updates the current Vector4 coordinates with the given floats.
  3462. * @param x float to set from
  3463. * @param y float to set from
  3464. * @param z float to set from
  3465. * @param w float to set from
  3466. * @returns the updated Vector4.
  3467. */
  3468. set(x: number, y: number, z: number, w: number): Vector4;
  3469. /**
  3470. * Copies the given float to the current Vector3 coordinates
  3471. * @param v defines the x, y, z and w coordinates of the operand
  3472. * @returns the current updated Vector3
  3473. */
  3474. setAll(v: number): Vector4;
  3475. /**
  3476. * Returns a new Vector4 set from the starting index of the given array.
  3477. * @param array the array to pull values from
  3478. * @param offset the offset into the array to start at
  3479. * @returns the new vector
  3480. */
  3481. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3482. /**
  3483. * Updates the given vector "result" from the starting index of the given array.
  3484. * @param array the array to pull values from
  3485. * @param offset the offset into the array to start at
  3486. * @param result the vector to store the result in
  3487. */
  3488. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3489. /**
  3490. * Updates the given vector "result" from the starting index of the given Float32Array.
  3491. * @param array the array to pull values from
  3492. * @param offset the offset into the array to start at
  3493. * @param result the vector to store the result in
  3494. */
  3495. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3496. /**
  3497. * Updates the given vector "result" coordinates from the given floats.
  3498. * @param x float to set from
  3499. * @param y float to set from
  3500. * @param z float to set from
  3501. * @param w float to set from
  3502. * @param result the vector to the floats in
  3503. */
  3504. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3505. /**
  3506. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3507. * @returns the new vector
  3508. */
  3509. static Zero(): Vector4;
  3510. /**
  3511. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3512. * @returns the new vector
  3513. */
  3514. static One(): Vector4;
  3515. /**
  3516. * Returns a new normalized Vector4 from the given one.
  3517. * @param vector the vector to normalize
  3518. * @returns the vector
  3519. */
  3520. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3521. /**
  3522. * Updates the given vector "result" from the normalization of the given one.
  3523. * @param vector the vector to normalize
  3524. * @param result the vector to store the result in
  3525. */
  3526. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3527. /**
  3528. * Returns a vector with the minimum values from the left and right vectors
  3529. * @param left left vector to minimize
  3530. * @param right right vector to minimize
  3531. * @returns a new vector with the minimum of the left and right vector values
  3532. */
  3533. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3534. /**
  3535. * Returns a vector with the maximum values from the left and right vectors
  3536. * @param left left vector to maximize
  3537. * @param right right vector to maximize
  3538. * @returns a new vector with the maximum of the left and right vector values
  3539. */
  3540. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3541. /**
  3542. * Returns the distance (float) between the vectors "value1" and "value2".
  3543. * @param value1 value to calulate the distance between
  3544. * @param value2 value to calulate the distance between
  3545. * @return the distance between the two vectors
  3546. */
  3547. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3548. /**
  3549. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3550. * @param value1 value to calulate the distance between
  3551. * @param value2 value to calulate the distance between
  3552. * @return the distance between the two vectors squared
  3553. */
  3554. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3555. /**
  3556. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3557. * @param value1 value to calulate the center between
  3558. * @param value2 value to calulate the center between
  3559. * @return the center between the two vectors
  3560. */
  3561. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3562. /**
  3563. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @returns the new vector
  3568. */
  3569. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param vector the vector to transform
  3574. * @param transformation the transformation matrix to apply
  3575. * @param result the vector to store the result in
  3576. */
  3577. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3578. /**
  3579. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3580. * This methods computes transformed normalized direction vectors only.
  3581. * @param x value to transform
  3582. * @param y value to transform
  3583. * @param z value to transform
  3584. * @param w value to transform
  3585. * @param transformation the transformation matrix to apply
  3586. * @param result the vector to store the results in
  3587. */
  3588. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3589. /**
  3590. * Creates a new Vector4 from a Vector3
  3591. * @param source defines the source data
  3592. * @param w defines the 4th component (default is 0)
  3593. * @returns a new Vector4
  3594. */
  3595. static FromVector3(source: Vector3, w?: number): Vector4;
  3596. }
  3597. /**
  3598. * Class used to store quaternion data
  3599. * @see https://en.wikipedia.org/wiki/Quaternion
  3600. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3601. */
  3602. export class Quaternion {
  3603. /** defines the first component (0 by default) */
  3604. x: number;
  3605. /** defines the second component (0 by default) */
  3606. y: number;
  3607. /** defines the third component (0 by default) */
  3608. z: number;
  3609. /** defines the fourth component (1.0 by default) */
  3610. w: number;
  3611. /**
  3612. * Creates a new Quaternion from the given floats
  3613. * @param x defines the first component (0 by default)
  3614. * @param y defines the second component (0 by default)
  3615. * @param z defines the third component (0 by default)
  3616. * @param w defines the fourth component (1.0 by default)
  3617. */
  3618. constructor(
  3619. /** defines the first component (0 by default) */
  3620. x?: number,
  3621. /** defines the second component (0 by default) */
  3622. y?: number,
  3623. /** defines the third component (0 by default) */
  3624. z?: number,
  3625. /** defines the fourth component (1.0 by default) */
  3626. w?: number);
  3627. /**
  3628. * Gets a string representation for the current quaternion
  3629. * @returns a string with the Quaternion coordinates
  3630. */
  3631. toString(): string;
  3632. /**
  3633. * Gets the class name of the quaternion
  3634. * @returns the string "Quaternion"
  3635. */
  3636. getClassName(): string;
  3637. /**
  3638. * Gets a hash code for this quaternion
  3639. * @returns the quaternion hash code
  3640. */
  3641. getHashCode(): number;
  3642. /**
  3643. * Copy the quaternion to an array
  3644. * @returns a new array populated with 4 elements from the quaternion coordinates
  3645. */
  3646. asArray(): number[];
  3647. /**
  3648. * Check if two quaternions are equals
  3649. * @param otherQuaternion defines the second operand
  3650. * @return true if the current quaternion and the given one coordinates are strictly equals
  3651. */
  3652. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3653. /**
  3654. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3655. * @param otherQuaternion defines the other quaternion
  3656. * @param epsilon defines the minimal distance to consider equality
  3657. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3658. */
  3659. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3660. /**
  3661. * Clone the current quaternion
  3662. * @returns a new quaternion copied from the current one
  3663. */
  3664. clone(): Quaternion;
  3665. /**
  3666. * Copy a quaternion to the current one
  3667. * @param other defines the other quaternion
  3668. * @returns the updated current quaternion
  3669. */
  3670. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3671. /**
  3672. * Updates the current quaternion with the given float coordinates
  3673. * @param x defines the x coordinate
  3674. * @param y defines the y coordinate
  3675. * @param z defines the z coordinate
  3676. * @param w defines the w coordinate
  3677. * @returns the updated current quaternion
  3678. */
  3679. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given float coordinates
  3682. * @param x defines the x coordinate
  3683. * @param y defines the y coordinate
  3684. * @param z defines the z coordinate
  3685. * @param w defines the w coordinate
  3686. * @returns the updated current quaternion
  3687. */
  3688. set(x: number, y: number, z: number, w: number): Quaternion;
  3689. /**
  3690. * Adds two quaternions
  3691. * @param other defines the second operand
  3692. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3693. */
  3694. add(other: DeepImmutable<Quaternion>): Quaternion;
  3695. /**
  3696. * Add a quaternion to the current one
  3697. * @param other defines the quaternion to add
  3698. * @returns the current quaternion
  3699. */
  3700. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3701. /**
  3702. * Subtract two quaternions
  3703. * @param other defines the second operand
  3704. * @returns a new quaternion as the subtraction result of the given one from the current one
  3705. */
  3706. subtract(other: Quaternion): Quaternion;
  3707. /**
  3708. * Multiplies the current quaternion by a scale factor
  3709. * @param value defines the scale factor
  3710. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3711. */
  3712. scale(value: number): Quaternion;
  3713. /**
  3714. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3715. * @param scale defines the scale factor
  3716. * @param result defines the Quaternion object where to store the result
  3717. * @returns the unmodified current quaternion
  3718. */
  3719. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3720. /**
  3721. * Multiplies in place the current quaternion by a scale factor
  3722. * @param value defines the scale factor
  3723. * @returns the current modified quaternion
  3724. */
  3725. scaleInPlace(value: number): Quaternion;
  3726. /**
  3727. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3728. * @param scale defines the scale factor
  3729. * @param result defines the Quaternion object where to store the result
  3730. * @returns the unmodified current quaternion
  3731. */
  3732. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3733. /**
  3734. * Multiplies two quaternions
  3735. * @param q1 defines the second operand
  3736. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3737. */
  3738. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3741. * @param q1 defines the second operand
  3742. * @param result defines the target quaternion
  3743. * @returns the current quaternion
  3744. */
  3745. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3746. /**
  3747. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3748. * @param q1 defines the second operand
  3749. * @returns the currentupdated quaternion
  3750. */
  3751. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3752. /**
  3753. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3754. * @param ref defines the target quaternion
  3755. * @returns the current quaternion
  3756. */
  3757. conjugateToRef(ref: Quaternion): Quaternion;
  3758. /**
  3759. * Conjugates in place (1-q) the current quaternion
  3760. * @returns the current updated quaternion
  3761. */
  3762. conjugateInPlace(): Quaternion;
  3763. /**
  3764. * Conjugates in place (1-q) the current quaternion
  3765. * @returns a new quaternion
  3766. */
  3767. conjugate(): Quaternion;
  3768. /**
  3769. * Gets length of current quaternion
  3770. * @returns the quaternion length (float)
  3771. */
  3772. length(): number;
  3773. /**
  3774. * Normalize in place the current quaternion
  3775. * @returns the current updated quaternion
  3776. */
  3777. normalize(): Quaternion;
  3778. /**
  3779. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3780. * @param order is a reserved parameter and is ignore for now
  3781. * @returns a new Vector3 containing the Euler angles
  3782. */
  3783. toEulerAngles(order?: string): Vector3;
  3784. /**
  3785. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3786. * @param result defines the vector which will be filled with the Euler angles
  3787. * @param order is a reserved parameter and is ignore for now
  3788. * @returns the current unchanged quaternion
  3789. */
  3790. toEulerAnglesToRef(result: Vector3): Quaternion;
  3791. /**
  3792. * Updates the given rotation matrix with the current quaternion values
  3793. * @param result defines the target matrix
  3794. * @returns the current unchanged quaternion
  3795. */
  3796. toRotationMatrix(result: Matrix): Quaternion;
  3797. /**
  3798. * Updates the current quaternion from the given rotation matrix values
  3799. * @param matrix defines the source matrix
  3800. * @returns the current updated quaternion
  3801. */
  3802. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3803. /**
  3804. * Creates a new quaternion from a rotation matrix
  3805. * @param matrix defines the source matrix
  3806. * @returns a new quaternion created from the given rotation matrix values
  3807. */
  3808. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3809. /**
  3810. * Updates the given quaternion with the given rotation matrix values
  3811. * @param matrix defines the source matrix
  3812. * @param result defines the target quaternion
  3813. */
  3814. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3815. /**
  3816. * Returns the dot product (float) between the quaternions "left" and "right"
  3817. * @param left defines the left operand
  3818. * @param right defines the right operand
  3819. * @returns the dot product
  3820. */
  3821. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3822. /**
  3823. * Checks if the two quaternions are close to each other
  3824. * @param quat0 defines the first quaternion to check
  3825. * @param quat1 defines the second quaternion to check
  3826. * @returns true if the two quaternions are close to each other
  3827. */
  3828. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3829. /**
  3830. * Creates an empty quaternion
  3831. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3832. */
  3833. static Zero(): Quaternion;
  3834. /**
  3835. * Inverse a given quaternion
  3836. * @param q defines the source quaternion
  3837. * @returns a new quaternion as the inverted current quaternion
  3838. */
  3839. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3840. /**
  3841. * Inverse a given quaternion
  3842. * @param q defines the source quaternion
  3843. * @param result the quaternion the result will be stored in
  3844. * @returns the result quaternion
  3845. */
  3846. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3847. /**
  3848. * Creates an identity quaternion
  3849. * @returns the identity quaternion
  3850. */
  3851. static Identity(): Quaternion;
  3852. /**
  3853. * Gets a boolean indicating if the given quaternion is identity
  3854. * @param quaternion defines the quaternion to check
  3855. * @returns true if the quaternion is identity
  3856. */
  3857. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3858. /**
  3859. * Creates a quaternion from a rotation around an axis
  3860. * @param axis defines the axis to use
  3861. * @param angle defines the angle to use
  3862. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3863. */
  3864. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3865. /**
  3866. * Creates a rotation around an axis and stores it into the given quaternion
  3867. * @param axis defines the axis to use
  3868. * @param angle defines the angle to use
  3869. * @param result defines the target quaternion
  3870. * @returns the target quaternion
  3871. */
  3872. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3873. /**
  3874. * Creates a new quaternion from data stored into an array
  3875. * @param array defines the data source
  3876. * @param offset defines the offset in the source array where the data starts
  3877. * @returns a new quaternion
  3878. */
  3879. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3880. /**
  3881. * Updates the given quaternion "result" from the starting index of the given array.
  3882. * @param array the array to pull values from
  3883. * @param offset the offset into the array to start at
  3884. * @param result the quaternion to store the result in
  3885. */
  3886. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3887. /**
  3888. * Create a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @returns the new Quaternion
  3893. */
  3894. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3895. /**
  3896. * Updates a quaternion from Euler rotation angles
  3897. * @param x Pitch
  3898. * @param y Yaw
  3899. * @param z Roll
  3900. * @param result the quaternion to store the result
  3901. * @returns the updated quaternion
  3902. */
  3903. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3904. /**
  3905. * Create a quaternion from Euler rotation vector
  3906. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3907. * @returns the new Quaternion
  3908. */
  3909. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3910. /**
  3911. * Updates a quaternion from Euler rotation vector
  3912. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3913. * @param result the quaternion to store the result
  3914. * @returns the updated quaternion
  3915. */
  3916. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3917. /**
  3918. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @returns the new quaternion
  3923. */
  3924. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3925. /**
  3926. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3927. * @param yaw defines the rotation around Y axis
  3928. * @param pitch defines the rotation around X axis
  3929. * @param roll defines the rotation around Z axis
  3930. * @param result defines the target quaternion
  3931. */
  3932. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @returns the new quaternion
  3939. */
  3940. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3941. /**
  3942. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3943. * @param alpha defines the rotation around first axis
  3944. * @param beta defines the rotation around second axis
  3945. * @param gamma defines the rotation around third axis
  3946. * @param result defines the target quaternion
  3947. */
  3948. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3949. /**
  3950. * 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)
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @returns the new quaternion
  3955. */
  3956. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3957. /**
  3958. * 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
  3959. * @param axis1 defines the first axis
  3960. * @param axis2 defines the second axis
  3961. * @param axis3 defines the third axis
  3962. * @param ref defines the target quaternion
  3963. */
  3964. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3965. /**
  3966. * Interpolates between two quaternions
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @returns the new interpolated quaternion
  3971. */
  3972. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3973. /**
  3974. * Interpolates between two quaternions and stores it into a target quaternion
  3975. * @param left defines first quaternion
  3976. * @param right defines second quaternion
  3977. * @param amount defines the gradient to use
  3978. * @param result defines the target quaternion
  3979. */
  3980. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3981. /**
  3982. * Interpolate between two quaternions using Hermite interpolation
  3983. * @param value1 defines first quaternion
  3984. * @param tangent1 defines the incoming tangent
  3985. * @param value2 defines second quaternion
  3986. * @param tangent2 defines the outgoing tangent
  3987. * @param amount defines the target quaternion
  3988. * @returns the new interpolated quaternion
  3989. */
  3990. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3991. }
  3992. /**
  3993. * Class used to store matrix data (4x4)
  3994. */
  3995. export class Matrix {
  3996. private static _updateFlagSeed;
  3997. private static _identityReadOnly;
  3998. private _isIdentity;
  3999. private _isIdentityDirty;
  4000. private _isIdentity3x2;
  4001. private _isIdentity3x2Dirty;
  4002. /**
  4003. * Gets the update flag of the matrix which is an unique number for the matrix.
  4004. * It will be incremented every time the matrix data change.
  4005. * You can use it to speed the comparison between two versions of the same matrix.
  4006. */
  4007. updateFlag: number;
  4008. private readonly _m;
  4009. /**
  4010. * Gets the internal data of the matrix
  4011. */
  4012. get m(): DeepImmutable<Float32Array>;
  4013. /** @hidden */
  4014. _markAsUpdated(): void;
  4015. /** @hidden */
  4016. private _updateIdentityStatus;
  4017. /**
  4018. * Creates an empty matrix (filled with zeros)
  4019. */
  4020. constructor();
  4021. /**
  4022. * Check if the current matrix is identity
  4023. * @returns true is the matrix is the identity matrix
  4024. */
  4025. isIdentity(): boolean;
  4026. /**
  4027. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4028. * @returns true is the matrix is the identity matrix
  4029. */
  4030. isIdentityAs3x2(): boolean;
  4031. /**
  4032. * Gets the determinant of the matrix
  4033. * @returns the matrix determinant
  4034. */
  4035. determinant(): number;
  4036. /**
  4037. * Returns the matrix as a Float32Array
  4038. * @returns the matrix underlying array
  4039. */
  4040. toArray(): DeepImmutable<Float32Array>;
  4041. /**
  4042. * Returns the matrix as a Float32Array
  4043. * @returns the matrix underlying array.
  4044. */
  4045. asArray(): DeepImmutable<Float32Array>;
  4046. /**
  4047. * Inverts the current matrix in place
  4048. * @returns the current inverted matrix
  4049. */
  4050. invert(): Matrix;
  4051. /**
  4052. * Sets all the matrix elements to zero
  4053. * @returns the current matrix
  4054. */
  4055. reset(): Matrix;
  4056. /**
  4057. * Adds the current matrix with a second one
  4058. * @param other defines the matrix to add
  4059. * @returns a new matrix as the addition of the current matrix and the given one
  4060. */
  4061. add(other: DeepImmutable<Matrix>): Matrix;
  4062. /**
  4063. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4064. * @param other defines the matrix to add
  4065. * @param result defines the target matrix
  4066. * @returns the current matrix
  4067. */
  4068. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4069. /**
  4070. * Adds in place the given matrix to the current matrix
  4071. * @param other defines the second operand
  4072. * @returns the current updated matrix
  4073. */
  4074. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4075. /**
  4076. * Sets the given matrix to the current inverted Matrix
  4077. * @param other defines the target matrix
  4078. * @returns the unmodified current matrix
  4079. */
  4080. invertToRef(other: Matrix): Matrix;
  4081. /**
  4082. * add a value at the specified position in the current Matrix
  4083. * @param index the index of the value within the matrix. between 0 and 15.
  4084. * @param value the value to be added
  4085. * @returns the current updated matrix
  4086. */
  4087. addAtIndex(index: number, value: number): Matrix;
  4088. /**
  4089. * mutiply the specified position in the current Matrix by a value
  4090. * @param index the index of the value within the matrix. between 0 and 15.
  4091. * @param value the value to be added
  4092. * @returns the current updated matrix
  4093. */
  4094. multiplyAtIndex(index: number, value: number): Matrix;
  4095. /**
  4096. * Inserts the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Adds the translation vector (using 3 floats) in the current matrix
  4105. * @param x defines the 1st component of the translation
  4106. * @param y defines the 2nd component of the translation
  4107. * @param z defines the 3rd component of the translation
  4108. * @returns the current updated matrix
  4109. */
  4110. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4111. /**
  4112. * Inserts the translation vector in the current matrix
  4113. * @param vector3 defines the translation to insert
  4114. * @returns the current updated matrix
  4115. */
  4116. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4117. /**
  4118. * Gets the translation value of the current matrix
  4119. * @returns a new Vector3 as the extracted translation from the matrix
  4120. */
  4121. getTranslation(): Vector3;
  4122. /**
  4123. * Fill a Vector3 with the extracted translation from the matrix
  4124. * @param result defines the Vector3 where to store the translation
  4125. * @returns the current matrix
  4126. */
  4127. getTranslationToRef(result: Vector3): Matrix;
  4128. /**
  4129. * Remove rotation and scaling part from the matrix
  4130. * @returns the updated matrix
  4131. */
  4132. removeRotationAndScaling(): Matrix;
  4133. /**
  4134. * Multiply two matrices
  4135. * @param other defines the second operand
  4136. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4137. */
  4138. multiply(other: DeepImmutable<Matrix>): Matrix;
  4139. /**
  4140. * Copy the current matrix from the given one
  4141. * @param other defines the source matrix
  4142. * @returns the current updated matrix
  4143. */
  4144. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4145. /**
  4146. * Populates the given array from the starting index with the current matrix values
  4147. * @param array defines the target array
  4148. * @param offset defines the offset in the target array where to start storing values
  4149. * @returns the current matrix
  4150. */
  4151. copyToArray(array: Float32Array, offset?: number): Matrix;
  4152. /**
  4153. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4154. * @param other defines the second operand
  4155. * @param result defines the matrix where to store the multiplication
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4159. /**
  4160. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4161. * @param other defines the second operand
  4162. * @param result defines the array where to store the multiplication
  4163. * @param offset defines the offset in the target array where to start storing values
  4164. * @returns the current matrix
  4165. */
  4166. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4167. /**
  4168. * Check equality between this matrix and a second one
  4169. * @param value defines the second matrix to compare
  4170. * @returns true is the current matrix and the given one values are strictly equal
  4171. */
  4172. equals(value: DeepImmutable<Matrix>): boolean;
  4173. /**
  4174. * Clone the current matrix
  4175. * @returns a new matrix from the current matrix
  4176. */
  4177. clone(): Matrix;
  4178. /**
  4179. * Returns the name of the current matrix class
  4180. * @returns the string "Matrix"
  4181. */
  4182. getClassName(): string;
  4183. /**
  4184. * Gets the hash code of the current matrix
  4185. * @returns the hash code
  4186. */
  4187. getHashCode(): number;
  4188. /**
  4189. * Decomposes the current Matrix into a translation, rotation and scaling components
  4190. * @param scale defines the scale vector3 given as a reference to update
  4191. * @param rotation defines the rotation quaternion given as a reference to update
  4192. * @param translation defines the translation vector3 given as a reference to update
  4193. * @returns true if operation was successful
  4194. */
  4195. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4196. /**
  4197. * Gets specific row of the matrix
  4198. * @param index defines the number of the row to get
  4199. * @returns the index-th row of the current matrix as a new Vector4
  4200. */
  4201. getRow(index: number): Nullable<Vector4>;
  4202. /**
  4203. * Sets the index-th row of the current matrix to the vector4 values
  4204. * @param index defines the number of the row to set
  4205. * @param row defines the target vector4
  4206. * @returns the updated current matrix
  4207. */
  4208. setRow(index: number, row: Vector4): Matrix;
  4209. /**
  4210. * Compute the transpose of the matrix
  4211. * @returns the new transposed matrix
  4212. */
  4213. transpose(): Matrix;
  4214. /**
  4215. * Compute the transpose of the matrix and store it in a given matrix
  4216. * @param result defines the target matrix
  4217. * @returns the current matrix
  4218. */
  4219. transposeToRef(result: Matrix): Matrix;
  4220. /**
  4221. * Sets the index-th row of the current matrix with the given 4 x float values
  4222. * @param index defines the row index
  4223. * @param x defines the x component to set
  4224. * @param y defines the y component to set
  4225. * @param z defines the z component to set
  4226. * @param w defines the w component to set
  4227. * @returns the updated current matrix
  4228. */
  4229. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4230. /**
  4231. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4232. * @param scale defines the scale factor
  4233. * @returns a new matrix
  4234. */
  4235. scale(scale: number): Matrix;
  4236. /**
  4237. * Scale the current matrix values by a factor to a given result matrix
  4238. * @param scale defines the scale factor
  4239. * @param result defines the matrix to store the result
  4240. * @returns the current matrix
  4241. */
  4242. scaleToRef(scale: number, result: Matrix): Matrix;
  4243. /**
  4244. * Scale the current matrix values by a factor and add the result to a given matrix
  4245. * @param scale defines the scale factor
  4246. * @param result defines the Matrix to store the result
  4247. * @returns the current matrix
  4248. */
  4249. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4250. /**
  4251. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4252. * @param ref matrix to store the result
  4253. */
  4254. toNormalMatrix(ref: Matrix): void;
  4255. /**
  4256. * Gets only rotation part of the current matrix
  4257. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4258. */
  4259. getRotationMatrix(): Matrix;
  4260. /**
  4261. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4262. * @param result defines the target matrix to store data to
  4263. * @returns the current matrix
  4264. */
  4265. getRotationMatrixToRef(result: Matrix): Matrix;
  4266. /**
  4267. * Toggles model matrix from being right handed to left handed in place and vice versa
  4268. */
  4269. toggleModelMatrixHandInPlace(): void;
  4270. /**
  4271. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4272. */
  4273. toggleProjectionMatrixHandInPlace(): void;
  4274. /**
  4275. * Creates a matrix from an array
  4276. * @param array defines the source array
  4277. * @param offset defines an offset in the source array
  4278. * @returns a new Matrix set from the starting index of the given array
  4279. */
  4280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4281. /**
  4282. * Copy the content of an array into a given matrix
  4283. * @param array defines the source array
  4284. * @param offset defines an offset in the source array
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4288. /**
  4289. * Stores an array into a matrix after having multiplied each component by a given factor
  4290. * @param array defines the source array
  4291. * @param offset defines the offset in the source array
  4292. * @param scale defines the scaling factor
  4293. * @param result defines the target matrix
  4294. */
  4295. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4296. /**
  4297. * Gets an identity matrix that must not be updated
  4298. */
  4299. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4300. /**
  4301. * Stores a list of values (16) inside a given matrix
  4302. * @param initialM11 defines 1st value of 1st row
  4303. * @param initialM12 defines 2nd value of 1st row
  4304. * @param initialM13 defines 3rd value of 1st row
  4305. * @param initialM14 defines 4th value of 1st row
  4306. * @param initialM21 defines 1st value of 2nd row
  4307. * @param initialM22 defines 2nd value of 2nd row
  4308. * @param initialM23 defines 3rd value of 2nd row
  4309. * @param initialM24 defines 4th value of 2nd row
  4310. * @param initialM31 defines 1st value of 3rd row
  4311. * @param initialM32 defines 2nd value of 3rd row
  4312. * @param initialM33 defines 3rd value of 3rd row
  4313. * @param initialM34 defines 4th value of 3rd row
  4314. * @param initialM41 defines 1st value of 4th row
  4315. * @param initialM42 defines 2nd value of 4th row
  4316. * @param initialM43 defines 3rd value of 4th row
  4317. * @param initialM44 defines 4th value of 4th row
  4318. * @param result defines the target matrix
  4319. */
  4320. 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;
  4321. /**
  4322. * Creates new matrix from a list of values (16)
  4323. * @param initialM11 defines 1st value of 1st row
  4324. * @param initialM12 defines 2nd value of 1st row
  4325. * @param initialM13 defines 3rd value of 1st row
  4326. * @param initialM14 defines 4th value of 1st row
  4327. * @param initialM21 defines 1st value of 2nd row
  4328. * @param initialM22 defines 2nd value of 2nd row
  4329. * @param initialM23 defines 3rd value of 2nd row
  4330. * @param initialM24 defines 4th value of 2nd row
  4331. * @param initialM31 defines 1st value of 3rd row
  4332. * @param initialM32 defines 2nd value of 3rd row
  4333. * @param initialM33 defines 3rd value of 3rd row
  4334. * @param initialM34 defines 4th value of 3rd row
  4335. * @param initialM41 defines 1st value of 4th row
  4336. * @param initialM42 defines 2nd value of 4th row
  4337. * @param initialM43 defines 3rd value of 4th row
  4338. * @param initialM44 defines 4th value of 4th row
  4339. * @returns the new matrix
  4340. */
  4341. 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;
  4342. /**
  4343. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @returns a new matrix
  4348. */
  4349. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4350. /**
  4351. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4352. * @param scale defines the scale vector3
  4353. * @param rotation defines the rotation quaternion
  4354. * @param translation defines the translation vector3
  4355. * @param result defines the target matrix
  4356. */
  4357. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4358. /**
  4359. * Creates a new identity matrix
  4360. * @returns a new identity matrix
  4361. */
  4362. static Identity(): Matrix;
  4363. /**
  4364. * Creates a new identity matrix and stores the result in a given matrix
  4365. * @param result defines the target matrix
  4366. */
  4367. static IdentityToRef(result: Matrix): void;
  4368. /**
  4369. * Creates a new zero matrix
  4370. * @returns a new zero matrix
  4371. */
  4372. static Zero(): Matrix;
  4373. /**
  4374. * Creates a new rotation matrix for "angle" radians around the X axis
  4375. * @param angle defines the angle (in radians) to use
  4376. * @return the new matrix
  4377. */
  4378. static RotationX(angle: number): Matrix;
  4379. /**
  4380. * Creates a new matrix as the invert of a given matrix
  4381. * @param source defines the source matrix
  4382. * @returns the new matrix
  4383. */
  4384. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4385. /**
  4386. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4387. * @param angle defines the angle (in radians) to use
  4388. * @param result defines the target matrix
  4389. */
  4390. static RotationXToRef(angle: number, result: Matrix): void;
  4391. /**
  4392. * Creates a new rotation matrix for "angle" radians around the Y axis
  4393. * @param angle defines the angle (in radians) to use
  4394. * @return the new matrix
  4395. */
  4396. static RotationY(angle: number): Matrix;
  4397. /**
  4398. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4399. * @param angle defines the angle (in radians) to use
  4400. * @param result defines the target matrix
  4401. */
  4402. static RotationYToRef(angle: number, result: Matrix): void;
  4403. /**
  4404. * Creates a new rotation matrix for "angle" radians around the Z axis
  4405. * @param angle defines the angle (in radians) to use
  4406. * @return the new matrix
  4407. */
  4408. static RotationZ(angle: number): Matrix;
  4409. /**
  4410. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4411. * @param angle defines the angle (in radians) to use
  4412. * @param result defines the target matrix
  4413. */
  4414. static RotationZToRef(angle: number, result: Matrix): void;
  4415. /**
  4416. * Creates a new rotation matrix for "angle" radians around the given axis
  4417. * @param axis defines the axis to use
  4418. * @param angle defines the angle (in radians) to use
  4419. * @return the new matrix
  4420. */
  4421. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4422. /**
  4423. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4424. * @param axis defines the axis to use
  4425. * @param angle defines the angle (in radians) to use
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4429. /**
  4430. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4431. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4432. * @param from defines the vector to align
  4433. * @param to defines the vector to align to
  4434. * @param result defines the target matrix
  4435. */
  4436. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4437. /**
  4438. * Creates a rotation matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @returns the new rotation matrix
  4443. */
  4444. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4445. /**
  4446. * Creates a rotation matrix and stores it in a given matrix
  4447. * @param yaw defines the yaw angle in radians (Y axis)
  4448. * @param pitch defines the pitch angle in radians (X axis)
  4449. * @param roll defines the roll angle in radians (X axis)
  4450. * @param result defines the target matrix
  4451. */
  4452. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4453. /**
  4454. * Creates a scaling matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @returns the new matrix
  4459. */
  4460. static Scaling(x: number, y: number, z: number): Matrix;
  4461. /**
  4462. * Creates a scaling matrix and stores it in a given matrix
  4463. * @param x defines the scale factor on X axis
  4464. * @param y defines the scale factor on Y axis
  4465. * @param z defines the scale factor on Z axis
  4466. * @param result defines the target matrix
  4467. */
  4468. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4469. /**
  4470. * Creates a translation matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @returns the new matrix
  4475. */
  4476. static Translation(x: number, y: number, z: number): Matrix;
  4477. /**
  4478. * Creates a translation matrix and stores it in a given matrix
  4479. * @param x defines the translation on X axis
  4480. * @param y defines the translation on Y axis
  4481. * @param z defines the translationon Z axis
  4482. * @param result defines the target matrix
  4483. */
  4484. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4485. /**
  4486. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @returns the new matrix
  4491. */
  4492. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4493. /**
  4494. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4495. * @param startValue defines the start value
  4496. * @param endValue defines the end value
  4497. * @param gradient defines the gradient factor
  4498. * @param result defines the Matrix object where to store data
  4499. */
  4500. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4501. /**
  4502. * Builds a new matrix whose values are computed by:
  4503. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4504. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4505. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4506. * @param startValue defines the first matrix
  4507. * @param endValue defines the second matrix
  4508. * @param gradient defines the gradient between the two matrices
  4509. * @returns the new matrix
  4510. */
  4511. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4512. /**
  4513. * Update a matrix to values which are computed by:
  4514. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4515. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4516. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4517. * @param startValue defines the first matrix
  4518. * @param endValue defines the second matrix
  4519. * @param gradient defines the gradient between the two matrices
  4520. * @param result defines the target matrix
  4521. */
  4522. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4523. /**
  4524. * 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"
  4525. * This function works in left handed mode
  4526. * @param eye defines the final position of the entity
  4527. * @param target defines where the entity should look at
  4528. * @param up defines the up vector for the entity
  4529. * @returns the new matrix
  4530. */
  4531. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4532. /**
  4533. * 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".
  4534. * This function works in left handed mode
  4535. * @param eye defines the final position of the entity
  4536. * @param target defines where the entity should look at
  4537. * @param up defines the up vector for the entity
  4538. * @param result defines the target matrix
  4539. */
  4540. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4541. /**
  4542. * 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"
  4543. * This function works in right handed mode
  4544. * @param eye defines the final position of the entity
  4545. * @param target defines where the entity should look at
  4546. * @param up defines the up vector for the entity
  4547. * @returns the new matrix
  4548. */
  4549. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4550. /**
  4551. * 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".
  4552. * This function works in right handed mode
  4553. * @param eye defines the final position of the entity
  4554. * @param target defines where the entity should look at
  4555. * @param up defines the up vector for the entity
  4556. * @param result defines the target matrix
  4557. */
  4558. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4559. /**
  4560. * Create a left-handed orthographic projection matrix
  4561. * @param width defines the viewport width
  4562. * @param height defines the viewport height
  4563. * @param znear defines the near clip plane
  4564. * @param zfar defines the far clip plane
  4565. * @returns a new matrix as a left-handed orthographic projection matrix
  4566. */
  4567. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4568. /**
  4569. * Store a left-handed orthographic projection to a given matrix
  4570. * @param width defines the viewport width
  4571. * @param height defines the viewport height
  4572. * @param znear defines the near clip plane
  4573. * @param zfar defines the far clip plane
  4574. * @param result defines the target matrix
  4575. */
  4576. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4577. /**
  4578. * Create a left-handed orthographic projection matrix
  4579. * @param left defines the viewport left coordinate
  4580. * @param right defines the viewport right coordinate
  4581. * @param bottom defines the viewport bottom coordinate
  4582. * @param top defines the viewport top coordinate
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @returns a new matrix as a left-handed orthographic projection matrix
  4586. */
  4587. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4588. /**
  4589. * Stores a left-handed orthographic projection into a given matrix
  4590. * @param left defines the viewport left coordinate
  4591. * @param right defines the viewport right coordinate
  4592. * @param bottom defines the viewport bottom coordinate
  4593. * @param top defines the viewport top coordinate
  4594. * @param znear defines the near clip plane
  4595. * @param zfar defines the far clip plane
  4596. * @param result defines the target matrix
  4597. */
  4598. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4599. /**
  4600. * Creates a right-handed orthographic projection matrix
  4601. * @param left defines the viewport left coordinate
  4602. * @param right defines the viewport right coordinate
  4603. * @param bottom defines the viewport bottom coordinate
  4604. * @param top defines the viewport top coordinate
  4605. * @param znear defines the near clip plane
  4606. * @param zfar defines the far clip plane
  4607. * @returns a new matrix as a right-handed orthographic projection matrix
  4608. */
  4609. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4610. /**
  4611. * Stores a right-handed orthographic projection into a given matrix
  4612. * @param left defines the viewport left coordinate
  4613. * @param right defines the viewport right coordinate
  4614. * @param bottom defines the viewport bottom coordinate
  4615. * @param top defines the viewport top coordinate
  4616. * @param znear defines the near clip plane
  4617. * @param zfar defines the far clip plane
  4618. * @param result defines the target matrix
  4619. */
  4620. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4621. /**
  4622. * Creates a left-handed perspective projection matrix
  4623. * @param width defines the viewport width
  4624. * @param height defines the viewport height
  4625. * @param znear defines the near clip plane
  4626. * @param zfar defines the far clip plane
  4627. * @returns a new matrix as a left-handed perspective projection matrix
  4628. */
  4629. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4630. /**
  4631. * Creates a left-handed perspective projection matrix
  4632. * @param fov defines the horizontal field of view
  4633. * @param aspect defines the aspect ratio
  4634. * @param znear defines the near clip plane
  4635. * @param zfar defines the far clip plane
  4636. * @returns a new matrix as a left-handed perspective projection matrix
  4637. */
  4638. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4639. /**
  4640. * Stores a left-handed perspective projection into a given matrix
  4641. * @param fov defines the horizontal field of view
  4642. * @param aspect defines the aspect ratio
  4643. * @param znear defines the near clip plane
  4644. * @param zfar defines the far clip plane
  4645. * @param result defines the target matrix
  4646. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4647. */
  4648. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4649. /**
  4650. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4651. * @param fov defines the horizontal field of view
  4652. * @param aspect defines the aspect ratio
  4653. * @param znear defines the near clip plane
  4654. * @param zfar not used as infinity is used as far clip
  4655. * @param result defines the target matrix
  4656. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4657. */
  4658. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4659. /**
  4660. * Creates a right-handed perspective projection matrix
  4661. * @param fov defines the horizontal field of view
  4662. * @param aspect defines the aspect ratio
  4663. * @param znear defines the near clip plane
  4664. * @param zfar defines the far clip plane
  4665. * @returns a new matrix as a right-handed perspective projection matrix
  4666. */
  4667. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4668. /**
  4669. * Stores a right-handed perspective projection into a given matrix
  4670. * @param fov defines the horizontal field of view
  4671. * @param aspect defines the aspect ratio
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4676. */
  4677. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4678. /**
  4679. * Stores a right-handed perspective projection into a given matrix
  4680. * @param fov defines the horizontal field of view
  4681. * @param aspect defines the aspect ratio
  4682. * @param znear defines the near clip plane
  4683. * @param zfar not used as infinity is used as far clip
  4684. * @param result defines the target matrix
  4685. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4686. */
  4687. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4688. /**
  4689. * Stores a perspective projection for WebVR info a given matrix
  4690. * @param fov defines the field of view
  4691. * @param znear defines the near clip plane
  4692. * @param zfar defines the far clip plane
  4693. * @param result defines the target matrix
  4694. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4695. */
  4696. static PerspectiveFovWebVRToRef(fov: {
  4697. upDegrees: number;
  4698. downDegrees: number;
  4699. leftDegrees: number;
  4700. rightDegrees: number;
  4701. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4702. /**
  4703. * Computes a complete transformation matrix
  4704. * @param viewport defines the viewport to use
  4705. * @param world defines the world matrix
  4706. * @param view defines the view matrix
  4707. * @param projection defines the projection matrix
  4708. * @param zmin defines the near clip plane
  4709. * @param zmax defines the far clip plane
  4710. * @returns the transformation matrix
  4711. */
  4712. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4713. /**
  4714. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4715. * @param matrix defines the matrix to use
  4716. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4717. */
  4718. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4719. /**
  4720. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4721. * @param matrix defines the matrix to use
  4722. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4723. */
  4724. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4725. /**
  4726. * Compute the transpose of a given matrix
  4727. * @param matrix defines the matrix to transpose
  4728. * @returns the new matrix
  4729. */
  4730. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4731. /**
  4732. * Compute the transpose of a matrix and store it in a target matrix
  4733. * @param matrix defines the matrix to transpose
  4734. * @param result defines the target matrix
  4735. */
  4736. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4737. /**
  4738. * Computes a reflection matrix from a plane
  4739. * @param plane defines the reflection plane
  4740. * @returns a new matrix
  4741. */
  4742. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4743. /**
  4744. * Computes a reflection matrix from a plane
  4745. * @param plane defines the reflection plane
  4746. * @param result defines the target matrix
  4747. */
  4748. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4749. /**
  4750. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4751. * @param xaxis defines the value of the 1st axis
  4752. * @param yaxis defines the value of the 2nd axis
  4753. * @param zaxis defines the value of the 3rd axis
  4754. * @param result defines the target matrix
  4755. */
  4756. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4757. /**
  4758. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4759. * @param quat defines the quaternion to use
  4760. * @param result defines the target matrix
  4761. */
  4762. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4763. }
  4764. /**
  4765. * @hidden
  4766. */
  4767. export class TmpVectors {
  4768. static Vector2: Vector2[];
  4769. static Vector3: Vector3[];
  4770. static Vector4: Vector4[];
  4771. static Quaternion: Quaternion[];
  4772. static Matrix: Matrix[];
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /**
  4777. * Defines potential orientation for back face culling
  4778. */
  4779. export enum Orientation {
  4780. /**
  4781. * Clockwise
  4782. */
  4783. CW = 0,
  4784. /** Counter clockwise */
  4785. CCW = 1
  4786. }
  4787. /** Class used to represent a Bezier curve */
  4788. export class BezierCurve {
  4789. /**
  4790. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4791. * @param t defines the time
  4792. * @param x1 defines the left coordinate on X axis
  4793. * @param y1 defines the left coordinate on Y axis
  4794. * @param x2 defines the right coordinate on X axis
  4795. * @param y2 defines the right coordinate on Y axis
  4796. * @returns the interpolated value
  4797. */
  4798. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4799. }
  4800. /**
  4801. * Defines angle representation
  4802. */
  4803. export class Angle {
  4804. private _radians;
  4805. /**
  4806. * Creates an Angle object of "radians" radians (float).
  4807. * @param radians the angle in radians
  4808. */
  4809. constructor(radians: number);
  4810. /**
  4811. * Get value in degrees
  4812. * @returns the Angle value in degrees (float)
  4813. */
  4814. degrees(): number;
  4815. /**
  4816. * Get value in radians
  4817. * @returns the Angle value in radians (float)
  4818. */
  4819. radians(): number;
  4820. /**
  4821. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4822. * @param a defines first vector
  4823. * @param b defines second vector
  4824. * @returns a new Angle
  4825. */
  4826. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4827. /**
  4828. * Gets a new Angle object from the given float in radians
  4829. * @param radians defines the angle value in radians
  4830. * @returns a new Angle
  4831. */
  4832. static FromRadians(radians: number): Angle;
  4833. /**
  4834. * Gets a new Angle object from the given float in degrees
  4835. * @param degrees defines the angle value in degrees
  4836. * @returns a new Angle
  4837. */
  4838. static FromDegrees(degrees: number): Angle;
  4839. }
  4840. /**
  4841. * This represents an arc in a 2d space.
  4842. */
  4843. export class Arc2 {
  4844. /** Defines the start point of the arc */
  4845. startPoint: Vector2;
  4846. /** Defines the mid point of the arc */
  4847. midPoint: Vector2;
  4848. /** Defines the end point of the arc */
  4849. endPoint: Vector2;
  4850. /**
  4851. * Defines the center point of the arc.
  4852. */
  4853. centerPoint: Vector2;
  4854. /**
  4855. * Defines the radius of the arc.
  4856. */
  4857. radius: number;
  4858. /**
  4859. * Defines the angle of the arc (from mid point to end point).
  4860. */
  4861. angle: Angle;
  4862. /**
  4863. * Defines the start angle of the arc (from start point to middle point).
  4864. */
  4865. startAngle: Angle;
  4866. /**
  4867. * Defines the orientation of the arc (clock wise/counter clock wise).
  4868. */
  4869. orientation: Orientation;
  4870. /**
  4871. * Creates an Arc object from the three given points : start, middle and end.
  4872. * @param startPoint Defines the start point of the arc
  4873. * @param midPoint Defines the midlle point of the arc
  4874. * @param endPoint Defines the end point of the arc
  4875. */
  4876. constructor(
  4877. /** Defines the start point of the arc */
  4878. startPoint: Vector2,
  4879. /** Defines the mid point of the arc */
  4880. midPoint: Vector2,
  4881. /** Defines the end point of the arc */
  4882. endPoint: Vector2);
  4883. }
  4884. /**
  4885. * Represents a 2D path made up of multiple 2D points
  4886. */
  4887. export class Path2 {
  4888. private _points;
  4889. private _length;
  4890. /**
  4891. * If the path start and end point are the same
  4892. */
  4893. closed: boolean;
  4894. /**
  4895. * Creates a Path2 object from the starting 2D coordinates x and y.
  4896. * @param x the starting points x value
  4897. * @param y the starting points y value
  4898. */
  4899. constructor(x: number, y: number);
  4900. /**
  4901. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4902. * @param x the added points x value
  4903. * @param y the added points y value
  4904. * @returns the updated Path2.
  4905. */
  4906. addLineTo(x: number, y: number): Path2;
  4907. /**
  4908. * 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.
  4909. * @param midX middle point x value
  4910. * @param midY middle point y value
  4911. * @param endX end point x value
  4912. * @param endY end point y value
  4913. * @param numberOfSegments (default: 36)
  4914. * @returns the updated Path2.
  4915. */
  4916. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4917. /**
  4918. * Closes the Path2.
  4919. * @returns the Path2.
  4920. */
  4921. close(): Path2;
  4922. /**
  4923. * Gets the sum of the distance between each sequential point in the path
  4924. * @returns the Path2 total length (float).
  4925. */
  4926. length(): number;
  4927. /**
  4928. * Gets the points which construct the path
  4929. * @returns the Path2 internal array of points.
  4930. */
  4931. getPoints(): Vector2[];
  4932. /**
  4933. * Retreives the point at the distance aways from the starting point
  4934. * @param normalizedLengthPosition the length along the path to retreive the point from
  4935. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4936. */
  4937. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4938. /**
  4939. * Creates a new path starting from an x and y position
  4940. * @param x starting x value
  4941. * @param y starting y value
  4942. * @returns a new Path2 starting at the coordinates (x, y).
  4943. */
  4944. static StartingAt(x: number, y: number): Path2;
  4945. }
  4946. /**
  4947. * Represents a 3D path made up of multiple 3D points
  4948. */
  4949. export class Path3D {
  4950. /**
  4951. * an array of Vector3, the curve axis of the Path3D
  4952. */
  4953. path: Vector3[];
  4954. private _curve;
  4955. private _distances;
  4956. private _tangents;
  4957. private _normals;
  4958. private _binormals;
  4959. private _raw;
  4960. private _alignTangentsWithPath;
  4961. private readonly _pointAtData;
  4962. /**
  4963. * new Path3D(path, normal, raw)
  4964. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4965. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4966. * @param path an array of Vector3, the curve axis of the Path3D
  4967. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4968. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4969. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4970. */
  4971. constructor(
  4972. /**
  4973. * an array of Vector3, the curve axis of the Path3D
  4974. */
  4975. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4976. /**
  4977. * Returns the Path3D array of successive Vector3 designing its curve.
  4978. * @returns the Path3D array of successive Vector3 designing its curve.
  4979. */
  4980. getCurve(): Vector3[];
  4981. /**
  4982. * Returns the Path3D array of successive Vector3 designing its curve.
  4983. * @returns the Path3D array of successive Vector3 designing its curve.
  4984. */
  4985. getPoints(): Vector3[];
  4986. /**
  4987. * @returns the computed length (float) of the path.
  4988. */
  4989. length(): number;
  4990. /**
  4991. * Returns an array populated with tangent vectors on each Path3D curve point.
  4992. * @returns an array populated with tangent vectors on each Path3D curve point.
  4993. */
  4994. getTangents(): Vector3[];
  4995. /**
  4996. * Returns an array populated with normal vectors on each Path3D curve point.
  4997. * @returns an array populated with normal vectors on each Path3D curve point.
  4998. */
  4999. getNormals(): Vector3[];
  5000. /**
  5001. * Returns an array populated with binormal vectors on each Path3D curve point.
  5002. * @returns an array populated with binormal vectors on each Path3D curve point.
  5003. */
  5004. getBinormals(): Vector3[];
  5005. /**
  5006. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5008. */
  5009. getDistances(): number[];
  5010. /**
  5011. * Returns an interpolated point along this path
  5012. * @param position the position of the point along this path, from 0.0 to 1.0
  5013. * @returns a new Vector3 as the point
  5014. */
  5015. getPointAt(position: number): Vector3;
  5016. /**
  5017. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5018. * @param position the position of the point along this path, from 0.0 to 1.0
  5019. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5020. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5021. */
  5022. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5023. /**
  5024. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5025. * @param position the position of the point along this path, from 0.0 to 1.0
  5026. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5027. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5028. */
  5029. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5030. /**
  5031. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5032. * @param position the position of the point along this path, from 0.0 to 1.0
  5033. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5034. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5035. */
  5036. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5037. /**
  5038. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5039. * @param position the position of the point along this path, from 0.0 to 1.0
  5040. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5041. */
  5042. getDistanceAt(position: number): number;
  5043. /**
  5044. * Returns the array index of the previous point of an interpolated point along this path
  5045. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5046. * @returns the array index
  5047. */
  5048. getPreviousPointIndexAt(position: number): number;
  5049. /**
  5050. * 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)
  5051. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5052. * @returns the sub position
  5053. */
  5054. getSubPositionAt(position: number): number;
  5055. /**
  5056. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5057. * @param target the vector of which to get the closest position to
  5058. * @returns the position of the closest virtual point on this path to the target vector
  5059. */
  5060. getClosestPositionTo(target: Vector3): number;
  5061. /**
  5062. * Returns a sub path (slice) of this path
  5063. * @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
  5064. * @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
  5065. * @returns a sub path (slice) of this path
  5066. */
  5067. slice(start?: number, end?: number): Path3D;
  5068. /**
  5069. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5070. * @param path path which all values are copied into the curves points
  5071. * @param firstNormal which should be projected onto the curve
  5072. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5073. * @returns the same object updated.
  5074. */
  5075. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5076. private _compute;
  5077. private _getFirstNonNullVector;
  5078. private _getLastNonNullVector;
  5079. private _normalVector;
  5080. /**
  5081. * Updates the point at data for an interpolated point along this curve
  5082. * @param position the position of the point along this curve, from 0.0 to 1.0
  5083. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5084. * @returns the (updated) point at data
  5085. */
  5086. private _updatePointAtData;
  5087. /**
  5088. * Updates the point at data from the specified parameters
  5089. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5090. * @param point the interpolated point
  5091. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5092. */
  5093. private _setPointAtData;
  5094. /**
  5095. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5096. */
  5097. private _updateInterpolationMatrix;
  5098. }
  5099. /**
  5100. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5101. * A Curve3 is designed from a series of successive Vector3.
  5102. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5103. */
  5104. export class Curve3 {
  5105. private _points;
  5106. private _length;
  5107. /**
  5108. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5109. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5110. * @param v1 (Vector3) the control point
  5111. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5112. * @param nbPoints (integer) the wanted number of points in the curve
  5113. * @returns the created Curve3
  5114. */
  5115. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5116. /**
  5117. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5118. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5119. * @param v1 (Vector3) the first control point
  5120. * @param v2 (Vector3) the second control point
  5121. * @param v3 (Vector3) the end point of the Cubic Bezier
  5122. * @param nbPoints (integer) the wanted number of points in the curve
  5123. * @returns the created Curve3
  5124. */
  5125. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5126. /**
  5127. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5128. * @param p1 (Vector3) the origin point of the Hermite Spline
  5129. * @param t1 (Vector3) the tangent vector at the origin point
  5130. * @param p2 (Vector3) the end point of the Hermite Spline
  5131. * @param t2 (Vector3) the tangent vector at the end point
  5132. * @param nbPoints (integer) the wanted number of points in the curve
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5136. /**
  5137. * Returns a Curve3 object along a CatmullRom Spline curve :
  5138. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5139. * @param nbPoints (integer) the wanted number of points between each curve control points
  5140. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5141. * @returns the created Curve3
  5142. */
  5143. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5144. /**
  5145. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5146. * A Curve3 is designed from a series of successive Vector3.
  5147. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5148. * @param points points which make up the curve
  5149. */
  5150. constructor(points: Vector3[]);
  5151. /**
  5152. * @returns the Curve3 stored array of successive Vector3
  5153. */
  5154. getPoints(): Vector3[];
  5155. /**
  5156. * @returns the computed length (float) of the curve.
  5157. */
  5158. length(): number;
  5159. /**
  5160. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5161. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5162. * curveA and curveB keep unchanged.
  5163. * @param curve the curve to continue from this curve
  5164. * @returns the newly constructed curve
  5165. */
  5166. continue(curve: DeepImmutable<Curve3>): Curve3;
  5167. private _computeLength;
  5168. }
  5169. }
  5170. declare module BABYLON {
  5171. /**
  5172. * This represents the main contract an easing function should follow.
  5173. * Easing functions are used throughout the animation system.
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export interface IEasingFunction {
  5177. /**
  5178. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5179. * of the easing function.
  5180. * The link below provides some of the most common examples of easing functions.
  5181. * @see https://easings.net/
  5182. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5183. * @returns the corresponding value on the curve defined by the easing function
  5184. */
  5185. ease(gradient: number): number;
  5186. }
  5187. /**
  5188. * Base class used for every default easing function.
  5189. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5190. */
  5191. export class EasingFunction implements IEasingFunction {
  5192. /**
  5193. * Interpolation follows the mathematical formula associated with the easing function.
  5194. */
  5195. static readonly EASINGMODE_EASEIN: number;
  5196. /**
  5197. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5198. */
  5199. static readonly EASINGMODE_EASEOUT: number;
  5200. /**
  5201. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5202. */
  5203. static readonly EASINGMODE_EASEINOUT: number;
  5204. private _easingMode;
  5205. /**
  5206. * Sets the easing mode of the current function.
  5207. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5208. */
  5209. setEasingMode(easingMode: number): void;
  5210. /**
  5211. * Gets the current easing mode.
  5212. * @returns the easing mode
  5213. */
  5214. getEasingMode(): number;
  5215. /**
  5216. * @hidden
  5217. */
  5218. easeInCore(gradient: number): number;
  5219. /**
  5220. * Given an input gradient between 0 and 1, this returns the corresponding value
  5221. * of the easing function.
  5222. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5223. * @returns the corresponding value on the curve defined by the easing function
  5224. */
  5225. ease(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a circle shape (see link below).
  5229. * @see https://easings.net/#easeInCirc
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class CircleEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a ease back shape (see link below).
  5238. * @see https://easings.net/#easeInBack
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class BackEase extends EasingFunction implements IEasingFunction {
  5242. /** Defines the amplitude of the function */
  5243. amplitude: number;
  5244. /**
  5245. * Instantiates a back ease easing
  5246. * @see https://easings.net/#easeInBack
  5247. * @param amplitude Defines the amplitude of the function
  5248. */
  5249. constructor(
  5250. /** Defines the amplitude of the function */
  5251. amplitude?: number);
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a bouncing shape (see link below).
  5257. * @see https://easings.net/#easeInBounce
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class BounceEase extends EasingFunction implements IEasingFunction {
  5261. /** Defines the number of bounces */
  5262. bounces: number;
  5263. /** Defines the amplitude of the bounce */
  5264. bounciness: number;
  5265. /**
  5266. * Instantiates a bounce easing
  5267. * @see https://easings.net/#easeInBounce
  5268. * @param bounces Defines the number of bounces
  5269. * @param bounciness Defines the amplitude of the bounce
  5270. */
  5271. constructor(
  5272. /** Defines the number of bounces */
  5273. bounces?: number,
  5274. /** Defines the amplitude of the bounce */
  5275. bounciness?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. /**
  5280. * Easing function with a power of 3 shape (see link below).
  5281. * @see https://easings.net/#easeInCubic
  5282. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5283. */
  5284. export class CubicEase extends EasingFunction implements IEasingFunction {
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. /**
  5289. * Easing function with an elastic shape (see link below).
  5290. * @see https://easings.net/#easeInElastic
  5291. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5292. */
  5293. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5294. /** Defines the number of oscillations*/
  5295. oscillations: number;
  5296. /** Defines the amplitude of the oscillations*/
  5297. springiness: number;
  5298. /**
  5299. * Instantiates an elastic easing function
  5300. * @see https://easings.net/#easeInElastic
  5301. * @param oscillations Defines the number of oscillations
  5302. * @param springiness Defines the amplitude of the oscillations
  5303. */
  5304. constructor(
  5305. /** Defines the number of oscillations*/
  5306. oscillations?: number,
  5307. /** Defines the amplitude of the oscillations*/
  5308. springiness?: number);
  5309. /** @hidden */
  5310. easeInCore(gradient: number): number;
  5311. }
  5312. /**
  5313. * Easing function with an exponential shape (see link below).
  5314. * @see https://easings.net/#easeInExpo
  5315. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5316. */
  5317. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5318. /** Defines the exponent of the function */
  5319. exponent: number;
  5320. /**
  5321. * Instantiates an exponential easing function
  5322. * @see https://easings.net/#easeInExpo
  5323. * @param exponent Defines the exponent of the function
  5324. */
  5325. constructor(
  5326. /** Defines the exponent of the function */
  5327. exponent?: number);
  5328. /** @hidden */
  5329. easeInCore(gradient: number): number;
  5330. }
  5331. /**
  5332. * Easing function with a power shape (see link below).
  5333. * @see https://easings.net/#easeInQuad
  5334. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5335. */
  5336. export class PowerEase extends EasingFunction implements IEasingFunction {
  5337. /** Defines the power of the function */
  5338. power: number;
  5339. /**
  5340. * Instantiates an power base easing function
  5341. * @see https://easings.net/#easeInQuad
  5342. * @param power Defines the power of the function
  5343. */
  5344. constructor(
  5345. /** Defines the power of the function */
  5346. power?: number);
  5347. /** @hidden */
  5348. easeInCore(gradient: number): number;
  5349. }
  5350. /**
  5351. * Easing function with a power of 2 shape (see link below).
  5352. * @see https://easings.net/#easeInQuad
  5353. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5354. */
  5355. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5356. /** @hidden */
  5357. easeInCore(gradient: number): number;
  5358. }
  5359. /**
  5360. * Easing function with a power of 4 shape (see link below).
  5361. * @see https://easings.net/#easeInQuart
  5362. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5363. */
  5364. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a power of 5 shape (see link below).
  5370. * @see https://easings.net/#easeInQuint
  5371. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5374. /** @hidden */
  5375. easeInCore(gradient: number): number;
  5376. }
  5377. /**
  5378. * Easing function with a sin shape (see link below).
  5379. * @see https://easings.net/#easeInSine
  5380. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5381. */
  5382. export class SineEase extends EasingFunction implements IEasingFunction {
  5383. /** @hidden */
  5384. easeInCore(gradient: number): number;
  5385. }
  5386. /**
  5387. * Easing function with a bezier shape (see link below).
  5388. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5389. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5390. */
  5391. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5392. /** Defines the x component of the start tangent in the bezier curve */
  5393. x1: number;
  5394. /** Defines the y component of the start tangent in the bezier curve */
  5395. y1: number;
  5396. /** Defines the x component of the end tangent in the bezier curve */
  5397. x2: number;
  5398. /** Defines the y component of the end tangent in the bezier curve */
  5399. y2: number;
  5400. /**
  5401. * Instantiates a bezier function
  5402. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5403. * @param x1 Defines the x component of the start tangent in the bezier curve
  5404. * @param y1 Defines the y component of the start tangent in the bezier curve
  5405. * @param x2 Defines the x component of the end tangent in the bezier curve
  5406. * @param y2 Defines the y component of the end tangent in the bezier curve
  5407. */
  5408. constructor(
  5409. /** Defines the x component of the start tangent in the bezier curve */
  5410. x1?: number,
  5411. /** Defines the y component of the start tangent in the bezier curve */
  5412. y1?: number,
  5413. /** Defines the x component of the end tangent in the bezier curve */
  5414. x2?: number,
  5415. /** Defines the y component of the end tangent in the bezier curve */
  5416. y2?: number);
  5417. /** @hidden */
  5418. easeInCore(gradient: number): number;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /**
  5423. * Class used to hold a RBG color
  5424. */
  5425. export class Color3 {
  5426. /**
  5427. * Defines the red component (between 0 and 1, default is 0)
  5428. */
  5429. r: number;
  5430. /**
  5431. * Defines the green component (between 0 and 1, default is 0)
  5432. */
  5433. g: number;
  5434. /**
  5435. * Defines the blue component (between 0 and 1, default is 0)
  5436. */
  5437. b: number;
  5438. /**
  5439. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5440. * @param r defines the red component (between 0 and 1, default is 0)
  5441. * @param g defines the green component (between 0 and 1, default is 0)
  5442. * @param b defines the blue component (between 0 and 1, default is 0)
  5443. */
  5444. constructor(
  5445. /**
  5446. * Defines the red component (between 0 and 1, default is 0)
  5447. */
  5448. r?: number,
  5449. /**
  5450. * Defines the green component (between 0 and 1, default is 0)
  5451. */
  5452. g?: number,
  5453. /**
  5454. * Defines the blue component (between 0 and 1, default is 0)
  5455. */
  5456. b?: number);
  5457. /**
  5458. * Creates a string with the Color3 current values
  5459. * @returns the string representation of the Color3 object
  5460. */
  5461. toString(): string;
  5462. /**
  5463. * Returns the string "Color3"
  5464. * @returns "Color3"
  5465. */
  5466. getClassName(): string;
  5467. /**
  5468. * Compute the Color3 hash code
  5469. * @returns an unique number that can be used to hash Color3 objects
  5470. */
  5471. getHashCode(): number;
  5472. /**
  5473. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5474. * @param array defines the array where to store the r,g,b components
  5475. * @param index defines an optional index in the target array to define where to start storing values
  5476. * @returns the current Color3 object
  5477. */
  5478. toArray(array: FloatArray, index?: number): Color3;
  5479. /**
  5480. * Returns a new Color4 object from the current Color3 and the given alpha
  5481. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5482. * @returns a new Color4 object
  5483. */
  5484. toColor4(alpha?: number): Color4;
  5485. /**
  5486. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5487. * @returns the new array
  5488. */
  5489. asArray(): number[];
  5490. /**
  5491. * Returns the luminance value
  5492. * @returns a float value
  5493. */
  5494. toLuminance(): number;
  5495. /**
  5496. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5497. * @param otherColor defines the second operand
  5498. * @returns the new Color3 object
  5499. */
  5500. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5501. /**
  5502. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5503. * @param otherColor defines the second operand
  5504. * @param result defines the Color3 object where to store the result
  5505. * @returns the current Color3
  5506. */
  5507. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5508. /**
  5509. * Determines equality between Color3 objects
  5510. * @param otherColor defines the second operand
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equals(otherColor: DeepImmutable<Color3>): boolean;
  5514. /**
  5515. * Determines equality between the current Color3 object and a set of r,b,g values
  5516. * @param r defines the red component to check
  5517. * @param g defines the green component to check
  5518. * @param b defines the blue component to check
  5519. * @returns true if the rgb values are equal to the given ones
  5520. */
  5521. equalsFloats(r: number, g: number, b: number): boolean;
  5522. /**
  5523. * Multiplies in place each rgb value by scale
  5524. * @param scale defines the scaling factor
  5525. * @returns the updated Color3
  5526. */
  5527. scale(scale: number): Color3;
  5528. /**
  5529. * Multiplies the rgb values by scale and stores the result into "result"
  5530. * @param scale defines the scaling factor
  5531. * @param result defines the Color3 object where to store the result
  5532. * @returns the unmodified current Color3
  5533. */
  5534. scaleToRef(scale: number, result: Color3): Color3;
  5535. /**
  5536. * Scale the current Color3 values by a factor and add the result to a given Color3
  5537. * @param scale defines the scale factor
  5538. * @param result defines color to store the result into
  5539. * @returns the unmodified current Color3
  5540. */
  5541. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5542. /**
  5543. * Clamps the rgb values by the min and max values and stores the result into "result"
  5544. * @param min defines minimum clamping value (default is 0)
  5545. * @param max defines maximum clamping value (default is 1)
  5546. * @param result defines color to store the result into
  5547. * @returns the original Color3
  5548. */
  5549. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5550. /**
  5551. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5552. * @param otherColor defines the second operand
  5553. * @returns the new Color3
  5554. */
  5555. add(otherColor: DeepImmutable<Color3>): Color3;
  5556. /**
  5557. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5558. * @param otherColor defines the second operand
  5559. * @param result defines Color3 object to store the result into
  5560. * @returns the unmodified current Color3
  5561. */
  5562. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5563. /**
  5564. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5565. * @param otherColor defines the second operand
  5566. * @returns the new Color3
  5567. */
  5568. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5569. /**
  5570. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5571. * @param otherColor defines the second operand
  5572. * @param result defines Color3 object to store the result into
  5573. * @returns the unmodified current Color3
  5574. */
  5575. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5576. /**
  5577. * Copy the current object
  5578. * @returns a new Color3 copied the current one
  5579. */
  5580. clone(): Color3;
  5581. /**
  5582. * Copies the rgb values from the source in the current Color3
  5583. * @param source defines the source Color3 object
  5584. * @returns the updated Color3 object
  5585. */
  5586. copyFrom(source: DeepImmutable<Color3>): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. copyFromFloats(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Updates the Color3 rgb values from the given floats
  5597. * @param r defines the red component to read from
  5598. * @param g defines the green component to read from
  5599. * @param b defines the blue component to read from
  5600. * @returns the current Color3 object
  5601. */
  5602. set(r: number, g: number, b: number): Color3;
  5603. /**
  5604. * Compute the Color3 hexadecimal code as a string
  5605. * @returns a string containing the hexadecimal representation of the Color3 object
  5606. */
  5607. toHexString(): string;
  5608. /**
  5609. * Computes a new Color3 converted from the current one to linear space
  5610. * @returns a new Color3 object
  5611. */
  5612. toLinearSpace(): Color3;
  5613. /**
  5614. * Converts current color in rgb space to HSV values
  5615. * @returns a new color3 representing the HSV values
  5616. */
  5617. toHSV(): Color3;
  5618. /**
  5619. * Converts current color in rgb space to HSV values
  5620. * @param result defines the Color3 where to store the HSV values
  5621. */
  5622. toHSVToRef(result: Color3): void;
  5623. /**
  5624. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5625. * @param convertedColor defines the Color3 object where to store the linear space version
  5626. * @returns the unmodified Color3
  5627. */
  5628. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5629. /**
  5630. * Computes a new Color3 converted from the current one to gamma space
  5631. * @returns a new Color3 object
  5632. */
  5633. toGammaSpace(): Color3;
  5634. /**
  5635. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5636. * @param convertedColor defines the Color3 object where to store the gamma space version
  5637. * @returns the unmodified Color3
  5638. */
  5639. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5640. private static _BlackReadOnly;
  5641. /**
  5642. * Convert Hue, saturation and value to a Color3 (RGB)
  5643. * @param hue defines the hue
  5644. * @param saturation defines the saturation
  5645. * @param value defines the value
  5646. * @param result defines the Color3 where to store the RGB values
  5647. */
  5648. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5649. /**
  5650. * Creates a new Color3 from the string containing valid hexadecimal values
  5651. * @param hex defines a string containing valid hexadecimal values
  5652. * @returns a new Color3 object
  5653. */
  5654. static FromHexString(hex: string): Color3;
  5655. /**
  5656. * Creates a new Color3 from the starting index of the given array
  5657. * @param array defines the source array
  5658. * @param offset defines an offset in the source array
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5662. /**
  5663. * Creates a new Color3 from integer values (< 256)
  5664. * @param r defines the red component to read from (value between 0 and 255)
  5665. * @param g defines the green component to read from (value between 0 and 255)
  5666. * @param b defines the blue component to read from (value between 0 and 255)
  5667. * @returns a new Color3 object
  5668. */
  5669. static FromInts(r: number, g: number, b: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param start defines the start Color3 value
  5673. * @param end defines the end Color3 value
  5674. * @param amount defines the gradient value between start and end
  5675. * @returns a new Color3 object
  5676. */
  5677. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5678. /**
  5679. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5680. * @param left defines the start value
  5681. * @param right defines the end value
  5682. * @param amount defines the gradient factor
  5683. * @param result defines the Color3 object where to store the result
  5684. */
  5685. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5686. /**
  5687. * Returns a Color3 value containing a red color
  5688. * @returns a new Color3 object
  5689. */
  5690. static Red(): Color3;
  5691. /**
  5692. * Returns a Color3 value containing a green color
  5693. * @returns a new Color3 object
  5694. */
  5695. static Green(): Color3;
  5696. /**
  5697. * Returns a Color3 value containing a blue color
  5698. * @returns a new Color3 object
  5699. */
  5700. static Blue(): Color3;
  5701. /**
  5702. * Returns a Color3 value containing a black color
  5703. * @returns a new Color3 object
  5704. */
  5705. static Black(): Color3;
  5706. /**
  5707. * Gets a Color3 value containing a black color that must not be updated
  5708. */
  5709. static get BlackReadOnly(): DeepImmutable<Color3>;
  5710. /**
  5711. * Returns a Color3 value containing a white color
  5712. * @returns a new Color3 object
  5713. */
  5714. static White(): Color3;
  5715. /**
  5716. * Returns a Color3 value containing a purple color
  5717. * @returns a new Color3 object
  5718. */
  5719. static Purple(): Color3;
  5720. /**
  5721. * Returns a Color3 value containing a magenta color
  5722. * @returns a new Color3 object
  5723. */
  5724. static Magenta(): Color3;
  5725. /**
  5726. * Returns a Color3 value containing a yellow color
  5727. * @returns a new Color3 object
  5728. */
  5729. static Yellow(): Color3;
  5730. /**
  5731. * Returns a Color3 value containing a gray color
  5732. * @returns a new Color3 object
  5733. */
  5734. static Gray(): Color3;
  5735. /**
  5736. * Returns a Color3 value containing a teal color
  5737. * @returns a new Color3 object
  5738. */
  5739. static Teal(): Color3;
  5740. /**
  5741. * Returns a Color3 value containing a random color
  5742. * @returns a new Color3 object
  5743. */
  5744. static Random(): Color3;
  5745. }
  5746. /**
  5747. * Class used to hold a RBGA color
  5748. */
  5749. export class Color4 {
  5750. /**
  5751. * Defines the red component (between 0 and 1, default is 0)
  5752. */
  5753. r: number;
  5754. /**
  5755. * Defines the green component (between 0 and 1, default is 0)
  5756. */
  5757. g: number;
  5758. /**
  5759. * Defines the blue component (between 0 and 1, default is 0)
  5760. */
  5761. b: number;
  5762. /**
  5763. * Defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. a: number;
  5766. /**
  5767. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5768. * @param r defines the red component (between 0 and 1, default is 0)
  5769. * @param g defines the green component (between 0 and 1, default is 0)
  5770. * @param b defines the blue component (between 0 and 1, default is 0)
  5771. * @param a defines the alpha component (between 0 and 1, default is 1)
  5772. */
  5773. constructor(
  5774. /**
  5775. * Defines the red component (between 0 and 1, default is 0)
  5776. */
  5777. r?: number,
  5778. /**
  5779. * Defines the green component (between 0 and 1, default is 0)
  5780. */
  5781. g?: number,
  5782. /**
  5783. * Defines the blue component (between 0 and 1, default is 0)
  5784. */
  5785. b?: number,
  5786. /**
  5787. * Defines the alpha component (between 0 and 1, default is 1)
  5788. */
  5789. a?: number);
  5790. /**
  5791. * Adds in place the given Color4 values to the current Color4 object
  5792. * @param right defines the second operand
  5793. * @returns the current updated Color4 object
  5794. */
  5795. addInPlace(right: DeepImmutable<Color4>): Color4;
  5796. /**
  5797. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5798. * @returns the new array
  5799. */
  5800. asArray(): number[];
  5801. /**
  5802. * Stores from the starting index in the given array the Color4 successive values
  5803. * @param array defines the array where to store the r,g,b components
  5804. * @param index defines an optional index in the target array to define where to start storing values
  5805. * @returns the current Color4 object
  5806. */
  5807. toArray(array: number[], index?: number): Color4;
  5808. /**
  5809. * Determines equality between Color4 objects
  5810. * @param otherColor defines the second operand
  5811. * @returns true if the rgba values are equal to the given ones
  5812. */
  5813. equals(otherColor: DeepImmutable<Color4>): boolean;
  5814. /**
  5815. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5816. * @param right defines the second operand
  5817. * @returns a new Color4 object
  5818. */
  5819. add(right: DeepImmutable<Color4>): Color4;
  5820. /**
  5821. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5822. * @param right defines the second operand
  5823. * @returns a new Color4 object
  5824. */
  5825. subtract(right: DeepImmutable<Color4>): Color4;
  5826. /**
  5827. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5828. * @param right defines the second operand
  5829. * @param result defines the Color4 object where to store the result
  5830. * @returns the current Color4 object
  5831. */
  5832. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5833. /**
  5834. * Creates a new Color4 with the current Color4 values multiplied by scale
  5835. * @param scale defines the scaling factor to apply
  5836. * @returns a new Color4 object
  5837. */
  5838. scale(scale: number): Color4;
  5839. /**
  5840. * Multiplies the current Color4 values by scale and stores the result in "result"
  5841. * @param scale defines the scaling factor to apply
  5842. * @param result defines the Color4 object where to store the result
  5843. * @returns the current unmodified Color4
  5844. */
  5845. scaleToRef(scale: number, result: Color4): Color4;
  5846. /**
  5847. * Scale the current Color4 values by a factor and add the result to a given Color4
  5848. * @param scale defines the scale factor
  5849. * @param result defines the Color4 object where to store the result
  5850. * @returns the unmodified current Color4
  5851. */
  5852. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5853. /**
  5854. * Clamps the rgb values by the min and max values and stores the result into "result"
  5855. * @param min defines minimum clamping value (default is 0)
  5856. * @param max defines maximum clamping value (default is 1)
  5857. * @param result defines color to store the result into.
  5858. * @returns the cuurent Color4
  5859. */
  5860. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5861. /**
  5862. * Multipy an Color4 value by another and return a new Color4 object
  5863. * @param color defines the Color4 value to multiply by
  5864. * @returns a new Color4 object
  5865. */
  5866. multiply(color: Color4): Color4;
  5867. /**
  5868. * Multipy a Color4 value by another and push the result in a reference value
  5869. * @param color defines the Color4 value to multiply by
  5870. * @param result defines the Color4 to fill the result in
  5871. * @returns the result Color4
  5872. */
  5873. multiplyToRef(color: Color4, result: Color4): Color4;
  5874. /**
  5875. * Creates a string with the Color4 current values
  5876. * @returns the string representation of the Color4 object
  5877. */
  5878. toString(): string;
  5879. /**
  5880. * Returns the string "Color4"
  5881. * @returns "Color4"
  5882. */
  5883. getClassName(): string;
  5884. /**
  5885. * Compute the Color4 hash code
  5886. * @returns an unique number that can be used to hash Color4 objects
  5887. */
  5888. getHashCode(): number;
  5889. /**
  5890. * Creates a new Color4 copied from the current one
  5891. * @returns a new Color4 object
  5892. */
  5893. clone(): Color4;
  5894. /**
  5895. * Copies the given Color4 values into the current one
  5896. * @param source defines the source Color4 object
  5897. * @returns the current updated Color4 object
  5898. */
  5899. copyFrom(source: Color4): Color4;
  5900. /**
  5901. * Copies the given float values into the current one
  5902. * @param r defines the red component to read from
  5903. * @param g defines the green component to read from
  5904. * @param b defines the blue component to read from
  5905. * @param a defines the alpha component to read from
  5906. * @returns the current updated Color4 object
  5907. */
  5908. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5909. /**
  5910. * Copies the given float values into the current one
  5911. * @param r defines the red component to read from
  5912. * @param g defines the green component to read from
  5913. * @param b defines the blue component to read from
  5914. * @param a defines the alpha component to read from
  5915. * @returns the current updated Color4 object
  5916. */
  5917. set(r: number, g: number, b: number, a: number): Color4;
  5918. /**
  5919. * Compute the Color4 hexadecimal code as a string
  5920. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5921. * @returns a string containing the hexadecimal representation of the Color4 object
  5922. */
  5923. toHexString(returnAsColor3?: boolean): string;
  5924. /**
  5925. * Computes a new Color4 converted from the current one to linear space
  5926. * @returns a new Color4 object
  5927. */
  5928. toLinearSpace(): Color4;
  5929. /**
  5930. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5931. * @param convertedColor defines the Color4 object where to store the linear space version
  5932. * @returns the unmodified Color4
  5933. */
  5934. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5935. /**
  5936. * Computes a new Color4 converted from the current one to gamma space
  5937. * @returns a new Color4 object
  5938. */
  5939. toGammaSpace(): Color4;
  5940. /**
  5941. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5942. * @param convertedColor defines the Color4 object where to store the gamma space version
  5943. * @returns the unmodified Color4
  5944. */
  5945. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5946. /**
  5947. * Creates a new Color4 from the string containing valid hexadecimal values
  5948. * @param hex defines a string containing valid hexadecimal values
  5949. * @returns a new Color4 object
  5950. */
  5951. static FromHexString(hex: string): Color4;
  5952. /**
  5953. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @returns a new Color4 object
  5958. */
  5959. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5960. /**
  5961. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5962. * @param left defines the start value
  5963. * @param right defines the end value
  5964. * @param amount defines the gradient factor
  5965. * @param result defines the Color4 object where to store data
  5966. */
  5967. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5968. /**
  5969. * Creates a new Color4 from a Color3 and an alpha value
  5970. * @param color3 defines the source Color3 to read from
  5971. * @param alpha defines the alpha component (1.0 by default)
  5972. * @returns a new Color4 object
  5973. */
  5974. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5975. /**
  5976. * Creates a new Color4 from the starting index element of the given array
  5977. * @param array defines the source array to read from
  5978. * @param offset defines the offset in the source array
  5979. * @returns a new Color4 object
  5980. */
  5981. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5982. /**
  5983. * Creates a new Color3 from integer values (< 256)
  5984. * @param r defines the red component to read from (value between 0 and 255)
  5985. * @param g defines the green component to read from (value between 0 and 255)
  5986. * @param b defines the blue component to read from (value between 0 and 255)
  5987. * @param a defines the alpha component to read from (value between 0 and 255)
  5988. * @returns a new Color3 object
  5989. */
  5990. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5991. /**
  5992. * Check the content of a given array and convert it to an array containing RGBA data
  5993. * If the original array was already containing count * 4 values then it is returned directly
  5994. * @param colors defines the array to check
  5995. * @param count defines the number of RGBA data to expect
  5996. * @returns an array containing count * 4 values (RGBA)
  5997. */
  5998. static CheckColors4(colors: number[], count: number): number[];
  5999. }
  6000. /**
  6001. * @hidden
  6002. */
  6003. export class TmpColors {
  6004. static Color3: Color3[];
  6005. static Color4: Color4[];
  6006. }
  6007. }
  6008. declare module BABYLON {
  6009. /**
  6010. * Defines an interface which represents an animation key frame
  6011. */
  6012. export interface IAnimationKey {
  6013. /**
  6014. * Frame of the key frame
  6015. */
  6016. frame: number;
  6017. /**
  6018. * Value at the specifies key frame
  6019. */
  6020. value: any;
  6021. /**
  6022. * The input tangent for the cubic hermite spline
  6023. */
  6024. inTangent?: any;
  6025. /**
  6026. * The output tangent for the cubic hermite spline
  6027. */
  6028. outTangent?: any;
  6029. /**
  6030. * The animation interpolation type
  6031. */
  6032. interpolation?: AnimationKeyInterpolation;
  6033. }
  6034. /**
  6035. * Enum for the animation key frame interpolation type
  6036. */
  6037. export enum AnimationKeyInterpolation {
  6038. /**
  6039. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6040. */
  6041. STEP = 1
  6042. }
  6043. }
  6044. declare module BABYLON {
  6045. /**
  6046. * Represents the range of an animation
  6047. */
  6048. export class AnimationRange {
  6049. /**The name of the animation range**/
  6050. name: string;
  6051. /**The starting frame of the animation */
  6052. from: number;
  6053. /**The ending frame of the animation*/
  6054. to: number;
  6055. /**
  6056. * Initializes the range of an animation
  6057. * @param name The name of the animation range
  6058. * @param from The starting frame of the animation
  6059. * @param to The ending frame of the animation
  6060. */
  6061. constructor(
  6062. /**The name of the animation range**/
  6063. name: string,
  6064. /**The starting frame of the animation */
  6065. from: number,
  6066. /**The ending frame of the animation*/
  6067. to: number);
  6068. /**
  6069. * Makes a copy of the animation range
  6070. * @returns A copy of the animation range
  6071. */
  6072. clone(): AnimationRange;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * Composed of a frame, and an action function
  6078. */
  6079. export class AnimationEvent {
  6080. /** The frame for which the event is triggered **/
  6081. frame: number;
  6082. /** The event to perform when triggered **/
  6083. action: (currentFrame: number) => void;
  6084. /** Specifies if the event should be triggered only once**/
  6085. onlyOnce?: boolean | undefined;
  6086. /**
  6087. * Specifies if the animation event is done
  6088. */
  6089. isDone: boolean;
  6090. /**
  6091. * Initializes the animation event
  6092. * @param frame The frame for which the event is triggered
  6093. * @param action The event to perform when triggered
  6094. * @param onlyOnce Specifies if the event should be triggered only once
  6095. */
  6096. constructor(
  6097. /** The frame for which the event is triggered **/
  6098. frame: number,
  6099. /** The event to perform when triggered **/
  6100. action: (currentFrame: number) => void,
  6101. /** Specifies if the event should be triggered only once**/
  6102. onlyOnce?: boolean | undefined);
  6103. /** @hidden */
  6104. _clone(): AnimationEvent;
  6105. }
  6106. }
  6107. declare module BABYLON {
  6108. /**
  6109. * Interface used to define a behavior
  6110. */
  6111. export interface Behavior<T> {
  6112. /** gets or sets behavior's name */
  6113. name: string;
  6114. /**
  6115. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6116. */
  6117. init(): void;
  6118. /**
  6119. * Called when the behavior is attached to a target
  6120. * @param target defines the target where the behavior is attached to
  6121. */
  6122. attach(target: T): void;
  6123. /**
  6124. * Called when the behavior is detached from its target
  6125. */
  6126. detach(): void;
  6127. }
  6128. /**
  6129. * Interface implemented by classes supporting behaviors
  6130. */
  6131. export interface IBehaviorAware<T> {
  6132. /**
  6133. * Attach a behavior
  6134. * @param behavior defines the behavior to attach
  6135. * @returns the current host
  6136. */
  6137. addBehavior(behavior: Behavior<T>): T;
  6138. /**
  6139. * Remove a behavior from the current object
  6140. * @param behavior defines the behavior to detach
  6141. * @returns the current host
  6142. */
  6143. removeBehavior(behavior: Behavior<T>): T;
  6144. /**
  6145. * Gets a behavior using its name to search
  6146. * @param name defines the name to search
  6147. * @returns the behavior or null if not found
  6148. */
  6149. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6150. }
  6151. }
  6152. declare module BABYLON {
  6153. /**
  6154. * Defines an array and its length.
  6155. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6156. */
  6157. export interface ISmartArrayLike<T> {
  6158. /**
  6159. * The data of the array.
  6160. */
  6161. data: Array<T>;
  6162. /**
  6163. * The active length of the array.
  6164. */
  6165. length: number;
  6166. }
  6167. /**
  6168. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6169. */
  6170. export class SmartArray<T> implements ISmartArrayLike<T> {
  6171. /**
  6172. * The full set of data from the array.
  6173. */
  6174. data: Array<T>;
  6175. /**
  6176. * The active length of the array.
  6177. */
  6178. length: number;
  6179. protected _id: number;
  6180. /**
  6181. * Instantiates a Smart Array.
  6182. * @param capacity defines the default capacity of the array.
  6183. */
  6184. constructor(capacity: number);
  6185. /**
  6186. * Pushes a value at the end of the active data.
  6187. * @param value defines the object to push in the array.
  6188. */
  6189. push(value: T): void;
  6190. /**
  6191. * Iterates over the active data and apply the lambda to them.
  6192. * @param func defines the action to apply on each value.
  6193. */
  6194. forEach(func: (content: T) => void): void;
  6195. /**
  6196. * Sorts the full sets of data.
  6197. * @param compareFn defines the comparison function to apply.
  6198. */
  6199. sort(compareFn: (a: T, b: T) => number): void;
  6200. /**
  6201. * Resets the active data to an empty array.
  6202. */
  6203. reset(): void;
  6204. /**
  6205. * Releases all the data from the array as well as the array.
  6206. */
  6207. dispose(): void;
  6208. /**
  6209. * Concats the active data with a given array.
  6210. * @param array defines the data to concatenate with.
  6211. */
  6212. concat(array: any): void;
  6213. /**
  6214. * Returns the position of a value in the active data.
  6215. * @param value defines the value to find the index for
  6216. * @returns the index if found in the active data otherwise -1
  6217. */
  6218. indexOf(value: T): number;
  6219. /**
  6220. * Returns whether an element is part of the active data.
  6221. * @param value defines the value to look for
  6222. * @returns true if found in the active data otherwise false
  6223. */
  6224. contains(value: T): boolean;
  6225. private static _GlobalId;
  6226. }
  6227. /**
  6228. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6229. * The data in this array can only be present once
  6230. */
  6231. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6232. private _duplicateId;
  6233. /**
  6234. * Pushes a value at the end of the active data.
  6235. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6236. * @param value defines the object to push in the array.
  6237. */
  6238. push(value: T): void;
  6239. /**
  6240. * Pushes a value at the end of the active data.
  6241. * If the data is already present, it won t be added again
  6242. * @param value defines the object to push in the array.
  6243. * @returns true if added false if it was already present
  6244. */
  6245. pushNoDuplicate(value: T): boolean;
  6246. /**
  6247. * Resets the active data to an empty array.
  6248. */
  6249. reset(): void;
  6250. /**
  6251. * Concats the active data with a given array.
  6252. * This ensures no dupplicate will be present in the result.
  6253. * @param array defines the data to concatenate with.
  6254. */
  6255. concatWithNoDuplicate(array: any): void;
  6256. }
  6257. }
  6258. declare module BABYLON {
  6259. /**
  6260. * @ignore
  6261. * This is a list of all the different input types that are available in the application.
  6262. * Fo instance: ArcRotateCameraGamepadInput...
  6263. */
  6264. export var CameraInputTypes: {};
  6265. /**
  6266. * This is the contract to implement in order to create a new input class.
  6267. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6268. */
  6269. export interface ICameraInput<TCamera extends Camera> {
  6270. /**
  6271. * Defines the camera the input is attached to.
  6272. */
  6273. camera: Nullable<TCamera>;
  6274. /**
  6275. * Gets the class name of the current intput.
  6276. * @returns the class name
  6277. */
  6278. getClassName(): string;
  6279. /**
  6280. * Get the friendly name associated with the input class.
  6281. * @returns the input friendly name
  6282. */
  6283. getSimpleName(): string;
  6284. /**
  6285. * Attach the input controls to a specific dom element to get the input from.
  6286. * @param element Defines the element the controls should be listened from
  6287. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6288. */
  6289. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6290. /**
  6291. * Detach the current controls from the specified dom element.
  6292. * @param element Defines the element to stop listening the inputs from
  6293. */
  6294. detachControl(element: Nullable<HTMLElement>): void;
  6295. /**
  6296. * Update the current camera state depending on the inputs that have been used this frame.
  6297. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6298. */
  6299. checkInputs?: () => void;
  6300. }
  6301. /**
  6302. * Represents a map of input types to input instance or input index to input instance.
  6303. */
  6304. export interface CameraInputsMap<TCamera extends Camera> {
  6305. /**
  6306. * Accessor to the input by input type.
  6307. */
  6308. [name: string]: ICameraInput<TCamera>;
  6309. /**
  6310. * Accessor to the input by input index.
  6311. */
  6312. [idx: number]: ICameraInput<TCamera>;
  6313. }
  6314. /**
  6315. * This represents the input manager used within a camera.
  6316. * It helps dealing with all the different kind of input attached to a camera.
  6317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6318. */
  6319. export class CameraInputsManager<TCamera extends Camera> {
  6320. /**
  6321. * Defines the list of inputs attahed to the camera.
  6322. */
  6323. attached: CameraInputsMap<TCamera>;
  6324. /**
  6325. * Defines the dom element the camera is collecting inputs from.
  6326. * This is null if the controls have not been attached.
  6327. */
  6328. attachedElement: Nullable<HTMLElement>;
  6329. /**
  6330. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6331. */
  6332. noPreventDefault: boolean;
  6333. /**
  6334. * Defined the camera the input manager belongs to.
  6335. */
  6336. camera: TCamera;
  6337. /**
  6338. * Update the current camera state depending on the inputs that have been used this frame.
  6339. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6340. */
  6341. checkInputs: () => void;
  6342. /**
  6343. * Instantiate a new Camera Input Manager.
  6344. * @param camera Defines the camera the input manager blongs to
  6345. */
  6346. constructor(camera: TCamera);
  6347. /**
  6348. * Add an input method to a camera
  6349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6350. * @param input camera input method
  6351. */
  6352. add(input: ICameraInput<TCamera>): void;
  6353. /**
  6354. * Remove a specific input method from a camera
  6355. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6356. * @param inputToRemove camera input method
  6357. */
  6358. remove(inputToRemove: ICameraInput<TCamera>): void;
  6359. /**
  6360. * Remove a specific input type from a camera
  6361. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6362. * @param inputType the type of the input to remove
  6363. */
  6364. removeByType(inputType: string): void;
  6365. private _addCheckInputs;
  6366. /**
  6367. * Attach the input controls to the currently attached dom element to listen the events from.
  6368. * @param input Defines the input to attach
  6369. */
  6370. attachInput(input: ICameraInput<TCamera>): void;
  6371. /**
  6372. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6373. * @param element Defines the dom element to collect the events from
  6374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6375. */
  6376. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6377. /**
  6378. * Detach the current manager inputs controls from a specific dom element.
  6379. * @param element Defines the dom element to collect the events from
  6380. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6381. */
  6382. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6383. /**
  6384. * Rebuild the dynamic inputCheck function from the current list of
  6385. * defined inputs in the manager.
  6386. */
  6387. rebuildInputCheck(): void;
  6388. /**
  6389. * Remove all attached input methods from a camera
  6390. */
  6391. clear(): void;
  6392. /**
  6393. * Serialize the current input manager attached to a camera.
  6394. * This ensures than once parsed,
  6395. * the input associated to the camera will be identical to the current ones
  6396. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6397. */
  6398. serialize(serializedCamera: any): void;
  6399. /**
  6400. * Parses an input manager serialized JSON to restore the previous list of inputs
  6401. * and states associated to a camera.
  6402. * @param parsedCamera Defines the JSON to parse
  6403. */
  6404. parse(parsedCamera: any): void;
  6405. }
  6406. }
  6407. declare module BABYLON {
  6408. /**
  6409. * Class used to store data that will be store in GPU memory
  6410. */
  6411. export class Buffer {
  6412. private _engine;
  6413. private _buffer;
  6414. /** @hidden */
  6415. _data: Nullable<DataArray>;
  6416. private _updatable;
  6417. private _instanced;
  6418. private _divisor;
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Constructor
  6425. * @param engine the engine
  6426. * @param data the data to use for this buffer
  6427. * @param updatable whether the data is updatable
  6428. * @param stride the stride (optional)
  6429. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param useBytes set to true if the stride in in bytes (optional)
  6432. * @param divisor sets an optional divisor for instances (1 by default)
  6433. */
  6434. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6435. /**
  6436. * Create a new VertexBuffer based on the current buffer
  6437. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6438. * @param offset defines offset in the buffer (0 by default)
  6439. * @param size defines the size in floats of attributes (position is 3 for instance)
  6440. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6441. * @param instanced defines if the vertex buffer contains indexed data
  6442. * @param useBytes defines if the offset and stride are in bytes *
  6443. * @param divisor sets an optional divisor for instances (1 by default)
  6444. * @returns the new vertex buffer
  6445. */
  6446. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6447. /**
  6448. * Gets a boolean indicating if the Buffer is updatable?
  6449. * @returns true if the buffer is updatable
  6450. */
  6451. isUpdatable(): boolean;
  6452. /**
  6453. * Gets current buffer's data
  6454. * @returns a DataArray or null
  6455. */
  6456. getData(): Nullable<DataArray>;
  6457. /**
  6458. * Gets underlying native buffer
  6459. * @returns underlying native buffer
  6460. */
  6461. getBuffer(): Nullable<DataBuffer>;
  6462. /**
  6463. * Gets the stride in float32 units (i.e. byte stride / 4).
  6464. * May not be an integer if the byte stride is not divisible by 4.
  6465. * @returns the stride in float32 units
  6466. * @deprecated Please use byteStride instead.
  6467. */
  6468. getStrideSize(): number;
  6469. /**
  6470. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6471. * @param data defines the data to store
  6472. */
  6473. create(data?: Nullable<DataArray>): void;
  6474. /** @hidden */
  6475. _rebuild(): void;
  6476. /**
  6477. * Update current buffer data
  6478. * @param data defines the data to store
  6479. */
  6480. update(data: DataArray): void;
  6481. /**
  6482. * Updates the data directly.
  6483. * @param data the new data
  6484. * @param offset the new offset
  6485. * @param vertexCount the vertex count (optional)
  6486. * @param useBytes set to true if the offset is in bytes
  6487. */
  6488. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6489. /**
  6490. * Release all resources
  6491. */
  6492. dispose(): void;
  6493. }
  6494. /**
  6495. * Specialized buffer used to store vertex data
  6496. */
  6497. export class VertexBuffer {
  6498. /** @hidden */
  6499. _buffer: Buffer;
  6500. private _kind;
  6501. private _size;
  6502. private _ownsBuffer;
  6503. private _instanced;
  6504. private _instanceDivisor;
  6505. /**
  6506. * The byte type.
  6507. */
  6508. static readonly BYTE: number;
  6509. /**
  6510. * The unsigned byte type.
  6511. */
  6512. static readonly UNSIGNED_BYTE: number;
  6513. /**
  6514. * The short type.
  6515. */
  6516. static readonly SHORT: number;
  6517. /**
  6518. * The unsigned short type.
  6519. */
  6520. static readonly UNSIGNED_SHORT: number;
  6521. /**
  6522. * The integer type.
  6523. */
  6524. static readonly INT: number;
  6525. /**
  6526. * The unsigned integer type.
  6527. */
  6528. static readonly UNSIGNED_INT: number;
  6529. /**
  6530. * The float type.
  6531. */
  6532. static readonly FLOAT: number;
  6533. /**
  6534. * Gets or sets the instance divisor when in instanced mode
  6535. */
  6536. get instanceDivisor(): number;
  6537. set instanceDivisor(value: number);
  6538. /**
  6539. * Gets the byte stride.
  6540. */
  6541. readonly byteStride: number;
  6542. /**
  6543. * Gets the byte offset.
  6544. */
  6545. readonly byteOffset: number;
  6546. /**
  6547. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6548. */
  6549. readonly normalized: boolean;
  6550. /**
  6551. * Gets the data type of each component in the array.
  6552. */
  6553. readonly type: number;
  6554. /**
  6555. * Constructor
  6556. * @param engine the engine
  6557. * @param data the data to use for this vertex buffer
  6558. * @param kind the vertex buffer kind
  6559. * @param updatable whether the data is updatable
  6560. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6561. * @param stride the stride (optional)
  6562. * @param instanced whether the buffer is instanced (optional)
  6563. * @param offset the offset of the data (optional)
  6564. * @param size the number of components (optional)
  6565. * @param type the type of the component (optional)
  6566. * @param normalized whether the data contains normalized data (optional)
  6567. * @param useBytes set to true if stride and offset are in bytes (optional)
  6568. * @param divisor defines the instance divisor to use (1 by default)
  6569. */
  6570. 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);
  6571. /** @hidden */
  6572. _rebuild(): void;
  6573. /**
  6574. * Returns the kind of the VertexBuffer (string)
  6575. * @returns a string
  6576. */
  6577. getKind(): string;
  6578. /**
  6579. * Gets a boolean indicating if the VertexBuffer is updatable?
  6580. * @returns true if the buffer is updatable
  6581. */
  6582. isUpdatable(): boolean;
  6583. /**
  6584. * Gets current buffer's data
  6585. * @returns a DataArray or null
  6586. */
  6587. getData(): Nullable<DataArray>;
  6588. /**
  6589. * Gets underlying native buffer
  6590. * @returns underlying native buffer
  6591. */
  6592. getBuffer(): Nullable<DataBuffer>;
  6593. /**
  6594. * Gets the stride in float32 units (i.e. byte stride / 4).
  6595. * May not be an integer if the byte stride is not divisible by 4.
  6596. * @returns the stride in float32 units
  6597. * @deprecated Please use byteStride instead.
  6598. */
  6599. getStrideSize(): number;
  6600. /**
  6601. * Returns the offset as a multiple of the type byte length.
  6602. * @returns the offset in bytes
  6603. * @deprecated Please use byteOffset instead.
  6604. */
  6605. getOffset(): number;
  6606. /**
  6607. * Returns the number of components per vertex attribute (integer)
  6608. * @returns the size in float
  6609. */
  6610. getSize(): number;
  6611. /**
  6612. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6613. * @returns true if this buffer is instanced
  6614. */
  6615. getIsInstanced(): boolean;
  6616. /**
  6617. * Returns the instancing divisor, zero for non-instanced (integer).
  6618. * @returns a number
  6619. */
  6620. getInstanceDivisor(): number;
  6621. /**
  6622. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6623. * @param data defines the data to store
  6624. */
  6625. create(data?: DataArray): void;
  6626. /**
  6627. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6628. * This function will create a new buffer if the current one is not updatable
  6629. * @param data defines the data to store
  6630. */
  6631. update(data: DataArray): void;
  6632. /**
  6633. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6634. * Returns the directly updated WebGLBuffer.
  6635. * @param data the new data
  6636. * @param offset the new offset
  6637. * @param useBytes set to true if the offset is in bytes
  6638. */
  6639. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6640. /**
  6641. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6642. */
  6643. dispose(): void;
  6644. /**
  6645. * Enumerates each value of this vertex buffer as numbers.
  6646. * @param count the number of values to enumerate
  6647. * @param callback the callback function called for each value
  6648. */
  6649. forEach(count: number, callback: (value: number, index: number) => void): void;
  6650. /**
  6651. * Positions
  6652. */
  6653. static readonly PositionKind: string;
  6654. /**
  6655. * Normals
  6656. */
  6657. static readonly NormalKind: string;
  6658. /**
  6659. * Tangents
  6660. */
  6661. static readonly TangentKind: string;
  6662. /**
  6663. * Texture coordinates
  6664. */
  6665. static readonly UVKind: string;
  6666. /**
  6667. * Texture coordinates 2
  6668. */
  6669. static readonly UV2Kind: string;
  6670. /**
  6671. * Texture coordinates 3
  6672. */
  6673. static readonly UV3Kind: string;
  6674. /**
  6675. * Texture coordinates 4
  6676. */
  6677. static readonly UV4Kind: string;
  6678. /**
  6679. * Texture coordinates 5
  6680. */
  6681. static readonly UV5Kind: string;
  6682. /**
  6683. * Texture coordinates 6
  6684. */
  6685. static readonly UV6Kind: string;
  6686. /**
  6687. * Colors
  6688. */
  6689. static readonly ColorKind: string;
  6690. /**
  6691. * Matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesKind: string;
  6694. /**
  6695. * Matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsKind: string;
  6698. /**
  6699. * Additional matrix indices (for bones)
  6700. */
  6701. static readonly MatricesIndicesExtraKind: string;
  6702. /**
  6703. * Additional matrix weights (for bones)
  6704. */
  6705. static readonly MatricesWeightsExtraKind: string;
  6706. /**
  6707. * Deduces the stride given a kind.
  6708. * @param kind The kind string to deduce
  6709. * @returns The deduced stride
  6710. */
  6711. static DeduceStride(kind: string): number;
  6712. /**
  6713. * Gets the byte length of the given type.
  6714. * @param type the type
  6715. * @returns the number of bytes
  6716. */
  6717. static GetTypeByteLength(type: number): number;
  6718. /**
  6719. * Enumerates each value of the given parameters as numbers.
  6720. * @param data the data to enumerate
  6721. * @param byteOffset the byte offset of the data
  6722. * @param byteStride the byte stride of the data
  6723. * @param componentCount the number of components per element
  6724. * @param componentType the type of the component
  6725. * @param count the number of values to enumerate
  6726. * @param normalized whether the data is normalized
  6727. * @param callback the callback function called for each value
  6728. */
  6729. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6730. private static _GetFloatValue;
  6731. }
  6732. }
  6733. declare module BABYLON {
  6734. /**
  6735. * @hidden
  6736. */
  6737. export class IntersectionInfo {
  6738. bu: Nullable<number>;
  6739. bv: Nullable<number>;
  6740. distance: number;
  6741. faceId: number;
  6742. subMeshId: number;
  6743. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6744. }
  6745. }
  6746. declare module BABYLON {
  6747. /**
  6748. * Class used to store bounding sphere information
  6749. */
  6750. export class BoundingSphere {
  6751. /**
  6752. * Gets the center of the bounding sphere in local space
  6753. */
  6754. readonly center: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in local space
  6757. */
  6758. radius: number;
  6759. /**
  6760. * Gets the center of the bounding sphere in world space
  6761. */
  6762. readonly centerWorld: Vector3;
  6763. /**
  6764. * Radius of the bounding sphere in world space
  6765. */
  6766. radiusWorld: number;
  6767. /**
  6768. * Gets the minimum vector in local space
  6769. */
  6770. readonly minimum: Vector3;
  6771. /**
  6772. * Gets the maximum vector in local space
  6773. */
  6774. readonly maximum: Vector3;
  6775. private _worldMatrix;
  6776. private static readonly TmpVector3;
  6777. /**
  6778. * Creates a new bounding sphere
  6779. * @param min defines the minimum vector (in local space)
  6780. * @param max defines the maximum vector (in local space)
  6781. * @param worldMatrix defines the new world matrix
  6782. */
  6783. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6784. /**
  6785. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6786. * @param min defines the new minimum vector (in local space)
  6787. * @param max defines the new maximum vector (in local space)
  6788. * @param worldMatrix defines the new world matrix
  6789. */
  6790. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6791. /**
  6792. * Scale the current bounding sphere by applying a scale factor
  6793. * @param factor defines the scale factor to apply
  6794. * @returns the current bounding box
  6795. */
  6796. scale(factor: number): BoundingSphere;
  6797. /**
  6798. * Gets the world matrix of the bounding box
  6799. * @returns a matrix
  6800. */
  6801. getWorldMatrix(): DeepImmutable<Matrix>;
  6802. /** @hidden */
  6803. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Tests if the bounding sphere is intersecting the frustum planes
  6806. * @param frustumPlanes defines the frustum planes to test
  6807. * @returns true if there is an intersection
  6808. */
  6809. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6810. /**
  6811. * Tests if the bounding sphere center is in between the frustum planes.
  6812. * Used for optimistic fast inclusion.
  6813. * @param frustumPlanes defines the frustum planes to test
  6814. * @returns true if the sphere center is in between the frustum planes
  6815. */
  6816. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6817. /**
  6818. * Tests if a point is inside the bounding sphere
  6819. * @param point defines the point to test
  6820. * @returns true if the point is inside the bounding sphere
  6821. */
  6822. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6823. /**
  6824. * Checks if two sphere intersct
  6825. * @param sphere0 sphere 0
  6826. * @param sphere1 sphere 1
  6827. * @returns true if the speres intersect
  6828. */
  6829. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6830. }
  6831. }
  6832. declare module BABYLON {
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module BABYLON {
  6978. /** @hidden */
  6979. export class Collider {
  6980. /** Define if a collision was found */
  6981. collisionFound: boolean;
  6982. /**
  6983. * Define last intersection point in local space
  6984. */
  6985. intersectionPoint: Vector3;
  6986. /**
  6987. * Define last collided mesh
  6988. */
  6989. collidedMesh: Nullable<AbstractMesh>;
  6990. private _collisionPoint;
  6991. private _planeIntersectionPoint;
  6992. private _tempVector;
  6993. private _tempVector2;
  6994. private _tempVector3;
  6995. private _tempVector4;
  6996. private _edge;
  6997. private _baseToVertex;
  6998. private _destinationPoint;
  6999. private _slidePlaneNormal;
  7000. private _displacementVector;
  7001. /** @hidden */
  7002. _radius: Vector3;
  7003. /** @hidden */
  7004. _retry: number;
  7005. private _velocity;
  7006. private _basePoint;
  7007. private _epsilon;
  7008. /** @hidden */
  7009. _velocityWorldLength: number;
  7010. /** @hidden */
  7011. _basePointWorld: Vector3;
  7012. private _velocityWorld;
  7013. private _normalizedVelocity;
  7014. /** @hidden */
  7015. _initialVelocity: Vector3;
  7016. /** @hidden */
  7017. _initialPosition: Vector3;
  7018. private _nearestDistance;
  7019. private _collisionMask;
  7020. get collisionMask(): number;
  7021. set collisionMask(mask: number);
  7022. /**
  7023. * Gets the plane normal used to compute the sliding response (in local space)
  7024. */
  7025. get slidePlaneNormal(): Vector3;
  7026. /** @hidden */
  7027. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7028. /** @hidden */
  7029. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7030. /** @hidden */
  7031. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7032. /** @hidden */
  7033. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7034. /** @hidden */
  7035. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7036. /** @hidden */
  7037. _getResponse(pos: Vector3, vel: Vector3): void;
  7038. }
  7039. }
  7040. declare module BABYLON {
  7041. /**
  7042. * Interface for cullable objects
  7043. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7044. */
  7045. export interface ICullable {
  7046. /**
  7047. * Checks if the object or part of the object is in the frustum
  7048. * @param frustumPlanes Camera near/planes
  7049. * @returns true if the object is in frustum otherwise false
  7050. */
  7051. isInFrustum(frustumPlanes: Plane[]): boolean;
  7052. /**
  7053. * Checks if a cullable object (mesh...) is in the camera frustum
  7054. * Unlike isInFrustum this cheks the full bounding box
  7055. * @param frustumPlanes Camera near/planes
  7056. * @returns true if the object is in frustum otherwise false
  7057. */
  7058. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7059. }
  7060. /**
  7061. * Info for a bounding data of a mesh
  7062. */
  7063. export class BoundingInfo implements ICullable {
  7064. /**
  7065. * Bounding box for the mesh
  7066. */
  7067. readonly boundingBox: BoundingBox;
  7068. /**
  7069. * Bounding sphere for the mesh
  7070. */
  7071. readonly boundingSphere: BoundingSphere;
  7072. private _isLocked;
  7073. private static readonly TmpVector3;
  7074. /**
  7075. * Constructs bounding info
  7076. * @param minimum min vector of the bounding box/sphere
  7077. * @param maximum max vector of the bounding box/sphere
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7081. /**
  7082. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7083. * @param min defines the new minimum vector (in local space)
  7084. * @param max defines the new maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * min vector of the bounding box/sphere
  7090. */
  7091. get minimum(): Vector3;
  7092. /**
  7093. * max vector of the bounding box/sphere
  7094. */
  7095. get maximum(): Vector3;
  7096. /**
  7097. * If the info is locked and won't be updated to avoid perf overhead
  7098. */
  7099. get isLocked(): boolean;
  7100. set isLocked(value: boolean);
  7101. /**
  7102. * Updates the bounding sphere and box
  7103. * @param world world matrix to be used to update
  7104. */
  7105. update(world: DeepImmutable<Matrix>): void;
  7106. /**
  7107. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7108. * @param center New center of the bounding info
  7109. * @param extend New extend of the bounding info
  7110. * @returns the current bounding info
  7111. */
  7112. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7113. /**
  7114. * Scale the current bounding info by applying a scale factor
  7115. * @param factor defines the scale factor to apply
  7116. * @returns the current bounding info
  7117. */
  7118. scale(factor: number): BoundingInfo;
  7119. /**
  7120. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7121. * @param frustumPlanes defines the frustum to test
  7122. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7123. * @returns true if the bounding info is in the frustum planes
  7124. */
  7125. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7126. /**
  7127. * Gets the world distance between the min and max points of the bounding box
  7128. */
  7129. get diagonalLength(): number;
  7130. /**
  7131. * Checks if a cullable object (mesh...) is in the camera frustum
  7132. * Unlike isInFrustum this cheks the full bounding box
  7133. * @param frustumPlanes Camera near/planes
  7134. * @returns true if the object is in frustum otherwise false
  7135. */
  7136. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7137. /** @hidden */
  7138. _checkCollision(collider: Collider): boolean;
  7139. /**
  7140. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7141. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7142. * @param point the point to check intersection with
  7143. * @returns if the point intersects
  7144. */
  7145. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7148. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7149. * @param boundingInfo the bounding info to check intersection with
  7150. * @param precise if the intersection should be done using OBB
  7151. * @returns if the bounding info intersects
  7152. */
  7153. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7154. }
  7155. }
  7156. declare module BABYLON {
  7157. /**
  7158. * Extracts minimum and maximum values from a list of indexed positions
  7159. * @param positions defines the positions to use
  7160. * @param indices defines the indices to the positions
  7161. * @param indexStart defines the start index
  7162. * @param indexCount defines the end index
  7163. * @param bias defines bias value to add to the result
  7164. * @return minimum and maximum values
  7165. */
  7166. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7167. minimum: Vector3;
  7168. maximum: Vector3;
  7169. };
  7170. /**
  7171. * Extracts minimum and maximum values from a list of positions
  7172. * @param positions defines the positions to use
  7173. * @param start defines the start index in the positions array
  7174. * @param count defines the number of positions to handle
  7175. * @param bias defines bias value to add to the result
  7176. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7177. * @return minimum and maximum values
  7178. */
  7179. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7180. minimum: Vector3;
  7181. maximum: Vector3;
  7182. };
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLDataBuffer extends DataBuffer {
  7187. private _buffer;
  7188. constructor(resource: WebGLBuffer);
  7189. get underlyingResource(): any;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. /** @hidden */
  7194. export class WebGLPipelineContext implements IPipelineContext {
  7195. engine: ThinEngine;
  7196. program: Nullable<WebGLProgram>;
  7197. context?: WebGLRenderingContext;
  7198. vertexShader?: WebGLShader;
  7199. fragmentShader?: WebGLShader;
  7200. isParallelCompiled: boolean;
  7201. onCompiled?: () => void;
  7202. transformFeedback?: WebGLTransformFeedback | null;
  7203. vertexCompilationError: Nullable<string>;
  7204. fragmentCompilationError: Nullable<string>;
  7205. programLinkError: Nullable<string>;
  7206. programValidationError: Nullable<string>;
  7207. get isAsync(): boolean;
  7208. get isReady(): boolean;
  7209. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7210. _getVertexShaderCode(): string | null;
  7211. _getFragmentShaderCode(): string | null;
  7212. }
  7213. }
  7214. declare module BABYLON {
  7215. interface ThinEngine {
  7216. /**
  7217. * Create an uniform buffer
  7218. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7219. * @param elements defines the content of the uniform buffer
  7220. * @returns the webGL uniform buffer
  7221. */
  7222. createUniformBuffer(elements: FloatArray): DataBuffer;
  7223. /**
  7224. * Create a dynamic uniform buffer
  7225. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7226. * @param elements defines the content of the uniform buffer
  7227. * @returns the webGL uniform buffer
  7228. */
  7229. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7230. /**
  7231. * Update an existing uniform buffer
  7232. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7233. * @param uniformBuffer defines the target uniform buffer
  7234. * @param elements defines the content to update
  7235. * @param offset defines the offset in the uniform buffer where update should start
  7236. * @param count defines the size of the data to update
  7237. */
  7238. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7239. /**
  7240. * Bind an uniform buffer to the current webGL context
  7241. * @param buffer defines the buffer to bind
  7242. */
  7243. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7244. /**
  7245. * Bind a buffer to the current webGL context at a given location
  7246. * @param buffer defines the buffer to bind
  7247. * @param location defines the index where to bind the buffer
  7248. */
  7249. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7250. /**
  7251. * Bind a specific block at a given index in a specific shader program
  7252. * @param pipelineContext defines the pipeline context to use
  7253. * @param blockName defines the block name
  7254. * @param index defines the index where to bind the block
  7255. */
  7256. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7257. }
  7258. }
  7259. declare module BABYLON {
  7260. /**
  7261. * Uniform buffer objects.
  7262. *
  7263. * Handles blocks of uniform on the GPU.
  7264. *
  7265. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7266. *
  7267. * For more information, please refer to :
  7268. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7269. */
  7270. export class UniformBuffer {
  7271. private _engine;
  7272. private _buffer;
  7273. private _data;
  7274. private _bufferData;
  7275. private _dynamic?;
  7276. private _uniformLocations;
  7277. private _uniformSizes;
  7278. private _uniformLocationPointer;
  7279. private _needSync;
  7280. private _noUBO;
  7281. private _currentEffect;
  7282. /** @hidden */
  7283. _alreadyBound: boolean;
  7284. private static _MAX_UNIFORM_SIZE;
  7285. private static _tempBuffer;
  7286. /**
  7287. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7292. /**
  7293. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7298. /**
  7299. * Lambda to Update a single float in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateFloat: (name: string, x: number) => void;
  7304. /**
  7305. * Lambda to Update a vec2 of float in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update a vec3 of float in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7316. /**
  7317. * Lambda to Update a vec4 of float in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateMatrix: (name: string, mat: Matrix) => void;
  7328. /**
  7329. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7330. * This is dynamic to allow compat with webgl 1 and 2.
  7331. * You will need to pass the name of the uniform as well as the value.
  7332. */
  7333. updateVector3: (name: string, vector: Vector3) => void;
  7334. /**
  7335. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7336. * This is dynamic to allow compat with webgl 1 and 2.
  7337. * You will need to pass the name of the uniform as well as the value.
  7338. */
  7339. updateVector4: (name: string, vector: Vector4) => void;
  7340. /**
  7341. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7342. * This is dynamic to allow compat with webgl 1 and 2.
  7343. * You will need to pass the name of the uniform as well as the value.
  7344. */
  7345. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7346. /**
  7347. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7348. * This is dynamic to allow compat with webgl 1 and 2.
  7349. * You will need to pass the name of the uniform as well as the value.
  7350. */
  7351. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7352. /**
  7353. * Instantiates a new Uniform buffer objects.
  7354. *
  7355. * Handles blocks of uniform on the GPU.
  7356. *
  7357. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7358. *
  7359. * For more information, please refer to :
  7360. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7361. * @param engine Define the engine the buffer is associated with
  7362. * @param data Define the data contained in the buffer
  7363. * @param dynamic Define if the buffer is updatable
  7364. */
  7365. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7366. /**
  7367. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7368. * or just falling back on setUniformXXX calls.
  7369. */
  7370. get useUbo(): boolean;
  7371. /**
  7372. * Indicates if the WebGL underlying uniform buffer is in sync
  7373. * with the javascript cache data.
  7374. */
  7375. get isSync(): boolean;
  7376. /**
  7377. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7378. * Also, a dynamic UniformBuffer will disable cache verification and always
  7379. * update the underlying WebGL uniform buffer to the GPU.
  7380. * @returns if Dynamic, otherwise false
  7381. */
  7382. isDynamic(): boolean;
  7383. /**
  7384. * The data cache on JS side.
  7385. * @returns the underlying data as a float array
  7386. */
  7387. getData(): Float32Array;
  7388. /**
  7389. * The underlying WebGL Uniform buffer.
  7390. * @returns the webgl buffer
  7391. */
  7392. getBuffer(): Nullable<DataBuffer>;
  7393. /**
  7394. * std140 layout specifies how to align data within an UBO structure.
  7395. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7396. * for specs.
  7397. */
  7398. private _fillAlignment;
  7399. /**
  7400. * Adds an uniform in the buffer.
  7401. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7402. * for the layout to be correct !
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param size Data size, or data directly.
  7405. */
  7406. addUniform(name: string, size: number | number[]): void;
  7407. /**
  7408. * Adds a Matrix 4x4 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param mat A 4x4 matrix.
  7411. */
  7412. addMatrix(name: string, mat: Matrix): void;
  7413. /**
  7414. * Adds a vec2 to the uniform buffer.
  7415. * @param name Name of the uniform, as used in the uniform block in the shader.
  7416. * @param x Define the x component value of the vec2
  7417. * @param y Define the y component value of the vec2
  7418. */
  7419. addFloat2(name: string, x: number, y: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param x Define the x component value of the vec3
  7424. * @param y Define the y component value of the vec3
  7425. * @param z Define the z component value of the vec3
  7426. */
  7427. addFloat3(name: string, x: number, y: number, z: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param color Define the vec3 from a Color
  7432. */
  7433. addColor3(name: string, color: Color3): void;
  7434. /**
  7435. * Adds a vec4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param color Define the rgb components from a Color
  7438. * @param alpha Define the a component of the vec4
  7439. */
  7440. addColor4(name: string, color: Color3, alpha: number): void;
  7441. /**
  7442. * Adds a vec3 to the uniform buffer.
  7443. * @param name Name of the uniform, as used in the uniform block in the shader.
  7444. * @param vector Define the vec3 components from a Vector
  7445. */
  7446. addVector3(name: string, vector: Vector3): void;
  7447. /**
  7448. * Adds a Matrix 3x3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. */
  7451. addMatrix3x3(name: string): void;
  7452. /**
  7453. * Adds a Matrix 2x2 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. */
  7456. addMatrix2x2(name: string): void;
  7457. /**
  7458. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7459. */
  7460. create(): void;
  7461. /** @hidden */
  7462. _rebuild(): void;
  7463. /**
  7464. * Updates the WebGL Uniform Buffer on the GPU.
  7465. * If the `dynamic` flag is set to true, no cache comparison is done.
  7466. * Otherwise, the buffer will be updated only if the cache differs.
  7467. */
  7468. update(): void;
  7469. /**
  7470. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7471. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7472. * @param data Define the flattened data
  7473. * @param size Define the size of the data.
  7474. */
  7475. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7476. private _valueCache;
  7477. private _cacheMatrix;
  7478. private _updateMatrix3x3ForUniform;
  7479. private _updateMatrix3x3ForEffect;
  7480. private _updateMatrix2x2ForEffect;
  7481. private _updateMatrix2x2ForUniform;
  7482. private _updateFloatForEffect;
  7483. private _updateFloatForUniform;
  7484. private _updateFloat2ForEffect;
  7485. private _updateFloat2ForUniform;
  7486. private _updateFloat3ForEffect;
  7487. private _updateFloat3ForUniform;
  7488. private _updateFloat4ForEffect;
  7489. private _updateFloat4ForUniform;
  7490. private _updateMatrixForEffect;
  7491. private _updateMatrixForUniform;
  7492. private _updateVector3ForEffect;
  7493. private _updateVector3ForUniform;
  7494. private _updateVector4ForEffect;
  7495. private _updateVector4ForUniform;
  7496. private _updateColor3ForEffect;
  7497. private _updateColor3ForUniform;
  7498. private _updateColor4ForEffect;
  7499. private _updateColor4ForUniform;
  7500. /**
  7501. * Sets a sampler uniform on the effect.
  7502. * @param name Define the name of the sampler.
  7503. * @param texture Define the texture to set in the sampler
  7504. */
  7505. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7506. /**
  7507. * Directly updates the value of the uniform in the cache AND on the GPU.
  7508. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7509. * @param data Define the flattened data
  7510. */
  7511. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7512. /**
  7513. * Binds this uniform buffer to an effect.
  7514. * @param effect Define the effect to bind the buffer to
  7515. * @param name Name of the uniform block in the shader.
  7516. */
  7517. bindToEffect(effect: Effect, name: string): void;
  7518. /**
  7519. * Disposes the uniform buffer.
  7520. */
  7521. dispose(): void;
  7522. }
  7523. }
  7524. declare module BABYLON {
  7525. /**
  7526. * Enum that determines the text-wrapping mode to use.
  7527. */
  7528. export enum InspectableType {
  7529. /**
  7530. * Checkbox for booleans
  7531. */
  7532. Checkbox = 0,
  7533. /**
  7534. * Sliders for numbers
  7535. */
  7536. Slider = 1,
  7537. /**
  7538. * Vector3
  7539. */
  7540. Vector3 = 2,
  7541. /**
  7542. * Quaternions
  7543. */
  7544. Quaternion = 3,
  7545. /**
  7546. * Color3
  7547. */
  7548. Color3 = 4,
  7549. /**
  7550. * String
  7551. */
  7552. String = 5
  7553. }
  7554. /**
  7555. * Interface used to define custom inspectable properties.
  7556. * This interface is used by the inspector to display custom property grids
  7557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7558. */
  7559. export interface IInspectable {
  7560. /**
  7561. * Gets the label to display
  7562. */
  7563. label: string;
  7564. /**
  7565. * Gets the name of the property to edit
  7566. */
  7567. propertyName: string;
  7568. /**
  7569. * Gets the type of the editor to use
  7570. */
  7571. type: InspectableType;
  7572. /**
  7573. * Gets the minimum value of the property when using in "slider" mode
  7574. */
  7575. min?: number;
  7576. /**
  7577. * Gets the maximum value of the property when using in "slider" mode
  7578. */
  7579. max?: number;
  7580. /**
  7581. * Gets the setp to use when using in "slider" mode
  7582. */
  7583. step?: number;
  7584. }
  7585. }
  7586. declare module BABYLON {
  7587. /**
  7588. * Class used to provide helper for timing
  7589. */
  7590. export class TimingTools {
  7591. /**
  7592. * Polyfill for setImmediate
  7593. * @param action defines the action to execute after the current execution block
  7594. */
  7595. static SetImmediate(action: () => void): void;
  7596. }
  7597. }
  7598. declare module BABYLON {
  7599. /**
  7600. * Class used to enable instatition of objects by class name
  7601. */
  7602. export class InstantiationTools {
  7603. /**
  7604. * Use this object to register external classes like custom textures or material
  7605. * to allow the laoders to instantiate them
  7606. */
  7607. static RegisteredExternalClasses: {
  7608. [key: string]: Object;
  7609. };
  7610. /**
  7611. * Tries to instantiate a new object from a given class name
  7612. * @param className defines the class name to instantiate
  7613. * @returns the new object or null if the system was not able to do the instantiation
  7614. */
  7615. static Instantiate(className: string): any;
  7616. }
  7617. }
  7618. declare module BABYLON {
  7619. /**
  7620. * Define options used to create a depth texture
  7621. */
  7622. export class DepthTextureCreationOptions {
  7623. /** Specifies whether or not a stencil should be allocated in the texture */
  7624. generateStencil?: boolean;
  7625. /** Specifies whether or not bilinear filtering is enable on the texture */
  7626. bilinearFiltering?: boolean;
  7627. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7628. comparisonFunction?: number;
  7629. /** Specifies if the created texture is a cube texture */
  7630. isCube?: boolean;
  7631. }
  7632. }
  7633. declare module BABYLON {
  7634. interface ThinEngine {
  7635. /**
  7636. * Creates a depth stencil cube texture.
  7637. * This is only available in WebGL 2.
  7638. * @param size The size of face edge in the cube texture.
  7639. * @param options The options defining the cube texture.
  7640. * @returns The cube texture
  7641. */
  7642. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7643. /**
  7644. * Creates a cube texture
  7645. * @param rootUrl defines the url where the files to load is located
  7646. * @param scene defines the current scene
  7647. * @param files defines the list of files to load (1 per face)
  7648. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7649. * @param onLoad defines an optional callback raised when the texture is loaded
  7650. * @param onError defines an optional callback raised if there is an issue to load the texture
  7651. * @param format defines the format of the data
  7652. * @param forcedExtension defines the extension to use to pick the right loader
  7653. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7654. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7655. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7656. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7657. * @returns the cube texture as an InternalTexture
  7658. */
  7659. 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;
  7660. /**
  7661. * Creates a cube texture
  7662. * @param rootUrl defines the url where the files to load is located
  7663. * @param scene defines the current scene
  7664. * @param files defines the list of files to load (1 per face)
  7665. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7666. * @param onLoad defines an optional callback raised when the texture is loaded
  7667. * @param onError defines an optional callback raised if there is an issue to load the texture
  7668. * @param format defines the format of the data
  7669. * @param forcedExtension defines the extension to use to pick the right loader
  7670. * @returns the cube texture as an InternalTexture
  7671. */
  7672. 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;
  7673. /**
  7674. * Creates a cube texture
  7675. * @param rootUrl defines the url where the files to load is located
  7676. * @param scene defines the current scene
  7677. * @param files defines the list of files to load (1 per face)
  7678. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7679. * @param onLoad defines an optional callback raised when the texture is loaded
  7680. * @param onError defines an optional callback raised if there is an issue to load the texture
  7681. * @param format defines the format of the data
  7682. * @param forcedExtension defines the extension to use to pick the right loader
  7683. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7684. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7685. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7686. * @returns the cube texture as an InternalTexture
  7687. */
  7688. 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;
  7689. /** @hidden */
  7690. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7691. /** @hidden */
  7692. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7693. /** @hidden */
  7694. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7695. /** @hidden */
  7696. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7697. /**
  7698. * @hidden
  7699. */
  7700. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7701. }
  7702. }
  7703. declare module BABYLON {
  7704. /**
  7705. * Class for creating a cube texture
  7706. */
  7707. export class CubeTexture extends BaseTexture {
  7708. private _delayedOnLoad;
  7709. /**
  7710. * Observable triggered once the texture has been loaded.
  7711. */
  7712. onLoadObservable: Observable<CubeTexture>;
  7713. /**
  7714. * The url of the texture
  7715. */
  7716. url: string;
  7717. /**
  7718. * Gets or sets the center of the bounding box associated with the cube texture.
  7719. * It must define where the camera used to render the texture was set
  7720. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7721. */
  7722. boundingBoxPosition: Vector3;
  7723. private _boundingBoxSize;
  7724. /**
  7725. * Gets or sets the size of the bounding box associated with the cube texture
  7726. * When defined, the cubemap will switch to local mode
  7727. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7728. * @example https://www.babylonjs-playground.com/#RNASML
  7729. */
  7730. set boundingBoxSize(value: Vector3);
  7731. /**
  7732. * Returns the bounding box size
  7733. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7734. */
  7735. get boundingBoxSize(): Vector3;
  7736. protected _rotationY: number;
  7737. /**
  7738. * Sets texture matrix rotation angle around Y axis in radians.
  7739. */
  7740. set rotationY(value: number);
  7741. /**
  7742. * Gets texture matrix rotation angle around Y axis radians.
  7743. */
  7744. get rotationY(): number;
  7745. /**
  7746. * Are mip maps generated for this texture or not.
  7747. */
  7748. get noMipmap(): boolean;
  7749. private _noMipmap;
  7750. private _files;
  7751. protected _forcedExtension: Nullable<string>;
  7752. private _extensions;
  7753. private _textureMatrix;
  7754. private _format;
  7755. private _createPolynomials;
  7756. /**
  7757. * Creates a cube texture from an array of image urls
  7758. * @param files defines an array of image urls
  7759. * @param scene defines the hosting scene
  7760. * @param noMipmap specifies if mip maps are not used
  7761. * @returns a cube texture
  7762. */
  7763. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7764. /**
  7765. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7766. * @param url defines the url of the prefiltered texture
  7767. * @param scene defines the scene the texture is attached to
  7768. * @param forcedExtension defines the extension of the file if different from the url
  7769. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7770. * @return the prefiltered texture
  7771. */
  7772. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7773. /**
  7774. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7775. * as prefiltered data.
  7776. * @param rootUrl defines the url of the texture or the root name of the six images
  7777. * @param null defines the scene or engine the texture is attached to
  7778. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7779. * @param noMipmap defines if mipmaps should be created or not
  7780. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7781. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7782. * @param onError defines a callback triggered in case of error during load
  7783. * @param format defines the internal format to use for the texture once loaded
  7784. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7785. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7786. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7787. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7788. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7789. * @return the cube texture
  7790. */
  7791. 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);
  7792. /**
  7793. * Get the current class name of the texture useful for serialization or dynamic coding.
  7794. * @returns "CubeTexture"
  7795. */
  7796. getClassName(): string;
  7797. /**
  7798. * Update the url (and optional buffer) of this texture if url was null during construction.
  7799. * @param url the url of the texture
  7800. * @param forcedExtension defines the extension to use
  7801. * @param onLoad callback called when the texture is loaded (defaults to null)
  7802. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7803. */
  7804. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7805. /**
  7806. * Delays loading of the cube texture
  7807. * @param forcedExtension defines the extension to use
  7808. */
  7809. delayLoad(forcedExtension?: string): void;
  7810. /**
  7811. * Returns the reflection texture matrix
  7812. * @returns the reflection texture matrix
  7813. */
  7814. getReflectionTextureMatrix(): Matrix;
  7815. /**
  7816. * Sets the reflection texture matrix
  7817. * @param value Reflection texture matrix
  7818. */
  7819. setReflectionTextureMatrix(value: Matrix): void;
  7820. /**
  7821. * Parses text to create a cube texture
  7822. * @param parsedTexture define the serialized text to read from
  7823. * @param scene defines the hosting scene
  7824. * @param rootUrl defines the root url of the cube texture
  7825. * @returns a cube texture
  7826. */
  7827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7828. /**
  7829. * Makes a clone, or deep copy, of the cube texture
  7830. * @returns a new cube texture
  7831. */
  7832. clone(): CubeTexture;
  7833. }
  7834. }
  7835. declare module BABYLON {
  7836. /**
  7837. * Manages the defines for the Material
  7838. */
  7839. export class MaterialDefines {
  7840. /** @hidden */
  7841. protected _keys: string[];
  7842. private _isDirty;
  7843. /** @hidden */
  7844. _renderId: number;
  7845. /** @hidden */
  7846. _areLightsDirty: boolean;
  7847. /** @hidden */
  7848. _areLightsDisposed: boolean;
  7849. /** @hidden */
  7850. _areAttributesDirty: boolean;
  7851. /** @hidden */
  7852. _areTexturesDirty: boolean;
  7853. /** @hidden */
  7854. _areFresnelDirty: boolean;
  7855. /** @hidden */
  7856. _areMiscDirty: boolean;
  7857. /** @hidden */
  7858. _areImageProcessingDirty: boolean;
  7859. /** @hidden */
  7860. _normals: boolean;
  7861. /** @hidden */
  7862. _uvs: boolean;
  7863. /** @hidden */
  7864. _needNormals: boolean;
  7865. /** @hidden */
  7866. _needUVs: boolean;
  7867. [id: string]: any;
  7868. /**
  7869. * Specifies if the material needs to be re-calculated
  7870. */
  7871. get isDirty(): boolean;
  7872. /**
  7873. * Marks the material to indicate that it has been re-calculated
  7874. */
  7875. markAsProcessed(): void;
  7876. /**
  7877. * Marks the material to indicate that it needs to be re-calculated
  7878. */
  7879. markAsUnprocessed(): void;
  7880. /**
  7881. * Marks the material to indicate all of its defines need to be re-calculated
  7882. */
  7883. markAllAsDirty(): void;
  7884. /**
  7885. * Marks the material to indicate that image processing needs to be re-calculated
  7886. */
  7887. markAsImageProcessingDirty(): void;
  7888. /**
  7889. * Marks the material to indicate the lights need to be re-calculated
  7890. * @param disposed Defines whether the light is dirty due to dispose or not
  7891. */
  7892. markAsLightDirty(disposed?: boolean): void;
  7893. /**
  7894. * Marks the attribute state as changed
  7895. */
  7896. markAsAttributesDirty(): void;
  7897. /**
  7898. * Marks the texture state as changed
  7899. */
  7900. markAsTexturesDirty(): void;
  7901. /**
  7902. * Marks the fresnel state as changed
  7903. */
  7904. markAsFresnelDirty(): void;
  7905. /**
  7906. * Marks the misc state as changed
  7907. */
  7908. markAsMiscDirty(): void;
  7909. /**
  7910. * Rebuilds the material defines
  7911. */
  7912. rebuild(): void;
  7913. /**
  7914. * Specifies if two material defines are equal
  7915. * @param other - A material define instance to compare to
  7916. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7917. */
  7918. isEqual(other: MaterialDefines): boolean;
  7919. /**
  7920. * Clones this instance's defines to another instance
  7921. * @param other - material defines to clone values to
  7922. */
  7923. cloneTo(other: MaterialDefines): void;
  7924. /**
  7925. * Resets the material define values
  7926. */
  7927. reset(): void;
  7928. /**
  7929. * Converts the material define values to a string
  7930. * @returns - String of material define information
  7931. */
  7932. toString(): string;
  7933. }
  7934. }
  7935. declare module BABYLON {
  7936. /**
  7937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7939. * 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;
  7940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7941. */
  7942. export class ColorCurves {
  7943. private _dirty;
  7944. private _tempColor;
  7945. private _globalCurve;
  7946. private _highlightsCurve;
  7947. private _midtonesCurve;
  7948. private _shadowsCurve;
  7949. private _positiveCurve;
  7950. private _negativeCurve;
  7951. private _globalHue;
  7952. private _globalDensity;
  7953. private _globalSaturation;
  7954. private _globalExposure;
  7955. /**
  7956. * Gets the global Hue value.
  7957. * 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).
  7958. */
  7959. get globalHue(): number;
  7960. /**
  7961. * Sets the global Hue value.
  7962. * 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).
  7963. */
  7964. set globalHue(value: number);
  7965. /**
  7966. * Gets the global Density value.
  7967. * 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.
  7968. * Values less than zero provide a filter of opposite hue.
  7969. */
  7970. get globalDensity(): number;
  7971. /**
  7972. * Sets the global Density value.
  7973. * 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.
  7974. * Values less than zero provide a filter of opposite hue.
  7975. */
  7976. set globalDensity(value: number);
  7977. /**
  7978. * Gets the global Saturation value.
  7979. * 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.
  7980. */
  7981. get globalSaturation(): number;
  7982. /**
  7983. * Sets the global Saturation value.
  7984. * 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.
  7985. */
  7986. set globalSaturation(value: number);
  7987. /**
  7988. * Gets the global Exposure value.
  7989. * 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.
  7990. */
  7991. get globalExposure(): number;
  7992. /**
  7993. * Sets the global Exposure value.
  7994. * 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.
  7995. */
  7996. set globalExposure(value: number);
  7997. private _highlightsHue;
  7998. private _highlightsDensity;
  7999. private _highlightsSaturation;
  8000. private _highlightsExposure;
  8001. /**
  8002. * Gets the highlights Hue value.
  8003. * 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).
  8004. */
  8005. get highlightsHue(): number;
  8006. /**
  8007. * Sets the highlights Hue value.
  8008. * 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).
  8009. */
  8010. set highlightsHue(value: number);
  8011. /**
  8012. * Gets the highlights Density value.
  8013. * 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.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get highlightsDensity(): number;
  8017. /**
  8018. * Sets the highlights Density value.
  8019. * 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.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set highlightsDensity(value: number);
  8023. /**
  8024. * Gets the highlights Saturation value.
  8025. * 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.
  8026. */
  8027. get highlightsSaturation(): number;
  8028. /**
  8029. * Sets the highlights Saturation value.
  8030. * 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.
  8031. */
  8032. set highlightsSaturation(value: number);
  8033. /**
  8034. * Gets the highlights Exposure value.
  8035. * 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.
  8036. */
  8037. get highlightsExposure(): number;
  8038. /**
  8039. * Sets the highlights Exposure value.
  8040. * 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.
  8041. */
  8042. set highlightsExposure(value: number);
  8043. private _midtonesHue;
  8044. private _midtonesDensity;
  8045. private _midtonesSaturation;
  8046. private _midtonesExposure;
  8047. /**
  8048. * Gets the midtones Hue value.
  8049. * 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).
  8050. */
  8051. get midtonesHue(): number;
  8052. /**
  8053. * Sets the midtones Hue value.
  8054. * 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).
  8055. */
  8056. set midtonesHue(value: number);
  8057. /**
  8058. * Gets the midtones Density value.
  8059. * 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.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get midtonesDensity(): number;
  8063. /**
  8064. * Sets the midtones Density value.
  8065. * 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.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set midtonesDensity(value: number);
  8069. /**
  8070. * Gets the midtones Saturation value.
  8071. * 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.
  8072. */
  8073. get midtonesSaturation(): number;
  8074. /**
  8075. * Sets the midtones Saturation value.
  8076. * 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.
  8077. */
  8078. set midtonesSaturation(value: number);
  8079. /**
  8080. * Gets the midtones Exposure value.
  8081. * 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.
  8082. */
  8083. get midtonesExposure(): number;
  8084. /**
  8085. * Sets the midtones Exposure value.
  8086. * 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.
  8087. */
  8088. set midtonesExposure(value: number);
  8089. private _shadowsHue;
  8090. private _shadowsDensity;
  8091. private _shadowsSaturation;
  8092. private _shadowsExposure;
  8093. /**
  8094. * Gets the shadows Hue value.
  8095. * 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).
  8096. */
  8097. get shadowsHue(): number;
  8098. /**
  8099. * Sets the shadows Hue value.
  8100. * 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).
  8101. */
  8102. set shadowsHue(value: number);
  8103. /**
  8104. * Gets the shadows Density value.
  8105. * 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.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get shadowsDensity(): number;
  8109. /**
  8110. * Sets the shadows Density value.
  8111. * 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.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set shadowsDensity(value: number);
  8115. /**
  8116. * Gets the shadows Saturation value.
  8117. * 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.
  8118. */
  8119. get shadowsSaturation(): number;
  8120. /**
  8121. * Sets the shadows Saturation value.
  8122. * 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.
  8123. */
  8124. set shadowsSaturation(value: number);
  8125. /**
  8126. * Gets the shadows Exposure value.
  8127. * 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.
  8128. */
  8129. get shadowsExposure(): number;
  8130. /**
  8131. * Sets the shadows Exposure value.
  8132. * 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.
  8133. */
  8134. set shadowsExposure(value: number);
  8135. /**
  8136. * Returns the class name
  8137. * @returns The class name
  8138. */
  8139. getClassName(): string;
  8140. /**
  8141. * Binds the color curves to the shader.
  8142. * @param colorCurves The color curve to bind
  8143. * @param effect The effect to bind to
  8144. * @param positiveUniform The positive uniform shader parameter
  8145. * @param neutralUniform The neutral uniform shader parameter
  8146. * @param negativeUniform The negative uniform shader parameter
  8147. */
  8148. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8149. /**
  8150. * Prepare the list of uniforms associated with the ColorCurves effects.
  8151. * @param uniformsList The list of uniforms used in the effect
  8152. */
  8153. static PrepareUniforms(uniformsList: string[]): void;
  8154. /**
  8155. * Returns color grading data based on a hue, density, saturation and exposure value.
  8156. * @param filterHue The hue of the color filter.
  8157. * @param filterDensity The density of the color filter.
  8158. * @param saturation The saturation.
  8159. * @param exposure The exposure.
  8160. * @param result The result data container.
  8161. */
  8162. private getColorGradingDataToRef;
  8163. /**
  8164. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8165. * @param value The input slider value in range [-100,100].
  8166. * @returns Adjusted value.
  8167. */
  8168. private static applyColorGradingSliderNonlinear;
  8169. /**
  8170. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8171. * @param hue The hue (H) input.
  8172. * @param saturation The saturation (S) input.
  8173. * @param brightness The brightness (B) input.
  8174. * @result An RGBA color represented as Vector4.
  8175. */
  8176. private static fromHSBToRef;
  8177. /**
  8178. * Returns a value clamped between min and max
  8179. * @param value The value to clamp
  8180. * @param min The minimum of value
  8181. * @param max The maximum of value
  8182. * @returns The clamped value.
  8183. */
  8184. private static clamp;
  8185. /**
  8186. * Clones the current color curve instance.
  8187. * @return The cloned curves
  8188. */
  8189. clone(): ColorCurves;
  8190. /**
  8191. * Serializes the current color curve instance to a json representation.
  8192. * @return a JSON representation
  8193. */
  8194. serialize(): any;
  8195. /**
  8196. * Parses the color curve from a json representation.
  8197. * @param source the JSON source to parse
  8198. * @return The parsed curves
  8199. */
  8200. static Parse(source: any): ColorCurves;
  8201. }
  8202. }
  8203. declare module BABYLON {
  8204. /**
  8205. * Interface to follow in your material defines to integrate easily the
  8206. * Image proccessing functions.
  8207. * @hidden
  8208. */
  8209. export interface IImageProcessingConfigurationDefines {
  8210. IMAGEPROCESSING: boolean;
  8211. VIGNETTE: boolean;
  8212. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8213. VIGNETTEBLENDMODEOPAQUE: boolean;
  8214. TONEMAPPING: boolean;
  8215. TONEMAPPING_ACES: boolean;
  8216. CONTRAST: boolean;
  8217. EXPOSURE: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. }
  8225. /**
  8226. * @hidden
  8227. */
  8228. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8229. IMAGEPROCESSING: boolean;
  8230. VIGNETTE: boolean;
  8231. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8232. VIGNETTEBLENDMODEOPAQUE: boolean;
  8233. TONEMAPPING: boolean;
  8234. TONEMAPPING_ACES: boolean;
  8235. CONTRAST: boolean;
  8236. COLORCURVES: boolean;
  8237. COLORGRADING: boolean;
  8238. COLORGRADING3D: boolean;
  8239. SAMPLER3DGREENDEPTH: boolean;
  8240. SAMPLER3DBGRMAP: boolean;
  8241. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8242. EXPOSURE: boolean;
  8243. constructor();
  8244. }
  8245. /**
  8246. * This groups together the common properties used for image processing either in direct forward pass
  8247. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8248. * or not.
  8249. */
  8250. export class ImageProcessingConfiguration {
  8251. /**
  8252. * Default tone mapping applied in BabylonJS.
  8253. */
  8254. static readonly TONEMAPPING_STANDARD: number;
  8255. /**
  8256. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8257. * to other engines rendering to increase portability.
  8258. */
  8259. static readonly TONEMAPPING_ACES: number;
  8260. /**
  8261. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8262. */
  8263. colorCurves: Nullable<ColorCurves>;
  8264. private _colorCurvesEnabled;
  8265. /**
  8266. * Gets wether the color curves effect is enabled.
  8267. */
  8268. get colorCurvesEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color curves effect is enabled.
  8271. */
  8272. set colorCurvesEnabled(value: boolean);
  8273. private _colorGradingTexture;
  8274. /**
  8275. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8276. */
  8277. get colorGradingTexture(): Nullable<BaseTexture>;
  8278. /**
  8279. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8280. */
  8281. set colorGradingTexture(value: Nullable<BaseTexture>);
  8282. private _colorGradingEnabled;
  8283. /**
  8284. * Gets wether the color grading effect is enabled.
  8285. */
  8286. get colorGradingEnabled(): boolean;
  8287. /**
  8288. * Sets wether the color grading effect is enabled.
  8289. */
  8290. set colorGradingEnabled(value: boolean);
  8291. private _colorGradingWithGreenDepth;
  8292. /**
  8293. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8294. */
  8295. get colorGradingWithGreenDepth(): boolean;
  8296. /**
  8297. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8298. */
  8299. set colorGradingWithGreenDepth(value: boolean);
  8300. private _colorGradingBGR;
  8301. /**
  8302. * Gets wether the color grading texture contains BGR values.
  8303. */
  8304. get colorGradingBGR(): boolean;
  8305. /**
  8306. * Sets wether the color grading texture contains BGR values.
  8307. */
  8308. set colorGradingBGR(value: boolean);
  8309. /** @hidden */
  8310. _exposure: number;
  8311. /**
  8312. * Gets the Exposure used in the effect.
  8313. */
  8314. get exposure(): number;
  8315. /**
  8316. * Sets the Exposure used in the effect.
  8317. */
  8318. set exposure(value: number);
  8319. private _toneMappingEnabled;
  8320. /**
  8321. * Gets wether the tone mapping effect is enabled.
  8322. */
  8323. get toneMappingEnabled(): boolean;
  8324. /**
  8325. * Sets wether the tone mapping effect is enabled.
  8326. */
  8327. set toneMappingEnabled(value: boolean);
  8328. private _toneMappingType;
  8329. /**
  8330. * Gets the type of tone mapping effect.
  8331. */
  8332. get toneMappingType(): number;
  8333. /**
  8334. * Sets the type of tone mapping effect used in BabylonJS.
  8335. */
  8336. set toneMappingType(value: number);
  8337. protected _contrast: number;
  8338. /**
  8339. * Gets the contrast used in the effect.
  8340. */
  8341. get contrast(): number;
  8342. /**
  8343. * Sets the contrast used in the effect.
  8344. */
  8345. set contrast(value: number);
  8346. /**
  8347. * Vignette stretch size.
  8348. */
  8349. vignetteStretch: number;
  8350. /**
  8351. * Vignette centre X Offset.
  8352. */
  8353. vignetteCentreX: number;
  8354. /**
  8355. * Vignette centre Y Offset.
  8356. */
  8357. vignetteCentreY: number;
  8358. /**
  8359. * Vignette weight or intensity of the vignette effect.
  8360. */
  8361. vignetteWeight: number;
  8362. /**
  8363. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8364. * if vignetteEnabled is set to true.
  8365. */
  8366. vignetteColor: Color4;
  8367. /**
  8368. * Camera field of view used by the Vignette effect.
  8369. */
  8370. vignetteCameraFov: number;
  8371. private _vignetteBlendMode;
  8372. /**
  8373. * Gets the vignette blend mode allowing different kind of effect.
  8374. */
  8375. get vignetteBlendMode(): number;
  8376. /**
  8377. * Sets the vignette blend mode allowing different kind of effect.
  8378. */
  8379. set vignetteBlendMode(value: number);
  8380. private _vignetteEnabled;
  8381. /**
  8382. * Gets wether the vignette effect is enabled.
  8383. */
  8384. get vignetteEnabled(): boolean;
  8385. /**
  8386. * Sets wether the vignette effect is enabled.
  8387. */
  8388. set vignetteEnabled(value: boolean);
  8389. private _applyByPostProcess;
  8390. /**
  8391. * Gets wether the image processing is applied through a post process or not.
  8392. */
  8393. get applyByPostProcess(): boolean;
  8394. /**
  8395. * Sets wether the image processing is applied through a post process or not.
  8396. */
  8397. set applyByPostProcess(value: boolean);
  8398. private _isEnabled;
  8399. /**
  8400. * Gets wether the image processing is enabled or not.
  8401. */
  8402. get isEnabled(): boolean;
  8403. /**
  8404. * Sets wether the image processing is enabled or not.
  8405. */
  8406. set isEnabled(value: boolean);
  8407. /**
  8408. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8409. */
  8410. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8411. /**
  8412. * Method called each time the image processing information changes requires to recompile the effect.
  8413. */
  8414. protected _updateParameters(): void;
  8415. /**
  8416. * Gets the current class name.
  8417. * @return "ImageProcessingConfiguration"
  8418. */
  8419. getClassName(): string;
  8420. /**
  8421. * Prepare the list of uniforms associated with the Image Processing effects.
  8422. * @param uniforms The list of uniforms used in the effect
  8423. * @param defines the list of defines currently in use
  8424. */
  8425. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8426. /**
  8427. * Prepare the list of samplers associated with the Image Processing effects.
  8428. * @param samplersList The list of uniforms used in the effect
  8429. * @param defines the list of defines currently in use
  8430. */
  8431. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8432. /**
  8433. * Prepare the list of defines associated to the shader.
  8434. * @param defines the list of defines to complete
  8435. * @param forPostProcess Define if we are currently in post process mode or not
  8436. */
  8437. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8438. /**
  8439. * Returns true if all the image processing information are ready.
  8440. * @returns True if ready, otherwise, false
  8441. */
  8442. isReady(): boolean;
  8443. /**
  8444. * Binds the image processing to the shader.
  8445. * @param effect The effect to bind to
  8446. * @param overrideAspectRatio Override the aspect ratio of the effect
  8447. */
  8448. bind(effect: Effect, overrideAspectRatio?: number): void;
  8449. /**
  8450. * Clones the current image processing instance.
  8451. * @return The cloned image processing
  8452. */
  8453. clone(): ImageProcessingConfiguration;
  8454. /**
  8455. * Serializes the current image processing instance to a json representation.
  8456. * @return a JSON representation
  8457. */
  8458. serialize(): any;
  8459. /**
  8460. * Parses the image processing from a json representation.
  8461. * @param source the JSON source to parse
  8462. * @return The parsed image processing
  8463. */
  8464. static Parse(source: any): ImageProcessingConfiguration;
  8465. private static _VIGNETTEMODE_MULTIPLY;
  8466. private static _VIGNETTEMODE_OPAQUE;
  8467. /**
  8468. * Used to apply the vignette as a mix with the pixel color.
  8469. */
  8470. static get VIGNETTEMODE_MULTIPLY(): number;
  8471. /**
  8472. * Used to apply the vignette as a replacement of the pixel color.
  8473. */
  8474. static get VIGNETTEMODE_OPAQUE(): number;
  8475. }
  8476. }
  8477. declare module BABYLON {
  8478. /** @hidden */
  8479. export var postprocessVertexShader: {
  8480. name: string;
  8481. shader: string;
  8482. };
  8483. }
  8484. declare module BABYLON {
  8485. interface ThinEngine {
  8486. /**
  8487. * Creates a new render target texture
  8488. * @param size defines the size of the texture
  8489. * @param options defines the options used to create the texture
  8490. * @returns a new render target texture stored in an InternalTexture
  8491. */
  8492. createRenderTargetTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8497. /**
  8498. * Creates a depth stencil texture.
  8499. * This is only available in WebGL 2 or with the depth texture extension available.
  8500. * @param size The size of face edge in the texture.
  8501. * @param options The options defining the texture.
  8502. * @returns The texture
  8503. */
  8504. createDepthStencilTexture(size: number | {
  8505. width: number;
  8506. height: number;
  8507. layers?: number;
  8508. }, options: DepthTextureCreationOptions): InternalTexture;
  8509. /** @hidden */
  8510. _createDepthStencilTexture(size: number | {
  8511. width: number;
  8512. height: number;
  8513. layers?: number;
  8514. }, options: DepthTextureCreationOptions): InternalTexture;
  8515. }
  8516. }
  8517. declare module BABYLON {
  8518. /**
  8519. * Defines the kind of connection point for node based material
  8520. */
  8521. export enum NodeMaterialBlockConnectionPointTypes {
  8522. /** Float */
  8523. Float = 1,
  8524. /** Int */
  8525. Int = 2,
  8526. /** Vector2 */
  8527. Vector2 = 4,
  8528. /** Vector3 */
  8529. Vector3 = 8,
  8530. /** Vector4 */
  8531. Vector4 = 16,
  8532. /** Color3 */
  8533. Color3 = 32,
  8534. /** Color4 */
  8535. Color4 = 64,
  8536. /** Matrix */
  8537. Matrix = 128,
  8538. /** Custom object */
  8539. Object = 256,
  8540. /** Detect type based on connection */
  8541. AutoDetect = 1024,
  8542. /** Output type that will be defined by input type */
  8543. BasedOnInput = 2048
  8544. }
  8545. }
  8546. declare module BABYLON {
  8547. /**
  8548. * Enum used to define the target of a block
  8549. */
  8550. export enum NodeMaterialBlockTargets {
  8551. /** Vertex shader */
  8552. Vertex = 1,
  8553. /** Fragment shader */
  8554. Fragment = 2,
  8555. /** Neutral */
  8556. Neutral = 4,
  8557. /** Vertex and Fragment */
  8558. VertexAndFragment = 3
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /**
  8563. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8564. */
  8565. export enum NodeMaterialBlockConnectionPointMode {
  8566. /** Value is an uniform */
  8567. Uniform = 0,
  8568. /** Value is a mesh attribute */
  8569. Attribute = 1,
  8570. /** Value is a varying between vertex and fragment shaders */
  8571. Varying = 2,
  8572. /** Mode is undefined */
  8573. Undefined = 3
  8574. }
  8575. }
  8576. declare module BABYLON {
  8577. /**
  8578. * Enum used to define system values e.g. values automatically provided by the system
  8579. */
  8580. export enum NodeMaterialSystemValues {
  8581. /** World */
  8582. World = 1,
  8583. /** View */
  8584. View = 2,
  8585. /** Projection */
  8586. Projection = 3,
  8587. /** ViewProjection */
  8588. ViewProjection = 4,
  8589. /** WorldView */
  8590. WorldView = 5,
  8591. /** WorldViewProjection */
  8592. WorldViewProjection = 6,
  8593. /** CameraPosition */
  8594. CameraPosition = 7,
  8595. /** Fog Color */
  8596. FogColor = 8,
  8597. /** Delta time */
  8598. DeltaTime = 9
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /** Defines supported spaces */
  8603. export enum Space {
  8604. /** Local (object) space */
  8605. LOCAL = 0,
  8606. /** World space */
  8607. WORLD = 1,
  8608. /** Bone space */
  8609. BONE = 2
  8610. }
  8611. /** Defines the 3 main axes */
  8612. export class Axis {
  8613. /** X axis */
  8614. static X: Vector3;
  8615. /** Y axis */
  8616. static Y: Vector3;
  8617. /** Z axis */
  8618. static Z: Vector3;
  8619. }
  8620. }
  8621. declare module BABYLON {
  8622. /**
  8623. * Represents a camera frustum
  8624. */
  8625. export class Frustum {
  8626. /**
  8627. * Gets the planes representing the frustum
  8628. * @param transform matrix to be applied to the returned planes
  8629. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8630. */
  8631. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8632. /**
  8633. * Gets the near frustum plane transformed by the transform matrix
  8634. * @param transform transformation matrix to be applied to the resulting frustum plane
  8635. * @param frustumPlane the resuling frustum plane
  8636. */
  8637. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8638. /**
  8639. * Gets the far frustum plane transformed by the transform matrix
  8640. * @param transform transformation matrix to be applied to the resulting frustum plane
  8641. * @param frustumPlane the resuling frustum plane
  8642. */
  8643. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8644. /**
  8645. * Gets the left frustum plane transformed by the transform matrix
  8646. * @param transform transformation matrix to be applied to the resulting frustum plane
  8647. * @param frustumPlane the resuling frustum plane
  8648. */
  8649. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8650. /**
  8651. * Gets the right frustum plane transformed by the transform matrix
  8652. * @param transform transformation matrix to be applied to the resulting frustum plane
  8653. * @param frustumPlane the resuling frustum plane
  8654. */
  8655. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8656. /**
  8657. * Gets the top frustum plane transformed by the transform matrix
  8658. * @param transform transformation matrix to be applied to the resulting frustum plane
  8659. * @param frustumPlane the resuling frustum plane
  8660. */
  8661. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8662. /**
  8663. * Gets the bottom frustum plane transformed by the transform matrix
  8664. * @param transform transformation matrix to be applied to the resulting frustum plane
  8665. * @param frustumPlane the resuling frustum plane
  8666. */
  8667. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8668. /**
  8669. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8670. * @param transform transformation matrix to be applied to the resulting frustum planes
  8671. * @param frustumPlanes the resuling frustum planes
  8672. */
  8673. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Interface for the size containing width and height
  8679. */
  8680. export interface ISize {
  8681. /**
  8682. * Width
  8683. */
  8684. width: number;
  8685. /**
  8686. * Heighht
  8687. */
  8688. height: number;
  8689. }
  8690. /**
  8691. * Size containing widht and height
  8692. */
  8693. export class Size implements ISize {
  8694. /**
  8695. * Width
  8696. */
  8697. width: number;
  8698. /**
  8699. * Height
  8700. */
  8701. height: number;
  8702. /**
  8703. * Creates a Size object from the given width and height (floats).
  8704. * @param width width of the new size
  8705. * @param height height of the new size
  8706. */
  8707. constructor(width: number, height: number);
  8708. /**
  8709. * Returns a string with the Size width and height
  8710. * @returns a string with the Size width and height
  8711. */
  8712. toString(): string;
  8713. /**
  8714. * "Size"
  8715. * @returns the string "Size"
  8716. */
  8717. getClassName(): string;
  8718. /**
  8719. * Returns the Size hash code.
  8720. * @returns a hash code for a unique width and height
  8721. */
  8722. getHashCode(): number;
  8723. /**
  8724. * Updates the current size from the given one.
  8725. * @param src the given size
  8726. */
  8727. copyFrom(src: Size): void;
  8728. /**
  8729. * Updates in place the current Size from the given floats.
  8730. * @param width width of the new size
  8731. * @param height height of the new size
  8732. * @returns the updated Size.
  8733. */
  8734. copyFromFloats(width: number, height: number): Size;
  8735. /**
  8736. * Updates in place the current Size from the given floats.
  8737. * @param width width to set
  8738. * @param height height to set
  8739. * @returns the updated Size.
  8740. */
  8741. set(width: number, height: number): Size;
  8742. /**
  8743. * Multiplies the width and height by numbers
  8744. * @param w factor to multiple the width by
  8745. * @param h factor to multiple the height by
  8746. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8747. */
  8748. multiplyByFloats(w: number, h: number): Size;
  8749. /**
  8750. * Clones the size
  8751. * @returns a new Size copied from the given one.
  8752. */
  8753. clone(): Size;
  8754. /**
  8755. * True if the current Size and the given one width and height are strictly equal.
  8756. * @param other the other size to compare against
  8757. * @returns True if the current Size and the given one width and height are strictly equal.
  8758. */
  8759. equals(other: Size): boolean;
  8760. /**
  8761. * The surface of the Size : width * height (float).
  8762. */
  8763. get surface(): number;
  8764. /**
  8765. * Create a new size of zero
  8766. * @returns a new Size set to (0.0, 0.0)
  8767. */
  8768. static Zero(): Size;
  8769. /**
  8770. * Sums the width and height of two sizes
  8771. * @param otherSize size to add to this size
  8772. * @returns a new Size set as the addition result of the current Size and the given one.
  8773. */
  8774. add(otherSize: Size): Size;
  8775. /**
  8776. * Subtracts the width and height of two
  8777. * @param otherSize size to subtract to this size
  8778. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8779. */
  8780. subtract(otherSize: Size): Size;
  8781. /**
  8782. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8783. * @param start starting size to lerp between
  8784. * @param end end size to lerp between
  8785. * @param amount amount to lerp between the start and end values
  8786. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8787. */
  8788. static Lerp(start: Size, end: Size, amount: number): Size;
  8789. }
  8790. }
  8791. declare module BABYLON {
  8792. /**
  8793. * Contains position and normal vectors for a vertex
  8794. */
  8795. export class PositionNormalVertex {
  8796. /** the position of the vertex (defaut: 0,0,0) */
  8797. position: Vector3;
  8798. /** the normal of the vertex (defaut: 0,1,0) */
  8799. normal: Vector3;
  8800. /**
  8801. * Creates a PositionNormalVertex
  8802. * @param position the position of the vertex (defaut: 0,0,0)
  8803. * @param normal the normal of the vertex (defaut: 0,1,0)
  8804. */
  8805. constructor(
  8806. /** the position of the vertex (defaut: 0,0,0) */
  8807. position?: Vector3,
  8808. /** the normal of the vertex (defaut: 0,1,0) */
  8809. normal?: Vector3);
  8810. /**
  8811. * Clones the PositionNormalVertex
  8812. * @returns the cloned PositionNormalVertex
  8813. */
  8814. clone(): PositionNormalVertex;
  8815. }
  8816. /**
  8817. * Contains position, normal and uv vectors for a vertex
  8818. */
  8819. export class PositionNormalTextureVertex {
  8820. /** the position of the vertex (defaut: 0,0,0) */
  8821. position: Vector3;
  8822. /** the normal of the vertex (defaut: 0,1,0) */
  8823. normal: Vector3;
  8824. /** the uv of the vertex (default: 0,0) */
  8825. uv: Vector2;
  8826. /**
  8827. * Creates a PositionNormalTextureVertex
  8828. * @param position the position of the vertex (defaut: 0,0,0)
  8829. * @param normal the normal of the vertex (defaut: 0,1,0)
  8830. * @param uv the uv of the vertex (default: 0,0)
  8831. */
  8832. constructor(
  8833. /** the position of the vertex (defaut: 0,0,0) */
  8834. position?: Vector3,
  8835. /** the normal of the vertex (defaut: 0,1,0) */
  8836. normal?: Vector3,
  8837. /** the uv of the vertex (default: 0,0) */
  8838. uv?: Vector2);
  8839. /**
  8840. * Clones the PositionNormalTextureVertex
  8841. * @returns the cloned PositionNormalTextureVertex
  8842. */
  8843. clone(): PositionNormalTextureVertex;
  8844. }
  8845. }
  8846. declare module BABYLON {
  8847. /**
  8848. * Enum defining the type of animations supported by InputBlock
  8849. */
  8850. export enum AnimatedInputBlockTypes {
  8851. /** No animation */
  8852. None = 0,
  8853. /** Time based animation. Will only work for floats */
  8854. Time = 1
  8855. }
  8856. }
  8857. declare module BABYLON {
  8858. /**
  8859. * Interface describing all the common properties and methods a shadow light needs to implement.
  8860. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8861. * as well as binding the different shadow properties to the effects.
  8862. */
  8863. export interface IShadowLight extends Light {
  8864. /**
  8865. * The light id in the scene (used in scene.findLighById for instance)
  8866. */
  8867. id: string;
  8868. /**
  8869. * The position the shdow will be casted from.
  8870. */
  8871. position: Vector3;
  8872. /**
  8873. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8874. */
  8875. direction: Vector3;
  8876. /**
  8877. * The transformed position. Position of the light in world space taking parenting in account.
  8878. */
  8879. transformedPosition: Vector3;
  8880. /**
  8881. * The transformed direction. Direction of the light in world space taking parenting in account.
  8882. */
  8883. transformedDirection: Vector3;
  8884. /**
  8885. * The friendly name of the light in the scene.
  8886. */
  8887. name: string;
  8888. /**
  8889. * Defines the shadow projection clipping minimum z value.
  8890. */
  8891. shadowMinZ: number;
  8892. /**
  8893. * Defines the shadow projection clipping maximum z value.
  8894. */
  8895. shadowMaxZ: number;
  8896. /**
  8897. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8898. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8899. */
  8900. computeTransformedInformation(): boolean;
  8901. /**
  8902. * Gets the scene the light belongs to.
  8903. * @returns The scene
  8904. */
  8905. getScene(): Scene;
  8906. /**
  8907. * Callback defining a custom Projection Matrix Builder.
  8908. * This can be used to override the default projection matrix computation.
  8909. */
  8910. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8911. /**
  8912. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8913. * @param matrix The materix to updated with the projection information
  8914. * @param viewMatrix The transform matrix of the light
  8915. * @param renderList The list of mesh to render in the map
  8916. * @returns The current light
  8917. */
  8918. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8919. /**
  8920. * Gets the current depth scale used in ESM.
  8921. * @returns The scale
  8922. */
  8923. getDepthScale(): number;
  8924. /**
  8925. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8926. * @returns true if a cube texture needs to be use
  8927. */
  8928. needCube(): boolean;
  8929. /**
  8930. * Detects if the projection matrix requires to be recomputed this frame.
  8931. * @returns true if it requires to be recomputed otherwise, false.
  8932. */
  8933. needProjectionMatrixCompute(): boolean;
  8934. /**
  8935. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8936. */
  8937. forceProjectionMatrixCompute(): void;
  8938. /**
  8939. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8940. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8941. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8942. */
  8943. getShadowDirection(faceIndex?: number): Vector3;
  8944. /**
  8945. * Gets the minZ used for shadow according to both the scene and the light.
  8946. * @param activeCamera The camera we are returning the min for
  8947. * @returns the depth min z
  8948. */
  8949. getDepthMinZ(activeCamera: Camera): number;
  8950. /**
  8951. * Gets the maxZ used for shadow according to both the scene and the light.
  8952. * @param activeCamera The camera we are returning the max for
  8953. * @returns the depth max z
  8954. */
  8955. getDepthMaxZ(activeCamera: Camera): number;
  8956. }
  8957. /**
  8958. * Base implementation IShadowLight
  8959. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8960. */
  8961. export abstract class ShadowLight extends Light implements IShadowLight {
  8962. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8963. protected _position: Vector3;
  8964. protected _setPosition(value: Vector3): void;
  8965. /**
  8966. * Sets the position the shadow will be casted from. Also use as the light position for both
  8967. * point and spot lights.
  8968. */
  8969. get position(): Vector3;
  8970. /**
  8971. * Sets the position the shadow will be casted from. Also use as the light position for both
  8972. * point and spot lights.
  8973. */
  8974. set position(value: Vector3);
  8975. protected _direction: Vector3;
  8976. protected _setDirection(value: Vector3): void;
  8977. /**
  8978. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8979. * Also use as the light direction on spot and directional lights.
  8980. */
  8981. get direction(): Vector3;
  8982. /**
  8983. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8984. * Also use as the light direction on spot and directional lights.
  8985. */
  8986. set direction(value: Vector3);
  8987. protected _shadowMinZ: number;
  8988. /**
  8989. * Gets the shadow projection clipping minimum z value.
  8990. */
  8991. get shadowMinZ(): number;
  8992. /**
  8993. * Sets the shadow projection clipping minimum z value.
  8994. */
  8995. set shadowMinZ(value: number);
  8996. protected _shadowMaxZ: number;
  8997. /**
  8998. * Sets the shadow projection clipping maximum z value.
  8999. */
  9000. get shadowMaxZ(): number;
  9001. /**
  9002. * Gets the shadow projection clipping maximum z value.
  9003. */
  9004. set shadowMaxZ(value: number);
  9005. /**
  9006. * Callback defining a custom Projection Matrix Builder.
  9007. * This can be used to override the default projection matrix computation.
  9008. */
  9009. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9010. /**
  9011. * The transformed position. Position of the light in world space taking parenting in account.
  9012. */
  9013. transformedPosition: Vector3;
  9014. /**
  9015. * The transformed direction. Direction of the light in world space taking parenting in account.
  9016. */
  9017. transformedDirection: Vector3;
  9018. private _needProjectionMatrixCompute;
  9019. /**
  9020. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9021. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9022. */
  9023. computeTransformedInformation(): boolean;
  9024. /**
  9025. * Return the depth scale used for the shadow map.
  9026. * @returns the depth scale.
  9027. */
  9028. getDepthScale(): number;
  9029. /**
  9030. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9031. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9032. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9033. */
  9034. getShadowDirection(faceIndex?: number): Vector3;
  9035. /**
  9036. * Returns the ShadowLight absolute position in the World.
  9037. * @returns the position vector in world space
  9038. */
  9039. getAbsolutePosition(): Vector3;
  9040. /**
  9041. * Sets the ShadowLight direction toward the passed target.
  9042. * @param target The point to target in local space
  9043. * @returns the updated ShadowLight direction
  9044. */
  9045. setDirectionToTarget(target: Vector3): Vector3;
  9046. /**
  9047. * Returns the light rotation in euler definition.
  9048. * @returns the x y z rotation in local space.
  9049. */
  9050. getRotation(): Vector3;
  9051. /**
  9052. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9053. * @returns true if a cube texture needs to be use
  9054. */
  9055. needCube(): boolean;
  9056. /**
  9057. * Detects if the projection matrix requires to be recomputed this frame.
  9058. * @returns true if it requires to be recomputed otherwise, false.
  9059. */
  9060. needProjectionMatrixCompute(): boolean;
  9061. /**
  9062. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9063. */
  9064. forceProjectionMatrixCompute(): void;
  9065. /** @hidden */
  9066. _initCache(): void;
  9067. /** @hidden */
  9068. _isSynchronized(): boolean;
  9069. /**
  9070. * Computes the world matrix of the node
  9071. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9072. * @returns the world matrix
  9073. */
  9074. computeWorldMatrix(force?: boolean): Matrix;
  9075. /**
  9076. * Gets the minZ used for shadow according to both the scene and the light.
  9077. * @param activeCamera The camera we are returning the min for
  9078. * @returns the depth min z
  9079. */
  9080. getDepthMinZ(activeCamera: Camera): number;
  9081. /**
  9082. * Gets the maxZ used for shadow according to both the scene and the light.
  9083. * @param activeCamera The camera we are returning the max for
  9084. * @returns the depth max z
  9085. */
  9086. getDepthMaxZ(activeCamera: Camera): number;
  9087. /**
  9088. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9089. * @param matrix The materix to updated with the projection information
  9090. * @param viewMatrix The transform matrix of the light
  9091. * @param renderList The list of mesh to render in the map
  9092. * @returns The current light
  9093. */
  9094. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9095. }
  9096. }
  9097. declare module BABYLON {
  9098. /** @hidden */
  9099. export var packingFunctions: {
  9100. name: string;
  9101. shader: string;
  9102. };
  9103. }
  9104. declare module BABYLON {
  9105. /** @hidden */
  9106. export var bayerDitherFunctions: {
  9107. name: string;
  9108. shader: string;
  9109. };
  9110. }
  9111. declare module BABYLON {
  9112. /** @hidden */
  9113. export var shadowMapFragmentDeclaration: {
  9114. name: string;
  9115. shader: string;
  9116. };
  9117. }
  9118. declare module BABYLON {
  9119. /** @hidden */
  9120. export var clipPlaneFragmentDeclaration: {
  9121. name: string;
  9122. shader: string;
  9123. };
  9124. }
  9125. declare module BABYLON {
  9126. /** @hidden */
  9127. export var clipPlaneFragment: {
  9128. name: string;
  9129. shader: string;
  9130. };
  9131. }
  9132. declare module BABYLON {
  9133. /** @hidden */
  9134. export var shadowMapFragment: {
  9135. name: string;
  9136. shader: string;
  9137. };
  9138. }
  9139. declare module BABYLON {
  9140. /** @hidden */
  9141. export var shadowMapPixelShader: {
  9142. name: string;
  9143. shader: string;
  9144. };
  9145. }
  9146. declare module BABYLON {
  9147. /** @hidden */
  9148. export var bonesDeclaration: {
  9149. name: string;
  9150. shader: string;
  9151. };
  9152. }
  9153. declare module BABYLON {
  9154. /** @hidden */
  9155. export var morphTargetsVertexGlobalDeclaration: {
  9156. name: string;
  9157. shader: string;
  9158. };
  9159. }
  9160. declare module BABYLON {
  9161. /** @hidden */
  9162. export var morphTargetsVertexDeclaration: {
  9163. name: string;
  9164. shader: string;
  9165. };
  9166. }
  9167. declare module BABYLON {
  9168. /** @hidden */
  9169. export var instancesDeclaration: {
  9170. name: string;
  9171. shader: string;
  9172. };
  9173. }
  9174. declare module BABYLON {
  9175. /** @hidden */
  9176. export var helperFunctions: {
  9177. name: string;
  9178. shader: string;
  9179. };
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var shadowMapVertexDeclaration: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var clipPlaneVertexDeclaration: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var morphTargetsVertex: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var instancesVertex: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var bonesVertex: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapVertexNormalBias: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapVertexMetric: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var clipPlaneVertex: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var shadowMapVertexShader: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var depthBoxBlurPixelShader: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var shadowMapFragmentSoftTransparentShadow: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /**
  9260. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9261. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9262. */
  9263. export class EffectFallbacks implements IEffectFallbacks {
  9264. private _defines;
  9265. private _currentRank;
  9266. private _maxRank;
  9267. private _mesh;
  9268. /**
  9269. * Removes the fallback from the bound mesh.
  9270. */
  9271. unBindMesh(): void;
  9272. /**
  9273. * Adds a fallback on the specified property.
  9274. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9275. * @param define The name of the define in the shader
  9276. */
  9277. addFallback(rank: number, define: string): void;
  9278. /**
  9279. * Sets the mesh to use CPU skinning when needing to fallback.
  9280. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9281. * @param mesh The mesh to use the fallbacks.
  9282. */
  9283. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9284. /**
  9285. * Checks to see if more fallbacks are still availible.
  9286. */
  9287. get hasMoreFallbacks(): boolean;
  9288. /**
  9289. * Removes the defines that should be removed when falling back.
  9290. * @param currentDefines defines the current define statements for the shader.
  9291. * @param effect defines the current effect we try to compile
  9292. * @returns The resulting defines with defines of the current rank removed.
  9293. */
  9294. reduce(currentDefines: string, effect: Effect): string;
  9295. }
  9296. }
  9297. declare module BABYLON {
  9298. /**
  9299. * Interface used to define Action
  9300. */
  9301. export interface IAction {
  9302. /**
  9303. * Trigger for the action
  9304. */
  9305. trigger: number;
  9306. /** Options of the trigger */
  9307. triggerOptions: any;
  9308. /**
  9309. * Gets the trigger parameters
  9310. * @returns the trigger parameters
  9311. */
  9312. getTriggerParameter(): any;
  9313. /**
  9314. * Internal only - executes current action event
  9315. * @hidden
  9316. */
  9317. _executeCurrent(evt?: ActionEvent): void;
  9318. /**
  9319. * Serialize placeholder for child classes
  9320. * @param parent of child
  9321. * @returns the serialized object
  9322. */
  9323. serialize(parent: any): any;
  9324. /**
  9325. * Internal only
  9326. * @hidden
  9327. */
  9328. _prepare(): void;
  9329. /**
  9330. * Internal only - manager for action
  9331. * @hidden
  9332. */
  9333. _actionManager: AbstractActionManager;
  9334. /**
  9335. * Adds action to chain of actions, may be a DoNothingAction
  9336. * @param action defines the next action to execute
  9337. * @returns The action passed in
  9338. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9339. */
  9340. then(action: IAction): IAction;
  9341. }
  9342. /**
  9343. * The action to be carried out following a trigger
  9344. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9345. */
  9346. export class Action implements IAction {
  9347. /** the trigger, with or without parameters, for the action */
  9348. triggerOptions: any;
  9349. /**
  9350. * Trigger for the action
  9351. */
  9352. trigger: number;
  9353. /**
  9354. * Internal only - manager for action
  9355. * @hidden
  9356. */
  9357. _actionManager: ActionManager;
  9358. private _nextActiveAction;
  9359. private _child;
  9360. private _condition?;
  9361. private _triggerParameter;
  9362. /**
  9363. * An event triggered prior to action being executed.
  9364. */
  9365. onBeforeExecuteObservable: Observable<Action>;
  9366. /**
  9367. * Creates a new Action
  9368. * @param triggerOptions the trigger, with or without parameters, for the action
  9369. * @param condition an optional determinant of action
  9370. */
  9371. constructor(
  9372. /** the trigger, with or without parameters, for the action */
  9373. triggerOptions: any, condition?: Condition);
  9374. /**
  9375. * Internal only
  9376. * @hidden
  9377. */
  9378. _prepare(): void;
  9379. /**
  9380. * Gets the trigger parameters
  9381. * @returns the trigger parameters
  9382. */
  9383. getTriggerParameter(): any;
  9384. /**
  9385. * Internal only - executes current action event
  9386. * @hidden
  9387. */
  9388. _executeCurrent(evt?: ActionEvent): void;
  9389. /**
  9390. * Execute placeholder for child classes
  9391. * @param evt optional action event
  9392. */
  9393. execute(evt?: ActionEvent): void;
  9394. /**
  9395. * Skips to next active action
  9396. */
  9397. skipToNextActiveAction(): void;
  9398. /**
  9399. * Adds action to chain of actions, may be a DoNothingAction
  9400. * @param action defines the next action to execute
  9401. * @returns The action passed in
  9402. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9403. */
  9404. then(action: Action): Action;
  9405. /**
  9406. * Internal only
  9407. * @hidden
  9408. */
  9409. _getProperty(propertyPath: string): string;
  9410. /**
  9411. * Internal only
  9412. * @hidden
  9413. */
  9414. _getEffectiveTarget(target: any, propertyPath: string): any;
  9415. /**
  9416. * Serialize placeholder for child classes
  9417. * @param parent of child
  9418. * @returns the serialized object
  9419. */
  9420. serialize(parent: any): any;
  9421. /**
  9422. * Internal only called by serialize
  9423. * @hidden
  9424. */
  9425. protected _serialize(serializedAction: any, parent?: any): any;
  9426. /**
  9427. * Internal only
  9428. * @hidden
  9429. */
  9430. static _SerializeValueAsString: (value: any) => string;
  9431. /**
  9432. * Internal only
  9433. * @hidden
  9434. */
  9435. static _GetTargetProperty: (target: Node | Scene) => {
  9436. name: string;
  9437. targetType: string;
  9438. value: string;
  9439. };
  9440. }
  9441. }
  9442. declare module BABYLON {
  9443. /**
  9444. * A Condition applied to an Action
  9445. */
  9446. export class Condition {
  9447. /**
  9448. * Internal only - manager for action
  9449. * @hidden
  9450. */
  9451. _actionManager: ActionManager;
  9452. /**
  9453. * Internal only
  9454. * @hidden
  9455. */
  9456. _evaluationId: number;
  9457. /**
  9458. * Internal only
  9459. * @hidden
  9460. */
  9461. _currentResult: boolean;
  9462. /**
  9463. * Creates a new Condition
  9464. * @param actionManager the manager of the action the condition is applied to
  9465. */
  9466. constructor(actionManager: ActionManager);
  9467. /**
  9468. * Check if the current condition is valid
  9469. * @returns a boolean
  9470. */
  9471. isValid(): boolean;
  9472. /**
  9473. * Internal only
  9474. * @hidden
  9475. */
  9476. _getProperty(propertyPath: string): string;
  9477. /**
  9478. * Internal only
  9479. * @hidden
  9480. */
  9481. _getEffectiveTarget(target: any, propertyPath: string): any;
  9482. /**
  9483. * Serialize placeholder for child classes
  9484. * @returns the serialized object
  9485. */
  9486. serialize(): any;
  9487. /**
  9488. * Internal only
  9489. * @hidden
  9490. */
  9491. protected _serialize(serializedCondition: any): any;
  9492. }
  9493. /**
  9494. * Defines specific conditional operators as extensions of Condition
  9495. */
  9496. export class ValueCondition extends Condition {
  9497. /** path to specify the property of the target the conditional operator uses */
  9498. propertyPath: string;
  9499. /** the value compared by the conditional operator against the current value of the property */
  9500. value: any;
  9501. /** the conditional operator, default ValueCondition.IsEqual */
  9502. operator: number;
  9503. /**
  9504. * Internal only
  9505. * @hidden
  9506. */
  9507. private static _IsEqual;
  9508. /**
  9509. * Internal only
  9510. * @hidden
  9511. */
  9512. private static _IsDifferent;
  9513. /**
  9514. * Internal only
  9515. * @hidden
  9516. */
  9517. private static _IsGreater;
  9518. /**
  9519. * Internal only
  9520. * @hidden
  9521. */
  9522. private static _IsLesser;
  9523. /**
  9524. * returns the number for IsEqual
  9525. */
  9526. static get IsEqual(): number;
  9527. /**
  9528. * Returns the number for IsDifferent
  9529. */
  9530. static get IsDifferent(): number;
  9531. /**
  9532. * Returns the number for IsGreater
  9533. */
  9534. static get IsGreater(): number;
  9535. /**
  9536. * Returns the number for IsLesser
  9537. */
  9538. static get IsLesser(): number;
  9539. /**
  9540. * Internal only The action manager for the condition
  9541. * @hidden
  9542. */
  9543. _actionManager: ActionManager;
  9544. /**
  9545. * Internal only
  9546. * @hidden
  9547. */
  9548. private _target;
  9549. /**
  9550. * Internal only
  9551. * @hidden
  9552. */
  9553. private _effectiveTarget;
  9554. /**
  9555. * Internal only
  9556. * @hidden
  9557. */
  9558. private _property;
  9559. /**
  9560. * Creates a new ValueCondition
  9561. * @param actionManager manager for the action the condition applies to
  9562. * @param target for the action
  9563. * @param propertyPath path to specify the property of the target the conditional operator uses
  9564. * @param value the value compared by the conditional operator against the current value of the property
  9565. * @param operator the conditional operator, default ValueCondition.IsEqual
  9566. */
  9567. constructor(actionManager: ActionManager, target: any,
  9568. /** path to specify the property of the target the conditional operator uses */
  9569. propertyPath: string,
  9570. /** the value compared by the conditional operator against the current value of the property */
  9571. value: any,
  9572. /** the conditional operator, default ValueCondition.IsEqual */
  9573. operator?: number);
  9574. /**
  9575. * Compares the given value with the property value for the specified conditional operator
  9576. * @returns the result of the comparison
  9577. */
  9578. isValid(): boolean;
  9579. /**
  9580. * Serialize the ValueCondition into a JSON compatible object
  9581. * @returns serialization object
  9582. */
  9583. serialize(): any;
  9584. /**
  9585. * Gets the name of the conditional operator for the ValueCondition
  9586. * @param operator the conditional operator
  9587. * @returns the name
  9588. */
  9589. static GetOperatorName(operator: number): string;
  9590. }
  9591. /**
  9592. * Defines a predicate condition as an extension of Condition
  9593. */
  9594. export class PredicateCondition extends Condition {
  9595. /** defines the predicate function used to validate the condition */
  9596. predicate: () => boolean;
  9597. /**
  9598. * Internal only - manager for action
  9599. * @hidden
  9600. */
  9601. _actionManager: ActionManager;
  9602. /**
  9603. * Creates a new PredicateCondition
  9604. * @param actionManager manager for the action the condition applies to
  9605. * @param predicate defines the predicate function used to validate the condition
  9606. */
  9607. constructor(actionManager: ActionManager,
  9608. /** defines the predicate function used to validate the condition */
  9609. predicate: () => boolean);
  9610. /**
  9611. * @returns the validity of the predicate condition
  9612. */
  9613. isValid(): boolean;
  9614. }
  9615. /**
  9616. * Defines a state condition as an extension of Condition
  9617. */
  9618. export class StateCondition extends Condition {
  9619. /** Value to compare with target state */
  9620. value: string;
  9621. /**
  9622. * Internal only - manager for action
  9623. * @hidden
  9624. */
  9625. _actionManager: ActionManager;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. private _target;
  9631. /**
  9632. * Creates a new StateCondition
  9633. * @param actionManager manager for the action the condition applies to
  9634. * @param target of the condition
  9635. * @param value to compare with target state
  9636. */
  9637. constructor(actionManager: ActionManager, target: any,
  9638. /** Value to compare with target state */
  9639. value: string);
  9640. /**
  9641. * Gets a boolean indicating if the current condition is met
  9642. * @returns the validity of the state
  9643. */
  9644. isValid(): boolean;
  9645. /**
  9646. * Serialize the StateCondition into a JSON compatible object
  9647. * @returns serialization object
  9648. */
  9649. serialize(): any;
  9650. }
  9651. }
  9652. declare module BABYLON {
  9653. /**
  9654. * This defines an action responsible to toggle a boolean once triggered.
  9655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9656. */
  9657. export class SwitchBooleanAction extends Action {
  9658. /**
  9659. * The path to the boolean property in the target object
  9660. */
  9661. propertyPath: string;
  9662. private _target;
  9663. private _effectiveTarget;
  9664. private _property;
  9665. /**
  9666. * Instantiate the action
  9667. * @param triggerOptions defines the trigger options
  9668. * @param target defines the object containing the boolean
  9669. * @param propertyPath defines the path to the boolean property in the target object
  9670. * @param condition defines the trigger related conditions
  9671. */
  9672. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9673. /** @hidden */
  9674. _prepare(): void;
  9675. /**
  9676. * Execute the action toggle the boolean value.
  9677. */
  9678. execute(): void;
  9679. /**
  9680. * Serializes the actions and its related information.
  9681. * @param parent defines the object to serialize in
  9682. * @returns the serialized object
  9683. */
  9684. serialize(parent: any): any;
  9685. }
  9686. /**
  9687. * This defines an action responsible to set a the state field of the target
  9688. * to a desired value once triggered.
  9689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9690. */
  9691. export class SetStateAction extends Action {
  9692. /**
  9693. * The value to store in the state field.
  9694. */
  9695. value: string;
  9696. private _target;
  9697. /**
  9698. * Instantiate the action
  9699. * @param triggerOptions defines the trigger options
  9700. * @param target defines the object containing the state property
  9701. * @param value defines the value to store in the state field
  9702. * @param condition defines the trigger related conditions
  9703. */
  9704. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9705. /**
  9706. * Execute the action and store the value on the target state property.
  9707. */
  9708. execute(): void;
  9709. /**
  9710. * Serializes the actions and its related information.
  9711. * @param parent defines the object to serialize in
  9712. * @returns the serialized object
  9713. */
  9714. serialize(parent: any): any;
  9715. }
  9716. /**
  9717. * This defines an action responsible to set a property of the target
  9718. * to a desired value once triggered.
  9719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9720. */
  9721. export class SetValueAction extends Action {
  9722. /**
  9723. * The path of the property to set in the target.
  9724. */
  9725. propertyPath: string;
  9726. /**
  9727. * The value to set in the property
  9728. */
  9729. value: any;
  9730. private _target;
  9731. private _effectiveTarget;
  9732. private _property;
  9733. /**
  9734. * Instantiate the action
  9735. * @param triggerOptions defines the trigger options
  9736. * @param target defines the object containing the property
  9737. * @param propertyPath defines the path of the property to set in the target
  9738. * @param value defines the value to set in the property
  9739. * @param condition defines the trigger related conditions
  9740. */
  9741. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9742. /** @hidden */
  9743. _prepare(): void;
  9744. /**
  9745. * Execute the action and set the targetted property to the desired value.
  9746. */
  9747. execute(): void;
  9748. /**
  9749. * Serializes the actions and its related information.
  9750. * @param parent defines the object to serialize in
  9751. * @returns the serialized object
  9752. */
  9753. serialize(parent: any): any;
  9754. }
  9755. /**
  9756. * This defines an action responsible to increment the target value
  9757. * to a desired value once triggered.
  9758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9759. */
  9760. export class IncrementValueAction extends Action {
  9761. /**
  9762. * The path of the property to increment in the target.
  9763. */
  9764. propertyPath: string;
  9765. /**
  9766. * The value we should increment the property by.
  9767. */
  9768. value: any;
  9769. private _target;
  9770. private _effectiveTarget;
  9771. private _property;
  9772. /**
  9773. * Instantiate the action
  9774. * @param triggerOptions defines the trigger options
  9775. * @param target defines the object containing the property
  9776. * @param propertyPath defines the path of the property to increment in the target
  9777. * @param value defines the value value we should increment the property by
  9778. * @param condition defines the trigger related conditions
  9779. */
  9780. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9781. /** @hidden */
  9782. _prepare(): void;
  9783. /**
  9784. * Execute the action and increment the target of the value amount.
  9785. */
  9786. execute(): void;
  9787. /**
  9788. * Serializes the actions and its related information.
  9789. * @param parent defines the object to serialize in
  9790. * @returns the serialized object
  9791. */
  9792. serialize(parent: any): any;
  9793. }
  9794. /**
  9795. * This defines an action responsible to start an animation once triggered.
  9796. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9797. */
  9798. export class PlayAnimationAction extends Action {
  9799. /**
  9800. * Where the animation should start (animation frame)
  9801. */
  9802. from: number;
  9803. /**
  9804. * Where the animation should stop (animation frame)
  9805. */
  9806. to: number;
  9807. /**
  9808. * Define if the animation should loop or stop after the first play.
  9809. */
  9810. loop?: boolean;
  9811. private _target;
  9812. /**
  9813. * Instantiate the action
  9814. * @param triggerOptions defines the trigger options
  9815. * @param target defines the target animation or animation name
  9816. * @param from defines from where the animation should start (animation frame)
  9817. * @param end defines where the animation should stop (animation frame)
  9818. * @param loop defines if the animation should loop or stop after the first play
  9819. * @param condition defines the trigger related conditions
  9820. */
  9821. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9822. /** @hidden */
  9823. _prepare(): void;
  9824. /**
  9825. * Execute the action and play the animation.
  9826. */
  9827. execute(): void;
  9828. /**
  9829. * Serializes the actions and its related information.
  9830. * @param parent defines the object to serialize in
  9831. * @returns the serialized object
  9832. */
  9833. serialize(parent: any): any;
  9834. }
  9835. /**
  9836. * This defines an action responsible to stop an animation once triggered.
  9837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9838. */
  9839. export class StopAnimationAction extends Action {
  9840. private _target;
  9841. /**
  9842. * Instantiate the action
  9843. * @param triggerOptions defines the trigger options
  9844. * @param target defines the target animation or animation name
  9845. * @param condition defines the trigger related conditions
  9846. */
  9847. constructor(triggerOptions: any, target: any, condition?: Condition);
  9848. /** @hidden */
  9849. _prepare(): void;
  9850. /**
  9851. * Execute the action and stop the animation.
  9852. */
  9853. execute(): void;
  9854. /**
  9855. * Serializes the actions and its related information.
  9856. * @param parent defines the object to serialize in
  9857. * @returns the serialized object
  9858. */
  9859. serialize(parent: any): any;
  9860. }
  9861. /**
  9862. * This defines an action responsible that does nothing once triggered.
  9863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9864. */
  9865. export class DoNothingAction extends Action {
  9866. /**
  9867. * Instantiate the action
  9868. * @param triggerOptions defines the trigger options
  9869. * @param condition defines the trigger related conditions
  9870. */
  9871. constructor(triggerOptions?: any, condition?: Condition);
  9872. /**
  9873. * Execute the action and do nothing.
  9874. */
  9875. execute(): void;
  9876. /**
  9877. * Serializes the actions and its related information.
  9878. * @param parent defines the object to serialize in
  9879. * @returns the serialized object
  9880. */
  9881. serialize(parent: any): any;
  9882. }
  9883. /**
  9884. * This defines an action responsible to trigger several actions once triggered.
  9885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9886. */
  9887. export class CombineAction extends Action {
  9888. /**
  9889. * The list of aggregated animations to run.
  9890. */
  9891. children: Action[];
  9892. /**
  9893. * Instantiate the action
  9894. * @param triggerOptions defines the trigger options
  9895. * @param children defines the list of aggregated animations to run
  9896. * @param condition defines the trigger related conditions
  9897. */
  9898. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9899. /** @hidden */
  9900. _prepare(): void;
  9901. /**
  9902. * Execute the action and executes all the aggregated actions.
  9903. */
  9904. execute(evt: ActionEvent): void;
  9905. /**
  9906. * Serializes the actions and its related information.
  9907. * @param parent defines the object to serialize in
  9908. * @returns the serialized object
  9909. */
  9910. serialize(parent: any): any;
  9911. }
  9912. /**
  9913. * This defines an action responsible to run code (external event) once triggered.
  9914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9915. */
  9916. export class ExecuteCodeAction extends Action {
  9917. /**
  9918. * The callback function to run.
  9919. */
  9920. func: (evt: ActionEvent) => void;
  9921. /**
  9922. * Instantiate the action
  9923. * @param triggerOptions defines the trigger options
  9924. * @param func defines the callback function to run
  9925. * @param condition defines the trigger related conditions
  9926. */
  9927. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9928. /**
  9929. * Execute the action and run the attached code.
  9930. */
  9931. execute(evt: ActionEvent): void;
  9932. }
  9933. /**
  9934. * This defines an action responsible to set the parent property of the target once triggered.
  9935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9936. */
  9937. export class SetParentAction extends Action {
  9938. private _parent;
  9939. private _target;
  9940. /**
  9941. * Instantiate the action
  9942. * @param triggerOptions defines the trigger options
  9943. * @param target defines the target containing the parent property
  9944. * @param parent defines from where the animation should start (animation frame)
  9945. * @param condition defines the trigger related conditions
  9946. */
  9947. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9948. /** @hidden */
  9949. _prepare(): void;
  9950. /**
  9951. * Execute the action and set the parent property.
  9952. */
  9953. execute(): void;
  9954. /**
  9955. * Serializes the actions and its related information.
  9956. * @param parent defines the object to serialize in
  9957. * @returns the serialized object
  9958. */
  9959. serialize(parent: any): any;
  9960. }
  9961. }
  9962. declare module BABYLON {
  9963. /**
  9964. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9965. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9967. */
  9968. export class ActionManager extends AbstractActionManager {
  9969. /**
  9970. * Nothing
  9971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9972. */
  9973. static readonly NothingTrigger: number;
  9974. /**
  9975. * On pick
  9976. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9977. */
  9978. static readonly OnPickTrigger: number;
  9979. /**
  9980. * On left pick
  9981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9982. */
  9983. static readonly OnLeftPickTrigger: number;
  9984. /**
  9985. * On right pick
  9986. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9987. */
  9988. static readonly OnRightPickTrigger: number;
  9989. /**
  9990. * On center pick
  9991. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9992. */
  9993. static readonly OnCenterPickTrigger: number;
  9994. /**
  9995. * On pick down
  9996. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9997. */
  9998. static readonly OnPickDownTrigger: number;
  9999. /**
  10000. * On double pick
  10001. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10002. */
  10003. static readonly OnDoublePickTrigger: number;
  10004. /**
  10005. * On pick up
  10006. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10007. */
  10008. static readonly OnPickUpTrigger: number;
  10009. /**
  10010. * On pick out.
  10011. * This trigger will only be raised if you also declared a OnPickDown
  10012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickOutTrigger: number;
  10015. /**
  10016. * On long press
  10017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10018. */
  10019. static readonly OnLongPressTrigger: number;
  10020. /**
  10021. * On pointer over
  10022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10023. */
  10024. static readonly OnPointerOverTrigger: number;
  10025. /**
  10026. * On pointer out
  10027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10028. */
  10029. static readonly OnPointerOutTrigger: number;
  10030. /**
  10031. * On every frame
  10032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10033. */
  10034. static readonly OnEveryFrameTrigger: number;
  10035. /**
  10036. * On intersection enter
  10037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10038. */
  10039. static readonly OnIntersectionEnterTrigger: number;
  10040. /**
  10041. * On intersection exit
  10042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10043. */
  10044. static readonly OnIntersectionExitTrigger: number;
  10045. /**
  10046. * On key down
  10047. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10048. */
  10049. static readonly OnKeyDownTrigger: number;
  10050. /**
  10051. * On key up
  10052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10053. */
  10054. static readonly OnKeyUpTrigger: number;
  10055. private _scene;
  10056. /**
  10057. * Creates a new action manager
  10058. * @param scene defines the hosting scene
  10059. */
  10060. constructor(scene: Scene);
  10061. /**
  10062. * Releases all associated resources
  10063. */
  10064. dispose(): void;
  10065. /**
  10066. * Gets hosting scene
  10067. * @returns the hosting scene
  10068. */
  10069. getScene(): Scene;
  10070. /**
  10071. * Does this action manager handles actions of any of the given triggers
  10072. * @param triggers defines the triggers to be tested
  10073. * @return a boolean indicating whether one (or more) of the triggers is handled
  10074. */
  10075. hasSpecificTriggers(triggers: number[]): boolean;
  10076. /**
  10077. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10078. * speed.
  10079. * @param triggerA defines the trigger to be tested
  10080. * @param triggerB defines the trigger to be tested
  10081. * @return a boolean indicating whether one (or more) of the triggers is handled
  10082. */
  10083. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10084. /**
  10085. * Does this action manager handles actions of a given trigger
  10086. * @param trigger defines the trigger to be tested
  10087. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10088. * @return whether the trigger is handled
  10089. */
  10090. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10091. /**
  10092. * Does this action manager has pointer triggers
  10093. */
  10094. get hasPointerTriggers(): boolean;
  10095. /**
  10096. * Does this action manager has pick triggers
  10097. */
  10098. get hasPickTriggers(): boolean;
  10099. /**
  10100. * Registers an action to this action manager
  10101. * @param action defines the action to be registered
  10102. * @return the action amended (prepared) after registration
  10103. */
  10104. registerAction(action: IAction): Nullable<IAction>;
  10105. /**
  10106. * Unregisters an action to this action manager
  10107. * @param action defines the action to be unregistered
  10108. * @return a boolean indicating whether the action has been unregistered
  10109. */
  10110. unregisterAction(action: IAction): Boolean;
  10111. /**
  10112. * Process a specific trigger
  10113. * @param trigger defines the trigger to process
  10114. * @param evt defines the event details to be processed
  10115. */
  10116. processTrigger(trigger: number, evt?: IActionEvent): void;
  10117. /** @hidden */
  10118. _getEffectiveTarget(target: any, propertyPath: string): any;
  10119. /** @hidden */
  10120. _getProperty(propertyPath: string): string;
  10121. /**
  10122. * Serialize this manager to a JSON object
  10123. * @param name defines the property name to store this manager
  10124. * @returns a JSON representation of this manager
  10125. */
  10126. serialize(name: string): any;
  10127. /**
  10128. * Creates a new ActionManager from a JSON data
  10129. * @param parsedActions defines the JSON data to read from
  10130. * @param object defines the hosting mesh
  10131. * @param scene defines the hosting scene
  10132. */
  10133. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10134. /**
  10135. * Get a trigger name by index
  10136. * @param trigger defines the trigger index
  10137. * @returns a trigger name
  10138. */
  10139. static GetTriggerName(trigger: number): string;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Class used to represent a sprite
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class Sprite implements IAnimatable {
  10148. /** defines the name */
  10149. name: string;
  10150. /** Gets or sets the current world position */
  10151. position: Vector3;
  10152. /** Gets or sets the main color */
  10153. color: Color4;
  10154. /** Gets or sets the width */
  10155. width: number;
  10156. /** Gets or sets the height */
  10157. height: number;
  10158. /** Gets or sets rotation angle */
  10159. angle: number;
  10160. /** Gets or sets the cell index in the sprite sheet */
  10161. cellIndex: number;
  10162. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10163. cellRef: string;
  10164. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10165. invertU: boolean;
  10166. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10167. invertV: boolean;
  10168. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10169. disposeWhenFinishedAnimating: boolean;
  10170. /** Gets the list of attached animations */
  10171. animations: Nullable<Array<Animation>>;
  10172. /** Gets or sets a boolean indicating if the sprite can be picked */
  10173. isPickable: boolean;
  10174. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10175. useAlphaForPicking: boolean;
  10176. /** @hidden */
  10177. _xOffset: number;
  10178. /** @hidden */
  10179. _yOffset: number;
  10180. /** @hidden */
  10181. _xSize: number;
  10182. /** @hidden */
  10183. _ySize: number;
  10184. /**
  10185. * Gets or sets the associated action manager
  10186. */
  10187. actionManager: Nullable<ActionManager>;
  10188. /**
  10189. * An event triggered when the control has been disposed
  10190. */
  10191. onDisposeObservable: Observable<Sprite>;
  10192. private _animationStarted;
  10193. private _loopAnimation;
  10194. private _fromIndex;
  10195. private _toIndex;
  10196. private _delay;
  10197. private _direction;
  10198. private _manager;
  10199. private _time;
  10200. private _onAnimationEnd;
  10201. /**
  10202. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10203. */
  10204. isVisible: boolean;
  10205. /**
  10206. * Gets or sets the sprite size
  10207. */
  10208. get size(): number;
  10209. set size(value: number);
  10210. /**
  10211. * Returns a boolean indicating if the animation is started
  10212. */
  10213. get animationStarted(): boolean;
  10214. /**
  10215. * Gets or sets the unique id of the sprite
  10216. */
  10217. uniqueId: number;
  10218. /**
  10219. * Gets the manager of this sprite
  10220. */
  10221. get manager(): ISpriteManager;
  10222. /**
  10223. * Creates a new Sprite
  10224. * @param name defines the name
  10225. * @param manager defines the manager
  10226. */
  10227. constructor(
  10228. /** defines the name */
  10229. name: string, manager: ISpriteManager);
  10230. /**
  10231. * Returns the string "Sprite"
  10232. * @returns "Sprite"
  10233. */
  10234. getClassName(): string;
  10235. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10236. get fromIndex(): number;
  10237. set fromIndex(value: number);
  10238. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10239. get toIndex(): number;
  10240. set toIndex(value: number);
  10241. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10242. get loopAnimation(): boolean;
  10243. set loopAnimation(value: boolean);
  10244. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10245. get delay(): number;
  10246. set delay(value: number);
  10247. /**
  10248. * Starts an animation
  10249. * @param from defines the initial key
  10250. * @param to defines the end key
  10251. * @param loop defines if the animation must loop
  10252. * @param delay defines the start delay (in ms)
  10253. * @param onAnimationEnd defines a callback to call when animation ends
  10254. */
  10255. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10256. /** Stops current animation (if any) */
  10257. stopAnimation(): void;
  10258. /** @hidden */
  10259. _animate(deltaTime: number): void;
  10260. /** Release associated resources */
  10261. dispose(): void;
  10262. /**
  10263. * Serializes the sprite to a JSON object
  10264. * @returns the JSON object
  10265. */
  10266. serialize(): any;
  10267. /**
  10268. * Parses a JSON object to create a new sprite
  10269. * @param parsedSprite The JSON object to parse
  10270. * @param manager defines the hosting manager
  10271. * @returns the new sprite
  10272. */
  10273. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10274. }
  10275. }
  10276. declare module BABYLON {
  10277. /**
  10278. * Information about the result of picking within a scene
  10279. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10280. */
  10281. export class PickingInfo {
  10282. /** @hidden */
  10283. _pickingUnavailable: boolean;
  10284. /**
  10285. * If the pick collided with an object
  10286. */
  10287. hit: boolean;
  10288. /**
  10289. * Distance away where the pick collided
  10290. */
  10291. distance: number;
  10292. /**
  10293. * The location of pick collision
  10294. */
  10295. pickedPoint: Nullable<Vector3>;
  10296. /**
  10297. * The mesh corresponding the the pick collision
  10298. */
  10299. pickedMesh: Nullable<AbstractMesh>;
  10300. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10301. bu: number;
  10302. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10303. bv: number;
  10304. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10305. faceId: number;
  10306. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10307. subMeshFaceId: number;
  10308. /** Id of the the submesh that was picked */
  10309. subMeshId: number;
  10310. /** If a sprite was picked, this will be the sprite the pick collided with */
  10311. pickedSprite: Nullable<Sprite>;
  10312. /**
  10313. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10314. */
  10315. originMesh: Nullable<AbstractMesh>;
  10316. /**
  10317. * The ray that was used to perform the picking.
  10318. */
  10319. ray: Nullable<Ray>;
  10320. /**
  10321. * Gets the normal correspodning to the face the pick collided with
  10322. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10323. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10324. * @returns The normal correspodning to the face the pick collided with
  10325. */
  10326. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10327. /**
  10328. * Gets the texture coordinates of where the pick occured
  10329. * @returns the vector containing the coordnates of the texture
  10330. */
  10331. getTextureCoordinates(): Nullable<Vector2>;
  10332. }
  10333. }
  10334. declare module BABYLON {
  10335. /**
  10336. * Class representing a ray with position and direction
  10337. */
  10338. export class Ray {
  10339. /** origin point */
  10340. origin: Vector3;
  10341. /** direction */
  10342. direction: Vector3;
  10343. /** length of the ray */
  10344. length: number;
  10345. private static readonly TmpVector3;
  10346. private _tmpRay;
  10347. /**
  10348. * Creates a new ray
  10349. * @param origin origin point
  10350. * @param direction direction
  10351. * @param length length of the ray
  10352. */
  10353. constructor(
  10354. /** origin point */
  10355. origin: Vector3,
  10356. /** direction */
  10357. direction: Vector3,
  10358. /** length of the ray */
  10359. length?: number);
  10360. /**
  10361. * Checks if the ray intersects a box
  10362. * This does not account for the ray lenght by design to improve perfs.
  10363. * @param minimum bound of the box
  10364. * @param maximum bound of the box
  10365. * @param intersectionTreshold extra extend to be added to the box in all direction
  10366. * @returns if the box was hit
  10367. */
  10368. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10369. /**
  10370. * Checks if the ray intersects a box
  10371. * This does not account for the ray lenght by design to improve perfs.
  10372. * @param box the bounding box to check
  10373. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10374. * @returns if the box was hit
  10375. */
  10376. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10377. /**
  10378. * If the ray hits a sphere
  10379. * @param sphere the bounding sphere to check
  10380. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10381. * @returns true if it hits the sphere
  10382. */
  10383. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10384. /**
  10385. * If the ray hits a triange
  10386. * @param vertex0 triangle vertex
  10387. * @param vertex1 triangle vertex
  10388. * @param vertex2 triangle vertex
  10389. * @returns intersection information if hit
  10390. */
  10391. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10392. /**
  10393. * Checks if ray intersects a plane
  10394. * @param plane the plane to check
  10395. * @returns the distance away it was hit
  10396. */
  10397. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10398. /**
  10399. * Calculate the intercept of a ray on a given axis
  10400. * @param axis to check 'x' | 'y' | 'z'
  10401. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10402. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10403. */
  10404. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10405. /**
  10406. * Checks if ray intersects a mesh
  10407. * @param mesh the mesh to check
  10408. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10409. * @returns picking info of the intersecton
  10410. */
  10411. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10412. /**
  10413. * Checks if ray intersects a mesh
  10414. * @param meshes the meshes to check
  10415. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10416. * @param results array to store result in
  10417. * @returns Array of picking infos
  10418. */
  10419. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10420. private _comparePickingInfo;
  10421. private static smallnum;
  10422. private static rayl;
  10423. /**
  10424. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10425. * @param sega the first point of the segment to test the intersection against
  10426. * @param segb the second point of the segment to test the intersection against
  10427. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10428. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10429. */
  10430. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10431. /**
  10432. * Update the ray from viewport position
  10433. * @param x position
  10434. * @param y y position
  10435. * @param viewportWidth viewport width
  10436. * @param viewportHeight viewport height
  10437. * @param world world matrix
  10438. * @param view view matrix
  10439. * @param projection projection matrix
  10440. * @returns this ray updated
  10441. */
  10442. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10443. /**
  10444. * Creates a ray with origin and direction of 0,0,0
  10445. * @returns the new ray
  10446. */
  10447. static Zero(): Ray;
  10448. /**
  10449. * Creates a new ray from screen space and viewport
  10450. * @param x position
  10451. * @param y y position
  10452. * @param viewportWidth viewport width
  10453. * @param viewportHeight viewport height
  10454. * @param world world matrix
  10455. * @param view view matrix
  10456. * @param projection projection matrix
  10457. * @returns new ray
  10458. */
  10459. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10460. /**
  10461. * 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
  10462. * transformed to the given world matrix.
  10463. * @param origin The origin point
  10464. * @param end The end point
  10465. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10466. * @returns the new ray
  10467. */
  10468. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10469. /**
  10470. * Transforms a ray by a matrix
  10471. * @param ray ray to transform
  10472. * @param matrix matrix to apply
  10473. * @returns the resulting new ray
  10474. */
  10475. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10476. /**
  10477. * Transforms a ray by a matrix
  10478. * @param ray ray to transform
  10479. * @param matrix matrix to apply
  10480. * @param result ray to store result in
  10481. */
  10482. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10483. /**
  10484. * Unproject a ray from screen space to object space
  10485. * @param sourceX defines the screen space x coordinate to use
  10486. * @param sourceY defines the screen space y coordinate to use
  10487. * @param viewportWidth defines the current width of the viewport
  10488. * @param viewportHeight defines the current height of the viewport
  10489. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10490. * @param view defines the view matrix to use
  10491. * @param projection defines the projection matrix to use
  10492. */
  10493. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10494. }
  10495. /**
  10496. * Type used to define predicate used to select faces when a mesh intersection is detected
  10497. */
  10498. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10499. interface Scene {
  10500. /** @hidden */
  10501. _tempPickingRay: Nullable<Ray>;
  10502. /** @hidden */
  10503. _cachedRayForTransform: Ray;
  10504. /** @hidden */
  10505. _pickWithRayInverseMatrix: Matrix;
  10506. /** @hidden */
  10507. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10508. /** @hidden */
  10509. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10510. }
  10511. }
  10512. declare module BABYLON {
  10513. /**
  10514. * Groups all the scene component constants in one place to ease maintenance.
  10515. * @hidden
  10516. */
  10517. export class SceneComponentConstants {
  10518. static readonly NAME_EFFECTLAYER: string;
  10519. static readonly NAME_LAYER: string;
  10520. static readonly NAME_LENSFLARESYSTEM: string;
  10521. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10522. static readonly NAME_PARTICLESYSTEM: string;
  10523. static readonly NAME_GAMEPAD: string;
  10524. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10525. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10526. static readonly NAME_DEPTHRENDERER: string;
  10527. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10528. static readonly NAME_SPRITE: string;
  10529. static readonly NAME_OUTLINERENDERER: string;
  10530. static readonly NAME_PROCEDURALTEXTURE: string;
  10531. static readonly NAME_SHADOWGENERATOR: string;
  10532. static readonly NAME_OCTREE: string;
  10533. static readonly NAME_PHYSICSENGINE: string;
  10534. static readonly NAME_AUDIO: string;
  10535. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10536. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10538. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10539. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10540. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10541. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10542. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10543. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10544. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10545. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10546. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10547. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10548. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10549. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10550. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10551. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10552. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10553. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10554. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10555. static readonly STEP_AFTERRENDER_AUDIO: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10558. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10559. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10560. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10561. static readonly STEP_POINTERMOVE_SPRITE: number;
  10562. static readonly STEP_POINTERDOWN_SPRITE: number;
  10563. static readonly STEP_POINTERUP_SPRITE: number;
  10564. }
  10565. /**
  10566. * This represents a scene component.
  10567. *
  10568. * This is used to decouple the dependency the scene is having on the different workloads like
  10569. * layers, post processes...
  10570. */
  10571. export interface ISceneComponent {
  10572. /**
  10573. * The name of the component. Each component must have a unique name.
  10574. */
  10575. name: string;
  10576. /**
  10577. * The scene the component belongs to.
  10578. */
  10579. scene: Scene;
  10580. /**
  10581. * Register the component to one instance of a scene.
  10582. */
  10583. register(): void;
  10584. /**
  10585. * Rebuilds the elements related to this component in case of
  10586. * context lost for instance.
  10587. */
  10588. rebuild(): void;
  10589. /**
  10590. * Disposes the component and the associated ressources.
  10591. */
  10592. dispose(): void;
  10593. }
  10594. /**
  10595. * This represents a SERIALIZABLE scene component.
  10596. *
  10597. * This extends Scene Component to add Serialization methods on top.
  10598. */
  10599. export interface ISceneSerializableComponent extends ISceneComponent {
  10600. /**
  10601. * Adds all the elements from the container to the scene
  10602. * @param container the container holding the elements
  10603. */
  10604. addFromContainer(container: AbstractScene): void;
  10605. /**
  10606. * Removes all the elements in the container from the scene
  10607. * @param container contains the elements to remove
  10608. * @param dispose if the removed element should be disposed (default: false)
  10609. */
  10610. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10611. /**
  10612. * Serializes the component data to the specified json object
  10613. * @param serializationObject The object to serialize to
  10614. */
  10615. serialize(serializationObject: any): void;
  10616. }
  10617. /**
  10618. * Strong typing of a Mesh related stage step action
  10619. */
  10620. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10621. /**
  10622. * Strong typing of a Evaluate Sub Mesh related stage step action
  10623. */
  10624. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10625. /**
  10626. * Strong typing of a Active Mesh related stage step action
  10627. */
  10628. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10629. /**
  10630. * Strong typing of a Camera related stage step action
  10631. */
  10632. export type CameraStageAction = (camera: Camera) => void;
  10633. /**
  10634. * Strong typing of a Camera Frame buffer related stage step action
  10635. */
  10636. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10637. /**
  10638. * Strong typing of a Render Target related stage step action
  10639. */
  10640. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10641. /**
  10642. * Strong typing of a RenderingGroup related stage step action
  10643. */
  10644. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10645. /**
  10646. * Strong typing of a Mesh Render related stage step action
  10647. */
  10648. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10649. /**
  10650. * Strong typing of a simple stage step action
  10651. */
  10652. export type SimpleStageAction = () => void;
  10653. /**
  10654. * Strong typing of a render target action.
  10655. */
  10656. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10657. /**
  10658. * Strong typing of a pointer move action.
  10659. */
  10660. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10661. /**
  10662. * Strong typing of a pointer up/down action.
  10663. */
  10664. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10665. /**
  10666. * Representation of a stage in the scene (Basically a list of ordered steps)
  10667. * @hidden
  10668. */
  10669. export class Stage<T extends Function> extends Array<{
  10670. index: number;
  10671. component: ISceneComponent;
  10672. action: T;
  10673. }> {
  10674. /**
  10675. * Hide ctor from the rest of the world.
  10676. * @param items The items to add.
  10677. */
  10678. private constructor();
  10679. /**
  10680. * Creates a new Stage.
  10681. * @returns A new instance of a Stage
  10682. */
  10683. static Create<T extends Function>(): Stage<T>;
  10684. /**
  10685. * Registers a step in an ordered way in the targeted stage.
  10686. * @param index Defines the position to register the step in
  10687. * @param component Defines the component attached to the step
  10688. * @param action Defines the action to launch during the step
  10689. */
  10690. registerStep(index: number, component: ISceneComponent, action: T): void;
  10691. /**
  10692. * Clears all the steps from the stage.
  10693. */
  10694. clear(): void;
  10695. }
  10696. }
  10697. declare module BABYLON {
  10698. interface Scene {
  10699. /** @hidden */
  10700. _pointerOverSprite: Nullable<Sprite>;
  10701. /** @hidden */
  10702. _pickedDownSprite: Nullable<Sprite>;
  10703. /** @hidden */
  10704. _tempSpritePickingRay: Nullable<Ray>;
  10705. /**
  10706. * All of the sprite managers added to this scene
  10707. * @see http://doc.babylonjs.com/babylon101/sprites
  10708. */
  10709. spriteManagers: Array<ISpriteManager>;
  10710. /**
  10711. * An event triggered when sprites rendering is about to start
  10712. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10713. */
  10714. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10715. /**
  10716. * An event triggered when sprites rendering is done
  10717. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10718. */
  10719. onAfterSpritesRenderingObservable: Observable<Scene>;
  10720. /** @hidden */
  10721. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10722. /** Launch a ray to try to pick a sprite in the scene
  10723. * @param x position on screen
  10724. * @param y position on screen
  10725. * @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
  10726. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10727. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10728. * @returns a PickingInfo
  10729. */
  10730. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10731. /** Use the given ray to pick a sprite in the scene
  10732. * @param ray The ray (in world space) to use to pick meshes
  10733. * @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
  10734. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10735. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10736. * @returns a PickingInfo
  10737. */
  10738. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10739. /** @hidden */
  10740. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10741. /** Launch a ray to try to pick sprites in the scene
  10742. * @param x position on screen
  10743. * @param y position on screen
  10744. * @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
  10745. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10746. * @returns a PickingInfo array
  10747. */
  10748. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10749. /** Use the given ray to pick sprites in the scene
  10750. * @param ray The ray (in world space) to use to pick meshes
  10751. * @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
  10752. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10753. * @returns a PickingInfo array
  10754. */
  10755. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10756. /**
  10757. * Force the sprite under the pointer
  10758. * @param sprite defines the sprite to use
  10759. */
  10760. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10761. /**
  10762. * Gets the sprite under the pointer
  10763. * @returns a Sprite or null if no sprite is under the pointer
  10764. */
  10765. getPointerOverSprite(): Nullable<Sprite>;
  10766. }
  10767. /**
  10768. * Defines the sprite scene component responsible to manage sprites
  10769. * in a given scene.
  10770. */
  10771. export class SpriteSceneComponent implements ISceneComponent {
  10772. /**
  10773. * The component name helpfull to identify the component in the list of scene components.
  10774. */
  10775. readonly name: string;
  10776. /**
  10777. * The scene the component belongs to.
  10778. */
  10779. scene: Scene;
  10780. /** @hidden */
  10781. private _spritePredicate;
  10782. /**
  10783. * Creates a new instance of the component for the given scene
  10784. * @param scene Defines the scene to register the component in
  10785. */
  10786. constructor(scene: Scene);
  10787. /**
  10788. * Registers the component in a given scene
  10789. */
  10790. register(): void;
  10791. /**
  10792. * Rebuilds the elements related to this component in case of
  10793. * context lost for instance.
  10794. */
  10795. rebuild(): void;
  10796. /**
  10797. * Disposes the component and the associated ressources.
  10798. */
  10799. dispose(): void;
  10800. private _pickSpriteButKeepRay;
  10801. private _pointerMove;
  10802. private _pointerDown;
  10803. private _pointerUp;
  10804. }
  10805. }
  10806. declare module BABYLON {
  10807. /** @hidden */
  10808. export var fogFragmentDeclaration: {
  10809. name: string;
  10810. shader: string;
  10811. };
  10812. }
  10813. declare module BABYLON {
  10814. /** @hidden */
  10815. export var fogFragment: {
  10816. name: string;
  10817. shader: string;
  10818. };
  10819. }
  10820. declare module BABYLON {
  10821. /** @hidden */
  10822. export var spritesPixelShader: {
  10823. name: string;
  10824. shader: string;
  10825. };
  10826. }
  10827. declare module BABYLON {
  10828. /** @hidden */
  10829. export var fogVertexDeclaration: {
  10830. name: string;
  10831. shader: string;
  10832. };
  10833. }
  10834. declare module BABYLON {
  10835. /** @hidden */
  10836. export var spritesVertexShader: {
  10837. name: string;
  10838. shader: string;
  10839. };
  10840. }
  10841. declare module BABYLON {
  10842. /**
  10843. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10844. */
  10845. export interface ISpriteManager extends IDisposable {
  10846. /**
  10847. * Gets manager's name
  10848. */
  10849. name: string;
  10850. /**
  10851. * Restricts the camera to viewing objects with the same layerMask.
  10852. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10853. */
  10854. layerMask: number;
  10855. /**
  10856. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10857. */
  10858. isPickable: boolean;
  10859. /**
  10860. * Gets the hosting scene
  10861. */
  10862. scene: Scene;
  10863. /**
  10864. * Specifies the rendering group id for this mesh (0 by default)
  10865. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10866. */
  10867. renderingGroupId: number;
  10868. /**
  10869. * Defines the list of sprites managed by the manager.
  10870. */
  10871. sprites: Array<Sprite>;
  10872. /**
  10873. * Gets or sets the spritesheet texture
  10874. */
  10875. texture: Texture;
  10876. /** Defines the default width of a cell in the spritesheet */
  10877. cellWidth: number;
  10878. /** Defines the default height of a cell in the spritesheet */
  10879. cellHeight: number;
  10880. /**
  10881. * Tests the intersection of a sprite with a specific ray.
  10882. * @param ray The ray we are sending to test the collision
  10883. * @param camera The camera space we are sending rays in
  10884. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10885. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10886. * @returns picking info or null.
  10887. */
  10888. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10889. /**
  10890. * Intersects the sprites with a ray
  10891. * @param ray defines the ray to intersect with
  10892. * @param camera defines the current active camera
  10893. * @param predicate defines a predicate used to select candidate sprites
  10894. * @returns null if no hit or a PickingInfo array
  10895. */
  10896. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10897. /**
  10898. * Renders the list of sprites on screen.
  10899. */
  10900. render(): void;
  10901. }
  10902. /**
  10903. * Class used to manage multiple sprites on the same spritesheet
  10904. * @see http://doc.babylonjs.com/babylon101/sprites
  10905. */
  10906. export class SpriteManager implements ISpriteManager {
  10907. /** defines the manager's name */
  10908. name: string;
  10909. /** Define the Url to load snippets */
  10910. static SnippetUrl: string;
  10911. /** Snippet ID if the manager was created from the snippet server */
  10912. snippetId: string;
  10913. /** Gets the list of sprites */
  10914. sprites: Sprite[];
  10915. /** Gets or sets the rendering group id (0 by default) */
  10916. renderingGroupId: number;
  10917. /** Gets or sets camera layer mask */
  10918. layerMask: number;
  10919. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10920. fogEnabled: boolean;
  10921. /** Gets or sets a boolean indicating if the sprites are pickable */
  10922. isPickable: boolean;
  10923. /** Defines the default width of a cell in the spritesheet */
  10924. cellWidth: number;
  10925. /** Defines the default height of a cell in the spritesheet */
  10926. cellHeight: number;
  10927. /** Associative array from JSON sprite data file */
  10928. private _cellData;
  10929. /** Array of sprite names from JSON sprite data file */
  10930. private _spriteMap;
  10931. /** True when packed cell data from JSON file is ready*/
  10932. private _packedAndReady;
  10933. private _textureContent;
  10934. /**
  10935. * An event triggered when the manager is disposed.
  10936. */
  10937. onDisposeObservable: Observable<SpriteManager>;
  10938. private _onDisposeObserver;
  10939. /**
  10940. * Callback called when the manager is disposed
  10941. */
  10942. set onDispose(callback: () => void);
  10943. private _capacity;
  10944. private _fromPacked;
  10945. private _spriteTexture;
  10946. private _epsilon;
  10947. private _scene;
  10948. private _vertexData;
  10949. private _buffer;
  10950. private _vertexBuffers;
  10951. private _indexBuffer;
  10952. private _effectBase;
  10953. private _effectFog;
  10954. /**
  10955. * Gets or sets the unique id of the sprite
  10956. */
  10957. uniqueId: number;
  10958. /**
  10959. * Gets the array of sprites
  10960. */
  10961. get children(): Sprite[];
  10962. /**
  10963. * Gets the hosting scene
  10964. */
  10965. get scene(): Scene;
  10966. /**
  10967. * Gets the capacity of the manager
  10968. */
  10969. get capacity(): number;
  10970. /**
  10971. * Gets or sets the spritesheet texture
  10972. */
  10973. get texture(): Texture;
  10974. set texture(value: Texture);
  10975. private _blendMode;
  10976. /**
  10977. * Blend mode use to render the particle, it can be any of
  10978. * the static Constants.ALPHA_x properties provided in this class.
  10979. * Default value is Constants.ALPHA_COMBINE
  10980. */
  10981. get blendMode(): number;
  10982. set blendMode(blendMode: number);
  10983. /** Disables writing to the depth buffer when rendering the sprites.
  10984. * It can be handy to disable depth writing when using textures without alpha channel
  10985. * and setting some specific blend modes.
  10986. */
  10987. disableDepthWrite: boolean;
  10988. /**
  10989. * Creates a new sprite manager
  10990. * @param name defines the manager's name
  10991. * @param imgUrl defines the sprite sheet url
  10992. * @param capacity defines the maximum allowed number of sprites
  10993. * @param cellSize defines the size of a sprite cell
  10994. * @param scene defines the hosting scene
  10995. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10996. * @param samplingMode defines the smapling mode to use with spritesheet
  10997. * @param fromPacked set to false; do not alter
  10998. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10999. */
  11000. constructor(
  11001. /** defines the manager's name */
  11002. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11003. /**
  11004. * Returns the string "SpriteManager"
  11005. * @returns "SpriteManager"
  11006. */
  11007. getClassName(): string;
  11008. private _makePacked;
  11009. private _appendSpriteVertex;
  11010. private _checkTextureAlpha;
  11011. /**
  11012. * Intersects the sprites with a ray
  11013. * @param ray defines the ray to intersect with
  11014. * @param camera defines the current active camera
  11015. * @param predicate defines a predicate used to select candidate sprites
  11016. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11017. * @returns null if no hit or a PickingInfo
  11018. */
  11019. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11020. /**
  11021. * Intersects the sprites with a ray
  11022. * @param ray defines the ray to intersect with
  11023. * @param camera defines the current active camera
  11024. * @param predicate defines a predicate used to select candidate sprites
  11025. * @returns null if no hit or a PickingInfo array
  11026. */
  11027. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11028. /**
  11029. * Render all child sprites
  11030. */
  11031. render(): void;
  11032. /**
  11033. * Release associated resources
  11034. */
  11035. dispose(): void;
  11036. /**
  11037. * Serializes the sprite manager to a JSON object
  11038. * @param serializeTexture defines if the texture must be serialized as well
  11039. * @returns the JSON object
  11040. */
  11041. serialize(serializeTexture?: boolean): any;
  11042. /**
  11043. * Parses a JSON object to create a new sprite manager.
  11044. * @param parsedManager The JSON object to parse
  11045. * @param scene The scene to create the sprite managerin
  11046. * @param rootUrl The root url to use to load external dependencies like texture
  11047. * @returns the new sprite manager
  11048. */
  11049. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11050. /**
  11051. * Creates a sprite manager from a snippet saved in a remote file
  11052. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11053. * @param url defines the url to load from
  11054. * @param scene defines the hosting scene
  11055. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11056. * @returns a promise that will resolve to the new sprite manager
  11057. */
  11058. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11059. /**
  11060. * Creates a sprite manager from a snippet saved by the sprite editor
  11061. * @param snippetId defines the snippet to load
  11062. * @param scene defines the hosting scene
  11063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11064. * @returns a promise that will resolve to the new sprite manager
  11065. */
  11066. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11067. }
  11068. }
  11069. declare module BABYLON {
  11070. /** Interface used by value gradients (color, factor, ...) */
  11071. export interface IValueGradient {
  11072. /**
  11073. * Gets or sets the gradient value (between 0 and 1)
  11074. */
  11075. gradient: number;
  11076. }
  11077. /** Class used to store color4 gradient */
  11078. export class ColorGradient implements IValueGradient {
  11079. /**
  11080. * Gets or sets the gradient value (between 0 and 1)
  11081. */
  11082. gradient: number;
  11083. /**
  11084. * Gets or sets first associated color
  11085. */
  11086. color1: Color4;
  11087. /**
  11088. * Gets or sets second associated color
  11089. */
  11090. color2?: Color4 | undefined;
  11091. /**
  11092. * Creates a new color4 gradient
  11093. * @param gradient gets or sets the gradient value (between 0 and 1)
  11094. * @param color1 gets or sets first associated color
  11095. * @param color2 gets or sets first second color
  11096. */
  11097. constructor(
  11098. /**
  11099. * Gets or sets the gradient value (between 0 and 1)
  11100. */
  11101. gradient: number,
  11102. /**
  11103. * Gets or sets first associated color
  11104. */
  11105. color1: Color4,
  11106. /**
  11107. * Gets or sets second associated color
  11108. */
  11109. color2?: Color4 | undefined);
  11110. /**
  11111. * Will get a color picked randomly between color1 and color2.
  11112. * If color2 is undefined then color1 will be used
  11113. * @param result defines the target Color4 to store the result in
  11114. */
  11115. getColorToRef(result: Color4): void;
  11116. }
  11117. /** Class used to store color 3 gradient */
  11118. export class Color3Gradient implements IValueGradient {
  11119. /**
  11120. * Gets or sets the gradient value (between 0 and 1)
  11121. */
  11122. gradient: number;
  11123. /**
  11124. * Gets or sets the associated color
  11125. */
  11126. color: Color3;
  11127. /**
  11128. * Creates a new color3 gradient
  11129. * @param gradient gets or sets the gradient value (between 0 and 1)
  11130. * @param color gets or sets associated color
  11131. */
  11132. constructor(
  11133. /**
  11134. * Gets or sets the gradient value (between 0 and 1)
  11135. */
  11136. gradient: number,
  11137. /**
  11138. * Gets or sets the associated color
  11139. */
  11140. color: Color3);
  11141. }
  11142. /** Class used to store factor gradient */
  11143. export class FactorGradient implements IValueGradient {
  11144. /**
  11145. * Gets or sets the gradient value (between 0 and 1)
  11146. */
  11147. gradient: number;
  11148. /**
  11149. * Gets or sets first associated factor
  11150. */
  11151. factor1: number;
  11152. /**
  11153. * Gets or sets second associated factor
  11154. */
  11155. factor2?: number | undefined;
  11156. /**
  11157. * Creates a new factor gradient
  11158. * @param gradient gets or sets the gradient value (between 0 and 1)
  11159. * @param factor1 gets or sets first associated factor
  11160. * @param factor2 gets or sets second associated factor
  11161. */
  11162. constructor(
  11163. /**
  11164. * Gets or sets the gradient value (between 0 and 1)
  11165. */
  11166. gradient: number,
  11167. /**
  11168. * Gets or sets first associated factor
  11169. */
  11170. factor1: number,
  11171. /**
  11172. * Gets or sets second associated factor
  11173. */
  11174. factor2?: number | undefined);
  11175. /**
  11176. * Will get a number picked randomly between factor1 and factor2.
  11177. * If factor2 is undefined then factor1 will be used
  11178. * @returns the picked number
  11179. */
  11180. getFactor(): number;
  11181. }
  11182. /**
  11183. * Helper used to simplify some generic gradient tasks
  11184. */
  11185. export class GradientHelper {
  11186. /**
  11187. * Gets the current gradient from an array of IValueGradient
  11188. * @param ratio defines the current ratio to get
  11189. * @param gradients defines the array of IValueGradient
  11190. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11191. */
  11192. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11193. }
  11194. }
  11195. declare module BABYLON {
  11196. interface ThinEngine {
  11197. /**
  11198. * Creates a dynamic texture
  11199. * @param width defines the width of the texture
  11200. * @param height defines the height of the texture
  11201. * @param generateMipMaps defines if the engine should generate the mip levels
  11202. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11203. * @returns the dynamic texture inside an InternalTexture
  11204. */
  11205. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11206. /**
  11207. * Update the content of a dynamic texture
  11208. * @param texture defines the texture to update
  11209. * @param canvas defines the canvas containing the source
  11210. * @param invertY defines if data must be stored with Y axis inverted
  11211. * @param premulAlpha defines if alpha is stored as premultiplied
  11212. * @param format defines the format of the data
  11213. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11214. */
  11215. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11216. }
  11217. }
  11218. declare module BABYLON {
  11219. /**
  11220. * Helper class used to generate a canvas to manipulate images
  11221. */
  11222. export class CanvasGenerator {
  11223. /**
  11224. * Create a new canvas (or offscreen canvas depending on the context)
  11225. * @param width defines the expected width
  11226. * @param height defines the expected height
  11227. * @return a new canvas or offscreen canvas
  11228. */
  11229. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11230. }
  11231. }
  11232. declare module BABYLON {
  11233. /**
  11234. * A class extending Texture allowing drawing on a texture
  11235. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11236. */
  11237. export class DynamicTexture extends Texture {
  11238. private _generateMipMaps;
  11239. private _canvas;
  11240. private _context;
  11241. /**
  11242. * Creates a DynamicTexture
  11243. * @param name defines the name of the texture
  11244. * @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
  11245. * @param scene defines the scene where you want the texture
  11246. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11247. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11248. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11249. */
  11250. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11251. /**
  11252. * Get the current class name of the texture useful for serialization or dynamic coding.
  11253. * @returns "DynamicTexture"
  11254. */
  11255. getClassName(): string;
  11256. /**
  11257. * Gets the current state of canRescale
  11258. */
  11259. get canRescale(): boolean;
  11260. private _recreate;
  11261. /**
  11262. * Scales the texture
  11263. * @param ratio the scale factor to apply to both width and height
  11264. */
  11265. scale(ratio: number): void;
  11266. /**
  11267. * Resizes the texture
  11268. * @param width the new width
  11269. * @param height the new height
  11270. */
  11271. scaleTo(width: number, height: number): void;
  11272. /**
  11273. * Gets the context of the canvas used by the texture
  11274. * @returns the canvas context of the dynamic texture
  11275. */
  11276. getContext(): CanvasRenderingContext2D;
  11277. /**
  11278. * Clears the texture
  11279. */
  11280. clear(): void;
  11281. /**
  11282. * Updates the texture
  11283. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11284. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11285. */
  11286. update(invertY?: boolean, premulAlpha?: boolean): void;
  11287. /**
  11288. * Draws text onto the texture
  11289. * @param text defines the text to be drawn
  11290. * @param x defines the placement of the text from the left
  11291. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11292. * @param font defines the font to be used with font-style, font-size, font-name
  11293. * @param color defines the color used for the text
  11294. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11295. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11296. * @param update defines whether texture is immediately update (default is true)
  11297. */
  11298. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11299. /**
  11300. * Clones the texture
  11301. * @returns the clone of the texture.
  11302. */
  11303. clone(): DynamicTexture;
  11304. /**
  11305. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11306. * @returns a serialized dynamic texture object
  11307. */
  11308. serialize(): any;
  11309. /** @hidden */
  11310. _rebuild(): void;
  11311. }
  11312. }
  11313. declare module BABYLON {
  11314. interface ThinEngine {
  11315. /**
  11316. * Creates a raw texture
  11317. * @param data defines the data to store in the texture
  11318. * @param width defines the width of the texture
  11319. * @param height defines the height of the texture
  11320. * @param format defines the format of the data
  11321. * @param generateMipMaps defines if the engine should generate the mip levels
  11322. * @param invertY defines if data must be stored with Y axis inverted
  11323. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11324. * @param compression defines the compression used (null by default)
  11325. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11326. * @returns the raw texture inside an InternalTexture
  11327. */
  11328. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11329. /**
  11330. * Update a raw texture
  11331. * @param texture defines the texture to update
  11332. * @param data defines the data to store in the texture
  11333. * @param format defines the format of the data
  11334. * @param invertY defines if data must be stored with Y axis inverted
  11335. */
  11336. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11337. /**
  11338. * Update a raw texture
  11339. * @param texture defines the texture to update
  11340. * @param data defines the data to store in the texture
  11341. * @param format defines the format of the data
  11342. * @param invertY defines if data must be stored with Y axis inverted
  11343. * @param compression defines the compression used (null by default)
  11344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11345. */
  11346. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11347. /**
  11348. * Creates a new raw cube texture
  11349. * @param data defines the array of data to use to create each face
  11350. * @param size defines the size of the textures
  11351. * @param format defines the format of the data
  11352. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11353. * @param generateMipMaps defines if the engine should generate the mip levels
  11354. * @param invertY defines if data must be stored with Y axis inverted
  11355. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11356. * @param compression defines the compression used (null by default)
  11357. * @returns the cube texture as an InternalTexture
  11358. */
  11359. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11360. /**
  11361. * Update a raw cube texture
  11362. * @param texture defines the texture to udpdate
  11363. * @param data defines the data to store
  11364. * @param format defines the data format
  11365. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11366. * @param invertY defines if data must be stored with Y axis inverted
  11367. */
  11368. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11369. /**
  11370. * Update a raw cube texture
  11371. * @param texture defines the texture to udpdate
  11372. * @param data defines the data to store
  11373. * @param format defines the data format
  11374. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11375. * @param invertY defines if data must be stored with Y axis inverted
  11376. * @param compression defines the compression used (null by default)
  11377. */
  11378. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11379. /**
  11380. * Update a raw cube texture
  11381. * @param texture defines the texture to udpdate
  11382. * @param data defines the data to store
  11383. * @param format defines the data format
  11384. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11385. * @param invertY defines if data must be stored with Y axis inverted
  11386. * @param compression defines the compression used (null by default)
  11387. * @param level defines which level of the texture to update
  11388. */
  11389. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11390. /**
  11391. * Creates a new raw cube texture from a specified url
  11392. * @param url defines the url where the data is located
  11393. * @param scene defines the current scene
  11394. * @param size defines the size of the textures
  11395. * @param format defines the format of the data
  11396. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11397. * @param noMipmap defines if the engine should avoid generating the mip levels
  11398. * @param callback defines a callback used to extract texture data from loaded data
  11399. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11400. * @param onLoad defines a callback called when texture is loaded
  11401. * @param onError defines a callback called if there is an error
  11402. * @returns the cube texture as an InternalTexture
  11403. */
  11404. 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;
  11405. /**
  11406. * Creates a new raw cube texture from a specified url
  11407. * @param url defines the url where the data is located
  11408. * @param scene defines the current scene
  11409. * @param size defines the size of the textures
  11410. * @param format defines the format of the data
  11411. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11412. * @param noMipmap defines if the engine should avoid generating the mip levels
  11413. * @param callback defines a callback used to extract texture data from loaded data
  11414. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11415. * @param onLoad defines a callback called when texture is loaded
  11416. * @param onError defines a callback called if there is an error
  11417. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11418. * @param invertY defines if data must be stored with Y axis inverted
  11419. * @returns the cube texture as an InternalTexture
  11420. */
  11421. 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;
  11422. /**
  11423. * Creates a new raw 3D texture
  11424. * @param data defines the data used to create the texture
  11425. * @param width defines the width of the texture
  11426. * @param height defines the height of the texture
  11427. * @param depth defines the depth of the texture
  11428. * @param format defines the format of the texture
  11429. * @param generateMipMaps defines if the engine must generate mip levels
  11430. * @param invertY defines if data must be stored with Y axis inverted
  11431. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11432. * @param compression defines the compressed used (can be null)
  11433. * @param textureType defines the compressed used (can be null)
  11434. * @returns a new raw 3D texture (stored in an InternalTexture)
  11435. */
  11436. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11437. /**
  11438. * Update a raw 3D texture
  11439. * @param texture defines the texture to update
  11440. * @param data defines the data to store
  11441. * @param format defines the data format
  11442. * @param invertY defines if data must be stored with Y axis inverted
  11443. */
  11444. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11445. /**
  11446. * Update a raw 3D texture
  11447. * @param texture defines the texture to update
  11448. * @param data defines the data to store
  11449. * @param format defines the data format
  11450. * @param invertY defines if data must be stored with Y axis inverted
  11451. * @param compression defines the used compression (can be null)
  11452. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11453. */
  11454. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11455. /**
  11456. * Creates a new raw 2D array texture
  11457. * @param data defines the data used to create the texture
  11458. * @param width defines the width of the texture
  11459. * @param height defines the height of the texture
  11460. * @param depth defines the number of layers of the texture
  11461. * @param format defines the format of the texture
  11462. * @param generateMipMaps defines if the engine must generate mip levels
  11463. * @param invertY defines if data must be stored with Y axis inverted
  11464. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11465. * @param compression defines the compressed used (can be null)
  11466. * @param textureType defines the compressed used (can be null)
  11467. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11468. */
  11469. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11470. /**
  11471. * Update a raw 2D array texture
  11472. * @param texture defines the texture to update
  11473. * @param data defines the data to store
  11474. * @param format defines the data format
  11475. * @param invertY defines if data must be stored with Y axis inverted
  11476. */
  11477. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11478. /**
  11479. * Update a raw 2D array texture
  11480. * @param texture defines the texture to update
  11481. * @param data defines the data to store
  11482. * @param format defines the data format
  11483. * @param invertY defines if data must be stored with Y axis inverted
  11484. * @param compression defines the used compression (can be null)
  11485. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11486. */
  11487. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11488. }
  11489. }
  11490. declare module BABYLON {
  11491. /**
  11492. * Raw texture can help creating a texture directly from an array of data.
  11493. * This can be super useful if you either get the data from an uncompressed source or
  11494. * if you wish to create your texture pixel by pixel.
  11495. */
  11496. export class RawTexture extends Texture {
  11497. /**
  11498. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11499. */
  11500. format: number;
  11501. /**
  11502. * Instantiates a new RawTexture.
  11503. * Raw texture can help creating a texture directly from an array of data.
  11504. * This can be super useful if you either get the data from an uncompressed source or
  11505. * if you wish to create your texture pixel by pixel.
  11506. * @param data define the array of data to use to create the texture
  11507. * @param width define the width of the texture
  11508. * @param height define the height of the texture
  11509. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11510. * @param scene define the scene the texture belongs to
  11511. * @param generateMipMaps define whether mip maps should be generated or not
  11512. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11513. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11514. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11515. */
  11516. constructor(data: ArrayBufferView, width: number, height: number,
  11517. /**
  11518. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11519. */
  11520. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11521. /**
  11522. * Updates the texture underlying data.
  11523. * @param data Define the new data of the texture
  11524. */
  11525. update(data: ArrayBufferView): void;
  11526. /**
  11527. * Creates a luminance texture from some data.
  11528. * @param data Define the texture data
  11529. * @param width Define the width of the texture
  11530. * @param height Define the height of the texture
  11531. * @param scene Define the scene the texture belongs to
  11532. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11533. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11534. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11535. * @returns the luminance texture
  11536. */
  11537. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11538. /**
  11539. * Creates a luminance alpha texture from some data.
  11540. * @param data Define the texture data
  11541. * @param width Define the width of the texture
  11542. * @param height Define the height of the texture
  11543. * @param scene Define the scene the texture belongs to
  11544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11547. * @returns the luminance alpha texture
  11548. */
  11549. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11550. /**
  11551. * Creates an alpha texture from some data.
  11552. * @param data Define the texture data
  11553. * @param width Define the width of the texture
  11554. * @param height Define the height of the texture
  11555. * @param scene Define the scene the texture belongs to
  11556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11559. * @returns the alpha texture
  11560. */
  11561. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11562. /**
  11563. * Creates a RGB texture from some data.
  11564. * @param data Define the texture data
  11565. * @param width Define the width of the texture
  11566. * @param height Define the height of the texture
  11567. * @param scene Define the scene the texture belongs to
  11568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11571. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11572. * @returns the RGB alpha texture
  11573. */
  11574. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11575. /**
  11576. * Creates a RGBA texture from some data.
  11577. * @param data Define the texture data
  11578. * @param width Define the width of the texture
  11579. * @param height Define the height of the texture
  11580. * @param scene Define the scene the texture belongs to
  11581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11585. * @returns the RGBA texture
  11586. */
  11587. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11588. /**
  11589. * Creates a R texture from some data.
  11590. * @param data Define the texture data
  11591. * @param width Define the width of the texture
  11592. * @param height Define the height of the texture
  11593. * @param scene Define the scene the texture belongs to
  11594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11598. * @returns the R texture
  11599. */
  11600. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11601. }
  11602. }
  11603. declare module BABYLON {
  11604. interface AbstractScene {
  11605. /**
  11606. * The list of procedural textures added to the scene
  11607. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11608. */
  11609. proceduralTextures: Array<ProceduralTexture>;
  11610. }
  11611. /**
  11612. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11613. * in a given scene.
  11614. */
  11615. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11616. /**
  11617. * The component name helpfull to identify the component in the list of scene components.
  11618. */
  11619. readonly name: string;
  11620. /**
  11621. * The scene the component belongs to.
  11622. */
  11623. scene: Scene;
  11624. /**
  11625. * Creates a new instance of the component for the given scene
  11626. * @param scene Defines the scene to register the component in
  11627. */
  11628. constructor(scene: Scene);
  11629. /**
  11630. * Registers the component in a given scene
  11631. */
  11632. register(): void;
  11633. /**
  11634. * Rebuilds the elements related to this component in case of
  11635. * context lost for instance.
  11636. */
  11637. rebuild(): void;
  11638. /**
  11639. * Disposes the component and the associated ressources.
  11640. */
  11641. dispose(): void;
  11642. private _beforeClear;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. interface ThinEngine {
  11647. /**
  11648. * Creates a new render target cube texture
  11649. * @param size defines the size of the texture
  11650. * @param options defines the options used to create the texture
  11651. * @returns a new render target cube texture stored in an InternalTexture
  11652. */
  11653. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11654. }
  11655. }
  11656. declare module BABYLON {
  11657. /** @hidden */
  11658. export var proceduralVertexShader: {
  11659. name: string;
  11660. shader: string;
  11661. };
  11662. }
  11663. declare module BABYLON {
  11664. /**
  11665. * 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.
  11666. * This is the base class of any Procedural texture and contains most of the shareable code.
  11667. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11668. */
  11669. export class ProceduralTexture extends Texture {
  11670. isCube: boolean;
  11671. /**
  11672. * Define if the texture is enabled or not (disabled texture will not render)
  11673. */
  11674. isEnabled: boolean;
  11675. /**
  11676. * Define if the texture must be cleared before rendering (default is true)
  11677. */
  11678. autoClear: boolean;
  11679. /**
  11680. * Callback called when the texture is generated
  11681. */
  11682. onGenerated: () => void;
  11683. /**
  11684. * Event raised when the texture is generated
  11685. */
  11686. onGeneratedObservable: Observable<ProceduralTexture>;
  11687. /** @hidden */
  11688. _generateMipMaps: boolean;
  11689. /** @hidden **/
  11690. _effect: Effect;
  11691. /** @hidden */
  11692. _textures: {
  11693. [key: string]: Texture;
  11694. };
  11695. /** @hidden */
  11696. protected _fallbackTexture: Nullable<Texture>;
  11697. private _size;
  11698. private _currentRefreshId;
  11699. private _frameId;
  11700. private _refreshRate;
  11701. private _vertexBuffers;
  11702. private _indexBuffer;
  11703. private _uniforms;
  11704. private _samplers;
  11705. private _fragment;
  11706. private _floats;
  11707. private _ints;
  11708. private _floatsArrays;
  11709. private _colors3;
  11710. private _colors4;
  11711. private _vectors2;
  11712. private _vectors3;
  11713. private _matrices;
  11714. private _fallbackTextureUsed;
  11715. private _fullEngine;
  11716. private _cachedDefines;
  11717. private _contentUpdateId;
  11718. private _contentData;
  11719. /**
  11720. * Instantiates a new procedural texture.
  11721. * 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.
  11722. * This is the base class of any Procedural texture and contains most of the shareable code.
  11723. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11724. * @param name Define the name of the texture
  11725. * @param size Define the size of the texture to create
  11726. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11727. * @param scene Define the scene the texture belongs to
  11728. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11729. * @param generateMipMaps Define if the texture should creates mip maps or not
  11730. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11731. */
  11732. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11733. /**
  11734. * The effect that is created when initializing the post process.
  11735. * @returns The created effect corresponding the the postprocess.
  11736. */
  11737. getEffect(): Effect;
  11738. /**
  11739. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11740. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11741. */
  11742. getContent(): Nullable<ArrayBufferView>;
  11743. private _createIndexBuffer;
  11744. /** @hidden */
  11745. _rebuild(): void;
  11746. /**
  11747. * Resets the texture in order to recreate its associated resources.
  11748. * This can be called in case of context loss
  11749. */
  11750. reset(): void;
  11751. protected _getDefines(): string;
  11752. /**
  11753. * Is the texture ready to be used ? (rendered at least once)
  11754. * @returns true if ready, otherwise, false.
  11755. */
  11756. isReady(): boolean;
  11757. /**
  11758. * Resets the refresh counter of the texture and start bak from scratch.
  11759. * Could be useful to regenerate the texture if it is setup to render only once.
  11760. */
  11761. resetRefreshCounter(): void;
  11762. /**
  11763. * Set the fragment shader to use in order to render the texture.
  11764. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11765. */
  11766. setFragment(fragment: any): void;
  11767. /**
  11768. * Define the refresh rate of the texture or the rendering frequency.
  11769. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11770. */
  11771. get refreshRate(): number;
  11772. set refreshRate(value: number);
  11773. /** @hidden */
  11774. _shouldRender(): boolean;
  11775. /**
  11776. * Get the size the texture is rendering at.
  11777. * @returns the size (texture is always squared)
  11778. */
  11779. getRenderSize(): number;
  11780. /**
  11781. * Resize the texture to new value.
  11782. * @param size Define the new size the texture should have
  11783. * @param generateMipMaps Define whether the new texture should create mip maps
  11784. */
  11785. resize(size: number, generateMipMaps: boolean): void;
  11786. private _checkUniform;
  11787. /**
  11788. * Set a texture in the shader program used to render.
  11789. * @param name Define the name of the uniform samplers as defined in the shader
  11790. * @param texture Define the texture to bind to this sampler
  11791. * @return the texture itself allowing "fluent" like uniform updates
  11792. */
  11793. setTexture(name: string, texture: Texture): ProceduralTexture;
  11794. /**
  11795. * Set a float in the shader.
  11796. * @param name Define the name of the uniform as defined in the shader
  11797. * @param value Define the value to give to the uniform
  11798. * @return the texture itself allowing "fluent" like uniform updates
  11799. */
  11800. setFloat(name: string, value: number): ProceduralTexture;
  11801. /**
  11802. * Set a int in the shader.
  11803. * @param name Define the name of the uniform as defined in the shader
  11804. * @param value Define the value to give to the uniform
  11805. * @return the texture itself allowing "fluent" like uniform updates
  11806. */
  11807. setInt(name: string, value: number): ProceduralTexture;
  11808. /**
  11809. * Set an array of floats in the shader.
  11810. * @param name Define the name of the uniform as defined in the shader
  11811. * @param value Define the value to give to the uniform
  11812. * @return the texture itself allowing "fluent" like uniform updates
  11813. */
  11814. setFloats(name: string, value: number[]): ProceduralTexture;
  11815. /**
  11816. * Set a vec3 in the shader from a Color3.
  11817. * @param name Define the name of the uniform as defined in the shader
  11818. * @param value Define the value to give to the uniform
  11819. * @return the texture itself allowing "fluent" like uniform updates
  11820. */
  11821. setColor3(name: string, value: Color3): ProceduralTexture;
  11822. /**
  11823. * Set a vec4 in the shader from a Color4.
  11824. * @param name Define the name of the uniform as defined in the shader
  11825. * @param value Define the value to give to the uniform
  11826. * @return the texture itself allowing "fluent" like uniform updates
  11827. */
  11828. setColor4(name: string, value: Color4): ProceduralTexture;
  11829. /**
  11830. * Set a vec2 in the shader from a Vector2.
  11831. * @param name Define the name of the uniform as defined in the shader
  11832. * @param value Define the value to give to the uniform
  11833. * @return the texture itself allowing "fluent" like uniform updates
  11834. */
  11835. setVector2(name: string, value: Vector2): ProceduralTexture;
  11836. /**
  11837. * Set a vec3 in the shader from a Vector3.
  11838. * @param name Define the name of the uniform as defined in the shader
  11839. * @param value Define the value to give to the uniform
  11840. * @return the texture itself allowing "fluent" like uniform updates
  11841. */
  11842. setVector3(name: string, value: Vector3): ProceduralTexture;
  11843. /**
  11844. * Set a mat4 in the shader from a MAtrix.
  11845. * @param name Define the name of the uniform as defined in the shader
  11846. * @param value Define the value to give to the uniform
  11847. * @return the texture itself allowing "fluent" like uniform updates
  11848. */
  11849. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11850. /**
  11851. * Render the texture to its associated render target.
  11852. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11853. */
  11854. render(useCameraPostProcess?: boolean): void;
  11855. /**
  11856. * Clone the texture.
  11857. * @returns the cloned texture
  11858. */
  11859. clone(): ProceduralTexture;
  11860. /**
  11861. * Dispose the texture and release its asoociated resources.
  11862. */
  11863. dispose(): void;
  11864. }
  11865. }
  11866. declare module BABYLON {
  11867. /**
  11868. * This represents the base class for particle system in Babylon.
  11869. * 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.
  11870. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11871. * @example https://doc.babylonjs.com/babylon101/particles
  11872. */
  11873. export class BaseParticleSystem {
  11874. /**
  11875. * Source color is added to the destination color without alpha affecting the result
  11876. */
  11877. static BLENDMODE_ONEONE: number;
  11878. /**
  11879. * Blend current color and particle color using particle’s alpha
  11880. */
  11881. static BLENDMODE_STANDARD: number;
  11882. /**
  11883. * Add current color and particle color multiplied by particle’s alpha
  11884. */
  11885. static BLENDMODE_ADD: number;
  11886. /**
  11887. * Multiply current color with particle color
  11888. */
  11889. static BLENDMODE_MULTIPLY: number;
  11890. /**
  11891. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11892. */
  11893. static BLENDMODE_MULTIPLYADD: number;
  11894. /**
  11895. * List of animations used by the particle system.
  11896. */
  11897. animations: Animation[];
  11898. /**
  11899. * Gets or sets the unique id of the particle system
  11900. */
  11901. uniqueId: number;
  11902. /**
  11903. * The id of the Particle system.
  11904. */
  11905. id: string;
  11906. /**
  11907. * The friendly name of the Particle system.
  11908. */
  11909. name: string;
  11910. /**
  11911. * Snippet ID if the particle system was created from the snippet server
  11912. */
  11913. snippetId: string;
  11914. /**
  11915. * The rendering group used by the Particle system to chose when to render.
  11916. */
  11917. renderingGroupId: number;
  11918. /**
  11919. * The emitter represents the Mesh or position we are attaching the particle system to.
  11920. */
  11921. emitter: Nullable<AbstractMesh | Vector3>;
  11922. /**
  11923. * The maximum number of particles to emit per frame
  11924. */
  11925. emitRate: number;
  11926. /**
  11927. * If you want to launch only a few particles at once, that can be done, as well.
  11928. */
  11929. manualEmitCount: number;
  11930. /**
  11931. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11932. */
  11933. updateSpeed: number;
  11934. /**
  11935. * The amount of time the particle system is running (depends of the overall update speed).
  11936. */
  11937. targetStopDuration: number;
  11938. /**
  11939. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11940. */
  11941. disposeOnStop: boolean;
  11942. /**
  11943. * Minimum power of emitting particles.
  11944. */
  11945. minEmitPower: number;
  11946. /**
  11947. * Maximum power of emitting particles.
  11948. */
  11949. maxEmitPower: number;
  11950. /**
  11951. * Minimum life time of emitting particles.
  11952. */
  11953. minLifeTime: number;
  11954. /**
  11955. * Maximum life time of emitting particles.
  11956. */
  11957. maxLifeTime: number;
  11958. /**
  11959. * Minimum Size of emitting particles.
  11960. */
  11961. minSize: number;
  11962. /**
  11963. * Maximum Size of emitting particles.
  11964. */
  11965. maxSize: number;
  11966. /**
  11967. * Minimum scale of emitting particles on X axis.
  11968. */
  11969. minScaleX: number;
  11970. /**
  11971. * Maximum scale of emitting particles on X axis.
  11972. */
  11973. maxScaleX: number;
  11974. /**
  11975. * Minimum scale of emitting particles on Y axis.
  11976. */
  11977. minScaleY: number;
  11978. /**
  11979. * Maximum scale of emitting particles on Y axis.
  11980. */
  11981. maxScaleY: number;
  11982. /**
  11983. * Gets or sets the minimal initial rotation in radians.
  11984. */
  11985. minInitialRotation: number;
  11986. /**
  11987. * Gets or sets the maximal initial rotation in radians.
  11988. */
  11989. maxInitialRotation: number;
  11990. /**
  11991. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11992. */
  11993. minAngularSpeed: number;
  11994. /**
  11995. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11996. */
  11997. maxAngularSpeed: number;
  11998. /**
  11999. * The texture used to render each particle. (this can be a spritesheet)
  12000. */
  12001. particleTexture: Nullable<Texture>;
  12002. /**
  12003. * The layer mask we are rendering the particles through.
  12004. */
  12005. layerMask: number;
  12006. /**
  12007. * This can help using your own shader to render the particle system.
  12008. * The according effect will be created
  12009. */
  12010. customShader: any;
  12011. /**
  12012. * By default particle system starts as soon as they are created. This prevents the
  12013. * automatic start to happen and let you decide when to start emitting particles.
  12014. */
  12015. preventAutoStart: boolean;
  12016. private _noiseTexture;
  12017. /**
  12018. * Gets or sets a texture used to add random noise to particle positions
  12019. */
  12020. get noiseTexture(): Nullable<ProceduralTexture>;
  12021. set noiseTexture(value: Nullable<ProceduralTexture>);
  12022. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12023. noiseStrength: Vector3;
  12024. /**
  12025. * Callback triggered when the particle animation is ending.
  12026. */
  12027. onAnimationEnd: Nullable<() => void>;
  12028. /**
  12029. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12030. */
  12031. blendMode: number;
  12032. /**
  12033. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12034. * to override the particles.
  12035. */
  12036. forceDepthWrite: boolean;
  12037. /** 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 */
  12038. preWarmCycles: number;
  12039. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12040. preWarmStepOffset: number;
  12041. /**
  12042. * 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)
  12043. */
  12044. spriteCellChangeSpeed: number;
  12045. /**
  12046. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12047. */
  12048. startSpriteCellID: number;
  12049. /**
  12050. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12051. */
  12052. endSpriteCellID: number;
  12053. /**
  12054. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12055. */
  12056. spriteCellWidth: number;
  12057. /**
  12058. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12059. */
  12060. spriteCellHeight: number;
  12061. /**
  12062. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12063. */
  12064. spriteRandomStartCell: boolean;
  12065. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12066. translationPivot: Vector2;
  12067. /** @hidden */
  12068. protected _isAnimationSheetEnabled: boolean;
  12069. /**
  12070. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12071. */
  12072. beginAnimationOnStart: boolean;
  12073. /**
  12074. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12075. */
  12076. beginAnimationFrom: number;
  12077. /**
  12078. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12079. */
  12080. beginAnimationTo: number;
  12081. /**
  12082. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12083. */
  12084. beginAnimationLoop: boolean;
  12085. /**
  12086. * Gets or sets a world offset applied to all particles
  12087. */
  12088. worldOffset: Vector3;
  12089. /**
  12090. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12091. */
  12092. get isAnimationSheetEnabled(): boolean;
  12093. set isAnimationSheetEnabled(value: boolean);
  12094. /**
  12095. * Get hosting scene
  12096. * @returns the scene
  12097. */
  12098. getScene(): Scene;
  12099. /**
  12100. * You can use gravity if you want to give an orientation to your particles.
  12101. */
  12102. gravity: Vector3;
  12103. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12104. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12105. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12106. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12107. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12108. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12109. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12110. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12111. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12112. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12113. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12114. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12115. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12116. /**
  12117. * Defines the delay in milliseconds before starting the system (0 by default)
  12118. */
  12119. startDelay: number;
  12120. /**
  12121. * Gets the current list of drag gradients.
  12122. * You must use addDragGradient and removeDragGradient to udpate this list
  12123. * @returns the list of drag gradients
  12124. */
  12125. getDragGradients(): Nullable<Array<FactorGradient>>;
  12126. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12127. limitVelocityDamping: number;
  12128. /**
  12129. * Gets the current list of limit velocity gradients.
  12130. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12131. * @returns the list of limit velocity gradients
  12132. */
  12133. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12134. /**
  12135. * Gets the current list of color gradients.
  12136. * You must use addColorGradient and removeColorGradient to udpate this list
  12137. * @returns the list of color gradients
  12138. */
  12139. getColorGradients(): Nullable<Array<ColorGradient>>;
  12140. /**
  12141. * Gets the current list of size gradients.
  12142. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12143. * @returns the list of size gradients
  12144. */
  12145. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12146. /**
  12147. * Gets the current list of color remap gradients.
  12148. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12149. * @returns the list of color remap gradients
  12150. */
  12151. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12152. /**
  12153. * Gets the current list of alpha remap gradients.
  12154. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12155. * @returns the list of alpha remap gradients
  12156. */
  12157. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12158. /**
  12159. * Gets the current list of life time gradients.
  12160. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12161. * @returns the list of life time gradients
  12162. */
  12163. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12164. /**
  12165. * Gets the current list of angular speed gradients.
  12166. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12167. * @returns the list of angular speed gradients
  12168. */
  12169. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12170. /**
  12171. * Gets the current list of velocity gradients.
  12172. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12173. * @returns the list of velocity gradients
  12174. */
  12175. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12176. /**
  12177. * Gets the current list of start size gradients.
  12178. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12179. * @returns the list of start size gradients
  12180. */
  12181. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12182. /**
  12183. * Gets the current list of emit rate gradients.
  12184. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12185. * @returns the list of emit rate gradients
  12186. */
  12187. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12188. /**
  12189. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12190. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12191. */
  12192. get direction1(): Vector3;
  12193. set direction1(value: Vector3);
  12194. /**
  12195. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12196. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12197. */
  12198. get direction2(): Vector3;
  12199. set direction2(value: Vector3);
  12200. /**
  12201. * 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.
  12202. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12203. */
  12204. get minEmitBox(): Vector3;
  12205. set minEmitBox(value: Vector3);
  12206. /**
  12207. * 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.
  12208. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12209. */
  12210. get maxEmitBox(): Vector3;
  12211. set maxEmitBox(value: Vector3);
  12212. /**
  12213. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12214. */
  12215. color1: Color4;
  12216. /**
  12217. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12218. */
  12219. color2: Color4;
  12220. /**
  12221. * Color the particle will have at the end of its lifetime
  12222. */
  12223. colorDead: Color4;
  12224. /**
  12225. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12226. */
  12227. textureMask: Color4;
  12228. /**
  12229. * The particle emitter type defines the emitter used by the particle system.
  12230. * It can be for example box, sphere, or cone...
  12231. */
  12232. particleEmitterType: IParticleEmitterType;
  12233. /** @hidden */
  12234. _isSubEmitter: boolean;
  12235. /**
  12236. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12237. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12238. */
  12239. billboardMode: number;
  12240. protected _isBillboardBased: boolean;
  12241. /**
  12242. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12243. */
  12244. get isBillboardBased(): boolean;
  12245. set isBillboardBased(value: boolean);
  12246. /**
  12247. * The scene the particle system belongs to.
  12248. */
  12249. protected _scene: Scene;
  12250. /**
  12251. * Local cache of defines for image processing.
  12252. */
  12253. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12254. /**
  12255. * Default configuration related to image processing available in the standard Material.
  12256. */
  12257. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12258. /**
  12259. * Gets the image processing configuration used either in this material.
  12260. */
  12261. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12262. /**
  12263. * Sets the Default image processing configuration used either in the this material.
  12264. *
  12265. * If sets to null, the scene one is in use.
  12266. */
  12267. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12268. /**
  12269. * Attaches a new image processing configuration to the Standard Material.
  12270. * @param configuration
  12271. */
  12272. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12273. /** @hidden */
  12274. protected _reset(): void;
  12275. /** @hidden */
  12276. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12277. /**
  12278. * Instantiates a particle system.
  12279. * 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.
  12280. * @param name The name of the particle system
  12281. */
  12282. constructor(name: string);
  12283. /**
  12284. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12285. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12287. * @returns the emitter
  12288. */
  12289. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12290. /**
  12291. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12292. * @param radius The radius of the hemisphere to emit from
  12293. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12294. * @returns the emitter
  12295. */
  12296. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12297. /**
  12298. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12299. * @param radius The radius of the sphere to emit from
  12300. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12301. * @returns the emitter
  12302. */
  12303. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12304. /**
  12305. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12306. * @param radius The radius of the sphere to emit from
  12307. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12309. * @returns the emitter
  12310. */
  12311. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12312. /**
  12313. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12314. * @param radius The radius of the emission cylinder
  12315. * @param height The height of the emission cylinder
  12316. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12317. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12318. * @returns the emitter
  12319. */
  12320. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12321. /**
  12322. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12323. * @param radius The radius of the cylinder to emit from
  12324. * @param height The height of the emission cylinder
  12325. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12326. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12328. * @returns the emitter
  12329. */
  12330. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12331. /**
  12332. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12333. * @param radius The radius of the cone to emit from
  12334. * @param angle The base angle of the cone
  12335. * @returns the emitter
  12336. */
  12337. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12338. /**
  12339. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12342. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12344. * @returns the emitter
  12345. */
  12346. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12347. }
  12348. }
  12349. declare module BABYLON {
  12350. /**
  12351. * Type of sub emitter
  12352. */
  12353. export enum SubEmitterType {
  12354. /**
  12355. * Attached to the particle over it's lifetime
  12356. */
  12357. ATTACHED = 0,
  12358. /**
  12359. * Created when the particle dies
  12360. */
  12361. END = 1
  12362. }
  12363. /**
  12364. * Sub emitter class used to emit particles from an existing particle
  12365. */
  12366. export class SubEmitter {
  12367. /**
  12368. * the particle system to be used by the sub emitter
  12369. */
  12370. particleSystem: ParticleSystem;
  12371. /**
  12372. * Type of the submitter (Default: END)
  12373. */
  12374. type: SubEmitterType;
  12375. /**
  12376. * 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)
  12377. * Note: This only is supported when using an emitter of type Mesh
  12378. */
  12379. inheritDirection: boolean;
  12380. /**
  12381. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12382. */
  12383. inheritedVelocityAmount: number;
  12384. /**
  12385. * Creates a sub emitter
  12386. * @param particleSystem the particle system to be used by the sub emitter
  12387. */
  12388. constructor(
  12389. /**
  12390. * the particle system to be used by the sub emitter
  12391. */
  12392. particleSystem: ParticleSystem);
  12393. /**
  12394. * Clones the sub emitter
  12395. * @returns the cloned sub emitter
  12396. */
  12397. clone(): SubEmitter;
  12398. /**
  12399. * Serialize current object to a JSON object
  12400. * @returns the serialized object
  12401. */
  12402. serialize(): any;
  12403. /** @hidden */
  12404. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12405. /**
  12406. * Creates a new SubEmitter from a serialized JSON version
  12407. * @param serializationObject defines the JSON object to read from
  12408. * @param scene defines the hosting scene
  12409. * @param rootUrl defines the rootUrl for data loading
  12410. * @returns a new SubEmitter
  12411. */
  12412. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12413. /** Release associated resources */
  12414. dispose(): void;
  12415. }
  12416. }
  12417. declare module BABYLON {
  12418. /** @hidden */
  12419. export var imageProcessingDeclaration: {
  12420. name: string;
  12421. shader: string;
  12422. };
  12423. }
  12424. declare module BABYLON {
  12425. /** @hidden */
  12426. export var imageProcessingFunctions: {
  12427. name: string;
  12428. shader: string;
  12429. };
  12430. }
  12431. declare module BABYLON {
  12432. /** @hidden */
  12433. export var particlesPixelShader: {
  12434. name: string;
  12435. shader: string;
  12436. };
  12437. }
  12438. declare module BABYLON {
  12439. /** @hidden */
  12440. export var particlesVertexShader: {
  12441. name: string;
  12442. shader: string;
  12443. };
  12444. }
  12445. declare module BABYLON {
  12446. /**
  12447. * This represents a particle system in Babylon.
  12448. * 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.
  12449. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12450. * @example https://doc.babylonjs.com/babylon101/particles
  12451. */
  12452. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12453. /**
  12454. * Billboard mode will only apply to Y axis
  12455. */
  12456. static readonly BILLBOARDMODE_Y: number;
  12457. /**
  12458. * Billboard mode will apply to all axes
  12459. */
  12460. static readonly BILLBOARDMODE_ALL: number;
  12461. /**
  12462. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12463. */
  12464. static readonly BILLBOARDMODE_STRETCHED: number;
  12465. /**
  12466. * This function can be defined to provide custom update for active particles.
  12467. * This function will be called instead of regular update (age, position, color, etc.).
  12468. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12469. */
  12470. updateFunction: (particles: Particle[]) => void;
  12471. private _emitterWorldMatrix;
  12472. /**
  12473. * This function can be defined to specify initial direction for every new particle.
  12474. * It by default use the emitterType defined function
  12475. */
  12476. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12477. /**
  12478. * This function can be defined to specify initial position for every new particle.
  12479. * It by default use the emitterType defined function
  12480. */
  12481. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12482. /**
  12483. * @hidden
  12484. */
  12485. _inheritedVelocityOffset: Vector3;
  12486. /**
  12487. * An event triggered when the system is disposed
  12488. */
  12489. onDisposeObservable: Observable<IParticleSystem>;
  12490. private _onDisposeObserver;
  12491. /**
  12492. * Sets a callback that will be triggered when the system is disposed
  12493. */
  12494. set onDispose(callback: () => void);
  12495. private _particles;
  12496. private _epsilon;
  12497. private _capacity;
  12498. private _stockParticles;
  12499. private _newPartsExcess;
  12500. private _vertexData;
  12501. private _vertexBuffer;
  12502. private _vertexBuffers;
  12503. private _spriteBuffer;
  12504. private _indexBuffer;
  12505. private _effect;
  12506. private _customEffect;
  12507. private _cachedDefines;
  12508. private _scaledColorStep;
  12509. private _colorDiff;
  12510. private _scaledDirection;
  12511. private _scaledGravity;
  12512. private _currentRenderId;
  12513. private _alive;
  12514. private _useInstancing;
  12515. private _started;
  12516. private _stopped;
  12517. private _actualFrame;
  12518. private _scaledUpdateSpeed;
  12519. private _vertexBufferSize;
  12520. /** @hidden */
  12521. _currentEmitRateGradient: Nullable<FactorGradient>;
  12522. /** @hidden */
  12523. _currentEmitRate1: number;
  12524. /** @hidden */
  12525. _currentEmitRate2: number;
  12526. /** @hidden */
  12527. _currentStartSizeGradient: Nullable<FactorGradient>;
  12528. /** @hidden */
  12529. _currentStartSize1: number;
  12530. /** @hidden */
  12531. _currentStartSize2: number;
  12532. private readonly _rawTextureWidth;
  12533. private _rampGradientsTexture;
  12534. private _useRampGradients;
  12535. /** Gets or sets a boolean indicating that ramp gradients must be used
  12536. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12537. */
  12538. get useRampGradients(): boolean;
  12539. set useRampGradients(value: boolean);
  12540. /**
  12541. * 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.
  12542. * 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: [])
  12543. */
  12544. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12545. private _subEmitters;
  12546. /**
  12547. * @hidden
  12548. * If the particle systems emitter should be disposed when the particle system is disposed
  12549. */
  12550. _disposeEmitterOnDispose: boolean;
  12551. /**
  12552. * The current active Sub-systems, this property is used by the root particle system only.
  12553. */
  12554. activeSubSystems: Array<ParticleSystem>;
  12555. /**
  12556. * Specifies if the particles are updated in emitter local space or world space
  12557. */
  12558. isLocal: boolean;
  12559. private _rootParticleSystem;
  12560. /**
  12561. * Gets the current list of active particles
  12562. */
  12563. get particles(): Particle[];
  12564. /**
  12565. * Gets the number of particles active at the same time.
  12566. * @returns The number of active particles.
  12567. */
  12568. getActiveCount(): number;
  12569. /**
  12570. * Returns the string "ParticleSystem"
  12571. * @returns a string containing the class name
  12572. */
  12573. getClassName(): string;
  12574. /**
  12575. * Gets a boolean indicating that the system is stopping
  12576. * @returns true if the system is currently stopping
  12577. */
  12578. isStopping(): boolean;
  12579. /**
  12580. * Gets the custom effect used to render the particles
  12581. * @param blendMode Blend mode for which the effect should be retrieved
  12582. * @returns The effect
  12583. */
  12584. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12585. /**
  12586. * Sets the custom effect used to render the particles
  12587. * @param effect The effect to set
  12588. * @param blendMode Blend mode for which the effect should be set
  12589. */
  12590. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12591. /** @hidden */
  12592. private _onBeforeDrawParticlesObservable;
  12593. /**
  12594. * Observable that will be called just before the particles are drawn
  12595. */
  12596. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12597. /**
  12598. * Gets the name of the particle vertex shader
  12599. */
  12600. get vertexShaderName(): string;
  12601. /**
  12602. * Instantiates a particle system.
  12603. * 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.
  12604. * @param name The name of the particle system
  12605. * @param capacity The max number of particles alive at the same time
  12606. * @param scene The scene the particle system belongs to
  12607. * @param customEffect a custom effect used to change the way particles are rendered by default
  12608. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12609. * @param epsilon Offset used to render the particles
  12610. */
  12611. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12612. private _addFactorGradient;
  12613. private _removeFactorGradient;
  12614. /**
  12615. * Adds a new life time gradient
  12616. * @param gradient defines the gradient to use (between 0 and 1)
  12617. * @param factor defines the life time factor to affect to the specified gradient
  12618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12619. * @returns the current particle system
  12620. */
  12621. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12622. /**
  12623. * Remove a specific life time gradient
  12624. * @param gradient defines the gradient to remove
  12625. * @returns the current particle system
  12626. */
  12627. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12628. /**
  12629. * Adds a new size gradient
  12630. * @param gradient defines the gradient to use (between 0 and 1)
  12631. * @param factor defines the size factor to affect to the specified gradient
  12632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12633. * @returns the current particle system
  12634. */
  12635. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12636. /**
  12637. * Remove a specific size gradient
  12638. * @param gradient defines the gradient to remove
  12639. * @returns the current particle system
  12640. */
  12641. removeSizeGradient(gradient: number): IParticleSystem;
  12642. /**
  12643. * Adds a new color remap gradient
  12644. * @param gradient defines the gradient to use (between 0 and 1)
  12645. * @param min defines the color remap minimal range
  12646. * @param max defines the color remap maximal range
  12647. * @returns the current particle system
  12648. */
  12649. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12650. /**
  12651. * Remove a specific color remap gradient
  12652. * @param gradient defines the gradient to remove
  12653. * @returns the current particle system
  12654. */
  12655. removeColorRemapGradient(gradient: number): IParticleSystem;
  12656. /**
  12657. * Adds a new alpha remap gradient
  12658. * @param gradient defines the gradient to use (between 0 and 1)
  12659. * @param min defines the alpha remap minimal range
  12660. * @param max defines the alpha remap maximal range
  12661. * @returns the current particle system
  12662. */
  12663. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12664. /**
  12665. * Remove a specific alpha remap gradient
  12666. * @param gradient defines the gradient to remove
  12667. * @returns the current particle system
  12668. */
  12669. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12670. /**
  12671. * Adds a new angular speed gradient
  12672. * @param gradient defines the gradient to use (between 0 and 1)
  12673. * @param factor defines the angular speed to affect to the specified gradient
  12674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12675. * @returns the current particle system
  12676. */
  12677. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12678. /**
  12679. * Remove a specific angular speed gradient
  12680. * @param gradient defines the gradient to remove
  12681. * @returns the current particle system
  12682. */
  12683. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12684. /**
  12685. * Adds a new velocity gradient
  12686. * @param gradient defines the gradient to use (between 0 and 1)
  12687. * @param factor defines the velocity to affect to the specified gradient
  12688. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12689. * @returns the current particle system
  12690. */
  12691. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12692. /**
  12693. * Remove a specific velocity gradient
  12694. * @param gradient defines the gradient to remove
  12695. * @returns the current particle system
  12696. */
  12697. removeVelocityGradient(gradient: number): IParticleSystem;
  12698. /**
  12699. * Adds a new limit velocity gradient
  12700. * @param gradient defines the gradient to use (between 0 and 1)
  12701. * @param factor defines the limit velocity value to affect to the specified gradient
  12702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12703. * @returns the current particle system
  12704. */
  12705. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12706. /**
  12707. * Remove a specific limit velocity gradient
  12708. * @param gradient defines the gradient to remove
  12709. * @returns the current particle system
  12710. */
  12711. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12712. /**
  12713. * Adds a new drag gradient
  12714. * @param gradient defines the gradient to use (between 0 and 1)
  12715. * @param factor defines the drag value to affect to the specified gradient
  12716. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12717. * @returns the current particle system
  12718. */
  12719. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12720. /**
  12721. * Remove a specific drag gradient
  12722. * @param gradient defines the gradient to remove
  12723. * @returns the current particle system
  12724. */
  12725. removeDragGradient(gradient: number): IParticleSystem;
  12726. /**
  12727. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12728. * @param gradient defines the gradient to use (between 0 and 1)
  12729. * @param factor defines the emit rate value to affect to the specified gradient
  12730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12731. * @returns the current particle system
  12732. */
  12733. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12734. /**
  12735. * Remove a specific emit rate gradient
  12736. * @param gradient defines the gradient to remove
  12737. * @returns the current particle system
  12738. */
  12739. removeEmitRateGradient(gradient: number): IParticleSystem;
  12740. /**
  12741. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12742. * @param gradient defines the gradient to use (between 0 and 1)
  12743. * @param factor defines the start size value to affect to the specified gradient
  12744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12745. * @returns the current particle system
  12746. */
  12747. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12748. /**
  12749. * Remove a specific start size gradient
  12750. * @param gradient defines the gradient to remove
  12751. * @returns the current particle system
  12752. */
  12753. removeStartSizeGradient(gradient: number): IParticleSystem;
  12754. private _createRampGradientTexture;
  12755. /**
  12756. * Gets the current list of ramp gradients.
  12757. * You must use addRampGradient and removeRampGradient to udpate this list
  12758. * @returns the list of ramp gradients
  12759. */
  12760. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12761. /** Force the system to rebuild all gradients that need to be resync */
  12762. forceRefreshGradients(): void;
  12763. private _syncRampGradientTexture;
  12764. /**
  12765. * Adds a new ramp gradient used to remap particle colors
  12766. * @param gradient defines the gradient to use (between 0 and 1)
  12767. * @param color defines the color to affect to the specified gradient
  12768. * @returns the current particle system
  12769. */
  12770. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12771. /**
  12772. * Remove a specific ramp gradient
  12773. * @param gradient defines the gradient to remove
  12774. * @returns the current particle system
  12775. */
  12776. removeRampGradient(gradient: number): ParticleSystem;
  12777. /**
  12778. * Adds a new color gradient
  12779. * @param gradient defines the gradient to use (between 0 and 1)
  12780. * @param color1 defines the color to affect to the specified gradient
  12781. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12782. * @returns this particle system
  12783. */
  12784. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12785. /**
  12786. * Remove a specific color gradient
  12787. * @param gradient defines the gradient to remove
  12788. * @returns this particle system
  12789. */
  12790. removeColorGradient(gradient: number): IParticleSystem;
  12791. private _fetchR;
  12792. protected _reset(): void;
  12793. private _resetEffect;
  12794. private _createVertexBuffers;
  12795. private _createIndexBuffer;
  12796. /**
  12797. * Gets the maximum number of particles active at the same time.
  12798. * @returns The max number of active particles.
  12799. */
  12800. getCapacity(): number;
  12801. /**
  12802. * Gets whether there are still active particles in the system.
  12803. * @returns True if it is alive, otherwise false.
  12804. */
  12805. isAlive(): boolean;
  12806. /**
  12807. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12808. * @returns True if it has been started, otherwise false.
  12809. */
  12810. isStarted(): boolean;
  12811. private _prepareSubEmitterInternalArray;
  12812. /**
  12813. * Starts the particle system and begins to emit
  12814. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12815. */
  12816. start(delay?: number): void;
  12817. /**
  12818. * Stops the particle system.
  12819. * @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.
  12820. */
  12821. stop(stopSubEmitters?: boolean): void;
  12822. /**
  12823. * Remove all active particles
  12824. */
  12825. reset(): void;
  12826. /**
  12827. * @hidden (for internal use only)
  12828. */
  12829. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12830. /**
  12831. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12832. * Its lifetime will start back at 0.
  12833. */
  12834. recycleParticle: (particle: Particle) => void;
  12835. private _stopSubEmitters;
  12836. private _createParticle;
  12837. private _removeFromRoot;
  12838. private _emitFromParticle;
  12839. private _update;
  12840. /** @hidden */
  12841. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12842. /** @hidden */
  12843. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12844. /**
  12845. * Fill the defines array according to the current settings of the particle system
  12846. * @param defines Array to be updated
  12847. * @param blendMode blend mode to take into account when updating the array
  12848. */
  12849. fillDefines(defines: Array<string>, blendMode: number): void;
  12850. /**
  12851. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12852. * @param uniforms Uniforms array to fill
  12853. * @param attributes Attributes array to fill
  12854. * @param samplers Samplers array to fill
  12855. */
  12856. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12857. /** @hidden */
  12858. private _getEffect;
  12859. /**
  12860. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12861. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12862. */
  12863. animate(preWarmOnly?: boolean): void;
  12864. private _appendParticleVertices;
  12865. /**
  12866. * Rebuilds the particle system.
  12867. */
  12868. rebuild(): void;
  12869. /**
  12870. * Is this system ready to be used/rendered
  12871. * @return true if the system is ready
  12872. */
  12873. isReady(): boolean;
  12874. private _render;
  12875. /**
  12876. * Renders the particle system in its current state.
  12877. * @returns the current number of particles
  12878. */
  12879. render(): number;
  12880. /**
  12881. * Disposes the particle system and free the associated resources
  12882. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12883. */
  12884. dispose(disposeTexture?: boolean): void;
  12885. /**
  12886. * Clones the particle system.
  12887. * @param name The name of the cloned object
  12888. * @param newEmitter The new emitter to use
  12889. * @returns the cloned particle system
  12890. */
  12891. clone(name: string, newEmitter: any): ParticleSystem;
  12892. /**
  12893. * Serializes the particle system to a JSON object
  12894. * @param serializeTexture defines if the texture must be serialized as well
  12895. * @returns the JSON object
  12896. */
  12897. serialize(serializeTexture?: boolean): any;
  12898. /** @hidden */
  12899. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12900. /** @hidden */
  12901. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12902. /**
  12903. * Parses a JSON object to create a particle system.
  12904. * @param parsedParticleSystem The JSON object to parse
  12905. * @param scene The scene to create the particle system in
  12906. * @param rootUrl The root url to use to load external dependencies like texture
  12907. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12908. * @returns the Parsed particle system
  12909. */
  12910. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12911. }
  12912. }
  12913. declare module BABYLON {
  12914. /**
  12915. * A particle represents one of the element emitted by a particle system.
  12916. * This is mainly define by its coordinates, direction, velocity and age.
  12917. */
  12918. export class Particle {
  12919. /**
  12920. * The particle system the particle belongs to.
  12921. */
  12922. particleSystem: ParticleSystem;
  12923. private static _Count;
  12924. /**
  12925. * Unique ID of the particle
  12926. */
  12927. id: number;
  12928. /**
  12929. * The world position of the particle in the scene.
  12930. */
  12931. position: Vector3;
  12932. /**
  12933. * The world direction of the particle in the scene.
  12934. */
  12935. direction: Vector3;
  12936. /**
  12937. * The color of the particle.
  12938. */
  12939. color: Color4;
  12940. /**
  12941. * The color change of the particle per step.
  12942. */
  12943. colorStep: Color4;
  12944. /**
  12945. * Defines how long will the life of the particle be.
  12946. */
  12947. lifeTime: number;
  12948. /**
  12949. * The current age of the particle.
  12950. */
  12951. age: number;
  12952. /**
  12953. * The current size of the particle.
  12954. */
  12955. size: number;
  12956. /**
  12957. * The current scale of the particle.
  12958. */
  12959. scale: Vector2;
  12960. /**
  12961. * The current angle of the particle.
  12962. */
  12963. angle: number;
  12964. /**
  12965. * Defines how fast is the angle changing.
  12966. */
  12967. angularSpeed: number;
  12968. /**
  12969. * Defines the cell index used by the particle to be rendered from a sprite.
  12970. */
  12971. cellIndex: number;
  12972. /**
  12973. * The information required to support color remapping
  12974. */
  12975. remapData: Vector4;
  12976. /** @hidden */
  12977. _randomCellOffset?: number;
  12978. /** @hidden */
  12979. _initialDirection: Nullable<Vector3>;
  12980. /** @hidden */
  12981. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12982. /** @hidden */
  12983. _initialStartSpriteCellID: number;
  12984. /** @hidden */
  12985. _initialEndSpriteCellID: number;
  12986. /** @hidden */
  12987. _currentColorGradient: Nullable<ColorGradient>;
  12988. /** @hidden */
  12989. _currentColor1: Color4;
  12990. /** @hidden */
  12991. _currentColor2: Color4;
  12992. /** @hidden */
  12993. _currentSizeGradient: Nullable<FactorGradient>;
  12994. /** @hidden */
  12995. _currentSize1: number;
  12996. /** @hidden */
  12997. _currentSize2: number;
  12998. /** @hidden */
  12999. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13000. /** @hidden */
  13001. _currentAngularSpeed1: number;
  13002. /** @hidden */
  13003. _currentAngularSpeed2: number;
  13004. /** @hidden */
  13005. _currentVelocityGradient: Nullable<FactorGradient>;
  13006. /** @hidden */
  13007. _currentVelocity1: number;
  13008. /** @hidden */
  13009. _currentVelocity2: number;
  13010. /** @hidden */
  13011. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13012. /** @hidden */
  13013. _currentLimitVelocity1: number;
  13014. /** @hidden */
  13015. _currentLimitVelocity2: number;
  13016. /** @hidden */
  13017. _currentDragGradient: Nullable<FactorGradient>;
  13018. /** @hidden */
  13019. _currentDrag1: number;
  13020. /** @hidden */
  13021. _currentDrag2: number;
  13022. /** @hidden */
  13023. _randomNoiseCoordinates1: Vector3;
  13024. /** @hidden */
  13025. _randomNoiseCoordinates2: Vector3;
  13026. /** @hidden */
  13027. _localPosition?: Vector3;
  13028. /**
  13029. * Creates a new instance Particle
  13030. * @param particleSystem the particle system the particle belongs to
  13031. */
  13032. constructor(
  13033. /**
  13034. * The particle system the particle belongs to.
  13035. */
  13036. particleSystem: ParticleSystem);
  13037. private updateCellInfoFromSystem;
  13038. /**
  13039. * Defines how the sprite cell index is updated for the particle
  13040. */
  13041. updateCellIndex(): void;
  13042. /** @hidden */
  13043. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13044. /** @hidden */
  13045. _inheritParticleInfoToSubEmitters(): void;
  13046. /** @hidden */
  13047. _reset(): void;
  13048. /**
  13049. * Copy the properties of particle to another one.
  13050. * @param other the particle to copy the information to.
  13051. */
  13052. copyTo(other: Particle): void;
  13053. }
  13054. }
  13055. declare module BABYLON {
  13056. /**
  13057. * Particle emitter represents a volume emitting particles.
  13058. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13059. */
  13060. export interface IParticleEmitterType {
  13061. /**
  13062. * Called by the particle System when the direction is computed for the created particle.
  13063. * @param worldMatrix is the world matrix of the particle system
  13064. * @param directionToUpdate is the direction vector to update with the result
  13065. * @param particle is the particle we are computed the direction for
  13066. * @param isLocal defines if the direction should be set in local space
  13067. */
  13068. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13069. /**
  13070. * Called by the particle System when the position is computed for the created particle.
  13071. * @param worldMatrix is the world matrix of the particle system
  13072. * @param positionToUpdate is the position vector to update with the result
  13073. * @param particle is the particle we are computed the position for
  13074. * @param isLocal defines if the position should be set in local space
  13075. */
  13076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13077. /**
  13078. * Clones the current emitter and returns a copy of it
  13079. * @returns the new emitter
  13080. */
  13081. clone(): IParticleEmitterType;
  13082. /**
  13083. * Called by the GPUParticleSystem to setup the update shader
  13084. * @param effect defines the update shader
  13085. */
  13086. applyToShader(effect: Effect): void;
  13087. /**
  13088. * Returns a string to use to update the GPU particles update shader
  13089. * @returns the effect defines string
  13090. */
  13091. getEffectDefines(): string;
  13092. /**
  13093. * Returns a string representing the class name
  13094. * @returns a string containing the class name
  13095. */
  13096. getClassName(): string;
  13097. /**
  13098. * Serializes the particle system to a JSON object.
  13099. * @returns the JSON object
  13100. */
  13101. serialize(): any;
  13102. /**
  13103. * Parse properties from a JSON object
  13104. * @param serializationObject defines the JSON object
  13105. * @param scene defines the hosting scene
  13106. */
  13107. parse(serializationObject: any, scene: Scene): void;
  13108. }
  13109. }
  13110. declare module BABYLON {
  13111. /**
  13112. * Particle emitter emitting particles from the inside of a box.
  13113. * It emits the particles randomly between 2 given directions.
  13114. */
  13115. export class BoxParticleEmitter implements IParticleEmitterType {
  13116. /**
  13117. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13118. */
  13119. direction1: Vector3;
  13120. /**
  13121. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13122. */
  13123. direction2: Vector3;
  13124. /**
  13125. * 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.
  13126. */
  13127. minEmitBox: Vector3;
  13128. /**
  13129. * 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.
  13130. */
  13131. maxEmitBox: Vector3;
  13132. /**
  13133. * Creates a new instance BoxParticleEmitter
  13134. */
  13135. constructor();
  13136. /**
  13137. * Called by the particle System when the direction is computed for the created particle.
  13138. * @param worldMatrix is the world matrix of the particle system
  13139. * @param directionToUpdate is the direction vector to update with the result
  13140. * @param particle is the particle we are computed the direction for
  13141. * @param isLocal defines if the direction should be set in local space
  13142. */
  13143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13144. /**
  13145. * Called by the particle System when the position is computed for the created particle.
  13146. * @param worldMatrix is the world matrix of the particle system
  13147. * @param positionToUpdate is the position vector to update with the result
  13148. * @param particle is the particle we are computed the position for
  13149. * @param isLocal defines if the position should be set in local space
  13150. */
  13151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13152. /**
  13153. * Clones the current emitter and returns a copy of it
  13154. * @returns the new emitter
  13155. */
  13156. clone(): BoxParticleEmitter;
  13157. /**
  13158. * Called by the GPUParticleSystem to setup the update shader
  13159. * @param effect defines the update shader
  13160. */
  13161. applyToShader(effect: Effect): void;
  13162. /**
  13163. * Returns a string to use to update the GPU particles update shader
  13164. * @returns a string containng the defines string
  13165. */
  13166. getEffectDefines(): string;
  13167. /**
  13168. * Returns the string "BoxParticleEmitter"
  13169. * @returns a string containing the class name
  13170. */
  13171. getClassName(): string;
  13172. /**
  13173. * Serializes the particle system to a JSON object.
  13174. * @returns the JSON object
  13175. */
  13176. serialize(): any;
  13177. /**
  13178. * Parse properties from a JSON object
  13179. * @param serializationObject defines the JSON object
  13180. */
  13181. parse(serializationObject: any): void;
  13182. }
  13183. }
  13184. declare module BABYLON {
  13185. /**
  13186. * Particle emitter emitting particles from the inside of a cone.
  13187. * It emits the particles alongside the cone volume from the base to the particle.
  13188. * The emission direction might be randomized.
  13189. */
  13190. export class ConeParticleEmitter implements IParticleEmitterType {
  13191. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13192. directionRandomizer: number;
  13193. private _radius;
  13194. private _angle;
  13195. private _height;
  13196. /**
  13197. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13198. */
  13199. radiusRange: number;
  13200. /**
  13201. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13202. */
  13203. heightRange: number;
  13204. /**
  13205. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13206. */
  13207. emitFromSpawnPointOnly: boolean;
  13208. /**
  13209. * Gets or sets the radius of the emission cone
  13210. */
  13211. get radius(): number;
  13212. set radius(value: number);
  13213. /**
  13214. * Gets or sets the angle of the emission cone
  13215. */
  13216. get angle(): number;
  13217. set angle(value: number);
  13218. private _buildHeight;
  13219. /**
  13220. * Creates a new instance ConeParticleEmitter
  13221. * @param radius the radius of the emission cone (1 by default)
  13222. * @param angle the cone base angle (PI by default)
  13223. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13224. */
  13225. constructor(radius?: number, angle?: number,
  13226. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13227. directionRandomizer?: number);
  13228. /**
  13229. * Called by the particle System when the direction is computed for the created particle.
  13230. * @param worldMatrix is the world matrix of the particle system
  13231. * @param directionToUpdate is the direction vector to update with the result
  13232. * @param particle is the particle we are computed the direction for
  13233. * @param isLocal defines if the direction should be set in local space
  13234. */
  13235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13236. /**
  13237. * Called by the particle System when the position is computed for the created particle.
  13238. * @param worldMatrix is the world matrix of the particle system
  13239. * @param positionToUpdate is the position vector to update with the result
  13240. * @param particle is the particle we are computed the position for
  13241. * @param isLocal defines if the position should be set in local space
  13242. */
  13243. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13244. /**
  13245. * Clones the current emitter and returns a copy of it
  13246. * @returns the new emitter
  13247. */
  13248. clone(): ConeParticleEmitter;
  13249. /**
  13250. * Called by the GPUParticleSystem to setup the update shader
  13251. * @param effect defines the update shader
  13252. */
  13253. applyToShader(effect: Effect): void;
  13254. /**
  13255. * Returns a string to use to update the GPU particles update shader
  13256. * @returns a string containng the defines string
  13257. */
  13258. getEffectDefines(): string;
  13259. /**
  13260. * Returns the string "ConeParticleEmitter"
  13261. * @returns a string containing the class name
  13262. */
  13263. getClassName(): string;
  13264. /**
  13265. * Serializes the particle system to a JSON object.
  13266. * @returns the JSON object
  13267. */
  13268. serialize(): any;
  13269. /**
  13270. * Parse properties from a JSON object
  13271. * @param serializationObject defines the JSON object
  13272. */
  13273. parse(serializationObject: any): void;
  13274. }
  13275. }
  13276. declare module BABYLON {
  13277. /**
  13278. * Particle emitter emitting particles from the inside of a cylinder.
  13279. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13280. */
  13281. export class CylinderParticleEmitter implements IParticleEmitterType {
  13282. /**
  13283. * The radius of the emission cylinder.
  13284. */
  13285. radius: number;
  13286. /**
  13287. * The height of the emission cylinder.
  13288. */
  13289. height: number;
  13290. /**
  13291. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13292. */
  13293. radiusRange: number;
  13294. /**
  13295. * How much to randomize the particle direction [0-1].
  13296. */
  13297. directionRandomizer: number;
  13298. /**
  13299. * Creates a new instance CylinderParticleEmitter
  13300. * @param radius the radius of the emission cylinder (1 by default)
  13301. * @param height the height of the emission cylinder (1 by default)
  13302. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13303. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13304. */
  13305. constructor(
  13306. /**
  13307. * The radius of the emission cylinder.
  13308. */
  13309. radius?: number,
  13310. /**
  13311. * The height of the emission cylinder.
  13312. */
  13313. height?: number,
  13314. /**
  13315. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13316. */
  13317. radiusRange?: number,
  13318. /**
  13319. * How much to randomize the particle direction [0-1].
  13320. */
  13321. directionRandomizer?: number);
  13322. /**
  13323. * Called by the particle System when the direction is computed for the created particle.
  13324. * @param worldMatrix is the world matrix of the particle system
  13325. * @param directionToUpdate is the direction vector to update with the result
  13326. * @param particle is the particle we are computed the direction for
  13327. * @param isLocal defines if the direction should be set in local space
  13328. */
  13329. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13330. /**
  13331. * Called by the particle System when the position is computed for the created particle.
  13332. * @param worldMatrix is the world matrix of the particle system
  13333. * @param positionToUpdate is the position vector to update with the result
  13334. * @param particle is the particle we are computed the position for
  13335. * @param isLocal defines if the position should be set in local space
  13336. */
  13337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13338. /**
  13339. * Clones the current emitter and returns a copy of it
  13340. * @returns the new emitter
  13341. */
  13342. clone(): CylinderParticleEmitter;
  13343. /**
  13344. * Called by the GPUParticleSystem to setup the update shader
  13345. * @param effect defines the update shader
  13346. */
  13347. applyToShader(effect: Effect): void;
  13348. /**
  13349. * Returns a string to use to update the GPU particles update shader
  13350. * @returns a string containng the defines string
  13351. */
  13352. getEffectDefines(): string;
  13353. /**
  13354. * Returns the string "CylinderParticleEmitter"
  13355. * @returns a string containing the class name
  13356. */
  13357. getClassName(): string;
  13358. /**
  13359. * Serializes the particle system to a JSON object.
  13360. * @returns the JSON object
  13361. */
  13362. serialize(): any;
  13363. /**
  13364. * Parse properties from a JSON object
  13365. * @param serializationObject defines the JSON object
  13366. */
  13367. parse(serializationObject: any): void;
  13368. }
  13369. /**
  13370. * Particle emitter emitting particles from the inside of a cylinder.
  13371. * It emits the particles randomly between two vectors.
  13372. */
  13373. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13374. /**
  13375. * The min limit of the emission direction.
  13376. */
  13377. direction1: Vector3;
  13378. /**
  13379. * The max limit of the emission direction.
  13380. */
  13381. direction2: Vector3;
  13382. /**
  13383. * Creates a new instance CylinderDirectedParticleEmitter
  13384. * @param radius the radius of the emission cylinder (1 by default)
  13385. * @param height the height of the emission cylinder (1 by default)
  13386. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13387. * @param direction1 the min limit of the emission direction (up vector by default)
  13388. * @param direction2 the max limit of the emission direction (up vector by default)
  13389. */
  13390. constructor(radius?: number, height?: number, radiusRange?: number,
  13391. /**
  13392. * The min limit of the emission direction.
  13393. */
  13394. direction1?: Vector3,
  13395. /**
  13396. * The max limit of the emission direction.
  13397. */
  13398. direction2?: Vector3);
  13399. /**
  13400. * Called by the particle System when the direction is computed for the created particle.
  13401. * @param worldMatrix is the world matrix of the particle system
  13402. * @param directionToUpdate is the direction vector to update with the result
  13403. * @param particle is the particle we are computed the direction for
  13404. */
  13405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13406. /**
  13407. * Clones the current emitter and returns a copy of it
  13408. * @returns the new emitter
  13409. */
  13410. clone(): CylinderDirectedParticleEmitter;
  13411. /**
  13412. * Called by the GPUParticleSystem to setup the update shader
  13413. * @param effect defines the update shader
  13414. */
  13415. applyToShader(effect: Effect): void;
  13416. /**
  13417. * Returns a string to use to update the GPU particles update shader
  13418. * @returns a string containng the defines string
  13419. */
  13420. getEffectDefines(): string;
  13421. /**
  13422. * Returns the string "CylinderDirectedParticleEmitter"
  13423. * @returns a string containing the class name
  13424. */
  13425. getClassName(): string;
  13426. /**
  13427. * Serializes the particle system to a JSON object.
  13428. * @returns the JSON object
  13429. */
  13430. serialize(): any;
  13431. /**
  13432. * Parse properties from a JSON object
  13433. * @param serializationObject defines the JSON object
  13434. */
  13435. parse(serializationObject: any): void;
  13436. }
  13437. }
  13438. declare module BABYLON {
  13439. /**
  13440. * Particle emitter emitting particles from the inside of a hemisphere.
  13441. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13442. */
  13443. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13444. /**
  13445. * The radius of the emission hemisphere.
  13446. */
  13447. radius: number;
  13448. /**
  13449. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13450. */
  13451. radiusRange: number;
  13452. /**
  13453. * How much to randomize the particle direction [0-1].
  13454. */
  13455. directionRandomizer: number;
  13456. /**
  13457. * Creates a new instance HemisphericParticleEmitter
  13458. * @param radius the radius of the emission hemisphere (1 by default)
  13459. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13460. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13461. */
  13462. constructor(
  13463. /**
  13464. * The radius of the emission hemisphere.
  13465. */
  13466. radius?: number,
  13467. /**
  13468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13469. */
  13470. radiusRange?: number,
  13471. /**
  13472. * How much to randomize the particle direction [0-1].
  13473. */
  13474. directionRandomizer?: number);
  13475. /**
  13476. * Called by the particle System when the direction is computed for the created particle.
  13477. * @param worldMatrix is the world matrix of the particle system
  13478. * @param directionToUpdate is the direction vector to update with the result
  13479. * @param particle is the particle we are computed the direction for
  13480. * @param isLocal defines if the direction should be set in local space
  13481. */
  13482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13483. /**
  13484. * Called by the particle System when the position is computed for the created particle.
  13485. * @param worldMatrix is the world matrix of the particle system
  13486. * @param positionToUpdate is the position vector to update with the result
  13487. * @param particle is the particle we are computed the position for
  13488. * @param isLocal defines if the position should be set in local space
  13489. */
  13490. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13491. /**
  13492. * Clones the current emitter and returns a copy of it
  13493. * @returns the new emitter
  13494. */
  13495. clone(): HemisphericParticleEmitter;
  13496. /**
  13497. * Called by the GPUParticleSystem to setup the update shader
  13498. * @param effect defines the update shader
  13499. */
  13500. applyToShader(effect: Effect): void;
  13501. /**
  13502. * Returns a string to use to update the GPU particles update shader
  13503. * @returns a string containng the defines string
  13504. */
  13505. getEffectDefines(): string;
  13506. /**
  13507. * Returns the string "HemisphericParticleEmitter"
  13508. * @returns a string containing the class name
  13509. */
  13510. getClassName(): string;
  13511. /**
  13512. * Serializes the particle system to a JSON object.
  13513. * @returns the JSON object
  13514. */
  13515. serialize(): any;
  13516. /**
  13517. * Parse properties from a JSON object
  13518. * @param serializationObject defines the JSON object
  13519. */
  13520. parse(serializationObject: any): void;
  13521. }
  13522. }
  13523. declare module BABYLON {
  13524. /**
  13525. * Particle emitter emitting particles from a point.
  13526. * It emits the particles randomly between 2 given directions.
  13527. */
  13528. export class PointParticleEmitter implements IParticleEmitterType {
  13529. /**
  13530. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13531. */
  13532. direction1: Vector3;
  13533. /**
  13534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13535. */
  13536. direction2: Vector3;
  13537. /**
  13538. * Creates a new instance PointParticleEmitter
  13539. */
  13540. constructor();
  13541. /**
  13542. * Called by the particle System when the direction is computed for the created particle.
  13543. * @param worldMatrix is the world matrix of the particle system
  13544. * @param directionToUpdate is the direction vector to update with the result
  13545. * @param particle is the particle we are computed the direction for
  13546. * @param isLocal defines if the direction should be set in local space
  13547. */
  13548. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13549. /**
  13550. * Called by the particle System when the position is computed for the created particle.
  13551. * @param worldMatrix is the world matrix of the particle system
  13552. * @param positionToUpdate is the position vector to update with the result
  13553. * @param particle is the particle we are computed the position for
  13554. * @param isLocal defines if the position should be set in local space
  13555. */
  13556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13557. /**
  13558. * Clones the current emitter and returns a copy of it
  13559. * @returns the new emitter
  13560. */
  13561. clone(): PointParticleEmitter;
  13562. /**
  13563. * Called by the GPUParticleSystem to setup the update shader
  13564. * @param effect defines the update shader
  13565. */
  13566. applyToShader(effect: Effect): void;
  13567. /**
  13568. * Returns a string to use to update the GPU particles update shader
  13569. * @returns a string containng the defines string
  13570. */
  13571. getEffectDefines(): string;
  13572. /**
  13573. * Returns the string "PointParticleEmitter"
  13574. * @returns a string containing the class name
  13575. */
  13576. getClassName(): string;
  13577. /**
  13578. * Serializes the particle system to a JSON object.
  13579. * @returns the JSON object
  13580. */
  13581. serialize(): any;
  13582. /**
  13583. * Parse properties from a JSON object
  13584. * @param serializationObject defines the JSON object
  13585. */
  13586. parse(serializationObject: any): void;
  13587. }
  13588. }
  13589. declare module BABYLON {
  13590. /**
  13591. * Particle emitter emitting particles from the inside of a sphere.
  13592. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13593. */
  13594. export class SphereParticleEmitter implements IParticleEmitterType {
  13595. /**
  13596. * The radius of the emission sphere.
  13597. */
  13598. radius: number;
  13599. /**
  13600. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13601. */
  13602. radiusRange: number;
  13603. /**
  13604. * How much to randomize the particle direction [0-1].
  13605. */
  13606. directionRandomizer: number;
  13607. /**
  13608. * Creates a new instance SphereParticleEmitter
  13609. * @param radius the radius of the emission sphere (1 by default)
  13610. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13611. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13612. */
  13613. constructor(
  13614. /**
  13615. * The radius of the emission sphere.
  13616. */
  13617. radius?: number,
  13618. /**
  13619. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13620. */
  13621. radiusRange?: number,
  13622. /**
  13623. * How much to randomize the particle direction [0-1].
  13624. */
  13625. directionRandomizer?: number);
  13626. /**
  13627. * Called by the particle System when the direction is computed for the created particle.
  13628. * @param worldMatrix is the world matrix of the particle system
  13629. * @param directionToUpdate is the direction vector to update with the result
  13630. * @param particle is the particle we are computed the direction for
  13631. * @param isLocal defines if the direction should be set in local space
  13632. */
  13633. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13634. /**
  13635. * Called by the particle System when the position is computed for the created particle.
  13636. * @param worldMatrix is the world matrix of the particle system
  13637. * @param positionToUpdate is the position vector to update with the result
  13638. * @param particle is the particle we are computed the position for
  13639. * @param isLocal defines if the position should be set in local space
  13640. */
  13641. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13642. /**
  13643. * Clones the current emitter and returns a copy of it
  13644. * @returns the new emitter
  13645. */
  13646. clone(): SphereParticleEmitter;
  13647. /**
  13648. * Called by the GPUParticleSystem to setup the update shader
  13649. * @param effect defines the update shader
  13650. */
  13651. applyToShader(effect: Effect): void;
  13652. /**
  13653. * Returns a string to use to update the GPU particles update shader
  13654. * @returns a string containng the defines string
  13655. */
  13656. getEffectDefines(): string;
  13657. /**
  13658. * Returns the string "SphereParticleEmitter"
  13659. * @returns a string containing the class name
  13660. */
  13661. getClassName(): string;
  13662. /**
  13663. * Serializes the particle system to a JSON object.
  13664. * @returns the JSON object
  13665. */
  13666. serialize(): any;
  13667. /**
  13668. * Parse properties from a JSON object
  13669. * @param serializationObject defines the JSON object
  13670. */
  13671. parse(serializationObject: any): void;
  13672. }
  13673. /**
  13674. * Particle emitter emitting particles from the inside of a sphere.
  13675. * It emits the particles randomly between two vectors.
  13676. */
  13677. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13678. /**
  13679. * The min limit of the emission direction.
  13680. */
  13681. direction1: Vector3;
  13682. /**
  13683. * The max limit of the emission direction.
  13684. */
  13685. direction2: Vector3;
  13686. /**
  13687. * Creates a new instance SphereDirectedParticleEmitter
  13688. * @param radius the radius of the emission sphere (1 by default)
  13689. * @param direction1 the min limit of the emission direction (up vector by default)
  13690. * @param direction2 the max limit of the emission direction (up vector by default)
  13691. */
  13692. constructor(radius?: number,
  13693. /**
  13694. * The min limit of the emission direction.
  13695. */
  13696. direction1?: Vector3,
  13697. /**
  13698. * The max limit of the emission direction.
  13699. */
  13700. direction2?: Vector3);
  13701. /**
  13702. * Called by the particle System when the direction is computed for the created particle.
  13703. * @param worldMatrix is the world matrix of the particle system
  13704. * @param directionToUpdate is the direction vector to update with the result
  13705. * @param particle is the particle we are computed the direction for
  13706. */
  13707. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13708. /**
  13709. * Clones the current emitter and returns a copy of it
  13710. * @returns the new emitter
  13711. */
  13712. clone(): SphereDirectedParticleEmitter;
  13713. /**
  13714. * Called by the GPUParticleSystem to setup the update shader
  13715. * @param effect defines the update shader
  13716. */
  13717. applyToShader(effect: Effect): void;
  13718. /**
  13719. * Returns a string to use to update the GPU particles update shader
  13720. * @returns a string containng the defines string
  13721. */
  13722. getEffectDefines(): string;
  13723. /**
  13724. * Returns the string "SphereDirectedParticleEmitter"
  13725. * @returns a string containing the class name
  13726. */
  13727. getClassName(): string;
  13728. /**
  13729. * Serializes the particle system to a JSON object.
  13730. * @returns the JSON object
  13731. */
  13732. serialize(): any;
  13733. /**
  13734. * Parse properties from a JSON object
  13735. * @param serializationObject defines the JSON object
  13736. */
  13737. parse(serializationObject: any): void;
  13738. }
  13739. }
  13740. declare module BABYLON {
  13741. /**
  13742. * Particle emitter emitting particles from a custom list of positions.
  13743. */
  13744. export class CustomParticleEmitter implements IParticleEmitterType {
  13745. /**
  13746. * Gets or sets the position generator that will create the inital position of each particle.
  13747. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13748. */
  13749. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13750. /**
  13751. * Gets or sets the destination generator that will create the final destination of each particle.
  13752. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13753. */
  13754. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13755. /**
  13756. * Creates a new instance CustomParticleEmitter
  13757. */
  13758. constructor();
  13759. /**
  13760. * Called by the particle System when the direction is computed for the created particle.
  13761. * @param worldMatrix is the world matrix of the particle system
  13762. * @param directionToUpdate is the direction vector to update with the result
  13763. * @param particle is the particle we are computed the direction for
  13764. * @param isLocal defines if the direction should be set in local space
  13765. */
  13766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13767. /**
  13768. * Called by the particle System when the position is computed for the created particle.
  13769. * @param worldMatrix is the world matrix of the particle system
  13770. * @param positionToUpdate is the position vector to update with the result
  13771. * @param particle is the particle we are computed the position for
  13772. * @param isLocal defines if the position should be set in local space
  13773. */
  13774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13775. /**
  13776. * Clones the current emitter and returns a copy of it
  13777. * @returns the new emitter
  13778. */
  13779. clone(): CustomParticleEmitter;
  13780. /**
  13781. * Called by the GPUParticleSystem to setup the update shader
  13782. * @param effect defines the update shader
  13783. */
  13784. applyToShader(effect: Effect): void;
  13785. /**
  13786. * Returns a string to use to update the GPU particles update shader
  13787. * @returns a string containng the defines string
  13788. */
  13789. getEffectDefines(): string;
  13790. /**
  13791. * Returns the string "PointParticleEmitter"
  13792. * @returns a string containing the class name
  13793. */
  13794. getClassName(): string;
  13795. /**
  13796. * Serializes the particle system to a JSON object.
  13797. * @returns the JSON object
  13798. */
  13799. serialize(): any;
  13800. /**
  13801. * Parse properties from a JSON object
  13802. * @param serializationObject defines the JSON object
  13803. */
  13804. parse(serializationObject: any): void;
  13805. }
  13806. }
  13807. declare module BABYLON {
  13808. /**
  13809. * Particle emitter emitting particles from the inside of a box.
  13810. * It emits the particles randomly between 2 given directions.
  13811. */
  13812. export class MeshParticleEmitter implements IParticleEmitterType {
  13813. private _indices;
  13814. private _positions;
  13815. private _normals;
  13816. private _storedNormal;
  13817. private _mesh;
  13818. /**
  13819. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13820. */
  13821. direction1: Vector3;
  13822. /**
  13823. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13824. */
  13825. direction2: Vector3;
  13826. /**
  13827. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13828. */
  13829. useMeshNormalsForDirection: boolean;
  13830. /** Defines the mesh to use as source */
  13831. get mesh(): Nullable<AbstractMesh>;
  13832. set mesh(value: Nullable<AbstractMesh>);
  13833. /**
  13834. * Creates a new instance MeshParticleEmitter
  13835. * @param mesh defines the mesh to use as source
  13836. */
  13837. constructor(mesh?: Nullable<AbstractMesh>);
  13838. /**
  13839. * Called by the particle System when the direction is computed for the created particle.
  13840. * @param worldMatrix is the world matrix of the particle system
  13841. * @param directionToUpdate is the direction vector to update with the result
  13842. * @param particle is the particle we are computed the direction for
  13843. * @param isLocal defines if the direction should be set in local space
  13844. */
  13845. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13846. /**
  13847. * Called by the particle System when the position is computed for the created particle.
  13848. * @param worldMatrix is the world matrix of the particle system
  13849. * @param positionToUpdate is the position vector to update with the result
  13850. * @param particle is the particle we are computed the position for
  13851. * @param isLocal defines if the position should be set in local space
  13852. */
  13853. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13854. /**
  13855. * Clones the current emitter and returns a copy of it
  13856. * @returns the new emitter
  13857. */
  13858. clone(): MeshParticleEmitter;
  13859. /**
  13860. * Called by the GPUParticleSystem to setup the update shader
  13861. * @param effect defines the update shader
  13862. */
  13863. applyToShader(effect: Effect): void;
  13864. /**
  13865. * Returns a string to use to update the GPU particles update shader
  13866. * @returns a string containng the defines string
  13867. */
  13868. getEffectDefines(): string;
  13869. /**
  13870. * Returns the string "BoxParticleEmitter"
  13871. * @returns a string containing the class name
  13872. */
  13873. getClassName(): string;
  13874. /**
  13875. * Serializes the particle system to a JSON object.
  13876. * @returns the JSON object
  13877. */
  13878. serialize(): any;
  13879. /**
  13880. * Parse properties from a JSON object
  13881. * @param serializationObject defines the JSON object
  13882. * @param scene defines the hosting scene
  13883. */
  13884. parse(serializationObject: any, scene: Scene): void;
  13885. }
  13886. }
  13887. declare module BABYLON {
  13888. /**
  13889. * Interface representing a particle system in Babylon.js.
  13890. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13891. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13892. */
  13893. export interface IParticleSystem {
  13894. /**
  13895. * List of animations used by the particle system.
  13896. */
  13897. animations: Animation[];
  13898. /**
  13899. * The id of the Particle system.
  13900. */
  13901. id: string;
  13902. /**
  13903. * The name of the Particle system.
  13904. */
  13905. name: string;
  13906. /**
  13907. * The emitter represents the Mesh or position we are attaching the particle system to.
  13908. */
  13909. emitter: Nullable<AbstractMesh | Vector3>;
  13910. /**
  13911. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13912. */
  13913. isBillboardBased: boolean;
  13914. /**
  13915. * The rendering group used by the Particle system to chose when to render.
  13916. */
  13917. renderingGroupId: number;
  13918. /**
  13919. * The layer mask we are rendering the particles through.
  13920. */
  13921. layerMask: number;
  13922. /**
  13923. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13924. */
  13925. updateSpeed: number;
  13926. /**
  13927. * The amount of time the particle system is running (depends of the overall update speed).
  13928. */
  13929. targetStopDuration: number;
  13930. /**
  13931. * The texture used to render each particle. (this can be a spritesheet)
  13932. */
  13933. particleTexture: Nullable<Texture>;
  13934. /**
  13935. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13936. */
  13937. blendMode: number;
  13938. /**
  13939. * Minimum life time of emitting particles.
  13940. */
  13941. minLifeTime: number;
  13942. /**
  13943. * Maximum life time of emitting particles.
  13944. */
  13945. maxLifeTime: number;
  13946. /**
  13947. * Minimum Size of emitting particles.
  13948. */
  13949. minSize: number;
  13950. /**
  13951. * Maximum Size of emitting particles.
  13952. */
  13953. maxSize: number;
  13954. /**
  13955. * Minimum scale of emitting particles on X axis.
  13956. */
  13957. minScaleX: number;
  13958. /**
  13959. * Maximum scale of emitting particles on X axis.
  13960. */
  13961. maxScaleX: number;
  13962. /**
  13963. * Minimum scale of emitting particles on Y axis.
  13964. */
  13965. minScaleY: number;
  13966. /**
  13967. * Maximum scale of emitting particles on Y axis.
  13968. */
  13969. maxScaleY: number;
  13970. /**
  13971. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13972. */
  13973. color1: Color4;
  13974. /**
  13975. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13976. */
  13977. color2: Color4;
  13978. /**
  13979. * Color the particle will have at the end of its lifetime.
  13980. */
  13981. colorDead: Color4;
  13982. /**
  13983. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13984. */
  13985. emitRate: number;
  13986. /**
  13987. * You can use gravity if you want to give an orientation to your particles.
  13988. */
  13989. gravity: Vector3;
  13990. /**
  13991. * Minimum power of emitting particles.
  13992. */
  13993. minEmitPower: number;
  13994. /**
  13995. * Maximum power of emitting particles.
  13996. */
  13997. maxEmitPower: number;
  13998. /**
  13999. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14000. */
  14001. minAngularSpeed: number;
  14002. /**
  14003. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14004. */
  14005. maxAngularSpeed: number;
  14006. /**
  14007. * Gets or sets the minimal initial rotation in radians.
  14008. */
  14009. minInitialRotation: number;
  14010. /**
  14011. * Gets or sets the maximal initial rotation in radians.
  14012. */
  14013. maxInitialRotation: number;
  14014. /**
  14015. * The particle emitter type defines the emitter used by the particle system.
  14016. * It can be for example box, sphere, or cone...
  14017. */
  14018. particleEmitterType: Nullable<IParticleEmitterType>;
  14019. /**
  14020. * Defines the delay in milliseconds before starting the system (0 by default)
  14021. */
  14022. startDelay: number;
  14023. /**
  14024. * 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
  14025. */
  14026. preWarmCycles: number;
  14027. /**
  14028. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14029. */
  14030. preWarmStepOffset: number;
  14031. /**
  14032. * 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)
  14033. */
  14034. spriteCellChangeSpeed: number;
  14035. /**
  14036. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14037. */
  14038. startSpriteCellID: number;
  14039. /**
  14040. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14041. */
  14042. endSpriteCellID: number;
  14043. /**
  14044. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14045. */
  14046. spriteCellWidth: number;
  14047. /**
  14048. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14049. */
  14050. spriteCellHeight: number;
  14051. /**
  14052. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14053. */
  14054. spriteRandomStartCell: boolean;
  14055. /**
  14056. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14057. */
  14058. isAnimationSheetEnabled: boolean;
  14059. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14060. translationPivot: Vector2;
  14061. /**
  14062. * Gets or sets a texture used to add random noise to particle positions
  14063. */
  14064. noiseTexture: Nullable<BaseTexture>;
  14065. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14066. noiseStrength: Vector3;
  14067. /**
  14068. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14069. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14070. */
  14071. billboardMode: number;
  14072. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14073. limitVelocityDamping: number;
  14074. /**
  14075. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14076. */
  14077. beginAnimationOnStart: boolean;
  14078. /**
  14079. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14080. */
  14081. beginAnimationFrom: number;
  14082. /**
  14083. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14084. */
  14085. beginAnimationTo: number;
  14086. /**
  14087. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14088. */
  14089. beginAnimationLoop: boolean;
  14090. /**
  14091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14092. */
  14093. disposeOnStop: boolean;
  14094. /**
  14095. * Specifies if the particles are updated in emitter local space or world space
  14096. */
  14097. isLocal: boolean;
  14098. /** Snippet ID if the particle system was created from the snippet server */
  14099. snippetId: string;
  14100. /**
  14101. * Gets the maximum number of particles active at the same time.
  14102. * @returns The max number of active particles.
  14103. */
  14104. getCapacity(): number;
  14105. /**
  14106. * Gets the number of particles active at the same time.
  14107. * @returns The number of active particles.
  14108. */
  14109. getActiveCount(): number;
  14110. /**
  14111. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14112. * @returns True if it has been started, otherwise false.
  14113. */
  14114. isStarted(): boolean;
  14115. /**
  14116. * Animates the particle system for this frame.
  14117. */
  14118. animate(): void;
  14119. /**
  14120. * Renders the particle system in its current state.
  14121. * @returns the current number of particles
  14122. */
  14123. render(): number;
  14124. /**
  14125. * Dispose the particle system and frees its associated resources.
  14126. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14127. */
  14128. dispose(disposeTexture?: boolean): void;
  14129. /**
  14130. * An event triggered when the system is disposed
  14131. */
  14132. onDisposeObservable: Observable<IParticleSystem>;
  14133. /**
  14134. * Clones the particle system.
  14135. * @param name The name of the cloned object
  14136. * @param newEmitter The new emitter to use
  14137. * @returns the cloned particle system
  14138. */
  14139. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14140. /**
  14141. * Serializes the particle system to a JSON object
  14142. * @param serializeTexture defines if the texture must be serialized as well
  14143. * @returns the JSON object
  14144. */
  14145. serialize(serializeTexture: boolean): any;
  14146. /**
  14147. * Rebuild the particle system
  14148. */
  14149. rebuild(): void;
  14150. /** Force the system to rebuild all gradients that need to be resync */
  14151. forceRefreshGradients(): void;
  14152. /**
  14153. * Starts the particle system and begins to emit
  14154. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14155. */
  14156. start(delay?: number): void;
  14157. /**
  14158. * Stops the particle system.
  14159. */
  14160. stop(): void;
  14161. /**
  14162. * Remove all active particles
  14163. */
  14164. reset(): void;
  14165. /**
  14166. * Gets a boolean indicating that the system is stopping
  14167. * @returns true if the system is currently stopping
  14168. */
  14169. isStopping(): boolean;
  14170. /**
  14171. * Is this system ready to be used/rendered
  14172. * @return true if the system is ready
  14173. */
  14174. isReady(): boolean;
  14175. /**
  14176. * Returns the string "ParticleSystem"
  14177. * @returns a string containing the class name
  14178. */
  14179. getClassName(): string;
  14180. /**
  14181. * Gets the custom effect used to render the particles
  14182. * @param blendMode Blend mode for which the effect should be retrieved
  14183. * @returns The effect
  14184. */
  14185. getCustomEffect(blendMode: number): Nullable<Effect>;
  14186. /**
  14187. * Sets the custom effect used to render the particles
  14188. * @param effect The effect to set
  14189. * @param blendMode Blend mode for which the effect should be set
  14190. */
  14191. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14192. /**
  14193. * Fill the defines array according to the current settings of the particle system
  14194. * @param defines Array to be updated
  14195. * @param blendMode blend mode to take into account when updating the array
  14196. */
  14197. fillDefines(defines: Array<string>, blendMode: number): void;
  14198. /**
  14199. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14200. * @param uniforms Uniforms array to fill
  14201. * @param attributes Attributes array to fill
  14202. * @param samplers Samplers array to fill
  14203. */
  14204. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14205. /**
  14206. * Observable that will be called just before the particles are drawn
  14207. */
  14208. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14209. /**
  14210. * Gets the name of the particle vertex shader
  14211. */
  14212. vertexShaderName: string;
  14213. /**
  14214. * Adds a new color gradient
  14215. * @param gradient defines the gradient to use (between 0 and 1)
  14216. * @param color1 defines the color to affect to the specified gradient
  14217. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14218. * @returns the current particle system
  14219. */
  14220. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14221. /**
  14222. * Remove a specific color gradient
  14223. * @param gradient defines the gradient to remove
  14224. * @returns the current particle system
  14225. */
  14226. removeColorGradient(gradient: number): IParticleSystem;
  14227. /**
  14228. * Adds a new size gradient
  14229. * @param gradient defines the gradient to use (between 0 and 1)
  14230. * @param factor defines the size factor to affect to the specified gradient
  14231. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14232. * @returns the current particle system
  14233. */
  14234. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14235. /**
  14236. * Remove a specific size gradient
  14237. * @param gradient defines the gradient to remove
  14238. * @returns the current particle system
  14239. */
  14240. removeSizeGradient(gradient: number): IParticleSystem;
  14241. /**
  14242. * Gets the current list of color gradients.
  14243. * You must use addColorGradient and removeColorGradient to udpate this list
  14244. * @returns the list of color gradients
  14245. */
  14246. getColorGradients(): Nullable<Array<ColorGradient>>;
  14247. /**
  14248. * Gets the current list of size gradients.
  14249. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14250. * @returns the list of size gradients
  14251. */
  14252. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14253. /**
  14254. * Gets the current list of angular speed gradients.
  14255. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14256. * @returns the list of angular speed gradients
  14257. */
  14258. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14259. /**
  14260. * Adds a new angular speed gradient
  14261. * @param gradient defines the gradient to use (between 0 and 1)
  14262. * @param factor defines the angular speed to affect to the specified gradient
  14263. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14264. * @returns the current particle system
  14265. */
  14266. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14267. /**
  14268. * Remove a specific angular speed gradient
  14269. * @param gradient defines the gradient to remove
  14270. * @returns the current particle system
  14271. */
  14272. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14273. /**
  14274. * Gets the current list of velocity gradients.
  14275. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14276. * @returns the list of velocity gradients
  14277. */
  14278. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14279. /**
  14280. * Adds a new velocity gradient
  14281. * @param gradient defines the gradient to use (between 0 and 1)
  14282. * @param factor defines the velocity to affect to the specified gradient
  14283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14284. * @returns the current particle system
  14285. */
  14286. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14287. /**
  14288. * Remove a specific velocity gradient
  14289. * @param gradient defines the gradient to remove
  14290. * @returns the current particle system
  14291. */
  14292. removeVelocityGradient(gradient: number): IParticleSystem;
  14293. /**
  14294. * Gets the current list of limit velocity gradients.
  14295. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14296. * @returns the list of limit velocity gradients
  14297. */
  14298. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14299. /**
  14300. * Adds a new limit velocity gradient
  14301. * @param gradient defines the gradient to use (between 0 and 1)
  14302. * @param factor defines the limit velocity to affect to the specified gradient
  14303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14304. * @returns the current particle system
  14305. */
  14306. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14307. /**
  14308. * Remove a specific limit velocity gradient
  14309. * @param gradient defines the gradient to remove
  14310. * @returns the current particle system
  14311. */
  14312. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14313. /**
  14314. * Adds a new drag gradient
  14315. * @param gradient defines the gradient to use (between 0 and 1)
  14316. * @param factor defines the drag to affect to the specified gradient
  14317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14318. * @returns the current particle system
  14319. */
  14320. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14321. /**
  14322. * Remove a specific drag gradient
  14323. * @param gradient defines the gradient to remove
  14324. * @returns the current particle system
  14325. */
  14326. removeDragGradient(gradient: number): IParticleSystem;
  14327. /**
  14328. * Gets the current list of drag gradients.
  14329. * You must use addDragGradient and removeDragGradient to udpate this list
  14330. * @returns the list of drag gradients
  14331. */
  14332. getDragGradients(): Nullable<Array<FactorGradient>>;
  14333. /**
  14334. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14335. * @param gradient defines the gradient to use (between 0 and 1)
  14336. * @param factor defines the emit rate to affect to the specified gradient
  14337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14338. * @returns the current particle system
  14339. */
  14340. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14341. /**
  14342. * Remove a specific emit rate gradient
  14343. * @param gradient defines the gradient to remove
  14344. * @returns the current particle system
  14345. */
  14346. removeEmitRateGradient(gradient: number): IParticleSystem;
  14347. /**
  14348. * Gets the current list of emit rate gradients.
  14349. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14350. * @returns the list of emit rate gradients
  14351. */
  14352. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14353. /**
  14354. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14355. * @param gradient defines the gradient to use (between 0 and 1)
  14356. * @param factor defines the start size to affect to the specified gradient
  14357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14358. * @returns the current particle system
  14359. */
  14360. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14361. /**
  14362. * Remove a specific start size gradient
  14363. * @param gradient defines the gradient to remove
  14364. * @returns the current particle system
  14365. */
  14366. removeStartSizeGradient(gradient: number): IParticleSystem;
  14367. /**
  14368. * Gets the current list of start size gradients.
  14369. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14370. * @returns the list of start size gradients
  14371. */
  14372. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14373. /**
  14374. * Adds a new life time gradient
  14375. * @param gradient defines the gradient to use (between 0 and 1)
  14376. * @param factor defines the life time factor to affect to the specified gradient
  14377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14378. * @returns the current particle system
  14379. */
  14380. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14381. /**
  14382. * Remove a specific life time gradient
  14383. * @param gradient defines the gradient to remove
  14384. * @returns the current particle system
  14385. */
  14386. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14387. /**
  14388. * Gets the current list of life time gradients.
  14389. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14390. * @returns the list of life time gradients
  14391. */
  14392. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14393. /**
  14394. * Gets the current list of color gradients.
  14395. * You must use addColorGradient and removeColorGradient to udpate this list
  14396. * @returns the list of color gradients
  14397. */
  14398. getColorGradients(): Nullable<Array<ColorGradient>>;
  14399. /**
  14400. * Adds a new ramp gradient used to remap particle colors
  14401. * @param gradient defines the gradient to use (between 0 and 1)
  14402. * @param color defines the color to affect to the specified gradient
  14403. * @returns the current particle system
  14404. */
  14405. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14406. /**
  14407. * Gets the current list of ramp gradients.
  14408. * You must use addRampGradient and removeRampGradient to udpate this list
  14409. * @returns the list of ramp gradients
  14410. */
  14411. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14412. /** Gets or sets a boolean indicating that ramp gradients must be used
  14413. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14414. */
  14415. useRampGradients: boolean;
  14416. /**
  14417. * Adds a new color remap gradient
  14418. * @param gradient defines the gradient to use (between 0 and 1)
  14419. * @param min defines the color remap minimal range
  14420. * @param max defines the color remap maximal range
  14421. * @returns the current particle system
  14422. */
  14423. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14424. /**
  14425. * Gets the current list of color remap gradients.
  14426. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14427. * @returns the list of color remap gradients
  14428. */
  14429. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14430. /**
  14431. * Adds a new alpha remap gradient
  14432. * @param gradient defines the gradient to use (between 0 and 1)
  14433. * @param min defines the alpha remap minimal range
  14434. * @param max defines the alpha remap maximal range
  14435. * @returns the current particle system
  14436. */
  14437. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14438. /**
  14439. * Gets the current list of alpha remap gradients.
  14440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14441. * @returns the list of alpha remap gradients
  14442. */
  14443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14444. /**
  14445. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14446. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14447. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14448. * @returns the emitter
  14449. */
  14450. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14451. /**
  14452. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14453. * @param radius The radius of the hemisphere to emit from
  14454. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14455. * @returns the emitter
  14456. */
  14457. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14458. /**
  14459. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14460. * @param radius The radius of the sphere to emit from
  14461. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14462. * @returns the emitter
  14463. */
  14464. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14465. /**
  14466. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14467. * @param radius The radius of the sphere to emit from
  14468. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14469. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14470. * @returns the emitter
  14471. */
  14472. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14473. /**
  14474. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14475. * @param radius The radius of the emission cylinder
  14476. * @param height The height of the emission cylinder
  14477. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14478. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14479. * @returns the emitter
  14480. */
  14481. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14482. /**
  14483. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14484. * @param radius The radius of the cylinder to emit from
  14485. * @param height The height of the emission cylinder
  14486. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14487. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14488. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14489. * @returns the emitter
  14490. */
  14491. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14492. /**
  14493. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14494. * @param radius The radius of the cone to emit from
  14495. * @param angle The base angle of the cone
  14496. * @returns the emitter
  14497. */
  14498. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14499. /**
  14500. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14501. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14502. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14503. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14504. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14505. * @returns the emitter
  14506. */
  14507. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14508. /**
  14509. * Get hosting scene
  14510. * @returns the scene
  14511. */
  14512. getScene(): Scene;
  14513. }
  14514. }
  14515. declare module BABYLON {
  14516. /**
  14517. * 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.
  14518. * @see https://doc.babylonjs.com/how_to/transformnode
  14519. */
  14520. export class TransformNode extends Node {
  14521. /**
  14522. * Object will not rotate to face the camera
  14523. */
  14524. static BILLBOARDMODE_NONE: number;
  14525. /**
  14526. * Object will rotate to face the camera but only on the x axis
  14527. */
  14528. static BILLBOARDMODE_X: number;
  14529. /**
  14530. * Object will rotate to face the camera but only on the y axis
  14531. */
  14532. static BILLBOARDMODE_Y: number;
  14533. /**
  14534. * Object will rotate to face the camera but only on the z axis
  14535. */
  14536. static BILLBOARDMODE_Z: number;
  14537. /**
  14538. * Object will rotate to face the camera
  14539. */
  14540. static BILLBOARDMODE_ALL: number;
  14541. /**
  14542. * Object will rotate to face the camera's position instead of orientation
  14543. */
  14544. static BILLBOARDMODE_USE_POSITION: number;
  14545. private _forward;
  14546. private _forwardInverted;
  14547. private _up;
  14548. private _right;
  14549. private _rightInverted;
  14550. private _position;
  14551. private _rotation;
  14552. private _rotationQuaternion;
  14553. protected _scaling: Vector3;
  14554. protected _isDirty: boolean;
  14555. private _transformToBoneReferal;
  14556. private _isAbsoluteSynced;
  14557. private _billboardMode;
  14558. /**
  14559. * Gets or sets the billboard mode. Default is 0.
  14560. *
  14561. * | Value | Type | Description |
  14562. * | --- | --- | --- |
  14563. * | 0 | BILLBOARDMODE_NONE | |
  14564. * | 1 | BILLBOARDMODE_X | |
  14565. * | 2 | BILLBOARDMODE_Y | |
  14566. * | 4 | BILLBOARDMODE_Z | |
  14567. * | 7 | BILLBOARDMODE_ALL | |
  14568. *
  14569. */
  14570. get billboardMode(): number;
  14571. set billboardMode(value: number);
  14572. private _preserveParentRotationForBillboard;
  14573. /**
  14574. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14575. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14576. */
  14577. get preserveParentRotationForBillboard(): boolean;
  14578. set preserveParentRotationForBillboard(value: boolean);
  14579. /**
  14580. * 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
  14581. */
  14582. scalingDeterminant: number;
  14583. private _infiniteDistance;
  14584. /**
  14585. * Gets or sets the distance of the object to max, often used by skybox
  14586. */
  14587. get infiniteDistance(): boolean;
  14588. set infiniteDistance(value: boolean);
  14589. /**
  14590. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14591. * By default the system will update normals to compensate
  14592. */
  14593. ignoreNonUniformScaling: boolean;
  14594. /**
  14595. * 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
  14596. */
  14597. reIntegrateRotationIntoRotationQuaternion: boolean;
  14598. /** @hidden */
  14599. _poseMatrix: Nullable<Matrix>;
  14600. /** @hidden */
  14601. _localMatrix: Matrix;
  14602. private _usePivotMatrix;
  14603. private _absolutePosition;
  14604. private _absoluteScaling;
  14605. private _absoluteRotationQuaternion;
  14606. private _pivotMatrix;
  14607. private _pivotMatrixInverse;
  14608. protected _postMultiplyPivotMatrix: boolean;
  14609. protected _isWorldMatrixFrozen: boolean;
  14610. /** @hidden */
  14611. _indexInSceneTransformNodesArray: number;
  14612. /**
  14613. * An event triggered after the world matrix is updated
  14614. */
  14615. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14616. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14617. /**
  14618. * Gets a string identifying the name of the class
  14619. * @returns "TransformNode" string
  14620. */
  14621. getClassName(): string;
  14622. /**
  14623. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14624. */
  14625. get position(): Vector3;
  14626. set position(newPosition: Vector3);
  14627. /**
  14628. * 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)).
  14629. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14630. */
  14631. get rotation(): Vector3;
  14632. set rotation(newRotation: Vector3);
  14633. /**
  14634. * 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)).
  14635. */
  14636. get scaling(): Vector3;
  14637. set scaling(newScaling: Vector3);
  14638. /**
  14639. * 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).
  14640. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14641. */
  14642. get rotationQuaternion(): Nullable<Quaternion>;
  14643. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14644. /**
  14645. * The forward direction of that transform in world space.
  14646. */
  14647. get forward(): Vector3;
  14648. /**
  14649. * The up direction of that transform in world space.
  14650. */
  14651. get up(): Vector3;
  14652. /**
  14653. * The right direction of that transform in world space.
  14654. */
  14655. get right(): Vector3;
  14656. /**
  14657. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14658. * @param matrix the matrix to copy the pose from
  14659. * @returns this TransformNode.
  14660. */
  14661. updatePoseMatrix(matrix: Matrix): TransformNode;
  14662. /**
  14663. * Returns the mesh Pose matrix.
  14664. * @returns the pose matrix
  14665. */
  14666. getPoseMatrix(): Matrix;
  14667. /** @hidden */
  14668. _isSynchronized(): boolean;
  14669. /** @hidden */
  14670. _initCache(): void;
  14671. /**
  14672. * Flag the transform node as dirty (Forcing it to update everything)
  14673. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14674. * @returns this transform node
  14675. */
  14676. markAsDirty(property: string): TransformNode;
  14677. /**
  14678. * Returns the current mesh absolute position.
  14679. * Returns a Vector3.
  14680. */
  14681. get absolutePosition(): Vector3;
  14682. /**
  14683. * Returns the current mesh absolute scaling.
  14684. * Returns a Vector3.
  14685. */
  14686. get absoluteScaling(): Vector3;
  14687. /**
  14688. * Returns the current mesh absolute rotation.
  14689. * Returns a Quaternion.
  14690. */
  14691. get absoluteRotationQuaternion(): Quaternion;
  14692. /**
  14693. * Sets a new matrix to apply before all other transformation
  14694. * @param matrix defines the transform matrix
  14695. * @returns the current TransformNode
  14696. */
  14697. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14698. /**
  14699. * Sets a new pivot matrix to the current node
  14700. * @param matrix defines the new pivot matrix to use
  14701. * @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
  14702. * @returns the current TransformNode
  14703. */
  14704. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14705. /**
  14706. * Returns the mesh pivot matrix.
  14707. * Default : Identity.
  14708. * @returns the matrix
  14709. */
  14710. getPivotMatrix(): Matrix;
  14711. /**
  14712. * Instantiate (when possible) or clone that node with its hierarchy
  14713. * @param newParent defines the new parent to use for the instance (or clone)
  14714. * @param options defines options to configure how copy is done
  14715. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14716. * @returns an instance (or a clone) of the current node with its hiearchy
  14717. */
  14718. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14719. doNotInstantiate: boolean;
  14720. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14721. /**
  14722. * Prevents the World matrix to be computed any longer
  14723. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14724. * @returns the TransformNode.
  14725. */
  14726. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14727. /**
  14728. * Allows back the World matrix computation.
  14729. * @returns the TransformNode.
  14730. */
  14731. unfreezeWorldMatrix(): this;
  14732. /**
  14733. * True if the World matrix has been frozen.
  14734. */
  14735. get isWorldMatrixFrozen(): boolean;
  14736. /**
  14737. * Retuns the mesh absolute position in the World.
  14738. * @returns a Vector3.
  14739. */
  14740. getAbsolutePosition(): Vector3;
  14741. /**
  14742. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14743. * @param absolutePosition the absolute position to set
  14744. * @returns the TransformNode.
  14745. */
  14746. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14747. /**
  14748. * Sets the mesh position in its local space.
  14749. * @param vector3 the position to set in localspace
  14750. * @returns the TransformNode.
  14751. */
  14752. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14753. /**
  14754. * Returns the mesh position in the local space from the current World matrix values.
  14755. * @returns a new Vector3.
  14756. */
  14757. getPositionExpressedInLocalSpace(): Vector3;
  14758. /**
  14759. * Translates the mesh along the passed Vector3 in its local space.
  14760. * @param vector3 the distance to translate in localspace
  14761. * @returns the TransformNode.
  14762. */
  14763. locallyTranslate(vector3: Vector3): TransformNode;
  14764. private static _lookAtVectorCache;
  14765. /**
  14766. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14767. * @param targetPoint the position (must be in same space as current mesh) to look at
  14768. * @param yawCor optional yaw (y-axis) correction in radians
  14769. * @param pitchCor optional pitch (x-axis) correction in radians
  14770. * @param rollCor optional roll (z-axis) correction in radians
  14771. * @param space the choosen space of the target
  14772. * @returns the TransformNode.
  14773. */
  14774. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14775. /**
  14776. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14777. * This Vector3 is expressed in the World space.
  14778. * @param localAxis axis to rotate
  14779. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14780. */
  14781. getDirection(localAxis: Vector3): Vector3;
  14782. /**
  14783. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14784. * localAxis is expressed in the mesh local space.
  14785. * result is computed in the Wordl space from the mesh World matrix.
  14786. * @param localAxis axis to rotate
  14787. * @param result the resulting transformnode
  14788. * @returns this TransformNode.
  14789. */
  14790. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14791. /**
  14792. * Sets this transform node rotation to the given local axis.
  14793. * @param localAxis the axis in local space
  14794. * @param yawCor optional yaw (y-axis) correction in radians
  14795. * @param pitchCor optional pitch (x-axis) correction in radians
  14796. * @param rollCor optional roll (z-axis) correction in radians
  14797. * @returns this TransformNode
  14798. */
  14799. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14800. /**
  14801. * Sets a new pivot point to the current node
  14802. * @param point defines the new pivot point to use
  14803. * @param space defines if the point is in world or local space (local by default)
  14804. * @returns the current TransformNode
  14805. */
  14806. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14807. /**
  14808. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14809. * @returns the pivot point
  14810. */
  14811. getPivotPoint(): Vector3;
  14812. /**
  14813. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14814. * @param result the vector3 to store the result
  14815. * @returns this TransformNode.
  14816. */
  14817. getPivotPointToRef(result: Vector3): TransformNode;
  14818. /**
  14819. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14820. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14821. */
  14822. getAbsolutePivotPoint(): Vector3;
  14823. /**
  14824. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14825. * @param result vector3 to store the result
  14826. * @returns this TransformNode.
  14827. */
  14828. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14829. /**
  14830. * Defines the passed node as the parent of the current node.
  14831. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14832. * @see https://doc.babylonjs.com/how_to/parenting
  14833. * @param node the node ot set as the parent
  14834. * @returns this TransformNode.
  14835. */
  14836. setParent(node: Nullable<Node>): TransformNode;
  14837. private _nonUniformScaling;
  14838. /**
  14839. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14840. */
  14841. get nonUniformScaling(): boolean;
  14842. /** @hidden */
  14843. _updateNonUniformScalingState(value: boolean): boolean;
  14844. /**
  14845. * Attach the current TransformNode to another TransformNode associated with a bone
  14846. * @param bone Bone affecting the TransformNode
  14847. * @param affectedTransformNode TransformNode associated with the bone
  14848. * @returns this object
  14849. */
  14850. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14851. /**
  14852. * Detach the transform node if its associated with a bone
  14853. * @returns this object
  14854. */
  14855. detachFromBone(): TransformNode;
  14856. private static _rotationAxisCache;
  14857. /**
  14858. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14859. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14860. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14861. * The passed axis is also normalized.
  14862. * @param axis the axis to rotate around
  14863. * @param amount the amount to rotate in radians
  14864. * @param space Space to rotate in (Default: local)
  14865. * @returns the TransformNode.
  14866. */
  14867. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14868. /**
  14869. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14870. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14871. * The passed axis is also normalized. .
  14872. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14873. * @param point the point to rotate around
  14874. * @param axis the axis to rotate around
  14875. * @param amount the amount to rotate in radians
  14876. * @returns the TransformNode
  14877. */
  14878. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14879. /**
  14880. * Translates the mesh along the axis vector for the passed distance in the given space.
  14881. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14882. * @param axis the axis to translate in
  14883. * @param distance the distance to translate
  14884. * @param space Space to rotate in (Default: local)
  14885. * @returns the TransformNode.
  14886. */
  14887. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14888. /**
  14889. * Adds a rotation step to the mesh current rotation.
  14890. * x, y, z are Euler angles expressed in radians.
  14891. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14892. * This means this rotation is made in the mesh local space only.
  14893. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14894. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14895. * ```javascript
  14896. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14897. * ```
  14898. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14899. * 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.
  14900. * @param x Rotation to add
  14901. * @param y Rotation to add
  14902. * @param z Rotation to add
  14903. * @returns the TransformNode.
  14904. */
  14905. addRotation(x: number, y: number, z: number): TransformNode;
  14906. /**
  14907. * @hidden
  14908. */
  14909. protected _getEffectiveParent(): Nullable<Node>;
  14910. /**
  14911. * Computes the world matrix of the node
  14912. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14913. * @returns the world matrix
  14914. */
  14915. computeWorldMatrix(force?: boolean): Matrix;
  14916. /**
  14917. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14918. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14919. */
  14920. resetLocalMatrix(independentOfChildren?: boolean): void;
  14921. protected _afterComputeWorldMatrix(): void;
  14922. /**
  14923. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14924. * @param func callback function to add
  14925. *
  14926. * @returns the TransformNode.
  14927. */
  14928. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14929. /**
  14930. * Removes a registered callback function.
  14931. * @param func callback function to remove
  14932. * @returns the TransformNode.
  14933. */
  14934. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14935. /**
  14936. * Gets the position of the current mesh in camera space
  14937. * @param camera defines the camera to use
  14938. * @returns a position
  14939. */
  14940. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14941. /**
  14942. * Returns the distance from the mesh to the active camera
  14943. * @param camera defines the camera to use
  14944. * @returns the distance
  14945. */
  14946. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14947. /**
  14948. * Clone the current transform node
  14949. * @param name Name of the new clone
  14950. * @param newParent New parent for the clone
  14951. * @param doNotCloneChildren Do not clone children hierarchy
  14952. * @returns the new transform node
  14953. */
  14954. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14955. /**
  14956. * Serializes the objects information.
  14957. * @param currentSerializationObject defines the object to serialize in
  14958. * @returns the serialized object
  14959. */
  14960. serialize(currentSerializationObject?: any): any;
  14961. /**
  14962. * Returns a new TransformNode object parsed from the source provided.
  14963. * @param parsedTransformNode is the source.
  14964. * @param scene the scne the object belongs to
  14965. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14966. * @returns a new TransformNode object parsed from the source provided.
  14967. */
  14968. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14969. /**
  14970. * Get all child-transformNodes of this node
  14971. * @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
  14972. * @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
  14973. * @returns an array of TransformNode
  14974. */
  14975. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14976. /**
  14977. * Releases resources associated with this transform node.
  14978. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14979. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14980. */
  14981. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14982. /**
  14983. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14984. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14985. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14986. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14987. * @returns the current mesh
  14988. */
  14989. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14990. private _syncAbsoluteScalingAndRotation;
  14991. }
  14992. }
  14993. declare module BABYLON {
  14994. /**
  14995. * Class used to override all child animations of a given target
  14996. */
  14997. export class AnimationPropertiesOverride {
  14998. /**
  14999. * Gets or sets a value indicating if animation blending must be used
  15000. */
  15001. enableBlending: boolean;
  15002. /**
  15003. * Gets or sets the blending speed to use when enableBlending is true
  15004. */
  15005. blendingSpeed: number;
  15006. /**
  15007. * Gets or sets the default loop mode to use
  15008. */
  15009. loopMode: number;
  15010. }
  15011. }
  15012. declare module BABYLON {
  15013. /**
  15014. * Class used to store bone information
  15015. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15016. */
  15017. export class Bone extends Node {
  15018. /**
  15019. * defines the bone name
  15020. */
  15021. name: string;
  15022. private static _tmpVecs;
  15023. private static _tmpQuat;
  15024. private static _tmpMats;
  15025. /**
  15026. * Gets the list of child bones
  15027. */
  15028. children: Bone[];
  15029. /** Gets the animations associated with this bone */
  15030. animations: Animation[];
  15031. /**
  15032. * Gets or sets bone length
  15033. */
  15034. length: number;
  15035. /**
  15036. * @hidden Internal only
  15037. * Set this value to map this bone to a different index in the transform matrices
  15038. * Set this value to -1 to exclude the bone from the transform matrices
  15039. */
  15040. _index: Nullable<number>;
  15041. private _skeleton;
  15042. private _localMatrix;
  15043. private _restPose;
  15044. private _baseMatrix;
  15045. private _absoluteTransform;
  15046. private _invertedAbsoluteTransform;
  15047. private _parent;
  15048. private _scalingDeterminant;
  15049. private _worldTransform;
  15050. private _localScaling;
  15051. private _localRotation;
  15052. private _localPosition;
  15053. private _needToDecompose;
  15054. private _needToCompose;
  15055. /** @hidden */
  15056. _linkedTransformNode: Nullable<TransformNode>;
  15057. /** @hidden */
  15058. _waitingTransformNodeId: Nullable<string>;
  15059. /** @hidden */
  15060. get _matrix(): Matrix;
  15061. /** @hidden */
  15062. set _matrix(value: Matrix);
  15063. /**
  15064. * Create a new bone
  15065. * @param name defines the bone name
  15066. * @param skeleton defines the parent skeleton
  15067. * @param parentBone defines the parent (can be null if the bone is the root)
  15068. * @param localMatrix defines the local matrix
  15069. * @param restPose defines the rest pose matrix
  15070. * @param baseMatrix defines the base matrix
  15071. * @param index defines index of the bone in the hiearchy
  15072. */
  15073. constructor(
  15074. /**
  15075. * defines the bone name
  15076. */
  15077. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15078. /**
  15079. * Gets the current object class name.
  15080. * @return the class name
  15081. */
  15082. getClassName(): string;
  15083. /**
  15084. * Gets the parent skeleton
  15085. * @returns a skeleton
  15086. */
  15087. getSkeleton(): Skeleton;
  15088. /**
  15089. * Gets parent bone
  15090. * @returns a bone or null if the bone is the root of the bone hierarchy
  15091. */
  15092. getParent(): Nullable<Bone>;
  15093. /**
  15094. * Returns an array containing the root bones
  15095. * @returns an array containing the root bones
  15096. */
  15097. getChildren(): Array<Bone>;
  15098. /**
  15099. * Gets the node index in matrix array generated for rendering
  15100. * @returns the node index
  15101. */
  15102. getIndex(): number;
  15103. /**
  15104. * Sets the parent bone
  15105. * @param parent defines the parent (can be null if the bone is the root)
  15106. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15107. */
  15108. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15109. /**
  15110. * Gets the local matrix
  15111. * @returns a matrix
  15112. */
  15113. getLocalMatrix(): Matrix;
  15114. /**
  15115. * Gets the base matrix (initial matrix which remains unchanged)
  15116. * @returns a matrix
  15117. */
  15118. getBaseMatrix(): Matrix;
  15119. /**
  15120. * Gets the rest pose matrix
  15121. * @returns a matrix
  15122. */
  15123. getRestPose(): Matrix;
  15124. /**
  15125. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15126. */
  15127. getWorldMatrix(): Matrix;
  15128. /**
  15129. * Sets the local matrix to rest pose matrix
  15130. */
  15131. returnToRest(): void;
  15132. /**
  15133. * Gets the inverse of the absolute transform matrix.
  15134. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15135. * @returns a matrix
  15136. */
  15137. getInvertedAbsoluteTransform(): Matrix;
  15138. /**
  15139. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15140. * @returns a matrix
  15141. */
  15142. getAbsoluteTransform(): Matrix;
  15143. /**
  15144. * Links with the given transform node.
  15145. * The local matrix of this bone is copied from the transform node every frame.
  15146. * @param transformNode defines the transform node to link to
  15147. */
  15148. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15149. /**
  15150. * Gets the node used to drive the bone's transformation
  15151. * @returns a transform node or null
  15152. */
  15153. getTransformNode(): Nullable<TransformNode>;
  15154. /** Gets or sets current position (in local space) */
  15155. get position(): Vector3;
  15156. set position(newPosition: Vector3);
  15157. /** Gets or sets current rotation (in local space) */
  15158. get rotation(): Vector3;
  15159. set rotation(newRotation: Vector3);
  15160. /** Gets or sets current rotation quaternion (in local space) */
  15161. get rotationQuaternion(): Quaternion;
  15162. set rotationQuaternion(newRotation: Quaternion);
  15163. /** Gets or sets current scaling (in local space) */
  15164. get scaling(): Vector3;
  15165. set scaling(newScaling: Vector3);
  15166. /**
  15167. * Gets the animation properties override
  15168. */
  15169. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15170. private _decompose;
  15171. private _compose;
  15172. /**
  15173. * Update the base and local matrices
  15174. * @param matrix defines the new base or local matrix
  15175. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15176. * @param updateLocalMatrix defines if the local matrix should be updated
  15177. */
  15178. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15179. /** @hidden */
  15180. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15181. /**
  15182. * Flag the bone as dirty (Forcing it to update everything)
  15183. */
  15184. markAsDirty(): void;
  15185. /** @hidden */
  15186. _markAsDirtyAndCompose(): void;
  15187. private _markAsDirtyAndDecompose;
  15188. /**
  15189. * Translate the bone in local or world space
  15190. * @param vec The amount to translate the bone
  15191. * @param space The space that the translation is in
  15192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15193. */
  15194. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15195. /**
  15196. * Set the postion of the bone in local or world space
  15197. * @param position The position to set the bone
  15198. * @param space The space that the position is in
  15199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15200. */
  15201. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15202. /**
  15203. * Set the absolute position of the bone (world space)
  15204. * @param position The position to set the bone
  15205. * @param mesh The mesh that this bone is attached to
  15206. */
  15207. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15208. /**
  15209. * Scale the bone on the x, y and z axes (in local space)
  15210. * @param x The amount to scale the bone on the x axis
  15211. * @param y The amount to scale the bone on the y axis
  15212. * @param z The amount to scale the bone on the z axis
  15213. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15214. */
  15215. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15216. /**
  15217. * Set the bone scaling in local space
  15218. * @param scale defines the scaling vector
  15219. */
  15220. setScale(scale: Vector3): void;
  15221. /**
  15222. * Gets the current scaling in local space
  15223. * @returns the current scaling vector
  15224. */
  15225. getScale(): Vector3;
  15226. /**
  15227. * Gets the current scaling in local space and stores it in a target vector
  15228. * @param result defines the target vector
  15229. */
  15230. getScaleToRef(result: Vector3): void;
  15231. /**
  15232. * Set the yaw, pitch, and roll of the bone in local or world space
  15233. * @param yaw The rotation of the bone on the y axis
  15234. * @param pitch The rotation of the bone on the x axis
  15235. * @param roll The rotation of the bone on the z axis
  15236. * @param space The space that the axes of rotation are in
  15237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15238. */
  15239. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15240. /**
  15241. * Add a rotation to the bone on an axis in local or world space
  15242. * @param axis The axis to rotate the bone on
  15243. * @param amount The amount to rotate the bone
  15244. * @param space The space that the axis is in
  15245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15246. */
  15247. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15248. /**
  15249. * Set the rotation of the bone to a particular axis angle in local or world space
  15250. * @param axis The axis to rotate the bone on
  15251. * @param angle The angle that the bone should be rotated to
  15252. * @param space The space that the axis is in
  15253. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15254. */
  15255. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15256. /**
  15257. * Set the euler rotation of the bone in local of world space
  15258. * @param rotation The euler rotation that the bone should be set to
  15259. * @param space The space that the rotation is in
  15260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15261. */
  15262. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15263. /**
  15264. * Set the quaternion rotation of the bone in local of world space
  15265. * @param quat The quaternion rotation that the bone should be set to
  15266. * @param space The space that the rotation is in
  15267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15268. */
  15269. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15270. /**
  15271. * Set the rotation matrix of the bone in local of world space
  15272. * @param rotMat The rotation matrix that the bone should be set to
  15273. * @param space The space that the rotation is in
  15274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15275. */
  15276. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15277. private _rotateWithMatrix;
  15278. private _getNegativeRotationToRef;
  15279. /**
  15280. * Get the position of the bone in local or world space
  15281. * @param space The space that the returned position is in
  15282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15283. * @returns The position of the bone
  15284. */
  15285. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15286. /**
  15287. * Copy the position of the bone to a vector3 in local or world space
  15288. * @param space The space that the returned position is in
  15289. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15290. * @param result The vector3 to copy the position to
  15291. */
  15292. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15293. /**
  15294. * Get the absolute position of the bone (world space)
  15295. * @param mesh The mesh that this bone is attached to
  15296. * @returns The absolute position of the bone
  15297. */
  15298. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15299. /**
  15300. * Copy the absolute position of the bone (world space) to the result param
  15301. * @param mesh The mesh that this bone is attached to
  15302. * @param result The vector3 to copy the absolute position to
  15303. */
  15304. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15305. /**
  15306. * Compute the absolute transforms of this bone and its children
  15307. */
  15308. computeAbsoluteTransforms(): void;
  15309. /**
  15310. * Get the world direction from an axis that is in the local space of the bone
  15311. * @param localAxis The local direction that is used to compute the world direction
  15312. * @param mesh The mesh that this bone is attached to
  15313. * @returns The world direction
  15314. */
  15315. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15316. /**
  15317. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15318. * @param localAxis The local direction that is used to compute the world direction
  15319. * @param mesh The mesh that this bone is attached to
  15320. * @param result The vector3 that the world direction will be copied to
  15321. */
  15322. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15323. /**
  15324. * Get the euler rotation of the bone in local or world space
  15325. * @param space The space that the rotation should be in
  15326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15327. * @returns The euler rotation
  15328. */
  15329. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15330. /**
  15331. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15332. * @param space The space that the rotation should be in
  15333. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15334. * @param result The vector3 that the rotation should be copied to
  15335. */
  15336. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15337. /**
  15338. * Get the quaternion rotation of the bone in either local or world space
  15339. * @param space The space that the rotation should be in
  15340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15341. * @returns The quaternion rotation
  15342. */
  15343. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15344. /**
  15345. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15346. * @param space The space that the rotation should be in
  15347. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15348. * @param result The quaternion that the rotation should be copied to
  15349. */
  15350. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15351. /**
  15352. * Get the rotation matrix of the bone in local or world space
  15353. * @param space The space that the rotation should be in
  15354. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15355. * @returns The rotation matrix
  15356. */
  15357. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15358. /**
  15359. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15360. * @param space The space that the rotation should be in
  15361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15362. * @param result The quaternion that the rotation should be copied to
  15363. */
  15364. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15365. /**
  15366. * Get the world position of a point that is in the local space of the bone
  15367. * @param position The local position
  15368. * @param mesh The mesh that this bone is attached to
  15369. * @returns The world position
  15370. */
  15371. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15372. /**
  15373. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15374. * @param position The local position
  15375. * @param mesh The mesh that this bone is attached to
  15376. * @param result The vector3 that the world position should be copied to
  15377. */
  15378. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15379. /**
  15380. * Get the local position of a point that is in world space
  15381. * @param position The world position
  15382. * @param mesh The mesh that this bone is attached to
  15383. * @returns The local position
  15384. */
  15385. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15386. /**
  15387. * Get the local position of a point that is in world space and copy it to the result param
  15388. * @param position The world position
  15389. * @param mesh The mesh that this bone is attached to
  15390. * @param result The vector3 that the local position should be copied to
  15391. */
  15392. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15393. }
  15394. }
  15395. declare module BABYLON {
  15396. /**
  15397. * Defines a runtime animation
  15398. */
  15399. export class RuntimeAnimation {
  15400. private _events;
  15401. /**
  15402. * The current frame of the runtime animation
  15403. */
  15404. private _currentFrame;
  15405. /**
  15406. * The animation used by the runtime animation
  15407. */
  15408. private _animation;
  15409. /**
  15410. * The target of the runtime animation
  15411. */
  15412. private _target;
  15413. /**
  15414. * The initiating animatable
  15415. */
  15416. private _host;
  15417. /**
  15418. * The original value of the runtime animation
  15419. */
  15420. private _originalValue;
  15421. /**
  15422. * The original blend value of the runtime animation
  15423. */
  15424. private _originalBlendValue;
  15425. /**
  15426. * The offsets cache of the runtime animation
  15427. */
  15428. private _offsetsCache;
  15429. /**
  15430. * The high limits cache of the runtime animation
  15431. */
  15432. private _highLimitsCache;
  15433. /**
  15434. * Specifies if the runtime animation has been stopped
  15435. */
  15436. private _stopped;
  15437. /**
  15438. * The blending factor of the runtime animation
  15439. */
  15440. private _blendingFactor;
  15441. /**
  15442. * The BabylonJS scene
  15443. */
  15444. private _scene;
  15445. /**
  15446. * The current value of the runtime animation
  15447. */
  15448. private _currentValue;
  15449. /** @hidden */
  15450. _animationState: _IAnimationState;
  15451. /**
  15452. * The active target of the runtime animation
  15453. */
  15454. private _activeTargets;
  15455. private _currentActiveTarget;
  15456. private _directTarget;
  15457. /**
  15458. * The target path of the runtime animation
  15459. */
  15460. private _targetPath;
  15461. /**
  15462. * The weight of the runtime animation
  15463. */
  15464. private _weight;
  15465. /**
  15466. * The ratio offset of the runtime animation
  15467. */
  15468. private _ratioOffset;
  15469. /**
  15470. * The previous delay of the runtime animation
  15471. */
  15472. private _previousDelay;
  15473. /**
  15474. * The previous ratio of the runtime animation
  15475. */
  15476. private _previousRatio;
  15477. private _enableBlending;
  15478. private _keys;
  15479. private _minFrame;
  15480. private _maxFrame;
  15481. private _minValue;
  15482. private _maxValue;
  15483. private _targetIsArray;
  15484. /**
  15485. * Gets the current frame of the runtime animation
  15486. */
  15487. get currentFrame(): number;
  15488. /**
  15489. * Gets the weight of the runtime animation
  15490. */
  15491. get weight(): number;
  15492. /**
  15493. * Gets the current value of the runtime animation
  15494. */
  15495. get currentValue(): any;
  15496. /**
  15497. * Gets the target path of the runtime animation
  15498. */
  15499. get targetPath(): string;
  15500. /**
  15501. * Gets the actual target of the runtime animation
  15502. */
  15503. get target(): any;
  15504. /**
  15505. * Gets the additive state of the runtime animation
  15506. */
  15507. get isAdditive(): boolean;
  15508. /** @hidden */
  15509. _onLoop: () => void;
  15510. /**
  15511. * Create a new RuntimeAnimation object
  15512. * @param target defines the target of the animation
  15513. * @param animation defines the source animation object
  15514. * @param scene defines the hosting scene
  15515. * @param host defines the initiating Animatable
  15516. */
  15517. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15518. private _preparePath;
  15519. /**
  15520. * Gets the animation from the runtime animation
  15521. */
  15522. get animation(): Animation;
  15523. /**
  15524. * Resets the runtime animation to the beginning
  15525. * @param restoreOriginal defines whether to restore the target property to the original value
  15526. */
  15527. reset(restoreOriginal?: boolean): void;
  15528. /**
  15529. * Specifies if the runtime animation is stopped
  15530. * @returns Boolean specifying if the runtime animation is stopped
  15531. */
  15532. isStopped(): boolean;
  15533. /**
  15534. * Disposes of the runtime animation
  15535. */
  15536. dispose(): void;
  15537. /**
  15538. * Apply the interpolated value to the target
  15539. * @param currentValue defines the value computed by the animation
  15540. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15541. */
  15542. setValue(currentValue: any, weight: number): void;
  15543. private _getOriginalValues;
  15544. private _setValue;
  15545. /**
  15546. * Gets the loop pmode of the runtime animation
  15547. * @returns Loop Mode
  15548. */
  15549. private _getCorrectLoopMode;
  15550. /**
  15551. * Move the current animation to a given frame
  15552. * @param frame defines the frame to move to
  15553. */
  15554. goToFrame(frame: number): void;
  15555. /**
  15556. * @hidden Internal use only
  15557. */
  15558. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15559. /**
  15560. * Execute the current animation
  15561. * @param delay defines the delay to add to the current frame
  15562. * @param from defines the lower bound of the animation range
  15563. * @param to defines the upper bound of the animation range
  15564. * @param loop defines if the current animation must loop
  15565. * @param speedRatio defines the current speed ratio
  15566. * @param weight defines the weight of the animation (default is -1 so no weight)
  15567. * @param onLoop optional callback called when animation loops
  15568. * @returns a boolean indicating if the animation is running
  15569. */
  15570. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15571. }
  15572. }
  15573. declare module BABYLON {
  15574. /**
  15575. * Class used to store an actual running animation
  15576. */
  15577. export class Animatable {
  15578. /** defines the target object */
  15579. target: any;
  15580. /** defines the starting frame number (default is 0) */
  15581. fromFrame: number;
  15582. /** defines the ending frame number (default is 100) */
  15583. toFrame: number;
  15584. /** defines if the animation must loop (default is false) */
  15585. loopAnimation: boolean;
  15586. /** defines a callback to call when animation ends if it is not looping */
  15587. onAnimationEnd?: (() => void) | null | undefined;
  15588. /** defines a callback to call when animation loops */
  15589. onAnimationLoop?: (() => void) | null | undefined;
  15590. /** defines whether the animation should be evaluated additively */
  15591. isAdditive: boolean;
  15592. private _localDelayOffset;
  15593. private _pausedDelay;
  15594. private _runtimeAnimations;
  15595. private _paused;
  15596. private _scene;
  15597. private _speedRatio;
  15598. private _weight;
  15599. private _syncRoot;
  15600. /**
  15601. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15602. * This will only apply for non looping animation (default is true)
  15603. */
  15604. disposeOnEnd: boolean;
  15605. /**
  15606. * Gets a boolean indicating if the animation has started
  15607. */
  15608. animationStarted: boolean;
  15609. /**
  15610. * Observer raised when the animation ends
  15611. */
  15612. onAnimationEndObservable: Observable<Animatable>;
  15613. /**
  15614. * Observer raised when the animation loops
  15615. */
  15616. onAnimationLoopObservable: Observable<Animatable>;
  15617. /**
  15618. * Gets the root Animatable used to synchronize and normalize animations
  15619. */
  15620. get syncRoot(): Nullable<Animatable>;
  15621. /**
  15622. * Gets the current frame of the first RuntimeAnimation
  15623. * Used to synchronize Animatables
  15624. */
  15625. get masterFrame(): number;
  15626. /**
  15627. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15628. */
  15629. get weight(): number;
  15630. set weight(value: number);
  15631. /**
  15632. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15633. */
  15634. get speedRatio(): number;
  15635. set speedRatio(value: number);
  15636. /**
  15637. * Creates a new Animatable
  15638. * @param scene defines the hosting scene
  15639. * @param target defines the target object
  15640. * @param fromFrame defines the starting frame number (default is 0)
  15641. * @param toFrame defines the ending frame number (default is 100)
  15642. * @param loopAnimation defines if the animation must loop (default is false)
  15643. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15644. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15645. * @param animations defines a group of animation to add to the new Animatable
  15646. * @param onAnimationLoop defines a callback to call when animation loops
  15647. * @param isAdditive defines whether the animation should be evaluated additively
  15648. */
  15649. constructor(scene: Scene,
  15650. /** defines the target object */
  15651. target: any,
  15652. /** defines the starting frame number (default is 0) */
  15653. fromFrame?: number,
  15654. /** defines the ending frame number (default is 100) */
  15655. toFrame?: number,
  15656. /** defines if the animation must loop (default is false) */
  15657. loopAnimation?: boolean, speedRatio?: number,
  15658. /** defines a callback to call when animation ends if it is not looping */
  15659. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15660. /** defines a callback to call when animation loops */
  15661. onAnimationLoop?: (() => void) | null | undefined,
  15662. /** defines whether the animation should be evaluated additively */
  15663. isAdditive?: boolean);
  15664. /**
  15665. * Synchronize and normalize current Animatable with a source Animatable
  15666. * This is useful when using animation weights and when animations are not of the same length
  15667. * @param root defines the root Animatable to synchronize with
  15668. * @returns the current Animatable
  15669. */
  15670. syncWith(root: Animatable): Animatable;
  15671. /**
  15672. * Gets the list of runtime animations
  15673. * @returns an array of RuntimeAnimation
  15674. */
  15675. getAnimations(): RuntimeAnimation[];
  15676. /**
  15677. * Adds more animations to the current animatable
  15678. * @param target defines the target of the animations
  15679. * @param animations defines the new animations to add
  15680. */
  15681. appendAnimations(target: any, animations: Animation[]): void;
  15682. /**
  15683. * Gets the source animation for a specific property
  15684. * @param property defines the propertyu to look for
  15685. * @returns null or the source animation for the given property
  15686. */
  15687. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15688. /**
  15689. * Gets the runtime animation for a specific property
  15690. * @param property defines the propertyu to look for
  15691. * @returns null or the runtime animation for the given property
  15692. */
  15693. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15694. /**
  15695. * Resets the animatable to its original state
  15696. */
  15697. reset(): void;
  15698. /**
  15699. * Allows the animatable to blend with current running animations
  15700. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15701. * @param blendingSpeed defines the blending speed to use
  15702. */
  15703. enableBlending(blendingSpeed: number): void;
  15704. /**
  15705. * Disable animation blending
  15706. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15707. */
  15708. disableBlending(): void;
  15709. /**
  15710. * Jump directly to a given frame
  15711. * @param frame defines the frame to jump to
  15712. */
  15713. goToFrame(frame: number): void;
  15714. /**
  15715. * Pause the animation
  15716. */
  15717. pause(): void;
  15718. /**
  15719. * Restart the animation
  15720. */
  15721. restart(): void;
  15722. private _raiseOnAnimationEnd;
  15723. /**
  15724. * Stop and delete the current animation
  15725. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15726. * @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)
  15727. */
  15728. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15729. /**
  15730. * Wait asynchronously for the animation to end
  15731. * @returns a promise which will be fullfilled when the animation ends
  15732. */
  15733. waitAsync(): Promise<Animatable>;
  15734. /** @hidden */
  15735. _animate(delay: number): boolean;
  15736. }
  15737. interface Scene {
  15738. /** @hidden */
  15739. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15740. /** @hidden */
  15741. _processLateAnimationBindingsForMatrices(holder: {
  15742. totalWeight: number;
  15743. totalAdditiveWeight: number;
  15744. animations: RuntimeAnimation[];
  15745. additiveAnimations: RuntimeAnimation[];
  15746. originalValue: Matrix;
  15747. }): any;
  15748. /** @hidden */
  15749. _processLateAnimationBindingsForQuaternions(holder: {
  15750. totalWeight: number;
  15751. totalAdditiveWeight: number;
  15752. animations: RuntimeAnimation[];
  15753. additiveAnimations: RuntimeAnimation[];
  15754. originalValue: Quaternion;
  15755. }, refQuaternion: Quaternion): Quaternion;
  15756. /** @hidden */
  15757. _processLateAnimationBindings(): void;
  15758. /**
  15759. * Will start the animation sequence of a given target
  15760. * @param target defines the target
  15761. * @param from defines from which frame should animation start
  15762. * @param to defines until which frame should animation run.
  15763. * @param weight defines the weight to apply to the animation (1.0 by default)
  15764. * @param loop defines if the animation loops
  15765. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15766. * @param onAnimationEnd defines the function to be executed when the animation ends
  15767. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15768. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15769. * @param onAnimationLoop defines the callback to call when an animation loops
  15770. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15771. * @returns the animatable object created for this animation
  15772. */
  15773. 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;
  15774. /**
  15775. * Will start the animation sequence of a given target
  15776. * @param target defines the target
  15777. * @param from defines from which frame should animation start
  15778. * @param to defines until which frame should animation run.
  15779. * @param loop defines if the animation loops
  15780. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15781. * @param onAnimationEnd defines the function to be executed when the animation ends
  15782. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15783. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15784. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15785. * @param onAnimationLoop defines the callback to call when an animation loops
  15786. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15787. * @returns the animatable object created for this animation
  15788. */
  15789. 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;
  15790. /**
  15791. * Will start the animation sequence of a given target and its hierarchy
  15792. * @param target defines the target
  15793. * @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.
  15794. * @param from defines from which frame should animation start
  15795. * @param to defines until which frame should animation run.
  15796. * @param loop defines if the animation loops
  15797. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15798. * @param onAnimationEnd defines the function to be executed when the animation ends
  15799. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15800. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15801. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15802. * @param onAnimationLoop defines the callback to call when an animation loops
  15803. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15804. * @returns the list of created animatables
  15805. */
  15806. 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[];
  15807. /**
  15808. * Begin a new animation on a given node
  15809. * @param target defines the target where the animation will take place
  15810. * @param animations defines the list of animations to start
  15811. * @param from defines the initial value
  15812. * @param to defines the final value
  15813. * @param loop defines if you want animation to loop (off by default)
  15814. * @param speedRatio defines the speed ratio to apply to all animations
  15815. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15816. * @param onAnimationLoop defines the callback to call when an animation loops
  15817. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15818. * @returns the list of created animatables
  15819. */
  15820. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15821. /**
  15822. * Begin a new animation on a given node and its hierarchy
  15823. * @param target defines the root node where the animation will take place
  15824. * @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.
  15825. * @param animations defines the list of animations to start
  15826. * @param from defines the initial value
  15827. * @param to defines the final value
  15828. * @param loop defines if you want animation to loop (off by default)
  15829. * @param speedRatio defines the speed ratio to apply to all animations
  15830. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15831. * @param onAnimationLoop defines the callback to call when an animation loops
  15832. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15833. * @returns the list of animatables created for all nodes
  15834. */
  15835. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15836. /**
  15837. * Gets the animatable associated with a specific target
  15838. * @param target defines the target of the animatable
  15839. * @returns the required animatable if found
  15840. */
  15841. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15842. /**
  15843. * Gets all animatables associated with a given target
  15844. * @param target defines the target to look animatables for
  15845. * @returns an array of Animatables
  15846. */
  15847. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15848. /**
  15849. * Stops and removes all animations that have been applied to the scene
  15850. */
  15851. stopAllAnimations(): void;
  15852. /**
  15853. * Gets the current delta time used by animation engine
  15854. */
  15855. deltaTime: number;
  15856. }
  15857. interface Bone {
  15858. /**
  15859. * Copy an animation range from another bone
  15860. * @param source defines the source bone
  15861. * @param rangeName defines the range name to copy
  15862. * @param frameOffset defines the frame offset
  15863. * @param rescaleAsRequired defines if rescaling must be applied if required
  15864. * @param skelDimensionsRatio defines the scaling ratio
  15865. * @returns true if operation was successful
  15866. */
  15867. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15868. }
  15869. }
  15870. declare module BABYLON {
  15871. /**
  15872. * Class used to handle skinning animations
  15873. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15874. */
  15875. export class Skeleton implements IAnimatable {
  15876. /** defines the skeleton name */
  15877. name: string;
  15878. /** defines the skeleton Id */
  15879. id: string;
  15880. /**
  15881. * Defines the list of child bones
  15882. */
  15883. bones: Bone[];
  15884. /**
  15885. * Defines an estimate of the dimension of the skeleton at rest
  15886. */
  15887. dimensionsAtRest: Vector3;
  15888. /**
  15889. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15890. */
  15891. needInitialSkinMatrix: boolean;
  15892. /**
  15893. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15894. */
  15895. overrideMesh: Nullable<AbstractMesh>;
  15896. /**
  15897. * Gets the list of animations attached to this skeleton
  15898. */
  15899. animations: Array<Animation>;
  15900. private _scene;
  15901. private _isDirty;
  15902. private _transformMatrices;
  15903. private _transformMatrixTexture;
  15904. private _meshesWithPoseMatrix;
  15905. private _animatables;
  15906. private _identity;
  15907. private _synchronizedWithMesh;
  15908. private _ranges;
  15909. private _lastAbsoluteTransformsUpdateId;
  15910. private _canUseTextureForBones;
  15911. private _uniqueId;
  15912. /** @hidden */
  15913. _numBonesWithLinkedTransformNode: number;
  15914. /** @hidden */
  15915. _hasWaitingData: Nullable<boolean>;
  15916. /**
  15917. * Specifies if the skeleton should be serialized
  15918. */
  15919. doNotSerialize: boolean;
  15920. private _useTextureToStoreBoneMatrices;
  15921. /**
  15922. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15923. * Please note that this option is not available if the hardware does not support it
  15924. */
  15925. get useTextureToStoreBoneMatrices(): boolean;
  15926. set useTextureToStoreBoneMatrices(value: boolean);
  15927. private _animationPropertiesOverride;
  15928. /**
  15929. * Gets or sets the animation properties override
  15930. */
  15931. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15932. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15933. /**
  15934. * List of inspectable custom properties (used by the Inspector)
  15935. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15936. */
  15937. inspectableCustomProperties: IInspectable[];
  15938. /**
  15939. * An observable triggered before computing the skeleton's matrices
  15940. */
  15941. onBeforeComputeObservable: Observable<Skeleton>;
  15942. /**
  15943. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15944. */
  15945. get isUsingTextureForMatrices(): boolean;
  15946. /**
  15947. * Gets the unique ID of this skeleton
  15948. */
  15949. get uniqueId(): number;
  15950. /**
  15951. * Creates a new skeleton
  15952. * @param name defines the skeleton name
  15953. * @param id defines the skeleton Id
  15954. * @param scene defines the hosting scene
  15955. */
  15956. constructor(
  15957. /** defines the skeleton name */
  15958. name: string,
  15959. /** defines the skeleton Id */
  15960. id: string, scene: Scene);
  15961. /**
  15962. * Gets the current object class name.
  15963. * @return the class name
  15964. */
  15965. getClassName(): string;
  15966. /**
  15967. * Returns an array containing the root bones
  15968. * @returns an array containing the root bones
  15969. */
  15970. getChildren(): Array<Bone>;
  15971. /**
  15972. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15973. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15974. * @returns a Float32Array containing matrices data
  15975. */
  15976. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15977. /**
  15978. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15979. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15980. * @returns a raw texture containing the data
  15981. */
  15982. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15983. /**
  15984. * Gets the current hosting scene
  15985. * @returns a scene object
  15986. */
  15987. getScene(): Scene;
  15988. /**
  15989. * Gets a string representing the current skeleton data
  15990. * @param fullDetails defines a boolean indicating if we want a verbose version
  15991. * @returns a string representing the current skeleton data
  15992. */
  15993. toString(fullDetails?: boolean): string;
  15994. /**
  15995. * Get bone's index searching by name
  15996. * @param name defines bone's name to search for
  15997. * @return the indice of the bone. Returns -1 if not found
  15998. */
  15999. getBoneIndexByName(name: string): number;
  16000. /**
  16001. * Creater a new animation range
  16002. * @param name defines the name of the range
  16003. * @param from defines the start key
  16004. * @param to defines the end key
  16005. */
  16006. createAnimationRange(name: string, from: number, to: number): void;
  16007. /**
  16008. * Delete a specific animation range
  16009. * @param name defines the name of the range
  16010. * @param deleteFrames defines if frames must be removed as well
  16011. */
  16012. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16013. /**
  16014. * Gets a specific animation range
  16015. * @param name defines the name of the range to look for
  16016. * @returns the requested animation range or null if not found
  16017. */
  16018. getAnimationRange(name: string): Nullable<AnimationRange>;
  16019. /**
  16020. * Gets the list of all animation ranges defined on this skeleton
  16021. * @returns an array
  16022. */
  16023. getAnimationRanges(): Nullable<AnimationRange>[];
  16024. /**
  16025. * Copy animation range from a source skeleton.
  16026. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16027. * @param source defines the source skeleton
  16028. * @param name defines the name of the range to copy
  16029. * @param rescaleAsRequired defines if rescaling must be applied if required
  16030. * @returns true if operation was successful
  16031. */
  16032. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16033. /**
  16034. * Forces the skeleton to go to rest pose
  16035. */
  16036. returnToRest(): void;
  16037. private _getHighestAnimationFrame;
  16038. /**
  16039. * Begin a specific animation range
  16040. * @param name defines the name of the range to start
  16041. * @param loop defines if looping must be turned on (false by default)
  16042. * @param speedRatio defines the speed ratio to apply (1 by default)
  16043. * @param onAnimationEnd defines a callback which will be called when animation will end
  16044. * @returns a new animatable
  16045. */
  16046. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16047. /**
  16048. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16049. * @param skeleton defines the Skeleton containing the animation range to convert
  16050. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16051. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16052. * @returns the original skeleton
  16053. */
  16054. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16055. /** @hidden */
  16056. _markAsDirty(): void;
  16057. /** @hidden */
  16058. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16059. /** @hidden */
  16060. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16061. private _computeTransformMatrices;
  16062. /**
  16063. * Build all resources required to render a skeleton
  16064. */
  16065. prepare(): void;
  16066. /**
  16067. * Gets the list of animatables currently running for this skeleton
  16068. * @returns an array of animatables
  16069. */
  16070. getAnimatables(): IAnimatable[];
  16071. /**
  16072. * Clone the current skeleton
  16073. * @param name defines the name of the new skeleton
  16074. * @param id defines the id of the new skeleton
  16075. * @returns the new skeleton
  16076. */
  16077. clone(name: string, id?: string): Skeleton;
  16078. /**
  16079. * Enable animation blending for this skeleton
  16080. * @param blendingSpeed defines the blending speed to apply
  16081. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16082. */
  16083. enableBlending(blendingSpeed?: number): void;
  16084. /**
  16085. * Releases all resources associated with the current skeleton
  16086. */
  16087. dispose(): void;
  16088. /**
  16089. * Serialize the skeleton in a JSON object
  16090. * @returns a JSON object
  16091. */
  16092. serialize(): any;
  16093. /**
  16094. * Creates a new skeleton from serialized data
  16095. * @param parsedSkeleton defines the serialized data
  16096. * @param scene defines the hosting scene
  16097. * @returns a new skeleton
  16098. */
  16099. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16100. /**
  16101. * Compute all node absolute transforms
  16102. * @param forceUpdate defines if computation must be done even if cache is up to date
  16103. */
  16104. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16105. /**
  16106. * Gets the root pose matrix
  16107. * @returns a matrix
  16108. */
  16109. getPoseMatrix(): Nullable<Matrix>;
  16110. /**
  16111. * Sorts bones per internal index
  16112. */
  16113. sortBones(): void;
  16114. private _sortBones;
  16115. }
  16116. }
  16117. declare module BABYLON {
  16118. /**
  16119. * Creates an instance based on a source mesh.
  16120. */
  16121. export class InstancedMesh extends AbstractMesh {
  16122. private _sourceMesh;
  16123. private _currentLOD;
  16124. /** @hidden */
  16125. _indexInSourceMeshInstanceArray: number;
  16126. constructor(name: string, source: Mesh);
  16127. /**
  16128. * Returns the string "InstancedMesh".
  16129. */
  16130. getClassName(): string;
  16131. /** Gets the list of lights affecting that mesh */
  16132. get lightSources(): Light[];
  16133. _resyncLightSources(): void;
  16134. _resyncLightSource(light: Light): void;
  16135. _removeLightSource(light: Light, dispose: boolean): void;
  16136. /**
  16137. * If the source mesh receives shadows
  16138. */
  16139. get receiveShadows(): boolean;
  16140. /**
  16141. * The material of the source mesh
  16142. */
  16143. get material(): Nullable<Material>;
  16144. /**
  16145. * Visibility of the source mesh
  16146. */
  16147. get visibility(): number;
  16148. /**
  16149. * Skeleton of the source mesh
  16150. */
  16151. get skeleton(): Nullable<Skeleton>;
  16152. /**
  16153. * Rendering ground id of the source mesh
  16154. */
  16155. get renderingGroupId(): number;
  16156. set renderingGroupId(value: number);
  16157. /**
  16158. * Returns the total number of vertices (integer).
  16159. */
  16160. getTotalVertices(): number;
  16161. /**
  16162. * Returns a positive integer : the total number of indices in this mesh geometry.
  16163. * @returns the numner of indices or zero if the mesh has no geometry.
  16164. */
  16165. getTotalIndices(): number;
  16166. /**
  16167. * The source mesh of the instance
  16168. */
  16169. get sourceMesh(): Mesh;
  16170. /**
  16171. * Creates a new InstancedMesh object from the mesh model.
  16172. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16173. * @param name defines the name of the new instance
  16174. * @returns a new InstancedMesh
  16175. */
  16176. createInstance(name: string): InstancedMesh;
  16177. /**
  16178. * Is this node ready to be used/rendered
  16179. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16180. * @return {boolean} is it ready
  16181. */
  16182. isReady(completeCheck?: boolean): boolean;
  16183. /**
  16184. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16185. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16186. * @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.
  16187. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16188. */
  16189. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16190. /**
  16191. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16192. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16193. * The `data` are either a numeric array either a Float32Array.
  16194. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16195. * 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).
  16196. * Note that a new underlying VertexBuffer object is created each call.
  16197. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16198. *
  16199. * Possible `kind` values :
  16200. * - VertexBuffer.PositionKind
  16201. * - VertexBuffer.UVKind
  16202. * - VertexBuffer.UV2Kind
  16203. * - VertexBuffer.UV3Kind
  16204. * - VertexBuffer.UV4Kind
  16205. * - VertexBuffer.UV5Kind
  16206. * - VertexBuffer.UV6Kind
  16207. * - VertexBuffer.ColorKind
  16208. * - VertexBuffer.MatricesIndicesKind
  16209. * - VertexBuffer.MatricesIndicesExtraKind
  16210. * - VertexBuffer.MatricesWeightsKind
  16211. * - VertexBuffer.MatricesWeightsExtraKind
  16212. *
  16213. * Returns the Mesh.
  16214. */
  16215. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16216. /**
  16217. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16218. * If the mesh has no geometry, it is simply returned as it is.
  16219. * The `data` are either a numeric array either a Float32Array.
  16220. * No new underlying VertexBuffer object is created.
  16221. * 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.
  16222. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16223. *
  16224. * Possible `kind` values :
  16225. * - VertexBuffer.PositionKind
  16226. * - VertexBuffer.UVKind
  16227. * - VertexBuffer.UV2Kind
  16228. * - VertexBuffer.UV3Kind
  16229. * - VertexBuffer.UV4Kind
  16230. * - VertexBuffer.UV5Kind
  16231. * - VertexBuffer.UV6Kind
  16232. * - VertexBuffer.ColorKind
  16233. * - VertexBuffer.MatricesIndicesKind
  16234. * - VertexBuffer.MatricesIndicesExtraKind
  16235. * - VertexBuffer.MatricesWeightsKind
  16236. * - VertexBuffer.MatricesWeightsExtraKind
  16237. *
  16238. * Returns the Mesh.
  16239. */
  16240. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16241. /**
  16242. * Sets the mesh indices.
  16243. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16244. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16245. * This method creates a new index buffer each call.
  16246. * Returns the Mesh.
  16247. */
  16248. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16249. /**
  16250. * Boolean : True if the mesh owns the requested kind of data.
  16251. */
  16252. isVerticesDataPresent(kind: string): boolean;
  16253. /**
  16254. * Returns an array of indices (IndicesArray).
  16255. */
  16256. getIndices(): Nullable<IndicesArray>;
  16257. get _positions(): Nullable<Vector3[]>;
  16258. /**
  16259. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16260. * This means the mesh underlying bounding box and sphere are recomputed.
  16261. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16262. * @returns the current mesh
  16263. */
  16264. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16265. /** @hidden */
  16266. _preActivate(): InstancedMesh;
  16267. /** @hidden */
  16268. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16269. /** @hidden */
  16270. _postActivate(): void;
  16271. getWorldMatrix(): Matrix;
  16272. get isAnInstance(): boolean;
  16273. /**
  16274. * Returns the current associated LOD AbstractMesh.
  16275. */
  16276. getLOD(camera: Camera): AbstractMesh;
  16277. /** @hidden */
  16278. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16279. /** @hidden */
  16280. _syncSubMeshes(): InstancedMesh;
  16281. /** @hidden */
  16282. _generatePointsArray(): boolean;
  16283. /**
  16284. * Creates a new InstancedMesh from the current mesh.
  16285. * - name (string) : the cloned mesh name
  16286. * - newParent (optional Node) : the optional Node to parent the clone to.
  16287. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16288. *
  16289. * Returns the clone.
  16290. */
  16291. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16292. /**
  16293. * Disposes the InstancedMesh.
  16294. * Returns nothing.
  16295. */
  16296. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16297. }
  16298. interface Mesh {
  16299. /**
  16300. * Register a custom buffer that will be instanced
  16301. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16302. * @param kind defines the buffer kind
  16303. * @param stride defines the stride in floats
  16304. */
  16305. registerInstancedBuffer(kind: string, stride: number): void;
  16306. /**
  16307. * true to use the edge renderer for all instances of this mesh
  16308. */
  16309. edgesShareWithInstances: boolean;
  16310. /** @hidden */
  16311. _userInstancedBuffersStorage: {
  16312. data: {
  16313. [key: string]: Float32Array;
  16314. };
  16315. sizes: {
  16316. [key: string]: number;
  16317. };
  16318. vertexBuffers: {
  16319. [key: string]: Nullable<VertexBuffer>;
  16320. };
  16321. strides: {
  16322. [key: string]: number;
  16323. };
  16324. };
  16325. }
  16326. interface AbstractMesh {
  16327. /**
  16328. * Object used to store instanced buffers defined by user
  16329. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16330. */
  16331. instancedBuffers: {
  16332. [key: string]: any;
  16333. };
  16334. }
  16335. }
  16336. declare module BABYLON {
  16337. /**
  16338. * Defines the options associated with the creation of a shader material.
  16339. */
  16340. export interface IShaderMaterialOptions {
  16341. /**
  16342. * Does the material work in alpha blend mode
  16343. */
  16344. needAlphaBlending: boolean;
  16345. /**
  16346. * Does the material work in alpha test mode
  16347. */
  16348. needAlphaTesting: boolean;
  16349. /**
  16350. * The list of attribute names used in the shader
  16351. */
  16352. attributes: string[];
  16353. /**
  16354. * The list of unifrom names used in the shader
  16355. */
  16356. uniforms: string[];
  16357. /**
  16358. * The list of UBO names used in the shader
  16359. */
  16360. uniformBuffers: string[];
  16361. /**
  16362. * The list of sampler names used in the shader
  16363. */
  16364. samplers: string[];
  16365. /**
  16366. * The list of defines used in the shader
  16367. */
  16368. defines: string[];
  16369. }
  16370. /**
  16371. * 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.
  16372. *
  16373. * This returned material effects how the mesh will look based on the code in the shaders.
  16374. *
  16375. * @see http://doc.babylonjs.com/how_to/shader_material
  16376. */
  16377. export class ShaderMaterial extends Material {
  16378. private _shaderPath;
  16379. private _options;
  16380. private _textures;
  16381. private _textureArrays;
  16382. private _floats;
  16383. private _ints;
  16384. private _floatsArrays;
  16385. private _colors3;
  16386. private _colors3Arrays;
  16387. private _colors4;
  16388. private _colors4Arrays;
  16389. private _vectors2;
  16390. private _vectors3;
  16391. private _vectors4;
  16392. private _matrices;
  16393. private _matrixArrays;
  16394. private _matrices3x3;
  16395. private _matrices2x2;
  16396. private _vectors2Arrays;
  16397. private _vectors3Arrays;
  16398. private _vectors4Arrays;
  16399. private _cachedWorldViewMatrix;
  16400. private _cachedWorldViewProjectionMatrix;
  16401. private _renderId;
  16402. private _multiview;
  16403. private _cachedDefines;
  16404. /** Define the Url to load snippets */
  16405. static SnippetUrl: string;
  16406. /** Snippet ID if the material was created from the snippet server */
  16407. snippetId: string;
  16408. /**
  16409. * Instantiate a new shader material.
  16410. * 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.
  16411. * This returned material effects how the mesh will look based on the code in the shaders.
  16412. * @see http://doc.babylonjs.com/how_to/shader_material
  16413. * @param name Define the name of the material in the scene
  16414. * @param scene Define the scene the material belongs to
  16415. * @param shaderPath Defines the route to the shader code in one of three ways:
  16416. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16417. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16418. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16419. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16420. * @param options Define the options used to create the shader
  16421. */
  16422. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16423. /**
  16424. * Gets the shader path used to define the shader code
  16425. * It can be modified to trigger a new compilation
  16426. */
  16427. get shaderPath(): any;
  16428. /**
  16429. * Sets the shader path used to define the shader code
  16430. * It can be modified to trigger a new compilation
  16431. */
  16432. set shaderPath(shaderPath: any);
  16433. /**
  16434. * Gets the options used to compile the shader.
  16435. * They can be modified to trigger a new compilation
  16436. */
  16437. get options(): IShaderMaterialOptions;
  16438. /**
  16439. * Gets the current class name of the material e.g. "ShaderMaterial"
  16440. * Mainly use in serialization.
  16441. * @returns the class name
  16442. */
  16443. getClassName(): string;
  16444. /**
  16445. * Specifies if the material will require alpha blending
  16446. * @returns a boolean specifying if alpha blending is needed
  16447. */
  16448. needAlphaBlending(): boolean;
  16449. /**
  16450. * Specifies if this material should be rendered in alpha test mode
  16451. * @returns a boolean specifying if an alpha test is needed.
  16452. */
  16453. needAlphaTesting(): boolean;
  16454. private _checkUniform;
  16455. /**
  16456. * Set a texture in the shader.
  16457. * @param name Define the name of the uniform samplers as defined in the shader
  16458. * @param texture Define the texture to bind to this sampler
  16459. * @return the material itself allowing "fluent" like uniform updates
  16460. */
  16461. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16462. /**
  16463. * Set a texture array in the shader.
  16464. * @param name Define the name of the uniform sampler array as defined in the shader
  16465. * @param textures Define the list of textures to bind to this sampler
  16466. * @return the material itself allowing "fluent" like uniform updates
  16467. */
  16468. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16469. /**
  16470. * Set a float in the shader.
  16471. * @param name Define the name of the uniform as defined in the shader
  16472. * @param value Define the value to give to the uniform
  16473. * @return the material itself allowing "fluent" like uniform updates
  16474. */
  16475. setFloat(name: string, value: number): ShaderMaterial;
  16476. /**
  16477. * Set a int in the shader.
  16478. * @param name Define the name of the uniform as defined in the shader
  16479. * @param value Define the value to give to the uniform
  16480. * @return the material itself allowing "fluent" like uniform updates
  16481. */
  16482. setInt(name: string, value: number): ShaderMaterial;
  16483. /**
  16484. * Set an array of floats in the shader.
  16485. * @param name Define the name of the uniform as defined in the shader
  16486. * @param value Define the value to give to the uniform
  16487. * @return the material itself allowing "fluent" like uniform updates
  16488. */
  16489. setFloats(name: string, value: number[]): ShaderMaterial;
  16490. /**
  16491. * Set a vec3 in the shader from a Color3.
  16492. * @param name Define the name of the uniform as defined in the shader
  16493. * @param value Define the value to give to the uniform
  16494. * @return the material itself allowing "fluent" like uniform updates
  16495. */
  16496. setColor3(name: string, value: Color3): ShaderMaterial;
  16497. /**
  16498. * Set a vec3 array in the shader from a Color3 array.
  16499. * @param name Define the name of the uniform as defined in the shader
  16500. * @param value Define the value to give to the uniform
  16501. * @return the material itself allowing "fluent" like uniform updates
  16502. */
  16503. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16504. /**
  16505. * Set a vec4 in the shader from a Color4.
  16506. * @param name Define the name of the uniform as defined in the shader
  16507. * @param value Define the value to give to the uniform
  16508. * @return the material itself allowing "fluent" like uniform updates
  16509. */
  16510. setColor4(name: string, value: Color4): ShaderMaterial;
  16511. /**
  16512. * Set a vec4 array in the shader from a Color4 array.
  16513. * @param name Define the name of the uniform as defined in the shader
  16514. * @param value Define the value to give to the uniform
  16515. * @return the material itself allowing "fluent" like uniform updates
  16516. */
  16517. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16518. /**
  16519. * Set a vec2 in the shader from a Vector2.
  16520. * @param name Define the name of the uniform as defined in the shader
  16521. * @param value Define the value to give to the uniform
  16522. * @return the material itself allowing "fluent" like uniform updates
  16523. */
  16524. setVector2(name: string, value: Vector2): ShaderMaterial;
  16525. /**
  16526. * Set a vec3 in the shader from a Vector3.
  16527. * @param name Define the name of the uniform as defined in the shader
  16528. * @param value Define the value to give to the uniform
  16529. * @return the material itself allowing "fluent" like uniform updates
  16530. */
  16531. setVector3(name: string, value: Vector3): ShaderMaterial;
  16532. /**
  16533. * Set a vec4 in the shader from a Vector4.
  16534. * @param name Define the name of the uniform as defined in the shader
  16535. * @param value Define the value to give to the uniform
  16536. * @return the material itself allowing "fluent" like uniform updates
  16537. */
  16538. setVector4(name: string, value: Vector4): ShaderMaterial;
  16539. /**
  16540. * Set a mat4 in the shader from a Matrix.
  16541. * @param name Define the name of the uniform as defined in the shader
  16542. * @param value Define the value to give to the uniform
  16543. * @return the material itself allowing "fluent" like uniform updates
  16544. */
  16545. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16546. /**
  16547. * Set a float32Array in the shader from a matrix array.
  16548. * @param name Define the name of the uniform as defined in the shader
  16549. * @param value Define the value to give to the uniform
  16550. * @return the material itself allowing "fluent" like uniform updates
  16551. */
  16552. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16553. /**
  16554. * Set a mat3 in the shader from a Float32Array.
  16555. * @param name Define the name of the uniform as defined in the shader
  16556. * @param value Define the value to give to the uniform
  16557. * @return the material itself allowing "fluent" like uniform updates
  16558. */
  16559. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16560. /**
  16561. * Set a mat2 in the shader from a Float32Array.
  16562. * @param name Define the name of the uniform as defined in the shader
  16563. * @param value Define the value to give to the uniform
  16564. * @return the material itself allowing "fluent" like uniform updates
  16565. */
  16566. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16567. /**
  16568. * Set a vec2 array in the shader from a number array.
  16569. * @param name Define the name of the uniform as defined in the shader
  16570. * @param value Define the value to give to the uniform
  16571. * @return the material itself allowing "fluent" like uniform updates
  16572. */
  16573. setArray2(name: string, value: number[]): ShaderMaterial;
  16574. /**
  16575. * Set a vec3 array in the shader from a number array.
  16576. * @param name Define the name of the uniform as defined in the shader
  16577. * @param value Define the value to give to the uniform
  16578. * @return the material itself allowing "fluent" like uniform updates
  16579. */
  16580. setArray3(name: string, value: number[]): ShaderMaterial;
  16581. /**
  16582. * Set a vec4 array in the shader from a number array.
  16583. * @param name Define the name of the uniform as defined in the shader
  16584. * @param value Define the value to give to the uniform
  16585. * @return the material itself allowing "fluent" like uniform updates
  16586. */
  16587. setArray4(name: string, value: number[]): ShaderMaterial;
  16588. private _checkCache;
  16589. /**
  16590. * Specifies that the submesh is ready to be used
  16591. * @param mesh defines the mesh to check
  16592. * @param subMesh defines which submesh to check
  16593. * @param useInstances specifies that instances should be used
  16594. * @returns a boolean indicating that the submesh is ready or not
  16595. */
  16596. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16597. /**
  16598. * Checks if the material is ready to render the requested mesh
  16599. * @param mesh Define the mesh to render
  16600. * @param useInstances Define whether or not the material is used with instances
  16601. * @returns true if ready, otherwise false
  16602. */
  16603. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16604. /**
  16605. * Binds the world matrix to the material
  16606. * @param world defines the world transformation matrix
  16607. * @param effectOverride - If provided, use this effect instead of internal effect
  16608. */
  16609. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16610. /**
  16611. * Binds the submesh to this material by preparing the effect and shader to draw
  16612. * @param world defines the world transformation matrix
  16613. * @param mesh defines the mesh containing the submesh
  16614. * @param subMesh defines the submesh to bind the material to
  16615. */
  16616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16617. /**
  16618. * Binds the material to the mesh
  16619. * @param world defines the world transformation matrix
  16620. * @param mesh defines the mesh to bind the material to
  16621. * @param effectOverride - If provided, use this effect instead of internal effect
  16622. */
  16623. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16624. protected _afterBind(mesh?: Mesh): void;
  16625. /**
  16626. * Gets the active textures from the material
  16627. * @returns an array of textures
  16628. */
  16629. getActiveTextures(): BaseTexture[];
  16630. /**
  16631. * Specifies if the material uses a texture
  16632. * @param texture defines the texture to check against the material
  16633. * @returns a boolean specifying if the material uses the texture
  16634. */
  16635. hasTexture(texture: BaseTexture): boolean;
  16636. /**
  16637. * Makes a duplicate of the material, and gives it a new name
  16638. * @param name defines the new name for the duplicated material
  16639. * @returns the cloned material
  16640. */
  16641. clone(name: string): ShaderMaterial;
  16642. /**
  16643. * Disposes the material
  16644. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16645. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16646. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16647. */
  16648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16649. /**
  16650. * Serializes this material in a JSON representation
  16651. * @returns the serialized material object
  16652. */
  16653. serialize(): any;
  16654. /**
  16655. * Creates a shader material from parsed shader material data
  16656. * @param source defines the JSON represnetation of the material
  16657. * @param scene defines the hosting scene
  16658. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16659. * @returns a new material
  16660. */
  16661. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16662. /**
  16663. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16664. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16665. * @param url defines the url to load from
  16666. * @param scene defines the hosting scene
  16667. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16668. * @returns a promise that will resolve to the new ShaderMaterial
  16669. */
  16670. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16671. /**
  16672. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16673. * @param snippetId defines the snippet to load
  16674. * @param scene defines the hosting scene
  16675. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16676. * @returns a promise that will resolve to the new ShaderMaterial
  16677. */
  16678. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16679. }
  16680. }
  16681. declare module BABYLON {
  16682. /** @hidden */
  16683. export var colorPixelShader: {
  16684. name: string;
  16685. shader: string;
  16686. };
  16687. }
  16688. declare module BABYLON {
  16689. /** @hidden */
  16690. export var colorVertexShader: {
  16691. name: string;
  16692. shader: string;
  16693. };
  16694. }
  16695. declare module BABYLON {
  16696. /**
  16697. * Line mesh
  16698. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16699. */
  16700. export class LinesMesh extends Mesh {
  16701. /**
  16702. * If vertex color should be applied to the mesh
  16703. */
  16704. readonly useVertexColor?: boolean | undefined;
  16705. /**
  16706. * If vertex alpha should be applied to the mesh
  16707. */
  16708. readonly useVertexAlpha?: boolean | undefined;
  16709. /**
  16710. * Color of the line (Default: White)
  16711. */
  16712. color: Color3;
  16713. /**
  16714. * Alpha of the line (Default: 1)
  16715. */
  16716. alpha: number;
  16717. /**
  16718. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16719. * This margin is expressed in world space coordinates, so its value may vary.
  16720. * Default value is 0.1
  16721. */
  16722. intersectionThreshold: number;
  16723. private _colorShader;
  16724. private color4;
  16725. /**
  16726. * Creates a new LinesMesh
  16727. * @param name defines the name
  16728. * @param scene defines the hosting scene
  16729. * @param parent defines the parent mesh if any
  16730. * @param source defines the optional source LinesMesh used to clone data from
  16731. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16732. * When false, achieved by calling a clone(), also passing False.
  16733. * This will make creation of children, recursive.
  16734. * @param useVertexColor defines if this LinesMesh supports vertex color
  16735. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16736. */
  16737. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16738. /**
  16739. * If vertex color should be applied to the mesh
  16740. */
  16741. useVertexColor?: boolean | undefined,
  16742. /**
  16743. * If vertex alpha should be applied to the mesh
  16744. */
  16745. useVertexAlpha?: boolean | undefined);
  16746. private _addClipPlaneDefine;
  16747. private _removeClipPlaneDefine;
  16748. isReady(): boolean;
  16749. /**
  16750. * Returns the string "LineMesh"
  16751. */
  16752. getClassName(): string;
  16753. /**
  16754. * @hidden
  16755. */
  16756. get material(): Material;
  16757. /**
  16758. * @hidden
  16759. */
  16760. set material(value: Material);
  16761. /**
  16762. * @hidden
  16763. */
  16764. get checkCollisions(): boolean;
  16765. /** @hidden */
  16766. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16767. /** @hidden */
  16768. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16769. /**
  16770. * Disposes of the line mesh
  16771. * @param doNotRecurse If children should be disposed
  16772. */
  16773. dispose(doNotRecurse?: boolean): void;
  16774. /**
  16775. * Returns a new LineMesh object cloned from the current one.
  16776. */
  16777. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16778. /**
  16779. * Creates a new InstancedLinesMesh object from the mesh model.
  16780. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16781. * @param name defines the name of the new instance
  16782. * @returns a new InstancedLinesMesh
  16783. */
  16784. createInstance(name: string): InstancedLinesMesh;
  16785. }
  16786. /**
  16787. * Creates an instance based on a source LinesMesh
  16788. */
  16789. export class InstancedLinesMesh extends InstancedMesh {
  16790. /**
  16791. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16792. * This margin is expressed in world space coordinates, so its value may vary.
  16793. * Initilized with the intersectionThreshold value of the source LinesMesh
  16794. */
  16795. intersectionThreshold: number;
  16796. constructor(name: string, source: LinesMesh);
  16797. /**
  16798. * Returns the string "InstancedLinesMesh".
  16799. */
  16800. getClassName(): string;
  16801. }
  16802. }
  16803. declare module BABYLON {
  16804. /** @hidden */
  16805. export var linePixelShader: {
  16806. name: string;
  16807. shader: string;
  16808. };
  16809. }
  16810. declare module BABYLON {
  16811. /** @hidden */
  16812. export var lineVertexShader: {
  16813. name: string;
  16814. shader: string;
  16815. };
  16816. }
  16817. declare module BABYLON {
  16818. interface Scene {
  16819. /** @hidden */
  16820. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16821. }
  16822. interface AbstractMesh {
  16823. /**
  16824. * Gets the edgesRenderer associated with the mesh
  16825. */
  16826. edgesRenderer: Nullable<EdgesRenderer>;
  16827. }
  16828. interface LinesMesh {
  16829. /**
  16830. * Enables the edge rendering mode on the mesh.
  16831. * This mode makes the mesh edges visible
  16832. * @param epsilon defines the maximal distance between two angles to detect a face
  16833. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16834. * @returns the currentAbstractMesh
  16835. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16836. */
  16837. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16838. }
  16839. interface InstancedLinesMesh {
  16840. /**
  16841. * Enables the edge rendering mode on the mesh.
  16842. * This mode makes the mesh edges visible
  16843. * @param epsilon defines the maximal distance between two angles to detect a face
  16844. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16845. * @returns the current InstancedLinesMesh
  16846. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16847. */
  16848. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16849. }
  16850. /**
  16851. * Defines the minimum contract an Edges renderer should follow.
  16852. */
  16853. export interface IEdgesRenderer extends IDisposable {
  16854. /**
  16855. * Gets or sets a boolean indicating if the edgesRenderer is active
  16856. */
  16857. isEnabled: boolean;
  16858. /**
  16859. * Renders the edges of the attached mesh,
  16860. */
  16861. render(): void;
  16862. /**
  16863. * Checks wether or not the edges renderer is ready to render.
  16864. * @return true if ready, otherwise false.
  16865. */
  16866. isReady(): boolean;
  16867. /**
  16868. * List of instances to render in case the source mesh has instances
  16869. */
  16870. customInstances: SmartArray<Matrix>;
  16871. }
  16872. /**
  16873. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16874. */
  16875. export class EdgesRenderer implements IEdgesRenderer {
  16876. /**
  16877. * Define the size of the edges with an orthographic camera
  16878. */
  16879. edgesWidthScalerForOrthographic: number;
  16880. /**
  16881. * Define the size of the edges with a perspective camera
  16882. */
  16883. edgesWidthScalerForPerspective: number;
  16884. protected _source: AbstractMesh;
  16885. protected _linesPositions: number[];
  16886. protected _linesNormals: number[];
  16887. protected _linesIndices: number[];
  16888. protected _epsilon: number;
  16889. protected _indicesCount: number;
  16890. protected _lineShader: ShaderMaterial;
  16891. protected _ib: DataBuffer;
  16892. protected _buffers: {
  16893. [key: string]: Nullable<VertexBuffer>;
  16894. };
  16895. protected _buffersForInstances: {
  16896. [key: string]: Nullable<VertexBuffer>;
  16897. };
  16898. protected _checkVerticesInsteadOfIndices: boolean;
  16899. private _meshRebuildObserver;
  16900. private _meshDisposeObserver;
  16901. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16902. isEnabled: boolean;
  16903. /**
  16904. * List of instances to render in case the source mesh has instances
  16905. */
  16906. customInstances: SmartArray<Matrix>;
  16907. private static GetShader;
  16908. /**
  16909. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16910. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16911. * @param source Mesh used to create edges
  16912. * @param epsilon sum of angles in adjacency to check for edge
  16913. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16914. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16915. */
  16916. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16917. protected _prepareRessources(): void;
  16918. /** @hidden */
  16919. _rebuild(): void;
  16920. /**
  16921. * Releases the required resources for the edges renderer
  16922. */
  16923. dispose(): void;
  16924. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16925. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16926. /**
  16927. * Checks if the pair of p0 and p1 is en edge
  16928. * @param faceIndex
  16929. * @param edge
  16930. * @param faceNormals
  16931. * @param p0
  16932. * @param p1
  16933. * @private
  16934. */
  16935. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16936. /**
  16937. * push line into the position, normal and index buffer
  16938. * @protected
  16939. */
  16940. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16941. /**
  16942. * Generates lines edges from adjacencjes
  16943. * @private
  16944. */
  16945. _generateEdgesLines(): void;
  16946. /**
  16947. * Checks wether or not the edges renderer is ready to render.
  16948. * @return true if ready, otherwise false.
  16949. */
  16950. isReady(): boolean;
  16951. /**
  16952. * Renders the edges of the attached mesh,
  16953. */
  16954. render(): void;
  16955. }
  16956. /**
  16957. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16958. */
  16959. export class LineEdgesRenderer extends EdgesRenderer {
  16960. /**
  16961. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16962. * @param source LineMesh used to generate edges
  16963. * @param epsilon not important (specified angle for edge detection)
  16964. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16965. */
  16966. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16967. /**
  16968. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16969. */
  16970. _generateEdgesLines(): void;
  16971. }
  16972. }
  16973. declare module BABYLON {
  16974. /**
  16975. * This represents the object necessary to create a rendering group.
  16976. * This is exclusively used and created by the rendering manager.
  16977. * To modify the behavior, you use the available helpers in your scene or meshes.
  16978. * @hidden
  16979. */
  16980. export class RenderingGroup {
  16981. index: number;
  16982. private static _zeroVector;
  16983. private _scene;
  16984. private _opaqueSubMeshes;
  16985. private _transparentSubMeshes;
  16986. private _alphaTestSubMeshes;
  16987. private _depthOnlySubMeshes;
  16988. private _particleSystems;
  16989. private _spriteManagers;
  16990. private _opaqueSortCompareFn;
  16991. private _alphaTestSortCompareFn;
  16992. private _transparentSortCompareFn;
  16993. private _renderOpaque;
  16994. private _renderAlphaTest;
  16995. private _renderTransparent;
  16996. /** @hidden */
  16997. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16998. onBeforeTransparentRendering: () => void;
  16999. /**
  17000. * Set the opaque sort comparison function.
  17001. * If null the sub meshes will be render in the order they were created
  17002. */
  17003. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17004. /**
  17005. * Set the alpha test sort comparison function.
  17006. * If null the sub meshes will be render in the order they were created
  17007. */
  17008. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17009. /**
  17010. * Set the transparent sort comparison function.
  17011. * If null the sub meshes will be render in the order they were created
  17012. */
  17013. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17014. /**
  17015. * Creates a new rendering group.
  17016. * @param index The rendering group index
  17017. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17018. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17019. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17020. */
  17021. 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>);
  17022. /**
  17023. * Render all the sub meshes contained in the group.
  17024. * @param customRenderFunction Used to override the default render behaviour of the group.
  17025. * @returns true if rendered some submeshes.
  17026. */
  17027. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17028. /**
  17029. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17030. * @param subMeshes The submeshes to render
  17031. */
  17032. private renderOpaqueSorted;
  17033. /**
  17034. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17035. * @param subMeshes The submeshes to render
  17036. */
  17037. private renderAlphaTestSorted;
  17038. /**
  17039. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17040. * @param subMeshes The submeshes to render
  17041. */
  17042. private renderTransparentSorted;
  17043. /**
  17044. * Renders the submeshes in a specified order.
  17045. * @param subMeshes The submeshes to sort before render
  17046. * @param sortCompareFn The comparison function use to sort
  17047. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17048. * @param transparent Specifies to activate blending if true
  17049. */
  17050. private static renderSorted;
  17051. /**
  17052. * Renders the submeshes in the order they were dispatched (no sort applied).
  17053. * @param subMeshes The submeshes to render
  17054. */
  17055. private static renderUnsorted;
  17056. /**
  17057. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17058. * are rendered back to front if in the same alpha index.
  17059. *
  17060. * @param a The first submesh
  17061. * @param b The second submesh
  17062. * @returns The result of the comparison
  17063. */
  17064. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17065. /**
  17066. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17067. * are rendered back to front.
  17068. *
  17069. * @param a The first submesh
  17070. * @param b The second submesh
  17071. * @returns The result of the comparison
  17072. */
  17073. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17074. /**
  17075. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17076. * are rendered front to back (prevent overdraw).
  17077. *
  17078. * @param a The first submesh
  17079. * @param b The second submesh
  17080. * @returns The result of the comparison
  17081. */
  17082. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17083. /**
  17084. * Resets the different lists of submeshes to prepare a new frame.
  17085. */
  17086. prepare(): void;
  17087. dispose(): void;
  17088. /**
  17089. * Inserts the submesh in its correct queue depending on its material.
  17090. * @param subMesh The submesh to dispatch
  17091. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17092. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17093. */
  17094. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17095. dispatchSprites(spriteManager: ISpriteManager): void;
  17096. dispatchParticles(particleSystem: IParticleSystem): void;
  17097. private _renderParticles;
  17098. private _renderSprites;
  17099. }
  17100. }
  17101. declare module BABYLON {
  17102. /**
  17103. * Interface describing the different options available in the rendering manager
  17104. * regarding Auto Clear between groups.
  17105. */
  17106. export interface IRenderingManagerAutoClearSetup {
  17107. /**
  17108. * Defines whether or not autoclear is enable.
  17109. */
  17110. autoClear: boolean;
  17111. /**
  17112. * Defines whether or not to autoclear the depth buffer.
  17113. */
  17114. depth: boolean;
  17115. /**
  17116. * Defines whether or not to autoclear the stencil buffer.
  17117. */
  17118. stencil: boolean;
  17119. }
  17120. /**
  17121. * This class is used by the onRenderingGroupObservable
  17122. */
  17123. export class RenderingGroupInfo {
  17124. /**
  17125. * The Scene that being rendered
  17126. */
  17127. scene: Scene;
  17128. /**
  17129. * The camera currently used for the rendering pass
  17130. */
  17131. camera: Nullable<Camera>;
  17132. /**
  17133. * The ID of the renderingGroup being processed
  17134. */
  17135. renderingGroupId: number;
  17136. }
  17137. /**
  17138. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17139. * It is enable to manage the different groups as well as the different necessary sort functions.
  17140. * This should not be used directly aside of the few static configurations
  17141. */
  17142. export class RenderingManager {
  17143. /**
  17144. * The max id used for rendering groups (not included)
  17145. */
  17146. static MAX_RENDERINGGROUPS: number;
  17147. /**
  17148. * The min id used for rendering groups (included)
  17149. */
  17150. static MIN_RENDERINGGROUPS: number;
  17151. /**
  17152. * Used to globally prevent autoclearing scenes.
  17153. */
  17154. static AUTOCLEAR: boolean;
  17155. /**
  17156. * @hidden
  17157. */
  17158. _useSceneAutoClearSetup: boolean;
  17159. private _scene;
  17160. private _renderingGroups;
  17161. private _depthStencilBufferAlreadyCleaned;
  17162. private _autoClearDepthStencil;
  17163. private _customOpaqueSortCompareFn;
  17164. private _customAlphaTestSortCompareFn;
  17165. private _customTransparentSortCompareFn;
  17166. private _renderingGroupInfo;
  17167. /**
  17168. * Instantiates a new rendering group for a particular scene
  17169. * @param scene Defines the scene the groups belongs to
  17170. */
  17171. constructor(scene: Scene);
  17172. private _clearDepthStencilBuffer;
  17173. /**
  17174. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17175. * @hidden
  17176. */
  17177. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17178. /**
  17179. * Resets the different information of the group to prepare a new frame
  17180. * @hidden
  17181. */
  17182. reset(): void;
  17183. /**
  17184. * Dispose and release the group and its associated resources.
  17185. * @hidden
  17186. */
  17187. dispose(): void;
  17188. /**
  17189. * Clear the info related to rendering groups preventing retention points during dispose.
  17190. */
  17191. freeRenderingGroups(): void;
  17192. private _prepareRenderingGroup;
  17193. /**
  17194. * Add a sprite manager to the rendering manager in order to render it this frame.
  17195. * @param spriteManager Define the sprite manager to render
  17196. */
  17197. dispatchSprites(spriteManager: ISpriteManager): void;
  17198. /**
  17199. * Add a particle system to the rendering manager in order to render it this frame.
  17200. * @param particleSystem Define the particle system to render
  17201. */
  17202. dispatchParticles(particleSystem: IParticleSystem): void;
  17203. /**
  17204. * Add a submesh to the manager in order to render it this frame
  17205. * @param subMesh The submesh to dispatch
  17206. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17207. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17208. */
  17209. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17210. /**
  17211. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17212. * This allowed control for front to back rendering or reversly depending of the special needs.
  17213. *
  17214. * @param renderingGroupId The rendering group id corresponding to its index
  17215. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17216. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17217. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17218. */
  17219. 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;
  17220. /**
  17221. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17222. *
  17223. * @param renderingGroupId The rendering group id corresponding to its index
  17224. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17225. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17226. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17227. */
  17228. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17229. /**
  17230. * Gets the current auto clear configuration for one rendering group of the rendering
  17231. * manager.
  17232. * @param index the rendering group index to get the information for
  17233. * @returns The auto clear setup for the requested rendering group
  17234. */
  17235. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17236. }
  17237. }
  17238. declare module BABYLON {
  17239. /**
  17240. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17241. */
  17242. export interface ICustomShaderOptions {
  17243. /**
  17244. * Gets or sets the custom shader name to use
  17245. */
  17246. shaderName: string;
  17247. /**
  17248. * The list of attribute names used in the shader
  17249. */
  17250. attributes?: string[];
  17251. /**
  17252. * The list of unifrom names used in the shader
  17253. */
  17254. uniforms?: string[];
  17255. /**
  17256. * The list of sampler names used in the shader
  17257. */
  17258. samplers?: string[];
  17259. /**
  17260. * The list of defines used in the shader
  17261. */
  17262. defines?: string[];
  17263. }
  17264. /**
  17265. * Interface to implement to create a shadow generator compatible with BJS.
  17266. */
  17267. export interface IShadowGenerator {
  17268. /**
  17269. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17270. * @returns The render target texture if present otherwise, null
  17271. */
  17272. getShadowMap(): Nullable<RenderTargetTexture>;
  17273. /**
  17274. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17275. * @param subMesh The submesh we want to render in the shadow map
  17276. * @param useInstances Defines wether will draw in the map using instances
  17277. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17278. * @returns true if ready otherwise, false
  17279. */
  17280. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17281. /**
  17282. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17283. * @param defines Defines of the material we want to update
  17284. * @param lightIndex Index of the light in the enabled light list of the material
  17285. */
  17286. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17287. /**
  17288. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17289. * defined in the generator but impacting the effect).
  17290. * It implies the unifroms available on the materials are the standard BJS ones.
  17291. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17292. * @param effect The effect we are binfing the information for
  17293. */
  17294. bindShadowLight(lightIndex: string, effect: Effect): void;
  17295. /**
  17296. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17297. * (eq to shadow prjection matrix * light transform matrix)
  17298. * @returns The transform matrix used to create the shadow map
  17299. */
  17300. getTransformMatrix(): Matrix;
  17301. /**
  17302. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17303. * Cube and 2D textures for instance.
  17304. */
  17305. recreateShadowMap(): void;
  17306. /**
  17307. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17308. * @param onCompiled Callback triggered at the and of the effects compilation
  17309. * @param options Sets of optional options forcing the compilation with different modes
  17310. */
  17311. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17312. useInstances: boolean;
  17313. }>): void;
  17314. /**
  17315. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17316. * @param options Sets of optional options forcing the compilation with different modes
  17317. * @returns A promise that resolves when the compilation completes
  17318. */
  17319. forceCompilationAsync(options?: Partial<{
  17320. useInstances: boolean;
  17321. }>): Promise<void>;
  17322. /**
  17323. * Serializes the shadow generator setup to a json object.
  17324. * @returns The serialized JSON object
  17325. */
  17326. serialize(): any;
  17327. /**
  17328. * Disposes the Shadow map and related Textures and effects.
  17329. */
  17330. dispose(): void;
  17331. }
  17332. /**
  17333. * Default implementation IShadowGenerator.
  17334. * This is the main object responsible of generating shadows in the framework.
  17335. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17336. */
  17337. export class ShadowGenerator implements IShadowGenerator {
  17338. /**
  17339. * Name of the shadow generator class
  17340. */
  17341. static CLASSNAME: string;
  17342. /**
  17343. * Shadow generator mode None: no filtering applied.
  17344. */
  17345. static readonly FILTER_NONE: number;
  17346. /**
  17347. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17348. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17349. */
  17350. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17351. /**
  17352. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17353. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17354. */
  17355. static readonly FILTER_POISSONSAMPLING: number;
  17356. /**
  17357. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17358. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17359. */
  17360. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17361. /**
  17362. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17363. * edge artifacts on steep falloff.
  17364. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17365. */
  17366. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17367. /**
  17368. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17369. * edge artifacts on steep falloff.
  17370. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17371. */
  17372. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17373. /**
  17374. * Shadow generator mode PCF: Percentage Closer Filtering
  17375. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17376. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17377. */
  17378. static readonly FILTER_PCF: number;
  17379. /**
  17380. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17381. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17382. * Contact Hardening
  17383. */
  17384. static readonly FILTER_PCSS: number;
  17385. /**
  17386. * Reserved for PCF and PCSS
  17387. * Highest Quality.
  17388. *
  17389. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17390. *
  17391. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17392. */
  17393. static readonly QUALITY_HIGH: number;
  17394. /**
  17395. * Reserved for PCF and PCSS
  17396. * Good tradeoff for quality/perf cross devices
  17397. *
  17398. * Execute PCF on a 3*3 kernel.
  17399. *
  17400. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17401. */
  17402. static readonly QUALITY_MEDIUM: number;
  17403. /**
  17404. * Reserved for PCF and PCSS
  17405. * The lowest quality but the fastest.
  17406. *
  17407. * Execute PCF on a 1*1 kernel.
  17408. *
  17409. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17410. */
  17411. static readonly QUALITY_LOW: number;
  17412. /** Gets or sets the custom shader name to use */
  17413. customShaderOptions: ICustomShaderOptions;
  17414. /**
  17415. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17416. */
  17417. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17418. /**
  17419. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17420. */
  17421. onAfterShadowMapRenderObservable: Observable<Effect>;
  17422. /**
  17423. * Observable triggered before a mesh is rendered in the shadow map.
  17424. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17425. */
  17426. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17427. /**
  17428. * Observable triggered after a mesh is rendered in the shadow map.
  17429. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17430. */
  17431. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17432. protected _bias: number;
  17433. /**
  17434. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17435. */
  17436. get bias(): number;
  17437. /**
  17438. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17439. */
  17440. set bias(bias: number);
  17441. protected _normalBias: number;
  17442. /**
  17443. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17444. */
  17445. get normalBias(): number;
  17446. /**
  17447. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17448. */
  17449. set normalBias(normalBias: number);
  17450. protected _blurBoxOffset: number;
  17451. /**
  17452. * Gets the blur box offset: offset applied during the blur pass.
  17453. * Only useful if useKernelBlur = false
  17454. */
  17455. get blurBoxOffset(): number;
  17456. /**
  17457. * Sets the blur box offset: offset applied during the blur pass.
  17458. * Only useful if useKernelBlur = false
  17459. */
  17460. set blurBoxOffset(value: number);
  17461. protected _blurScale: number;
  17462. /**
  17463. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17464. * 2 means half of the size.
  17465. */
  17466. get blurScale(): number;
  17467. /**
  17468. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17469. * 2 means half of the size.
  17470. */
  17471. set blurScale(value: number);
  17472. protected _blurKernel: number;
  17473. /**
  17474. * Gets the blur kernel: kernel size of the blur pass.
  17475. * Only useful if useKernelBlur = true
  17476. */
  17477. get blurKernel(): number;
  17478. /**
  17479. * Sets the blur kernel: kernel size of the blur pass.
  17480. * Only useful if useKernelBlur = true
  17481. */
  17482. set blurKernel(value: number);
  17483. protected _useKernelBlur: boolean;
  17484. /**
  17485. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17486. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17487. */
  17488. get useKernelBlur(): boolean;
  17489. /**
  17490. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17491. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17492. */
  17493. set useKernelBlur(value: boolean);
  17494. protected _depthScale: number;
  17495. /**
  17496. * Gets the depth scale used in ESM mode.
  17497. */
  17498. get depthScale(): number;
  17499. /**
  17500. * Sets the depth scale used in ESM mode.
  17501. * This can override the scale stored on the light.
  17502. */
  17503. set depthScale(value: number);
  17504. protected _validateFilter(filter: number): number;
  17505. protected _filter: number;
  17506. /**
  17507. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17508. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17509. */
  17510. get filter(): number;
  17511. /**
  17512. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17513. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17514. */
  17515. set filter(value: number);
  17516. /**
  17517. * Gets if the current filter is set to Poisson Sampling.
  17518. */
  17519. get usePoissonSampling(): boolean;
  17520. /**
  17521. * Sets the current filter to Poisson Sampling.
  17522. */
  17523. set usePoissonSampling(value: boolean);
  17524. /**
  17525. * Gets if the current filter is set to ESM.
  17526. */
  17527. get useExponentialShadowMap(): boolean;
  17528. /**
  17529. * Sets the current filter is to ESM.
  17530. */
  17531. set useExponentialShadowMap(value: boolean);
  17532. /**
  17533. * Gets if the current filter is set to filtered ESM.
  17534. */
  17535. get useBlurExponentialShadowMap(): boolean;
  17536. /**
  17537. * Gets if the current filter is set to filtered ESM.
  17538. */
  17539. set useBlurExponentialShadowMap(value: boolean);
  17540. /**
  17541. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17542. * exponential to prevent steep falloff artifacts).
  17543. */
  17544. get useCloseExponentialShadowMap(): boolean;
  17545. /**
  17546. * Sets the current filter to "close ESM" (using the inverse of the
  17547. * exponential to prevent steep falloff artifacts).
  17548. */
  17549. set useCloseExponentialShadowMap(value: boolean);
  17550. /**
  17551. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17552. * exponential to prevent steep falloff artifacts).
  17553. */
  17554. get useBlurCloseExponentialShadowMap(): boolean;
  17555. /**
  17556. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17557. * exponential to prevent steep falloff artifacts).
  17558. */
  17559. set useBlurCloseExponentialShadowMap(value: boolean);
  17560. /**
  17561. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17562. */
  17563. get usePercentageCloserFiltering(): boolean;
  17564. /**
  17565. * Sets the current filter to "PCF" (percentage closer filtering).
  17566. */
  17567. set usePercentageCloserFiltering(value: boolean);
  17568. protected _filteringQuality: number;
  17569. /**
  17570. * Gets the PCF or PCSS Quality.
  17571. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17572. */
  17573. get filteringQuality(): number;
  17574. /**
  17575. * Sets the PCF or PCSS Quality.
  17576. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17577. */
  17578. set filteringQuality(filteringQuality: number);
  17579. /**
  17580. * Gets if the current filter is set to "PCSS" (contact hardening).
  17581. */
  17582. get useContactHardeningShadow(): boolean;
  17583. /**
  17584. * Sets the current filter to "PCSS" (contact hardening).
  17585. */
  17586. set useContactHardeningShadow(value: boolean);
  17587. protected _contactHardeningLightSizeUVRatio: number;
  17588. /**
  17589. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17590. * Using a ratio helps keeping shape stability independently of the map size.
  17591. *
  17592. * It does not account for the light projection as it was having too much
  17593. * instability during the light setup or during light position changes.
  17594. *
  17595. * Only valid if useContactHardeningShadow is true.
  17596. */
  17597. get contactHardeningLightSizeUVRatio(): number;
  17598. /**
  17599. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17600. * Using a ratio helps keeping shape stability independently of the map size.
  17601. *
  17602. * It does not account for the light projection as it was having too much
  17603. * instability during the light setup or during light position changes.
  17604. *
  17605. * Only valid if useContactHardeningShadow is true.
  17606. */
  17607. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17608. protected _darkness: number;
  17609. /** Gets or sets the actual darkness of a shadow */
  17610. get darkness(): number;
  17611. set darkness(value: number);
  17612. /**
  17613. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17614. * 0 means strongest and 1 would means no shadow.
  17615. * @returns the darkness.
  17616. */
  17617. getDarkness(): number;
  17618. /**
  17619. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17620. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17621. * @returns the shadow generator allowing fluent coding.
  17622. */
  17623. setDarkness(darkness: number): ShadowGenerator;
  17624. protected _transparencyShadow: boolean;
  17625. /** Gets or sets the ability to have transparent shadow */
  17626. get transparencyShadow(): boolean;
  17627. set transparencyShadow(value: boolean);
  17628. /**
  17629. * Sets the ability to have transparent shadow (boolean).
  17630. * @param transparent True if transparent else False
  17631. * @returns the shadow generator allowing fluent coding
  17632. */
  17633. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17634. /**
  17635. * Enables or disables shadows with varying strength based on the transparency
  17636. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17637. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17638. * mesh.visibility * alphaTexture.a
  17639. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17640. */
  17641. enableSoftTransparentShadow: boolean;
  17642. protected _shadowMap: Nullable<RenderTargetTexture>;
  17643. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17644. /**
  17645. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17646. * @returns The render target texture if present otherwise, null
  17647. */
  17648. getShadowMap(): Nullable<RenderTargetTexture>;
  17649. /**
  17650. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17651. * @returns The render target texture if the shadow map is present otherwise, null
  17652. */
  17653. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17654. /**
  17655. * Gets the class name of that object
  17656. * @returns "ShadowGenerator"
  17657. */
  17658. getClassName(): string;
  17659. /**
  17660. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17661. * @param mesh Mesh to add
  17662. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17663. * @returns the Shadow Generator itself
  17664. */
  17665. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17666. /**
  17667. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17668. * @param mesh Mesh to remove
  17669. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17670. * @returns the Shadow Generator itself
  17671. */
  17672. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17673. /**
  17674. * Controls the extent to which the shadows fade out at the edge of the frustum
  17675. */
  17676. frustumEdgeFalloff: number;
  17677. protected _light: IShadowLight;
  17678. /**
  17679. * Returns the associated light object.
  17680. * @returns the light generating the shadow
  17681. */
  17682. getLight(): IShadowLight;
  17683. /**
  17684. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17685. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17686. * It might on the other hand introduce peter panning.
  17687. */
  17688. forceBackFacesOnly: boolean;
  17689. protected _scene: Scene;
  17690. protected _lightDirection: Vector3;
  17691. protected _effect: Effect;
  17692. protected _viewMatrix: Matrix;
  17693. protected _projectionMatrix: Matrix;
  17694. protected _transformMatrix: Matrix;
  17695. protected _cachedPosition: Vector3;
  17696. protected _cachedDirection: Vector3;
  17697. protected _cachedDefines: string;
  17698. protected _currentRenderID: number;
  17699. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17700. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17701. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17702. protected _blurPostProcesses: PostProcess[];
  17703. protected _mapSize: number;
  17704. protected _currentFaceIndex: number;
  17705. protected _currentFaceIndexCache: number;
  17706. protected _textureType: number;
  17707. protected _defaultTextureMatrix: Matrix;
  17708. protected _storedUniqueId: Nullable<number>;
  17709. /** @hidden */
  17710. static _SceneComponentInitialization: (scene: Scene) => void;
  17711. /**
  17712. * Creates a ShadowGenerator object.
  17713. * A ShadowGenerator is the required tool to use the shadows.
  17714. * Each light casting shadows needs to use its own ShadowGenerator.
  17715. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17716. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17717. * @param light The light object generating the shadows.
  17718. * @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.
  17719. */
  17720. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17721. protected _initializeGenerator(): void;
  17722. protected _createTargetRenderTexture(): void;
  17723. protected _initializeShadowMap(): void;
  17724. protected _initializeBlurRTTAndPostProcesses(): void;
  17725. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17726. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17727. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17728. protected _applyFilterValues(): void;
  17729. /**
  17730. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17731. * @param onCompiled Callback triggered at the and of the effects compilation
  17732. * @param options Sets of optional options forcing the compilation with different modes
  17733. */
  17734. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17735. useInstances: boolean;
  17736. }>): void;
  17737. /**
  17738. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17739. * @param options Sets of optional options forcing the compilation with different modes
  17740. * @returns A promise that resolves when the compilation completes
  17741. */
  17742. forceCompilationAsync(options?: Partial<{
  17743. useInstances: boolean;
  17744. }>): Promise<void>;
  17745. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17746. private _prepareShadowDefines;
  17747. /**
  17748. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17749. * @param subMesh The submesh we want to render in the shadow map
  17750. * @param useInstances Defines wether will draw in the map using instances
  17751. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17752. * @returns true if ready otherwise, false
  17753. */
  17754. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17755. /**
  17756. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17757. * @param defines Defines of the material we want to update
  17758. * @param lightIndex Index of the light in the enabled light list of the material
  17759. */
  17760. prepareDefines(defines: any, lightIndex: number): void;
  17761. /**
  17762. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17763. * defined in the generator but impacting the effect).
  17764. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17765. * @param effect The effect we are binfing the information for
  17766. */
  17767. bindShadowLight(lightIndex: string, effect: Effect): void;
  17768. /**
  17769. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17770. * (eq to shadow prjection matrix * light transform matrix)
  17771. * @returns The transform matrix used to create the shadow map
  17772. */
  17773. getTransformMatrix(): Matrix;
  17774. /**
  17775. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17776. * Cube and 2D textures for instance.
  17777. */
  17778. recreateShadowMap(): void;
  17779. protected _disposeBlurPostProcesses(): void;
  17780. protected _disposeRTTandPostProcesses(): void;
  17781. /**
  17782. * Disposes the ShadowGenerator.
  17783. * Returns nothing.
  17784. */
  17785. dispose(): void;
  17786. /**
  17787. * Serializes the shadow generator setup to a json object.
  17788. * @returns The serialized JSON object
  17789. */
  17790. serialize(): any;
  17791. /**
  17792. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17793. * @param parsedShadowGenerator The JSON object to parse
  17794. * @param scene The scene to create the shadow map for
  17795. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17796. * @returns The parsed shadow generator
  17797. */
  17798. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17799. }
  17800. }
  17801. declare module BABYLON {
  17802. /**
  17803. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17804. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17805. * 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.
  17806. */
  17807. export abstract class Light extends Node {
  17808. /**
  17809. * Falloff Default: light is falling off following the material specification:
  17810. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17811. */
  17812. static readonly FALLOFF_DEFAULT: number;
  17813. /**
  17814. * Falloff Physical: light is falling off following the inverse squared distance law.
  17815. */
  17816. static readonly FALLOFF_PHYSICAL: number;
  17817. /**
  17818. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17819. * to enhance interoperability with other engines.
  17820. */
  17821. static readonly FALLOFF_GLTF: number;
  17822. /**
  17823. * Falloff Standard: light is falling off like in the standard material
  17824. * to enhance interoperability with other materials.
  17825. */
  17826. static readonly FALLOFF_STANDARD: number;
  17827. /**
  17828. * If every light affecting the material is in this lightmapMode,
  17829. * material.lightmapTexture adds or multiplies
  17830. * (depends on material.useLightmapAsShadowmap)
  17831. * after every other light calculations.
  17832. */
  17833. static readonly LIGHTMAP_DEFAULT: number;
  17834. /**
  17835. * material.lightmapTexture as only diffuse lighting from this light
  17836. * adds only specular lighting from this light
  17837. * adds dynamic shadows
  17838. */
  17839. static readonly LIGHTMAP_SPECULAR: number;
  17840. /**
  17841. * material.lightmapTexture as only lighting
  17842. * no light calculation from this light
  17843. * only adds dynamic shadows from this light
  17844. */
  17845. static readonly LIGHTMAP_SHADOWSONLY: number;
  17846. /**
  17847. * Each light type uses the default quantity according to its type:
  17848. * point/spot lights use luminous intensity
  17849. * directional lights use illuminance
  17850. */
  17851. static readonly INTENSITYMODE_AUTOMATIC: number;
  17852. /**
  17853. * lumen (lm)
  17854. */
  17855. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17856. /**
  17857. * candela (lm/sr)
  17858. */
  17859. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17860. /**
  17861. * lux (lm/m^2)
  17862. */
  17863. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17864. /**
  17865. * nit (cd/m^2)
  17866. */
  17867. static readonly INTENSITYMODE_LUMINANCE: number;
  17868. /**
  17869. * Light type const id of the point light.
  17870. */
  17871. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17872. /**
  17873. * Light type const id of the directional light.
  17874. */
  17875. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17876. /**
  17877. * Light type const id of the spot light.
  17878. */
  17879. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17880. /**
  17881. * Light type const id of the hemispheric light.
  17882. */
  17883. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17884. /**
  17885. * Diffuse gives the basic color to an object.
  17886. */
  17887. diffuse: Color3;
  17888. /**
  17889. * Specular produces a highlight color on an object.
  17890. * Note: This is note affecting PBR materials.
  17891. */
  17892. specular: Color3;
  17893. /**
  17894. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17895. * falling off base on range or angle.
  17896. * This can be set to any values in Light.FALLOFF_x.
  17897. *
  17898. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17899. * other types of materials.
  17900. */
  17901. falloffType: number;
  17902. /**
  17903. * Strength of the light.
  17904. * Note: By default it is define in the framework own unit.
  17905. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17906. */
  17907. intensity: number;
  17908. private _range;
  17909. protected _inverseSquaredRange: number;
  17910. /**
  17911. * Defines how far from the source the light is impacting in scene units.
  17912. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17913. */
  17914. get range(): number;
  17915. /**
  17916. * Defines how far from the source the light is impacting in scene units.
  17917. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17918. */
  17919. set range(value: number);
  17920. /**
  17921. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17922. * of light.
  17923. */
  17924. private _photometricScale;
  17925. private _intensityMode;
  17926. /**
  17927. * Gets the photometric scale used to interpret the intensity.
  17928. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17929. */
  17930. get intensityMode(): number;
  17931. /**
  17932. * Sets the photometric scale used to interpret the intensity.
  17933. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17934. */
  17935. set intensityMode(value: number);
  17936. private _radius;
  17937. /**
  17938. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17939. */
  17940. get radius(): number;
  17941. /**
  17942. * sets the light radius used by PBR Materials to simulate soft area lights.
  17943. */
  17944. set radius(value: number);
  17945. private _renderPriority;
  17946. /**
  17947. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17948. * exceeding the number allowed of the materials.
  17949. */
  17950. renderPriority: number;
  17951. private _shadowEnabled;
  17952. /**
  17953. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17954. * the current shadow generator.
  17955. */
  17956. get shadowEnabled(): boolean;
  17957. /**
  17958. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17959. * the current shadow generator.
  17960. */
  17961. set shadowEnabled(value: boolean);
  17962. private _includedOnlyMeshes;
  17963. /**
  17964. * Gets the only meshes impacted by this light.
  17965. */
  17966. get includedOnlyMeshes(): AbstractMesh[];
  17967. /**
  17968. * Sets the only meshes impacted by this light.
  17969. */
  17970. set includedOnlyMeshes(value: AbstractMesh[]);
  17971. private _excludedMeshes;
  17972. /**
  17973. * Gets the meshes not impacted by this light.
  17974. */
  17975. get excludedMeshes(): AbstractMesh[];
  17976. /**
  17977. * Sets the meshes not impacted by this light.
  17978. */
  17979. set excludedMeshes(value: AbstractMesh[]);
  17980. private _excludeWithLayerMask;
  17981. /**
  17982. * Gets the layer id use to find what meshes are not impacted by the light.
  17983. * Inactive if 0
  17984. */
  17985. get excludeWithLayerMask(): number;
  17986. /**
  17987. * Sets the layer id use to find what meshes are not impacted by the light.
  17988. * Inactive if 0
  17989. */
  17990. set excludeWithLayerMask(value: number);
  17991. private _includeOnlyWithLayerMask;
  17992. /**
  17993. * Gets the layer id use to find what meshes are impacted by the light.
  17994. * Inactive if 0
  17995. */
  17996. get includeOnlyWithLayerMask(): number;
  17997. /**
  17998. * Sets the layer id use to find what meshes are impacted by the light.
  17999. * Inactive if 0
  18000. */
  18001. set includeOnlyWithLayerMask(value: number);
  18002. private _lightmapMode;
  18003. /**
  18004. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18005. */
  18006. get lightmapMode(): number;
  18007. /**
  18008. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18009. */
  18010. set lightmapMode(value: number);
  18011. /**
  18012. * Shadow generator associted to the light.
  18013. * @hidden Internal use only.
  18014. */
  18015. _shadowGenerator: Nullable<IShadowGenerator>;
  18016. /**
  18017. * @hidden Internal use only.
  18018. */
  18019. _excludedMeshesIds: string[];
  18020. /**
  18021. * @hidden Internal use only.
  18022. */
  18023. _includedOnlyMeshesIds: string[];
  18024. /**
  18025. * The current light unifom buffer.
  18026. * @hidden Internal use only.
  18027. */
  18028. _uniformBuffer: UniformBuffer;
  18029. /** @hidden */
  18030. _renderId: number;
  18031. /**
  18032. * Creates a Light object in the scene.
  18033. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18034. * @param name The firendly name of the light
  18035. * @param scene The scene the light belongs too
  18036. */
  18037. constructor(name: string, scene: Scene);
  18038. protected abstract _buildUniformLayout(): void;
  18039. /**
  18040. * Sets the passed Effect "effect" with the Light information.
  18041. * @param effect The effect to update
  18042. * @param lightIndex The index of the light in the effect to update
  18043. * @returns The light
  18044. */
  18045. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18046. /**
  18047. * Sets the passed Effect "effect" with the Light textures.
  18048. * @param effect The effect to update
  18049. * @param lightIndex The index of the light in the effect to update
  18050. * @returns The light
  18051. */
  18052. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18053. /**
  18054. * Binds the lights information from the scene to the effect for the given mesh.
  18055. * @param lightIndex Light index
  18056. * @param scene The scene where the light belongs to
  18057. * @param effect The effect we are binding the data to
  18058. * @param useSpecular Defines if specular is supported
  18059. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18060. */
  18061. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18062. /**
  18063. * Sets the passed Effect "effect" with the Light information.
  18064. * @param effect The effect to update
  18065. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18066. * @returns The light
  18067. */
  18068. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18069. /**
  18070. * Returns the string "Light".
  18071. * @returns the class name
  18072. */
  18073. getClassName(): string;
  18074. /** @hidden */
  18075. readonly _isLight: boolean;
  18076. /**
  18077. * Converts the light information to a readable string for debug purpose.
  18078. * @param fullDetails Supports for multiple levels of logging within scene loading
  18079. * @returns the human readable light info
  18080. */
  18081. toString(fullDetails?: boolean): string;
  18082. /** @hidden */
  18083. protected _syncParentEnabledState(): void;
  18084. /**
  18085. * Set the enabled state of this node.
  18086. * @param value - the new enabled state
  18087. */
  18088. setEnabled(value: boolean): void;
  18089. /**
  18090. * Returns the Light associated shadow generator if any.
  18091. * @return the associated shadow generator.
  18092. */
  18093. getShadowGenerator(): Nullable<IShadowGenerator>;
  18094. /**
  18095. * Returns a Vector3, the absolute light position in the World.
  18096. * @returns the world space position of the light
  18097. */
  18098. getAbsolutePosition(): Vector3;
  18099. /**
  18100. * Specifies if the light will affect the passed mesh.
  18101. * @param mesh The mesh to test against the light
  18102. * @return true the mesh is affected otherwise, false.
  18103. */
  18104. canAffectMesh(mesh: AbstractMesh): boolean;
  18105. /**
  18106. * Sort function to order lights for rendering.
  18107. * @param a First Light object to compare to second.
  18108. * @param b Second Light object to compare first.
  18109. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18110. */
  18111. static CompareLightsPriority(a: Light, b: Light): number;
  18112. /**
  18113. * Releases resources associated with this node.
  18114. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18115. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18116. */
  18117. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18118. /**
  18119. * Returns the light type ID (integer).
  18120. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18121. */
  18122. getTypeID(): number;
  18123. /**
  18124. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18125. * @returns the scaled intensity in intensity mode unit
  18126. */
  18127. getScaledIntensity(): number;
  18128. /**
  18129. * Returns a new Light object, named "name", from the current one.
  18130. * @param name The name of the cloned light
  18131. * @param newParent The parent of this light, if it has one
  18132. * @returns the new created light
  18133. */
  18134. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18135. /**
  18136. * Serializes the current light into a Serialization object.
  18137. * @returns the serialized object.
  18138. */
  18139. serialize(): any;
  18140. /**
  18141. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18142. * This new light is named "name" and added to the passed scene.
  18143. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18144. * @param name The friendly name of the light
  18145. * @param scene The scene the new light will belong to
  18146. * @returns the constructor function
  18147. */
  18148. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18149. /**
  18150. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18151. * @param parsedLight The JSON representation of the light
  18152. * @param scene The scene to create the parsed light in
  18153. * @returns the created light after parsing
  18154. */
  18155. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18156. private _hookArrayForExcluded;
  18157. private _hookArrayForIncludedOnly;
  18158. private _resyncMeshes;
  18159. /**
  18160. * Forces the meshes to update their light related information in their rendering used effects
  18161. * @hidden Internal Use Only
  18162. */
  18163. _markMeshesAsLightDirty(): void;
  18164. /**
  18165. * Recomputes the cached photometric scale if needed.
  18166. */
  18167. private _computePhotometricScale;
  18168. /**
  18169. * Returns the Photometric Scale according to the light type and intensity mode.
  18170. */
  18171. private _getPhotometricScale;
  18172. /**
  18173. * Reorder the light in the scene according to their defined priority.
  18174. * @hidden Internal Use Only
  18175. */
  18176. _reorderLightsInScene(): void;
  18177. /**
  18178. * Prepares the list of defines specific to the light type.
  18179. * @param defines the list of defines
  18180. * @param lightIndex defines the index of the light for the effect
  18181. */
  18182. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18183. }
  18184. }
  18185. declare module BABYLON {
  18186. /**
  18187. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18188. * This is the base of the follow, arc rotate cameras and Free camera
  18189. * @see http://doc.babylonjs.com/features/cameras
  18190. */
  18191. export class TargetCamera extends Camera {
  18192. private static _RigCamTransformMatrix;
  18193. private static _TargetTransformMatrix;
  18194. private static _TargetFocalPoint;
  18195. /**
  18196. * Define the current direction the camera is moving to
  18197. */
  18198. cameraDirection: Vector3;
  18199. /**
  18200. * Define the current rotation the camera is rotating to
  18201. */
  18202. cameraRotation: Vector2;
  18203. /**
  18204. * When set, the up vector of the camera will be updated by the rotation of the camera
  18205. */
  18206. updateUpVectorFromRotation: boolean;
  18207. private _tmpQuaternion;
  18208. /**
  18209. * Define the current rotation of the camera
  18210. */
  18211. rotation: Vector3;
  18212. /**
  18213. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18214. */
  18215. rotationQuaternion: Quaternion;
  18216. /**
  18217. * Define the current speed of the camera
  18218. */
  18219. speed: number;
  18220. /**
  18221. * Add constraint to the camera to prevent it to move freely in all directions and
  18222. * around all axis.
  18223. */
  18224. noRotationConstraint: boolean;
  18225. /**
  18226. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18227. * panning
  18228. */
  18229. invertRotation: boolean;
  18230. /**
  18231. * Speed multiplier for inverse camera panning
  18232. */
  18233. inverseRotationSpeed: number;
  18234. /**
  18235. * Define the current target of the camera as an object or a position.
  18236. */
  18237. lockedTarget: any;
  18238. /** @hidden */
  18239. _currentTarget: Vector3;
  18240. /** @hidden */
  18241. _initialFocalDistance: number;
  18242. /** @hidden */
  18243. _viewMatrix: Matrix;
  18244. /** @hidden */
  18245. _camMatrix: Matrix;
  18246. /** @hidden */
  18247. _cameraTransformMatrix: Matrix;
  18248. /** @hidden */
  18249. _cameraRotationMatrix: Matrix;
  18250. /** @hidden */
  18251. _referencePoint: Vector3;
  18252. /** @hidden */
  18253. _transformedReferencePoint: Vector3;
  18254. /** @hidden */
  18255. _reset: () => void;
  18256. private _defaultUp;
  18257. /**
  18258. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18259. * This is the base of the follow, arc rotate cameras and Free camera
  18260. * @see http://doc.babylonjs.com/features/cameras
  18261. * @param name Defines the name of the camera in the scene
  18262. * @param position Defines the start position of the camera in the scene
  18263. * @param scene Defines the scene the camera belongs to
  18264. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18265. */
  18266. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18267. /**
  18268. * Gets the position in front of the camera at a given distance.
  18269. * @param distance The distance from the camera we want the position to be
  18270. * @returns the position
  18271. */
  18272. getFrontPosition(distance: number): Vector3;
  18273. /** @hidden */
  18274. _getLockedTargetPosition(): Nullable<Vector3>;
  18275. private _storedPosition;
  18276. private _storedRotation;
  18277. private _storedRotationQuaternion;
  18278. /**
  18279. * Store current camera state of the camera (fov, position, rotation, etc..)
  18280. * @returns the camera
  18281. */
  18282. storeState(): Camera;
  18283. /**
  18284. * Restored camera state. You must call storeState() first
  18285. * @returns whether it was successful or not
  18286. * @hidden
  18287. */
  18288. _restoreStateValues(): boolean;
  18289. /** @hidden */
  18290. _initCache(): void;
  18291. /** @hidden */
  18292. _updateCache(ignoreParentClass?: boolean): void;
  18293. /** @hidden */
  18294. _isSynchronizedViewMatrix(): boolean;
  18295. /** @hidden */
  18296. _computeLocalCameraSpeed(): number;
  18297. /**
  18298. * Defines the target the camera should look at.
  18299. * @param target Defines the new target as a Vector or a mesh
  18300. */
  18301. setTarget(target: Vector3): void;
  18302. /**
  18303. * Return the current target position of the camera. This value is expressed in local space.
  18304. * @returns the target position
  18305. */
  18306. getTarget(): Vector3;
  18307. /** @hidden */
  18308. _decideIfNeedsToMove(): boolean;
  18309. /** @hidden */
  18310. _updatePosition(): void;
  18311. /** @hidden */
  18312. _checkInputs(): void;
  18313. protected _updateCameraRotationMatrix(): void;
  18314. /**
  18315. * 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)
  18316. * @returns the current camera
  18317. */
  18318. private _rotateUpVectorWithCameraRotationMatrix;
  18319. private _cachedRotationZ;
  18320. private _cachedQuaternionRotationZ;
  18321. /** @hidden */
  18322. _getViewMatrix(): Matrix;
  18323. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18324. /**
  18325. * @hidden
  18326. */
  18327. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18328. /**
  18329. * @hidden
  18330. */
  18331. _updateRigCameras(): void;
  18332. private _getRigCamPositionAndTarget;
  18333. /**
  18334. * Gets the current object class name.
  18335. * @return the class name
  18336. */
  18337. getClassName(): string;
  18338. }
  18339. }
  18340. declare module BABYLON {
  18341. /**
  18342. * Gather the list of keyboard event types as constants.
  18343. */
  18344. export class KeyboardEventTypes {
  18345. /**
  18346. * The keydown event is fired when a key becomes active (pressed).
  18347. */
  18348. static readonly KEYDOWN: number;
  18349. /**
  18350. * The keyup event is fired when a key has been released.
  18351. */
  18352. static readonly KEYUP: number;
  18353. }
  18354. /**
  18355. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18356. */
  18357. export class KeyboardInfo {
  18358. /**
  18359. * Defines the type of event (KeyboardEventTypes)
  18360. */
  18361. type: number;
  18362. /**
  18363. * Defines the related dom event
  18364. */
  18365. event: KeyboardEvent;
  18366. /**
  18367. * Instantiates a new keyboard info.
  18368. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18369. * @param type Defines the type of event (KeyboardEventTypes)
  18370. * @param event Defines the related dom event
  18371. */
  18372. constructor(
  18373. /**
  18374. * Defines the type of event (KeyboardEventTypes)
  18375. */
  18376. type: number,
  18377. /**
  18378. * Defines the related dom event
  18379. */
  18380. event: KeyboardEvent);
  18381. }
  18382. /**
  18383. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18384. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18385. */
  18386. export class KeyboardInfoPre extends KeyboardInfo {
  18387. /**
  18388. * Defines the type of event (KeyboardEventTypes)
  18389. */
  18390. type: number;
  18391. /**
  18392. * Defines the related dom event
  18393. */
  18394. event: KeyboardEvent;
  18395. /**
  18396. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18397. */
  18398. skipOnPointerObservable: boolean;
  18399. /**
  18400. * Instantiates a new keyboard pre info.
  18401. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18402. * @param type Defines the type of event (KeyboardEventTypes)
  18403. * @param event Defines the related dom event
  18404. */
  18405. constructor(
  18406. /**
  18407. * Defines the type of event (KeyboardEventTypes)
  18408. */
  18409. type: number,
  18410. /**
  18411. * Defines the related dom event
  18412. */
  18413. event: KeyboardEvent);
  18414. }
  18415. }
  18416. declare module BABYLON {
  18417. /**
  18418. * Manage the keyboard inputs to control the movement of a free camera.
  18419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18420. */
  18421. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18422. /**
  18423. * Defines the camera the input is attached to.
  18424. */
  18425. camera: FreeCamera;
  18426. /**
  18427. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18428. */
  18429. keysUp: number[];
  18430. /**
  18431. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18432. */
  18433. keysUpward: number[];
  18434. /**
  18435. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18436. */
  18437. keysDown: number[];
  18438. /**
  18439. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18440. */
  18441. keysDownward: number[];
  18442. /**
  18443. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18444. */
  18445. keysLeft: number[];
  18446. /**
  18447. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18448. */
  18449. keysRight: number[];
  18450. private _keys;
  18451. private _onCanvasBlurObserver;
  18452. private _onKeyboardObserver;
  18453. private _engine;
  18454. private _scene;
  18455. /**
  18456. * Attach the input controls to a specific dom element to get the input from.
  18457. * @param element Defines the element the controls should be listened from
  18458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18459. */
  18460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18461. /**
  18462. * Detach the current controls from the specified dom element.
  18463. * @param element Defines the element to stop listening the inputs from
  18464. */
  18465. detachControl(element: Nullable<HTMLElement>): void;
  18466. /**
  18467. * Update the current camera state depending on the inputs that have been used this frame.
  18468. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18469. */
  18470. checkInputs(): void;
  18471. /**
  18472. * Gets the class name of the current intput.
  18473. * @returns the class name
  18474. */
  18475. getClassName(): string;
  18476. /** @hidden */
  18477. _onLostFocus(): void;
  18478. /**
  18479. * Get the friendly name associated with the input class.
  18480. * @returns the input friendly name
  18481. */
  18482. getSimpleName(): string;
  18483. }
  18484. }
  18485. declare module BABYLON {
  18486. /**
  18487. * Gather the list of pointer event types as constants.
  18488. */
  18489. export class PointerEventTypes {
  18490. /**
  18491. * 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.
  18492. */
  18493. static readonly POINTERDOWN: number;
  18494. /**
  18495. * The pointerup event is fired when a pointer is no longer active.
  18496. */
  18497. static readonly POINTERUP: number;
  18498. /**
  18499. * The pointermove event is fired when a pointer changes coordinates.
  18500. */
  18501. static readonly POINTERMOVE: number;
  18502. /**
  18503. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18504. */
  18505. static readonly POINTERWHEEL: number;
  18506. /**
  18507. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18508. */
  18509. static readonly POINTERPICK: number;
  18510. /**
  18511. * The pointertap event is fired when a the object has been touched and released without drag.
  18512. */
  18513. static readonly POINTERTAP: number;
  18514. /**
  18515. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18516. */
  18517. static readonly POINTERDOUBLETAP: number;
  18518. }
  18519. /**
  18520. * Base class of pointer info types.
  18521. */
  18522. export class PointerInfoBase {
  18523. /**
  18524. * Defines the type of event (PointerEventTypes)
  18525. */
  18526. type: number;
  18527. /**
  18528. * Defines the related dom event
  18529. */
  18530. event: PointerEvent | MouseWheelEvent;
  18531. /**
  18532. * Instantiates the base class of pointers info.
  18533. * @param type Defines the type of event (PointerEventTypes)
  18534. * @param event Defines the related dom event
  18535. */
  18536. constructor(
  18537. /**
  18538. * Defines the type of event (PointerEventTypes)
  18539. */
  18540. type: number,
  18541. /**
  18542. * Defines the related dom event
  18543. */
  18544. event: PointerEvent | MouseWheelEvent);
  18545. }
  18546. /**
  18547. * This class is used to store pointer related info for the onPrePointerObservable event.
  18548. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18549. */
  18550. export class PointerInfoPre extends PointerInfoBase {
  18551. /**
  18552. * Ray from a pointer if availible (eg. 6dof controller)
  18553. */
  18554. ray: Nullable<Ray>;
  18555. /**
  18556. * Defines the local position of the pointer on the canvas.
  18557. */
  18558. localPosition: Vector2;
  18559. /**
  18560. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18561. */
  18562. skipOnPointerObservable: boolean;
  18563. /**
  18564. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18565. * @param type Defines the type of event (PointerEventTypes)
  18566. * @param event Defines the related dom event
  18567. * @param localX Defines the local x coordinates of the pointer when the event occured
  18568. * @param localY Defines the local y coordinates of the pointer when the event occured
  18569. */
  18570. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18571. }
  18572. /**
  18573. * This type contains all the data related to a pointer event in Babylon.js.
  18574. * 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.
  18575. */
  18576. export class PointerInfo extends PointerInfoBase {
  18577. /**
  18578. * Defines the picking info associated to the info (if any)\
  18579. */
  18580. pickInfo: Nullable<PickingInfo>;
  18581. /**
  18582. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18583. * @param type Defines the type of event (PointerEventTypes)
  18584. * @param event Defines the related dom event
  18585. * @param pickInfo Defines the picking info associated to the info (if any)\
  18586. */
  18587. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18588. /**
  18589. * Defines the picking info associated to the info (if any)\
  18590. */
  18591. pickInfo: Nullable<PickingInfo>);
  18592. }
  18593. /**
  18594. * Data relating to a touch event on the screen.
  18595. */
  18596. export interface PointerTouch {
  18597. /**
  18598. * X coordinate of touch.
  18599. */
  18600. x: number;
  18601. /**
  18602. * Y coordinate of touch.
  18603. */
  18604. y: number;
  18605. /**
  18606. * Id of touch. Unique for each finger.
  18607. */
  18608. pointerId: number;
  18609. /**
  18610. * Event type passed from DOM.
  18611. */
  18612. type: any;
  18613. }
  18614. }
  18615. declare module BABYLON {
  18616. /**
  18617. * Manage the mouse inputs to control the movement of a free camera.
  18618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18619. */
  18620. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18621. /**
  18622. * Define if touch is enabled in the mouse input
  18623. */
  18624. touchEnabled: boolean;
  18625. /**
  18626. * Defines the camera the input is attached to.
  18627. */
  18628. camera: FreeCamera;
  18629. /**
  18630. * Defines the buttons associated with the input to handle camera move.
  18631. */
  18632. buttons: number[];
  18633. /**
  18634. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18635. */
  18636. angularSensibility: number;
  18637. private _pointerInput;
  18638. private _onMouseMove;
  18639. private _observer;
  18640. private previousPosition;
  18641. /**
  18642. * Observable for when a pointer move event occurs containing the move offset
  18643. */
  18644. onPointerMovedObservable: Observable<{
  18645. offsetX: number;
  18646. offsetY: number;
  18647. }>;
  18648. /**
  18649. * @hidden
  18650. * If the camera should be rotated automatically based on pointer movement
  18651. */
  18652. _allowCameraRotation: boolean;
  18653. /**
  18654. * Manage the mouse inputs to control the movement of a free camera.
  18655. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18656. * @param touchEnabled Defines if touch is enabled or not
  18657. */
  18658. constructor(
  18659. /**
  18660. * Define if touch is enabled in the mouse input
  18661. */
  18662. touchEnabled?: boolean);
  18663. /**
  18664. * Attach the input controls to a specific dom element to get the input from.
  18665. * @param element Defines the element the controls should be listened from
  18666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18667. */
  18668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18669. /**
  18670. * Called on JS contextmenu event.
  18671. * Override this method to provide functionality.
  18672. */
  18673. protected onContextMenu(evt: PointerEvent): void;
  18674. /**
  18675. * Detach the current controls from the specified dom element.
  18676. * @param element Defines the element to stop listening the inputs from
  18677. */
  18678. detachControl(element: Nullable<HTMLElement>): void;
  18679. /**
  18680. * Gets the class name of the current intput.
  18681. * @returns the class name
  18682. */
  18683. getClassName(): string;
  18684. /**
  18685. * Get the friendly name associated with the input class.
  18686. * @returns the input friendly name
  18687. */
  18688. getSimpleName(): string;
  18689. }
  18690. }
  18691. declare module BABYLON {
  18692. /**
  18693. * Manage the touch inputs to control the movement of a free camera.
  18694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18695. */
  18696. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18697. /**
  18698. * Defines the camera the input is attached to.
  18699. */
  18700. camera: FreeCamera;
  18701. /**
  18702. * Defines the touch sensibility for rotation.
  18703. * The higher the faster.
  18704. */
  18705. touchAngularSensibility: number;
  18706. /**
  18707. * Defines the touch sensibility for move.
  18708. * The higher the faster.
  18709. */
  18710. touchMoveSensibility: number;
  18711. private _offsetX;
  18712. private _offsetY;
  18713. private _pointerPressed;
  18714. private _pointerInput;
  18715. private _observer;
  18716. private _onLostFocus;
  18717. /**
  18718. * Attach the input controls to a specific dom element to get the input from.
  18719. * @param element Defines the element the controls should be listened from
  18720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18721. */
  18722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18723. /**
  18724. * Detach the current controls from the specified dom element.
  18725. * @param element Defines the element to stop listening the inputs from
  18726. */
  18727. detachControl(element: Nullable<HTMLElement>): void;
  18728. /**
  18729. * Update the current camera state depending on the inputs that have been used this frame.
  18730. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18731. */
  18732. checkInputs(): void;
  18733. /**
  18734. * Gets the class name of the current intput.
  18735. * @returns the class name
  18736. */
  18737. getClassName(): string;
  18738. /**
  18739. * Get the friendly name associated with the input class.
  18740. * @returns the input friendly name
  18741. */
  18742. getSimpleName(): string;
  18743. }
  18744. }
  18745. declare module BABYLON {
  18746. /**
  18747. * Default Inputs manager for the FreeCamera.
  18748. * It groups all the default supported inputs for ease of use.
  18749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18750. */
  18751. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18752. /**
  18753. * @hidden
  18754. */
  18755. _mouseInput: Nullable<FreeCameraMouseInput>;
  18756. /**
  18757. * Instantiates a new FreeCameraInputsManager.
  18758. * @param camera Defines the camera the inputs belong to
  18759. */
  18760. constructor(camera: FreeCamera);
  18761. /**
  18762. * Add keyboard input support to the input manager.
  18763. * @returns the current input manager
  18764. */
  18765. addKeyboard(): FreeCameraInputsManager;
  18766. /**
  18767. * Add mouse input support to the input manager.
  18768. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18769. * @returns the current input manager
  18770. */
  18771. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18772. /**
  18773. * Removes the mouse input support from the manager
  18774. * @returns the current input manager
  18775. */
  18776. removeMouse(): FreeCameraInputsManager;
  18777. /**
  18778. * Add touch input support to the input manager.
  18779. * @returns the current input manager
  18780. */
  18781. addTouch(): FreeCameraInputsManager;
  18782. /**
  18783. * Remove all attached input methods from a camera
  18784. */
  18785. clear(): void;
  18786. }
  18787. }
  18788. declare module BABYLON {
  18789. /**
  18790. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18791. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18792. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18793. */
  18794. export class FreeCamera extends TargetCamera {
  18795. /**
  18796. * Define the collision ellipsoid of the camera.
  18797. * This is helpful to simulate a camera body like the player body around the camera
  18798. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18799. */
  18800. ellipsoid: Vector3;
  18801. /**
  18802. * Define an offset for the position of the ellipsoid around the camera.
  18803. * This can be helpful to determine the center of the body near the gravity center of the body
  18804. * instead of its head.
  18805. */
  18806. ellipsoidOffset: Vector3;
  18807. /**
  18808. * Enable or disable collisions of the camera with the rest of the scene objects.
  18809. */
  18810. checkCollisions: boolean;
  18811. /**
  18812. * Enable or disable gravity on the camera.
  18813. */
  18814. applyGravity: boolean;
  18815. /**
  18816. * Define the input manager associated to the camera.
  18817. */
  18818. inputs: FreeCameraInputsManager;
  18819. /**
  18820. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18821. * Higher values reduce sensitivity.
  18822. */
  18823. get angularSensibility(): number;
  18824. /**
  18825. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18826. * Higher values reduce sensitivity.
  18827. */
  18828. set angularSensibility(value: number);
  18829. /**
  18830. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18831. */
  18832. get keysUp(): number[];
  18833. set keysUp(value: number[]);
  18834. /**
  18835. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18836. */
  18837. get keysUpward(): number[];
  18838. set keysUpward(value: number[]);
  18839. /**
  18840. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18841. */
  18842. get keysDown(): number[];
  18843. set keysDown(value: number[]);
  18844. /**
  18845. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18846. */
  18847. get keysDownward(): number[];
  18848. set keysDownward(value: number[]);
  18849. /**
  18850. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18851. */
  18852. get keysLeft(): number[];
  18853. set keysLeft(value: number[]);
  18854. /**
  18855. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18856. */
  18857. get keysRight(): number[];
  18858. set keysRight(value: number[]);
  18859. /**
  18860. * Event raised when the camera collide with a mesh in the scene.
  18861. */
  18862. onCollide: (collidedMesh: AbstractMesh) => void;
  18863. private _collider;
  18864. private _needMoveForGravity;
  18865. private _oldPosition;
  18866. private _diffPosition;
  18867. private _newPosition;
  18868. /** @hidden */
  18869. _localDirection: Vector3;
  18870. /** @hidden */
  18871. _transformedDirection: Vector3;
  18872. /**
  18873. * Instantiates a Free Camera.
  18874. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18875. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18876. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18877. * @param name Define the name of the camera in the scene
  18878. * @param position Define the start position of the camera in the scene
  18879. * @param scene Define the scene the camera belongs to
  18880. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18881. */
  18882. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18883. /**
  18884. * Attached controls to the current camera.
  18885. * @param element Defines the element the controls should be listened from
  18886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18887. */
  18888. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18889. /**
  18890. * Detach the current controls from the camera.
  18891. * The camera will stop reacting to inputs.
  18892. * @param element Defines the element to stop listening the inputs from
  18893. */
  18894. detachControl(element: HTMLElement): void;
  18895. private _collisionMask;
  18896. /**
  18897. * Define a collision mask to limit the list of object the camera can collide with
  18898. */
  18899. get collisionMask(): number;
  18900. set collisionMask(mask: number);
  18901. /** @hidden */
  18902. _collideWithWorld(displacement: Vector3): void;
  18903. private _onCollisionPositionChange;
  18904. /** @hidden */
  18905. _checkInputs(): void;
  18906. /** @hidden */
  18907. _decideIfNeedsToMove(): boolean;
  18908. /** @hidden */
  18909. _updatePosition(): void;
  18910. /**
  18911. * Destroy the camera and release the current resources hold by it.
  18912. */
  18913. dispose(): void;
  18914. /**
  18915. * Gets the current object class name.
  18916. * @return the class name
  18917. */
  18918. getClassName(): string;
  18919. }
  18920. }
  18921. declare module BABYLON {
  18922. /**
  18923. * Represents a gamepad control stick position
  18924. */
  18925. export class StickValues {
  18926. /**
  18927. * The x component of the control stick
  18928. */
  18929. x: number;
  18930. /**
  18931. * The y component of the control stick
  18932. */
  18933. y: number;
  18934. /**
  18935. * Initializes the gamepad x and y control stick values
  18936. * @param x The x component of the gamepad control stick value
  18937. * @param y The y component of the gamepad control stick value
  18938. */
  18939. constructor(
  18940. /**
  18941. * The x component of the control stick
  18942. */
  18943. x: number,
  18944. /**
  18945. * The y component of the control stick
  18946. */
  18947. y: number);
  18948. }
  18949. /**
  18950. * An interface which manages callbacks for gamepad button changes
  18951. */
  18952. export interface GamepadButtonChanges {
  18953. /**
  18954. * Called when a gamepad has been changed
  18955. */
  18956. changed: boolean;
  18957. /**
  18958. * Called when a gamepad press event has been triggered
  18959. */
  18960. pressChanged: boolean;
  18961. /**
  18962. * Called when a touch event has been triggered
  18963. */
  18964. touchChanged: boolean;
  18965. /**
  18966. * Called when a value has changed
  18967. */
  18968. valueChanged: boolean;
  18969. }
  18970. /**
  18971. * Represents a gamepad
  18972. */
  18973. export class Gamepad {
  18974. /**
  18975. * The id of the gamepad
  18976. */
  18977. id: string;
  18978. /**
  18979. * The index of the gamepad
  18980. */
  18981. index: number;
  18982. /**
  18983. * The browser gamepad
  18984. */
  18985. browserGamepad: any;
  18986. /**
  18987. * Specifies what type of gamepad this represents
  18988. */
  18989. type: number;
  18990. private _leftStick;
  18991. private _rightStick;
  18992. /** @hidden */
  18993. _isConnected: boolean;
  18994. private _leftStickAxisX;
  18995. private _leftStickAxisY;
  18996. private _rightStickAxisX;
  18997. private _rightStickAxisY;
  18998. /**
  18999. * Triggered when the left control stick has been changed
  19000. */
  19001. private _onleftstickchanged;
  19002. /**
  19003. * Triggered when the right control stick has been changed
  19004. */
  19005. private _onrightstickchanged;
  19006. /**
  19007. * Represents a gamepad controller
  19008. */
  19009. static GAMEPAD: number;
  19010. /**
  19011. * Represents a generic controller
  19012. */
  19013. static GENERIC: number;
  19014. /**
  19015. * Represents an XBox controller
  19016. */
  19017. static XBOX: number;
  19018. /**
  19019. * Represents a pose-enabled controller
  19020. */
  19021. static POSE_ENABLED: number;
  19022. /**
  19023. * Represents an Dual Shock controller
  19024. */
  19025. static DUALSHOCK: number;
  19026. /**
  19027. * Specifies whether the left control stick should be Y-inverted
  19028. */
  19029. protected _invertLeftStickY: boolean;
  19030. /**
  19031. * Specifies if the gamepad has been connected
  19032. */
  19033. get isConnected(): boolean;
  19034. /**
  19035. * Initializes the gamepad
  19036. * @param id The id of the gamepad
  19037. * @param index The index of the gamepad
  19038. * @param browserGamepad The browser gamepad
  19039. * @param leftStickX The x component of the left joystick
  19040. * @param leftStickY The y component of the left joystick
  19041. * @param rightStickX The x component of the right joystick
  19042. * @param rightStickY The y component of the right joystick
  19043. */
  19044. constructor(
  19045. /**
  19046. * The id of the gamepad
  19047. */
  19048. id: string,
  19049. /**
  19050. * The index of the gamepad
  19051. */
  19052. index: number,
  19053. /**
  19054. * The browser gamepad
  19055. */
  19056. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19057. /**
  19058. * Callback triggered when the left joystick has changed
  19059. * @param callback
  19060. */
  19061. onleftstickchanged(callback: (values: StickValues) => void): void;
  19062. /**
  19063. * Callback triggered when the right joystick has changed
  19064. * @param callback
  19065. */
  19066. onrightstickchanged(callback: (values: StickValues) => void): void;
  19067. /**
  19068. * Gets the left joystick
  19069. */
  19070. get leftStick(): StickValues;
  19071. /**
  19072. * Sets the left joystick values
  19073. */
  19074. set leftStick(newValues: StickValues);
  19075. /**
  19076. * Gets the right joystick
  19077. */
  19078. get rightStick(): StickValues;
  19079. /**
  19080. * Sets the right joystick value
  19081. */
  19082. set rightStick(newValues: StickValues);
  19083. /**
  19084. * Updates the gamepad joystick positions
  19085. */
  19086. update(): void;
  19087. /**
  19088. * Disposes the gamepad
  19089. */
  19090. dispose(): void;
  19091. }
  19092. /**
  19093. * Represents a generic gamepad
  19094. */
  19095. export class GenericPad extends Gamepad {
  19096. private _buttons;
  19097. private _onbuttondown;
  19098. private _onbuttonup;
  19099. /**
  19100. * Observable triggered when a button has been pressed
  19101. */
  19102. onButtonDownObservable: Observable<number>;
  19103. /**
  19104. * Observable triggered when a button has been released
  19105. */
  19106. onButtonUpObservable: Observable<number>;
  19107. /**
  19108. * Callback triggered when a button has been pressed
  19109. * @param callback Called when a button has been pressed
  19110. */
  19111. onbuttondown(callback: (buttonPressed: number) => void): void;
  19112. /**
  19113. * Callback triggered when a button has been released
  19114. * @param callback Called when a button has been released
  19115. */
  19116. onbuttonup(callback: (buttonReleased: number) => void): void;
  19117. /**
  19118. * Initializes the generic gamepad
  19119. * @param id The id of the generic gamepad
  19120. * @param index The index of the generic gamepad
  19121. * @param browserGamepad The browser gamepad
  19122. */
  19123. constructor(id: string, index: number, browserGamepad: any);
  19124. private _setButtonValue;
  19125. /**
  19126. * Updates the generic gamepad
  19127. */
  19128. update(): void;
  19129. /**
  19130. * Disposes the generic gamepad
  19131. */
  19132. dispose(): void;
  19133. }
  19134. }
  19135. declare module BABYLON {
  19136. /**
  19137. * Defines the types of pose enabled controllers that are supported
  19138. */
  19139. export enum PoseEnabledControllerType {
  19140. /**
  19141. * HTC Vive
  19142. */
  19143. VIVE = 0,
  19144. /**
  19145. * Oculus Rift
  19146. */
  19147. OCULUS = 1,
  19148. /**
  19149. * Windows mixed reality
  19150. */
  19151. WINDOWS = 2,
  19152. /**
  19153. * Samsung gear VR
  19154. */
  19155. GEAR_VR = 3,
  19156. /**
  19157. * Google Daydream
  19158. */
  19159. DAYDREAM = 4,
  19160. /**
  19161. * Generic
  19162. */
  19163. GENERIC = 5
  19164. }
  19165. /**
  19166. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19167. */
  19168. export interface MutableGamepadButton {
  19169. /**
  19170. * Value of the button/trigger
  19171. */
  19172. value: number;
  19173. /**
  19174. * If the button/trigger is currently touched
  19175. */
  19176. touched: boolean;
  19177. /**
  19178. * If the button/trigger is currently pressed
  19179. */
  19180. pressed: boolean;
  19181. }
  19182. /**
  19183. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19184. * @hidden
  19185. */
  19186. export interface ExtendedGamepadButton extends GamepadButton {
  19187. /**
  19188. * If the button/trigger is currently pressed
  19189. */
  19190. readonly pressed: boolean;
  19191. /**
  19192. * If the button/trigger is currently touched
  19193. */
  19194. readonly touched: boolean;
  19195. /**
  19196. * Value of the button/trigger
  19197. */
  19198. readonly value: number;
  19199. }
  19200. /** @hidden */
  19201. export interface _GamePadFactory {
  19202. /**
  19203. * Returns whether or not the current gamepad can be created for this type of controller.
  19204. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19205. * @returns true if it can be created, otherwise false
  19206. */
  19207. canCreate(gamepadInfo: any): boolean;
  19208. /**
  19209. * Creates a new instance of the Gamepad.
  19210. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19211. * @returns the new gamepad instance
  19212. */
  19213. create(gamepadInfo: any): Gamepad;
  19214. }
  19215. /**
  19216. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19217. */
  19218. export class PoseEnabledControllerHelper {
  19219. /** @hidden */
  19220. static _ControllerFactories: _GamePadFactory[];
  19221. /** @hidden */
  19222. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19223. /**
  19224. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19225. * @param vrGamepad the gamepad to initialized
  19226. * @returns a vr controller of the type the gamepad identified as
  19227. */
  19228. static InitiateController(vrGamepad: any): Gamepad;
  19229. }
  19230. /**
  19231. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19232. */
  19233. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19234. /**
  19235. * If the controller is used in a webXR session
  19236. */
  19237. isXR: boolean;
  19238. private _deviceRoomPosition;
  19239. private _deviceRoomRotationQuaternion;
  19240. /**
  19241. * The device position in babylon space
  19242. */
  19243. devicePosition: Vector3;
  19244. /**
  19245. * The device rotation in babylon space
  19246. */
  19247. deviceRotationQuaternion: Quaternion;
  19248. /**
  19249. * The scale factor of the device in babylon space
  19250. */
  19251. deviceScaleFactor: number;
  19252. /**
  19253. * (Likely devicePosition should be used instead) The device position in its room space
  19254. */
  19255. position: Vector3;
  19256. /**
  19257. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19258. */
  19259. rotationQuaternion: Quaternion;
  19260. /**
  19261. * The type of controller (Eg. Windows mixed reality)
  19262. */
  19263. controllerType: PoseEnabledControllerType;
  19264. protected _calculatedPosition: Vector3;
  19265. private _calculatedRotation;
  19266. /**
  19267. * The raw pose from the device
  19268. */
  19269. rawPose: DevicePose;
  19270. private _trackPosition;
  19271. private _maxRotationDistFromHeadset;
  19272. private _draggedRoomRotation;
  19273. /**
  19274. * @hidden
  19275. */
  19276. _disableTrackPosition(fixedPosition: Vector3): void;
  19277. /**
  19278. * Internal, the mesh attached to the controller
  19279. * @hidden
  19280. */
  19281. _mesh: Nullable<AbstractMesh>;
  19282. private _poseControlledCamera;
  19283. private _leftHandSystemQuaternion;
  19284. /**
  19285. * Internal, matrix used to convert room space to babylon space
  19286. * @hidden
  19287. */
  19288. _deviceToWorld: Matrix;
  19289. /**
  19290. * Node to be used when casting a ray from the controller
  19291. * @hidden
  19292. */
  19293. _pointingPoseNode: Nullable<TransformNode>;
  19294. /**
  19295. * Name of the child mesh that can be used to cast a ray from the controller
  19296. */
  19297. static readonly POINTING_POSE: string;
  19298. /**
  19299. * Creates a new PoseEnabledController from a gamepad
  19300. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19301. */
  19302. constructor(browserGamepad: any);
  19303. private _workingMatrix;
  19304. /**
  19305. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19306. */
  19307. update(): void;
  19308. /**
  19309. * Updates only the pose device and mesh without doing any button event checking
  19310. */
  19311. protected _updatePoseAndMesh(): void;
  19312. /**
  19313. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19314. * @param poseData raw pose fromthe device
  19315. */
  19316. updateFromDevice(poseData: DevicePose): void;
  19317. /**
  19318. * @hidden
  19319. */
  19320. _meshAttachedObservable: Observable<AbstractMesh>;
  19321. /**
  19322. * Attaches a mesh to the controller
  19323. * @param mesh the mesh to be attached
  19324. */
  19325. attachToMesh(mesh: AbstractMesh): void;
  19326. /**
  19327. * Attaches the controllers mesh to a camera
  19328. * @param camera the camera the mesh should be attached to
  19329. */
  19330. attachToPoseControlledCamera(camera: TargetCamera): void;
  19331. /**
  19332. * Disposes of the controller
  19333. */
  19334. dispose(): void;
  19335. /**
  19336. * The mesh that is attached to the controller
  19337. */
  19338. get mesh(): Nullable<AbstractMesh>;
  19339. /**
  19340. * Gets the ray of the controller in the direction the controller is pointing
  19341. * @param length the length the resulting ray should be
  19342. * @returns a ray in the direction the controller is pointing
  19343. */
  19344. getForwardRay(length?: number): Ray;
  19345. }
  19346. }
  19347. declare module BABYLON {
  19348. /**
  19349. * Defines the WebVRController object that represents controllers tracked in 3D space
  19350. */
  19351. export abstract class WebVRController extends PoseEnabledController {
  19352. /**
  19353. * Internal, the default controller model for the controller
  19354. */
  19355. protected _defaultModel: Nullable<AbstractMesh>;
  19356. /**
  19357. * Fired when the trigger state has changed
  19358. */
  19359. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19360. /**
  19361. * Fired when the main button state has changed
  19362. */
  19363. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19364. /**
  19365. * Fired when the secondary button state has changed
  19366. */
  19367. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19368. /**
  19369. * Fired when the pad state has changed
  19370. */
  19371. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19372. /**
  19373. * Fired when controllers stick values have changed
  19374. */
  19375. onPadValuesChangedObservable: Observable<StickValues>;
  19376. /**
  19377. * Array of button availible on the controller
  19378. */
  19379. protected _buttons: Array<MutableGamepadButton>;
  19380. private _onButtonStateChange;
  19381. /**
  19382. * Fired when a controller button's state has changed
  19383. * @param callback the callback containing the button that was modified
  19384. */
  19385. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19386. /**
  19387. * X and Y axis corresponding to the controllers joystick
  19388. */
  19389. pad: StickValues;
  19390. /**
  19391. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19392. */
  19393. hand: string;
  19394. /**
  19395. * The default controller model for the controller
  19396. */
  19397. get defaultModel(): Nullable<AbstractMesh>;
  19398. /**
  19399. * Creates a new WebVRController from a gamepad
  19400. * @param vrGamepad the gamepad that the WebVRController should be created from
  19401. */
  19402. constructor(vrGamepad: any);
  19403. /**
  19404. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19405. */
  19406. update(): void;
  19407. /**
  19408. * Function to be called when a button is modified
  19409. */
  19410. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19411. /**
  19412. * Loads a mesh and attaches it to the controller
  19413. * @param scene the scene the mesh should be added to
  19414. * @param meshLoaded callback for when the mesh has been loaded
  19415. */
  19416. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19417. private _setButtonValue;
  19418. private _changes;
  19419. private _checkChanges;
  19420. /**
  19421. * Disposes of th webVRCOntroller
  19422. */
  19423. dispose(): void;
  19424. }
  19425. }
  19426. declare module BABYLON {
  19427. /**
  19428. * The HemisphericLight simulates the ambient environment light,
  19429. * so the passed direction is the light reflection direction, not the incoming direction.
  19430. */
  19431. export class HemisphericLight extends Light {
  19432. /**
  19433. * The groundColor is the light in the opposite direction to the one specified during creation.
  19434. * 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.
  19435. */
  19436. groundColor: Color3;
  19437. /**
  19438. * The light reflection direction, not the incoming direction.
  19439. */
  19440. direction: Vector3;
  19441. /**
  19442. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19443. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19444. * The HemisphericLight can't cast shadows.
  19445. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19446. * @param name The friendly name of the light
  19447. * @param direction The direction of the light reflection
  19448. * @param scene The scene the light belongs to
  19449. */
  19450. constructor(name: string, direction: Vector3, scene: Scene);
  19451. protected _buildUniformLayout(): void;
  19452. /**
  19453. * Returns the string "HemisphericLight".
  19454. * @return The class name
  19455. */
  19456. getClassName(): string;
  19457. /**
  19458. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19459. * Returns the updated direction.
  19460. * @param target The target the direction should point to
  19461. * @return The computed direction
  19462. */
  19463. setDirectionToTarget(target: Vector3): Vector3;
  19464. /**
  19465. * Returns the shadow generator associated to the light.
  19466. * @returns Always null for hemispheric lights because it does not support shadows.
  19467. */
  19468. getShadowGenerator(): Nullable<IShadowGenerator>;
  19469. /**
  19470. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19471. * @param effect The effect to update
  19472. * @param lightIndex The index of the light in the effect to update
  19473. * @returns The hemispheric light
  19474. */
  19475. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19476. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19477. /**
  19478. * Computes the world matrix of the node
  19479. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19480. * @param useWasUpdatedFlag defines a reserved property
  19481. * @returns the world matrix
  19482. */
  19483. computeWorldMatrix(): Matrix;
  19484. /**
  19485. * Returns the integer 3.
  19486. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19487. */
  19488. getTypeID(): number;
  19489. /**
  19490. * Prepares the list of defines specific to the light type.
  19491. * @param defines the list of defines
  19492. * @param lightIndex defines the index of the light for the effect
  19493. */
  19494. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19495. }
  19496. }
  19497. declare module BABYLON {
  19498. /** @hidden */
  19499. export var vrMultiviewToSingleviewPixelShader: {
  19500. name: string;
  19501. shader: string;
  19502. };
  19503. }
  19504. declare module BABYLON {
  19505. /**
  19506. * Renders to multiple views with a single draw call
  19507. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19508. */
  19509. export class MultiviewRenderTarget extends RenderTargetTexture {
  19510. /**
  19511. * Creates a multiview render target
  19512. * @param scene scene used with the render target
  19513. * @param size the size of the render target (used for each view)
  19514. */
  19515. constructor(scene: Scene, size?: number | {
  19516. width: number;
  19517. height: number;
  19518. } | {
  19519. ratio: number;
  19520. });
  19521. /**
  19522. * @hidden
  19523. * @param faceIndex the face index, if its a cube texture
  19524. */
  19525. _bindFrameBuffer(faceIndex?: number): void;
  19526. /**
  19527. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19528. * @returns the view count
  19529. */
  19530. getViewCount(): number;
  19531. }
  19532. }
  19533. declare module BABYLON {
  19534. interface Engine {
  19535. /**
  19536. * Creates a new multiview render target
  19537. * @param width defines the width of the texture
  19538. * @param height defines the height of the texture
  19539. * @returns the created multiview texture
  19540. */
  19541. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19542. /**
  19543. * Binds a multiview framebuffer to be drawn to
  19544. * @param multiviewTexture texture to bind
  19545. */
  19546. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19547. }
  19548. interface Camera {
  19549. /**
  19550. * @hidden
  19551. * 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)
  19552. */
  19553. _useMultiviewToSingleView: boolean;
  19554. /**
  19555. * @hidden
  19556. * 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)
  19557. */
  19558. _multiviewTexture: Nullable<RenderTargetTexture>;
  19559. /**
  19560. * @hidden
  19561. * ensures the multiview texture of the camera exists and has the specified width/height
  19562. * @param width height to set on the multiview texture
  19563. * @param height width to set on the multiview texture
  19564. */
  19565. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19566. }
  19567. interface Scene {
  19568. /** @hidden */
  19569. _transformMatrixR: Matrix;
  19570. /** @hidden */
  19571. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19572. /** @hidden */
  19573. _createMultiviewUbo(): void;
  19574. /** @hidden */
  19575. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19576. /** @hidden */
  19577. _renderMultiviewToSingleView(camera: Camera): void;
  19578. }
  19579. }
  19580. declare module BABYLON {
  19581. /**
  19582. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19583. * This will not be used for webXR as it supports displaying texture arrays directly
  19584. */
  19585. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19586. /**
  19587. * Initializes a VRMultiviewToSingleview
  19588. * @param name name of the post process
  19589. * @param camera camera to be applied to
  19590. * @param scaleFactor scaling factor to the size of the output texture
  19591. */
  19592. constructor(name: string, camera: Camera, scaleFactor: number);
  19593. }
  19594. }
  19595. declare module BABYLON {
  19596. /**
  19597. * Interface used to define additional presentation attributes
  19598. */
  19599. export interface IVRPresentationAttributes {
  19600. /**
  19601. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19602. */
  19603. highRefreshRate: boolean;
  19604. /**
  19605. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19606. */
  19607. foveationLevel: number;
  19608. }
  19609. interface Engine {
  19610. /** @hidden */
  19611. _vrDisplay: any;
  19612. /** @hidden */
  19613. _vrSupported: boolean;
  19614. /** @hidden */
  19615. _oldSize: Size;
  19616. /** @hidden */
  19617. _oldHardwareScaleFactor: number;
  19618. /** @hidden */
  19619. _vrExclusivePointerMode: boolean;
  19620. /** @hidden */
  19621. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19622. /** @hidden */
  19623. _onVRDisplayPointerRestricted: () => void;
  19624. /** @hidden */
  19625. _onVRDisplayPointerUnrestricted: () => void;
  19626. /** @hidden */
  19627. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19628. /** @hidden */
  19629. _onVrDisplayDisconnect: Nullable<() => void>;
  19630. /** @hidden */
  19631. _onVrDisplayPresentChange: Nullable<() => void>;
  19632. /**
  19633. * Observable signaled when VR display mode changes
  19634. */
  19635. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19636. /**
  19637. * Observable signaled when VR request present is complete
  19638. */
  19639. onVRRequestPresentComplete: Observable<boolean>;
  19640. /**
  19641. * Observable signaled when VR request present starts
  19642. */
  19643. onVRRequestPresentStart: Observable<Engine>;
  19644. /**
  19645. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19646. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19647. */
  19648. isInVRExclusivePointerMode: boolean;
  19649. /**
  19650. * Gets a boolean indicating if a webVR device was detected
  19651. * @returns true if a webVR device was detected
  19652. */
  19653. isVRDevicePresent(): boolean;
  19654. /**
  19655. * Gets the current webVR device
  19656. * @returns the current webVR device (or null)
  19657. */
  19658. getVRDevice(): any;
  19659. /**
  19660. * Initializes a webVR display and starts listening to display change events
  19661. * The onVRDisplayChangedObservable will be notified upon these changes
  19662. * @returns A promise containing a VRDisplay and if vr is supported
  19663. */
  19664. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19665. /** @hidden */
  19666. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19667. /**
  19668. * Gets or sets the presentation attributes used to configure VR rendering
  19669. */
  19670. vrPresentationAttributes?: IVRPresentationAttributes;
  19671. /**
  19672. * Call this function to switch to webVR mode
  19673. * Will do nothing if webVR is not supported or if there is no webVR device
  19674. * @param options the webvr options provided to the camera. mainly used for multiview
  19675. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19676. */
  19677. enableVR(options: WebVROptions): void;
  19678. /** @hidden */
  19679. _onVRFullScreenTriggered(): void;
  19680. }
  19681. }
  19682. declare module BABYLON {
  19683. /**
  19684. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19685. * IMPORTANT!! The data is right-hand data.
  19686. * @export
  19687. * @interface DevicePose
  19688. */
  19689. export interface DevicePose {
  19690. /**
  19691. * The position of the device, values in array are [x,y,z].
  19692. */
  19693. readonly position: Nullable<Float32Array>;
  19694. /**
  19695. * The linearVelocity of the device, values in array are [x,y,z].
  19696. */
  19697. readonly linearVelocity: Nullable<Float32Array>;
  19698. /**
  19699. * The linearAcceleration of the device, values in array are [x,y,z].
  19700. */
  19701. readonly linearAcceleration: Nullable<Float32Array>;
  19702. /**
  19703. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19704. */
  19705. readonly orientation: Nullable<Float32Array>;
  19706. /**
  19707. * The angularVelocity of the device, values in array are [x,y,z].
  19708. */
  19709. readonly angularVelocity: Nullable<Float32Array>;
  19710. /**
  19711. * The angularAcceleration of the device, values in array are [x,y,z].
  19712. */
  19713. readonly angularAcceleration: Nullable<Float32Array>;
  19714. }
  19715. /**
  19716. * Interface representing a pose controlled object in Babylon.
  19717. * A pose controlled object has both regular pose values as well as pose values
  19718. * from an external device such as a VR head mounted display
  19719. */
  19720. export interface PoseControlled {
  19721. /**
  19722. * The position of the object in babylon space.
  19723. */
  19724. position: Vector3;
  19725. /**
  19726. * The rotation quaternion of the object in babylon space.
  19727. */
  19728. rotationQuaternion: Quaternion;
  19729. /**
  19730. * The position of the device in babylon space.
  19731. */
  19732. devicePosition?: Vector3;
  19733. /**
  19734. * The rotation quaternion of the device in babylon space.
  19735. */
  19736. deviceRotationQuaternion: Quaternion;
  19737. /**
  19738. * The raw pose coming from the device.
  19739. */
  19740. rawPose: Nullable<DevicePose>;
  19741. /**
  19742. * The scale of the device to be used when translating from device space to babylon space.
  19743. */
  19744. deviceScaleFactor: number;
  19745. /**
  19746. * Updates the poseControlled values based on the input device pose.
  19747. * @param poseData the pose data to update the object with
  19748. */
  19749. updateFromDevice(poseData: DevicePose): void;
  19750. }
  19751. /**
  19752. * Set of options to customize the webVRCamera
  19753. */
  19754. export interface WebVROptions {
  19755. /**
  19756. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19757. */
  19758. trackPosition?: boolean;
  19759. /**
  19760. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19761. */
  19762. positionScale?: number;
  19763. /**
  19764. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19765. */
  19766. displayName?: string;
  19767. /**
  19768. * Should the native controller meshes be initialized. (default: true)
  19769. */
  19770. controllerMeshes?: boolean;
  19771. /**
  19772. * Creating a default HemiLight only on controllers. (default: true)
  19773. */
  19774. defaultLightingOnControllers?: boolean;
  19775. /**
  19776. * If you don't want to use the default VR button of the helper. (default: false)
  19777. */
  19778. useCustomVRButton?: boolean;
  19779. /**
  19780. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19781. */
  19782. customVRButton?: HTMLButtonElement;
  19783. /**
  19784. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19785. */
  19786. rayLength?: number;
  19787. /**
  19788. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19789. */
  19790. defaultHeight?: number;
  19791. /**
  19792. * If multiview should be used if availible (default: false)
  19793. */
  19794. useMultiview?: boolean;
  19795. }
  19796. /**
  19797. * This represents a WebVR camera.
  19798. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19799. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19800. */
  19801. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19802. private webVROptions;
  19803. /**
  19804. * @hidden
  19805. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19806. */
  19807. _vrDevice: any;
  19808. /**
  19809. * The rawPose of the vrDevice.
  19810. */
  19811. rawPose: Nullable<DevicePose>;
  19812. private _onVREnabled;
  19813. private _specsVersion;
  19814. private _attached;
  19815. private _frameData;
  19816. protected _descendants: Array<Node>;
  19817. private _deviceRoomPosition;
  19818. /** @hidden */
  19819. _deviceRoomRotationQuaternion: Quaternion;
  19820. private _standingMatrix;
  19821. /**
  19822. * Represents device position in babylon space.
  19823. */
  19824. devicePosition: Vector3;
  19825. /**
  19826. * Represents device rotation in babylon space.
  19827. */
  19828. deviceRotationQuaternion: Quaternion;
  19829. /**
  19830. * The scale of the device to be used when translating from device space to babylon space.
  19831. */
  19832. deviceScaleFactor: number;
  19833. private _deviceToWorld;
  19834. private _worldToDevice;
  19835. /**
  19836. * References to the webVR controllers for the vrDevice.
  19837. */
  19838. controllers: Array<WebVRController>;
  19839. /**
  19840. * Emits an event when a controller is attached.
  19841. */
  19842. onControllersAttachedObservable: Observable<WebVRController[]>;
  19843. /**
  19844. * Emits an event when a controller's mesh has been loaded;
  19845. */
  19846. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19847. /**
  19848. * Emits an event when the HMD's pose has been updated.
  19849. */
  19850. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19851. private _poseSet;
  19852. /**
  19853. * If the rig cameras be used as parent instead of this camera.
  19854. */
  19855. rigParenting: boolean;
  19856. private _lightOnControllers;
  19857. private _defaultHeight?;
  19858. /**
  19859. * Instantiates a WebVRFreeCamera.
  19860. * @param name The name of the WebVRFreeCamera
  19861. * @param position The starting anchor position for the camera
  19862. * @param scene The scene the camera belongs to
  19863. * @param webVROptions a set of customizable options for the webVRCamera
  19864. */
  19865. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19866. /**
  19867. * Gets the device distance from the ground in meters.
  19868. * @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.
  19869. */
  19870. deviceDistanceToRoomGround(): number;
  19871. /**
  19872. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19873. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19874. */
  19875. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19876. /**
  19877. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19878. * @returns A promise with a boolean set to if the standing matrix is supported.
  19879. */
  19880. useStandingMatrixAsync(): Promise<boolean>;
  19881. /**
  19882. * Disposes the camera
  19883. */
  19884. dispose(): void;
  19885. /**
  19886. * Gets a vrController by name.
  19887. * @param name The name of the controller to retreive
  19888. * @returns the controller matching the name specified or null if not found
  19889. */
  19890. getControllerByName(name: string): Nullable<WebVRController>;
  19891. private _leftController;
  19892. /**
  19893. * The controller corresponding to the users left hand.
  19894. */
  19895. get leftController(): Nullable<WebVRController>;
  19896. private _rightController;
  19897. /**
  19898. * The controller corresponding to the users right hand.
  19899. */
  19900. get rightController(): Nullable<WebVRController>;
  19901. /**
  19902. * Casts a ray forward from the vrCamera's gaze.
  19903. * @param length Length of the ray (default: 100)
  19904. * @returns the ray corresponding to the gaze
  19905. */
  19906. getForwardRay(length?: number): Ray;
  19907. /**
  19908. * @hidden
  19909. * Updates the camera based on device's frame data
  19910. */
  19911. _checkInputs(): void;
  19912. /**
  19913. * Updates the poseControlled values based on the input device pose.
  19914. * @param poseData Pose coming from the device
  19915. */
  19916. updateFromDevice(poseData: DevicePose): void;
  19917. private _htmlElementAttached;
  19918. private _detachIfAttached;
  19919. /**
  19920. * WebVR's attach control will start broadcasting frames to the device.
  19921. * Note that in certain browsers (chrome for example) this function must be called
  19922. * within a user-interaction callback. Example:
  19923. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19924. *
  19925. * @param element html element to attach the vrDevice to
  19926. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19927. */
  19928. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19929. /**
  19930. * Detaches the camera from the html element and disables VR
  19931. *
  19932. * @param element html element to detach from
  19933. */
  19934. detachControl(element: HTMLElement): void;
  19935. /**
  19936. * @returns the name of this class
  19937. */
  19938. getClassName(): string;
  19939. /**
  19940. * Calls resetPose on the vrDisplay
  19941. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19942. */
  19943. resetToCurrentRotation(): void;
  19944. /**
  19945. * @hidden
  19946. * Updates the rig cameras (left and right eye)
  19947. */
  19948. _updateRigCameras(): void;
  19949. private _workingVector;
  19950. private _oneVector;
  19951. private _workingMatrix;
  19952. private updateCacheCalled;
  19953. private _correctPositionIfNotTrackPosition;
  19954. /**
  19955. * @hidden
  19956. * Updates the cached values of the camera
  19957. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19958. */
  19959. _updateCache(ignoreParentClass?: boolean): void;
  19960. /**
  19961. * @hidden
  19962. * Get current device position in babylon world
  19963. */
  19964. _computeDevicePosition(): void;
  19965. /**
  19966. * Updates the current device position and rotation in the babylon world
  19967. */
  19968. update(): void;
  19969. /**
  19970. * @hidden
  19971. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19972. * @returns an identity matrix
  19973. */
  19974. _getViewMatrix(): Matrix;
  19975. private _tmpMatrix;
  19976. /**
  19977. * This function is called by the two RIG cameras.
  19978. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19979. * @hidden
  19980. */
  19981. _getWebVRViewMatrix(): Matrix;
  19982. /** @hidden */
  19983. _getWebVRProjectionMatrix(): Matrix;
  19984. private _onGamepadConnectedObserver;
  19985. private _onGamepadDisconnectedObserver;
  19986. private _updateCacheWhenTrackingDisabledObserver;
  19987. /**
  19988. * Initializes the controllers and their meshes
  19989. */
  19990. initControllers(): void;
  19991. }
  19992. }
  19993. declare module BABYLON {
  19994. /**
  19995. * "Static Class" containing the most commonly used helper while dealing with material for
  19996. * rendering purpose.
  19997. *
  19998. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19999. *
  20000. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20001. */
  20002. export class MaterialHelper {
  20003. /**
  20004. * Bind the current view position to an effect.
  20005. * @param effect The effect to be bound
  20006. * @param scene The scene the eyes position is used from
  20007. * @param variableName name of the shader variable that will hold the eye position
  20008. */
  20009. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20010. /**
  20011. * Helps preparing the defines values about the UVs in used in the effect.
  20012. * UVs are shared as much as we can accross channels in the shaders.
  20013. * @param texture The texture we are preparing the UVs for
  20014. * @param defines The defines to update
  20015. * @param key The channel key "diffuse", "specular"... used in the shader
  20016. */
  20017. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20018. /**
  20019. * Binds a texture matrix value to its corrsponding uniform
  20020. * @param texture The texture to bind the matrix for
  20021. * @param uniformBuffer The uniform buffer receivin the data
  20022. * @param key The channel key "diffuse", "specular"... used in the shader
  20023. */
  20024. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20025. /**
  20026. * Gets the current status of the fog (should it be enabled?)
  20027. * @param mesh defines the mesh to evaluate for fog support
  20028. * @param scene defines the hosting scene
  20029. * @returns true if fog must be enabled
  20030. */
  20031. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20032. /**
  20033. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20034. * @param mesh defines the current mesh
  20035. * @param scene defines the current scene
  20036. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20037. * @param pointsCloud defines if point cloud rendering has to be turned on
  20038. * @param fogEnabled defines if fog has to be turned on
  20039. * @param alphaTest defines if alpha testing has to be turned on
  20040. * @param defines defines the current list of defines
  20041. */
  20042. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20043. /**
  20044. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20045. * @param scene defines the current scene
  20046. * @param engine defines the current engine
  20047. * @param defines specifies the list of active defines
  20048. * @param useInstances defines if instances have to be turned on
  20049. * @param useClipPlane defines if clip plane have to be turned on
  20050. * @param useInstances defines if instances have to be turned on
  20051. * @param useThinInstances defines if thin instances have to be turned on
  20052. */
  20053. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20054. /**
  20055. * Prepares the defines for bones
  20056. * @param mesh The mesh containing the geometry data we will draw
  20057. * @param defines The defines to update
  20058. */
  20059. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20060. /**
  20061. * Prepares the defines for morph targets
  20062. * @param mesh The mesh containing the geometry data we will draw
  20063. * @param defines The defines to update
  20064. */
  20065. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20066. /**
  20067. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20068. * @param mesh The mesh containing the geometry data we will draw
  20069. * @param defines The defines to update
  20070. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20071. * @param useBones Precise whether bones should be used or not (override mesh info)
  20072. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20073. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20074. * @returns false if defines are considered not dirty and have not been checked
  20075. */
  20076. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20077. /**
  20078. * Prepares the defines related to multiview
  20079. * @param scene The scene we are intending to draw
  20080. * @param defines The defines to update
  20081. */
  20082. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20083. /**
  20084. * Prepares the defines related to the light information passed in parameter
  20085. * @param scene The scene we are intending to draw
  20086. * @param mesh The mesh the effect is compiling for
  20087. * @param light The light the effect is compiling for
  20088. * @param lightIndex The index of the light
  20089. * @param defines The defines to update
  20090. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20091. * @param state Defines the current state regarding what is needed (normals, etc...)
  20092. */
  20093. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20094. needNormals: boolean;
  20095. needRebuild: boolean;
  20096. shadowEnabled: boolean;
  20097. specularEnabled: boolean;
  20098. lightmapMode: boolean;
  20099. }): void;
  20100. /**
  20101. * Prepares the defines related to the light information passed in parameter
  20102. * @param scene The scene we are intending to draw
  20103. * @param mesh The mesh the effect is compiling for
  20104. * @param defines The defines to update
  20105. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20106. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20107. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20108. * @returns true if normals will be required for the rest of the effect
  20109. */
  20110. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20111. /**
  20112. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20113. * @param lightIndex defines the light index
  20114. * @param uniformsList The uniform list
  20115. * @param samplersList The sampler list
  20116. * @param projectedLightTexture defines if projected texture must be used
  20117. * @param uniformBuffersList defines an optional list of uniform buffers
  20118. */
  20119. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20120. /**
  20121. * Prepares the uniforms and samplers list to be used in the effect
  20122. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20123. * @param samplersList The sampler list
  20124. * @param defines The defines helping in the list generation
  20125. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20126. */
  20127. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20128. /**
  20129. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20130. * @param defines The defines to update while falling back
  20131. * @param fallbacks The authorized effect fallbacks
  20132. * @param maxSimultaneousLights The maximum number of lights allowed
  20133. * @param rank the current rank of the Effect
  20134. * @returns The newly affected rank
  20135. */
  20136. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20137. private static _TmpMorphInfluencers;
  20138. /**
  20139. * Prepares the list of attributes required for morph targets according to the effect defines.
  20140. * @param attribs The current list of supported attribs
  20141. * @param mesh The mesh to prepare the morph targets attributes for
  20142. * @param influencers The number of influencers
  20143. */
  20144. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20145. /**
  20146. * Prepares the list of attributes required for morph targets according to the effect defines.
  20147. * @param attribs The current list of supported attribs
  20148. * @param mesh The mesh to prepare the morph targets attributes for
  20149. * @param defines The current Defines of the effect
  20150. */
  20151. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20152. /**
  20153. * Prepares the list of attributes required for bones according to the effect defines.
  20154. * @param attribs The current list of supported attribs
  20155. * @param mesh The mesh to prepare the bones attributes for
  20156. * @param defines The current Defines of the effect
  20157. * @param fallbacks The current efffect fallback strategy
  20158. */
  20159. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20160. /**
  20161. * Check and prepare the list of attributes required for instances according to the effect defines.
  20162. * @param attribs The current list of supported attribs
  20163. * @param defines The current MaterialDefines of the effect
  20164. */
  20165. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20166. /**
  20167. * Add the list of attributes required for instances to the attribs array.
  20168. * @param attribs The current list of supported attribs
  20169. */
  20170. static PushAttributesForInstances(attribs: string[]): void;
  20171. /**
  20172. * Binds the light information to the effect.
  20173. * @param light The light containing the generator
  20174. * @param effect The effect we are binding the data to
  20175. * @param lightIndex The light index in the effect used to render
  20176. */
  20177. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20178. /**
  20179. * Binds the lights information from the scene to the effect for the given mesh.
  20180. * @param light Light to bind
  20181. * @param lightIndex Light index
  20182. * @param scene The scene where the light belongs to
  20183. * @param effect The effect we are binding the data to
  20184. * @param useSpecular Defines if specular is supported
  20185. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20186. */
  20187. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20188. /**
  20189. * Binds the lights information from the scene to the effect for the given mesh.
  20190. * @param scene The scene the lights belongs to
  20191. * @param mesh The mesh we are binding the information to render
  20192. * @param effect The effect we are binding the data to
  20193. * @param defines The generated defines for the effect
  20194. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20195. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20196. */
  20197. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20198. private static _tempFogColor;
  20199. /**
  20200. * Binds the fog information from the scene to the effect for the given mesh.
  20201. * @param scene The scene the lights belongs to
  20202. * @param mesh The mesh we are binding the information to render
  20203. * @param effect The effect we are binding the data to
  20204. * @param linearSpace Defines if the fog effect is applied in linear space
  20205. */
  20206. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20207. /**
  20208. * Binds the bones information from the mesh to the effect.
  20209. * @param mesh The mesh we are binding the information to render
  20210. * @param effect The effect we are binding the data to
  20211. */
  20212. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20213. /**
  20214. * Binds the morph targets information from the mesh to the effect.
  20215. * @param abstractMesh The mesh we are binding the information to render
  20216. * @param effect The effect we are binding the data to
  20217. */
  20218. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20219. /**
  20220. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20221. * @param defines The generated defines used in the effect
  20222. * @param effect The effect we are binding the data to
  20223. * @param scene The scene we are willing to render with logarithmic scale for
  20224. */
  20225. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20226. /**
  20227. * Binds the clip plane information from the scene to the effect.
  20228. * @param scene The scene the clip plane information are extracted from
  20229. * @param effect The effect we are binding the data to
  20230. */
  20231. static BindClipPlane(effect: Effect, scene: Scene): void;
  20232. }
  20233. }
  20234. declare module BABYLON {
  20235. /**
  20236. * Block used to expose an input value
  20237. */
  20238. export class InputBlock extends NodeMaterialBlock {
  20239. private _mode;
  20240. private _associatedVariableName;
  20241. private _storedValue;
  20242. private _valueCallback;
  20243. private _type;
  20244. private _animationType;
  20245. /** Gets or set a value used to limit the range of float values */
  20246. min: number;
  20247. /** Gets or set a value used to limit the range of float values */
  20248. max: number;
  20249. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20250. isBoolean: boolean;
  20251. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20252. matrixMode: number;
  20253. /** @hidden */
  20254. _systemValue: Nullable<NodeMaterialSystemValues>;
  20255. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20256. visibleInInspector: boolean;
  20257. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20258. isConstant: boolean;
  20259. /** Gets or sets the group to use to display this block in the Inspector */
  20260. groupInInspector: string;
  20261. /** Gets an observable raised when the value is changed */
  20262. onValueChangedObservable: Observable<InputBlock>;
  20263. /**
  20264. * Gets or sets the connection point type (default is float)
  20265. */
  20266. get type(): NodeMaterialBlockConnectionPointTypes;
  20267. /**
  20268. * Creates a new InputBlock
  20269. * @param name defines the block name
  20270. * @param target defines the target of that block (Vertex by default)
  20271. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20272. */
  20273. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20274. /**
  20275. * Gets the output component
  20276. */
  20277. get output(): NodeMaterialConnectionPoint;
  20278. /**
  20279. * Set the source of this connection point to a vertex attribute
  20280. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20281. * @returns the current connection point
  20282. */
  20283. setAsAttribute(attributeName?: string): InputBlock;
  20284. /**
  20285. * Set the source of this connection point to a system value
  20286. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20287. * @returns the current connection point
  20288. */
  20289. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20290. /**
  20291. * Gets or sets the value of that point.
  20292. * Please note that this value will be ignored if valueCallback is defined
  20293. */
  20294. get value(): any;
  20295. set value(value: any);
  20296. /**
  20297. * Gets or sets a callback used to get the value of that point.
  20298. * Please note that setting this value will force the connection point to ignore the value property
  20299. */
  20300. get valueCallback(): () => any;
  20301. set valueCallback(value: () => any);
  20302. /**
  20303. * Gets or sets the associated variable name in the shader
  20304. */
  20305. get associatedVariableName(): string;
  20306. set associatedVariableName(value: string);
  20307. /** Gets or sets the type of animation applied to the input */
  20308. get animationType(): AnimatedInputBlockTypes;
  20309. set animationType(value: AnimatedInputBlockTypes);
  20310. /**
  20311. * Gets a boolean indicating that this connection point not defined yet
  20312. */
  20313. get isUndefined(): boolean;
  20314. /**
  20315. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20316. * In this case the connection point name must be the name of the uniform to use.
  20317. * Can only be set on inputs
  20318. */
  20319. get isUniform(): boolean;
  20320. set isUniform(value: boolean);
  20321. /**
  20322. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20323. * In this case the connection point name must be the name of the attribute to use
  20324. * Can only be set on inputs
  20325. */
  20326. get isAttribute(): boolean;
  20327. set isAttribute(value: boolean);
  20328. /**
  20329. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20330. * Can only be set on exit points
  20331. */
  20332. get isVarying(): boolean;
  20333. set isVarying(value: boolean);
  20334. /**
  20335. * Gets a boolean indicating that the current connection point is a system value
  20336. */
  20337. get isSystemValue(): boolean;
  20338. /**
  20339. * Gets or sets the current well known value or null if not defined as a system value
  20340. */
  20341. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20342. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20343. /**
  20344. * Gets the current class name
  20345. * @returns the class name
  20346. */
  20347. getClassName(): string;
  20348. /**
  20349. * Animate the input if animationType !== None
  20350. * @param scene defines the rendering scene
  20351. */
  20352. animate(scene: Scene): void;
  20353. private _emitDefine;
  20354. initialize(state: NodeMaterialBuildState): void;
  20355. /**
  20356. * Set the input block to its default value (based on its type)
  20357. */
  20358. setDefaultValue(): void;
  20359. private _emitConstant;
  20360. /** @hidden */
  20361. get _noContextSwitch(): boolean;
  20362. private _emit;
  20363. /** @hidden */
  20364. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20365. /** @hidden */
  20366. _transmit(effect: Effect, scene: Scene): void;
  20367. protected _buildBlock(state: NodeMaterialBuildState): void;
  20368. protected _dumpPropertiesCode(): string;
  20369. dispose(): void;
  20370. serialize(): any;
  20371. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20372. }
  20373. }
  20374. declare module BABYLON {
  20375. /**
  20376. * Enum used to define the compatibility state between two connection points
  20377. */
  20378. export enum NodeMaterialConnectionPointCompatibilityStates {
  20379. /** Points are compatibles */
  20380. Compatible = 0,
  20381. /** Points are incompatible because of their types */
  20382. TypeIncompatible = 1,
  20383. /** Points are incompatible because of their targets (vertex vs fragment) */
  20384. TargetIncompatible = 2
  20385. }
  20386. /**
  20387. * Defines the direction of a connection point
  20388. */
  20389. export enum NodeMaterialConnectionPointDirection {
  20390. /** Input */
  20391. Input = 0,
  20392. /** Output */
  20393. Output = 1
  20394. }
  20395. /**
  20396. * Defines a connection point for a block
  20397. */
  20398. export class NodeMaterialConnectionPoint {
  20399. /** @hidden */
  20400. _ownerBlock: NodeMaterialBlock;
  20401. /** @hidden */
  20402. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20403. private _endpoints;
  20404. private _associatedVariableName;
  20405. private _direction;
  20406. /** @hidden */
  20407. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20408. /** @hidden */
  20409. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20410. private _type;
  20411. /** @hidden */
  20412. _enforceAssociatedVariableName: boolean;
  20413. /** Gets the direction of the point */
  20414. get direction(): NodeMaterialConnectionPointDirection;
  20415. /** Indicates that this connection point needs dual validation before being connected to another point */
  20416. needDualDirectionValidation: boolean;
  20417. /**
  20418. * Gets or sets the additional types supported by this connection point
  20419. */
  20420. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20421. /**
  20422. * Gets or sets the additional types excluded by this connection point
  20423. */
  20424. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20425. /**
  20426. * Observable triggered when this point is connected
  20427. */
  20428. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20429. /**
  20430. * Gets or sets the associated variable name in the shader
  20431. */
  20432. get associatedVariableName(): string;
  20433. set associatedVariableName(value: string);
  20434. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20435. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20436. /**
  20437. * Gets or sets the connection point type (default is float)
  20438. */
  20439. get type(): NodeMaterialBlockConnectionPointTypes;
  20440. set type(value: NodeMaterialBlockConnectionPointTypes);
  20441. /**
  20442. * Gets or sets the connection point name
  20443. */
  20444. name: string;
  20445. /**
  20446. * Gets or sets the connection point name
  20447. */
  20448. displayName: string;
  20449. /**
  20450. * Gets or sets a boolean indicating that this connection point can be omitted
  20451. */
  20452. isOptional: boolean;
  20453. /**
  20454. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20455. */
  20456. isExposedOnFrame: boolean;
  20457. /**
  20458. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20459. */
  20460. define: string;
  20461. /** @hidden */
  20462. _prioritizeVertex: boolean;
  20463. private _target;
  20464. /** Gets or sets the target of that connection point */
  20465. get target(): NodeMaterialBlockTargets;
  20466. set target(value: NodeMaterialBlockTargets);
  20467. /**
  20468. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20469. */
  20470. get isConnected(): boolean;
  20471. /**
  20472. * Gets a boolean indicating that the current point is connected to an input block
  20473. */
  20474. get isConnectedToInputBlock(): boolean;
  20475. /**
  20476. * Gets a the connected input block (if any)
  20477. */
  20478. get connectInputBlock(): Nullable<InputBlock>;
  20479. /** Get the other side of the connection (if any) */
  20480. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20481. /** Get the block that owns this connection point */
  20482. get ownerBlock(): NodeMaterialBlock;
  20483. /** Get the block connected on the other side of this connection (if any) */
  20484. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20485. /** Get the block connected on the endpoints of this connection (if any) */
  20486. get connectedBlocks(): Array<NodeMaterialBlock>;
  20487. /** Gets the list of connected endpoints */
  20488. get endpoints(): NodeMaterialConnectionPoint[];
  20489. /** Gets a boolean indicating if that output point is connected to at least one input */
  20490. get hasEndpoints(): boolean;
  20491. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20492. get isConnectedInVertexShader(): boolean;
  20493. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20494. get isConnectedInFragmentShader(): boolean;
  20495. /**
  20496. * Creates a block suitable to be used as an input for this input point.
  20497. * If null is returned, a block based on the point type will be created.
  20498. * @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
  20499. */
  20500. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20501. /**
  20502. * Creates a new connection point
  20503. * @param name defines the connection point name
  20504. * @param ownerBlock defines the block hosting this connection point
  20505. * @param direction defines the direction of the connection point
  20506. */
  20507. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20508. /**
  20509. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20510. * @returns the class name
  20511. */
  20512. getClassName(): string;
  20513. /**
  20514. * Gets a boolean indicating if the current point can be connected to another point
  20515. * @param connectionPoint defines the other connection point
  20516. * @returns a boolean
  20517. */
  20518. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20519. /**
  20520. * Gets a number indicating if the current point can be connected to another point
  20521. * @param connectionPoint defines the other connection point
  20522. * @returns a number defining the compatibility state
  20523. */
  20524. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20525. /**
  20526. * Connect this point to another connection point
  20527. * @param connectionPoint defines the other connection point
  20528. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20529. * @returns the current connection point
  20530. */
  20531. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20532. /**
  20533. * Disconnect this point from one of his endpoint
  20534. * @param endpoint defines the other connection point
  20535. * @returns the current connection point
  20536. */
  20537. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20538. /**
  20539. * Serializes this point in a JSON representation
  20540. * @param isInput defines if the connection point is an input (default is true)
  20541. * @returns the serialized point object
  20542. */
  20543. serialize(isInput?: boolean): any;
  20544. /**
  20545. * Release resources
  20546. */
  20547. dispose(): void;
  20548. }
  20549. }
  20550. declare module BABYLON {
  20551. /**
  20552. * Enum used to define the material modes
  20553. */
  20554. export enum NodeMaterialModes {
  20555. /** Regular material */
  20556. Material = 0,
  20557. /** For post process */
  20558. PostProcess = 1,
  20559. /** For particle system */
  20560. Particle = 2
  20561. }
  20562. }
  20563. declare module BABYLON {
  20564. /**
  20565. * Block used to read a texture from a sampler
  20566. */
  20567. export class TextureBlock extends NodeMaterialBlock {
  20568. private _defineName;
  20569. private _linearDefineName;
  20570. private _gammaDefineName;
  20571. private _tempTextureRead;
  20572. private _samplerName;
  20573. private _transformedUVName;
  20574. private _textureTransformName;
  20575. private _textureInfoName;
  20576. private _mainUVName;
  20577. private _mainUVDefineName;
  20578. private _fragmentOnly;
  20579. /**
  20580. * Gets or sets the texture associated with the node
  20581. */
  20582. texture: Nullable<Texture>;
  20583. /**
  20584. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20585. */
  20586. convertToGammaSpace: boolean;
  20587. /**
  20588. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20589. */
  20590. convertToLinearSpace: boolean;
  20591. /**
  20592. * Create a new TextureBlock
  20593. * @param name defines the block name
  20594. */
  20595. constructor(name: string, fragmentOnly?: boolean);
  20596. /**
  20597. * Gets the current class name
  20598. * @returns the class name
  20599. */
  20600. getClassName(): string;
  20601. /**
  20602. * Gets the uv input component
  20603. */
  20604. get uv(): NodeMaterialConnectionPoint;
  20605. /**
  20606. * Gets the rgba output component
  20607. */
  20608. get rgba(): NodeMaterialConnectionPoint;
  20609. /**
  20610. * Gets the rgb output component
  20611. */
  20612. get rgb(): NodeMaterialConnectionPoint;
  20613. /**
  20614. * Gets the r output component
  20615. */
  20616. get r(): NodeMaterialConnectionPoint;
  20617. /**
  20618. * Gets the g output component
  20619. */
  20620. get g(): NodeMaterialConnectionPoint;
  20621. /**
  20622. * Gets the b output component
  20623. */
  20624. get b(): NodeMaterialConnectionPoint;
  20625. /**
  20626. * Gets the a output component
  20627. */
  20628. get a(): NodeMaterialConnectionPoint;
  20629. get target(): NodeMaterialBlockTargets;
  20630. autoConfigure(material: NodeMaterial): void;
  20631. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20633. isReady(): boolean;
  20634. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20635. private get _isMixed();
  20636. private _injectVertexCode;
  20637. private _writeTextureRead;
  20638. private _writeOutput;
  20639. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20640. protected _dumpPropertiesCode(): string;
  20641. serialize(): any;
  20642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20643. }
  20644. }
  20645. declare module BABYLON {
  20646. /** @hidden */
  20647. export var reflectionFunction: {
  20648. name: string;
  20649. shader: string;
  20650. };
  20651. }
  20652. declare module BABYLON {
  20653. /**
  20654. * Base block used to read a reflection texture from a sampler
  20655. */
  20656. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20657. /** @hidden */
  20658. _define3DName: string;
  20659. /** @hidden */
  20660. _defineCubicName: string;
  20661. /** @hidden */
  20662. _defineExplicitName: string;
  20663. /** @hidden */
  20664. _defineProjectionName: string;
  20665. /** @hidden */
  20666. _defineLocalCubicName: string;
  20667. /** @hidden */
  20668. _defineSphericalName: string;
  20669. /** @hidden */
  20670. _definePlanarName: string;
  20671. /** @hidden */
  20672. _defineEquirectangularName: string;
  20673. /** @hidden */
  20674. _defineMirroredEquirectangularFixedName: string;
  20675. /** @hidden */
  20676. _defineEquirectangularFixedName: string;
  20677. /** @hidden */
  20678. _defineSkyboxName: string;
  20679. /** @hidden */
  20680. _defineOppositeZ: string;
  20681. /** @hidden */
  20682. _cubeSamplerName: string;
  20683. /** @hidden */
  20684. _2DSamplerName: string;
  20685. protected _positionUVWName: string;
  20686. protected _directionWName: string;
  20687. protected _reflectionVectorName: string;
  20688. /** @hidden */
  20689. _reflectionCoordsName: string;
  20690. /** @hidden */
  20691. _reflectionMatrixName: string;
  20692. protected _reflectionColorName: string;
  20693. /**
  20694. * Gets or sets the texture associated with the node
  20695. */
  20696. texture: Nullable<BaseTexture>;
  20697. /**
  20698. * Create a new ReflectionTextureBaseBlock
  20699. * @param name defines the block name
  20700. */
  20701. constructor(name: string);
  20702. /**
  20703. * Gets the current class name
  20704. * @returns the class name
  20705. */
  20706. getClassName(): string;
  20707. /**
  20708. * Gets the world position input component
  20709. */
  20710. abstract get position(): NodeMaterialConnectionPoint;
  20711. /**
  20712. * Gets the world position input component
  20713. */
  20714. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20715. /**
  20716. * Gets the world normal input component
  20717. */
  20718. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20719. /**
  20720. * Gets the world input component
  20721. */
  20722. abstract get world(): NodeMaterialConnectionPoint;
  20723. /**
  20724. * Gets the camera (or eye) position component
  20725. */
  20726. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20727. /**
  20728. * Gets the view input component
  20729. */
  20730. abstract get view(): NodeMaterialConnectionPoint;
  20731. protected _getTexture(): Nullable<BaseTexture>;
  20732. autoConfigure(material: NodeMaterial): void;
  20733. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20734. isReady(): boolean;
  20735. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20736. /**
  20737. * Gets the code to inject in the vertex shader
  20738. * @param state current state of the node material building
  20739. * @returns the shader code
  20740. */
  20741. handleVertexSide(state: NodeMaterialBuildState): string;
  20742. /**
  20743. * Handles the inits for the fragment code path
  20744. * @param state node material build state
  20745. */
  20746. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20747. /**
  20748. * Generates the reflection coords code for the fragment code path
  20749. * @param worldNormalVarName name of the world normal variable
  20750. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20751. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20752. * @returns the shader code
  20753. */
  20754. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20755. /**
  20756. * Generates the reflection color code for the fragment code path
  20757. * @param lodVarName name of the lod variable
  20758. * @param swizzleLookupTexture swizzle to use for the final color variable
  20759. * @returns the shader code
  20760. */
  20761. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20762. /**
  20763. * Generates the code corresponding to the connected output points
  20764. * @param state node material build state
  20765. * @param varName name of the variable to output
  20766. * @returns the shader code
  20767. */
  20768. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20769. protected _buildBlock(state: NodeMaterialBuildState): this;
  20770. protected _dumpPropertiesCode(): string;
  20771. serialize(): any;
  20772. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20773. }
  20774. }
  20775. declare module BABYLON {
  20776. /**
  20777. * Defines a connection point to be used for points with a custom object type
  20778. */
  20779. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20780. private _blockType;
  20781. private _blockName;
  20782. private _nameForCheking?;
  20783. /**
  20784. * Creates a new connection point
  20785. * @param name defines the connection point name
  20786. * @param ownerBlock defines the block hosting this connection point
  20787. * @param direction defines the direction of the connection point
  20788. */
  20789. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20790. /**
  20791. * Gets a number indicating if the current point can be connected to another point
  20792. * @param connectionPoint defines the other connection point
  20793. * @returns a number defining the compatibility state
  20794. */
  20795. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20796. /**
  20797. * Creates a block suitable to be used as an input for this input point.
  20798. * If null is returned, a block based on the point type will be created.
  20799. * @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
  20800. */
  20801. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20802. }
  20803. }
  20804. declare module BABYLON {
  20805. /**
  20806. * Enum defining the type of properties that can be edited in the property pages in the NME
  20807. */
  20808. export enum PropertyTypeForEdition {
  20809. /** property is a boolean */
  20810. Boolean = 0,
  20811. /** property is a float */
  20812. Float = 1,
  20813. /** property is a Vector2 */
  20814. Vector2 = 2,
  20815. /** property is a list of values */
  20816. List = 3
  20817. }
  20818. /**
  20819. * Interface that defines an option in a variable of type list
  20820. */
  20821. export interface IEditablePropertyListOption {
  20822. /** label of the option */
  20823. "label": string;
  20824. /** value of the option */
  20825. "value": number;
  20826. }
  20827. /**
  20828. * Interface that defines the options available for an editable property
  20829. */
  20830. export interface IEditablePropertyOption {
  20831. /** min value */
  20832. "min"?: number;
  20833. /** max value */
  20834. "max"?: number;
  20835. /** notifiers: indicates which actions to take when the property is changed */
  20836. "notifiers"?: {
  20837. /** the material should be rebuilt */
  20838. "rebuild"?: boolean;
  20839. /** the preview should be updated */
  20840. "update"?: boolean;
  20841. };
  20842. /** list of the options for a variable of type list */
  20843. "options"?: IEditablePropertyListOption[];
  20844. }
  20845. /**
  20846. * Interface that describes an editable property
  20847. */
  20848. export interface IPropertyDescriptionForEdition {
  20849. /** name of the property */
  20850. "propertyName": string;
  20851. /** display name of the property */
  20852. "displayName": string;
  20853. /** type of the property */
  20854. "type": PropertyTypeForEdition;
  20855. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20856. "groupName": string;
  20857. /** options for the property */
  20858. "options": IEditablePropertyOption;
  20859. }
  20860. /**
  20861. * Decorator that flags a property in a node material block as being editable
  20862. */
  20863. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20864. }
  20865. declare module BABYLON {
  20866. /**
  20867. * Block used to implement the refraction part of the sub surface module of the PBR material
  20868. */
  20869. export class RefractionBlock extends NodeMaterialBlock {
  20870. /** @hidden */
  20871. _define3DName: string;
  20872. /** @hidden */
  20873. _refractionMatrixName: string;
  20874. /** @hidden */
  20875. _defineLODRefractionAlpha: string;
  20876. /** @hidden */
  20877. _defineLinearSpecularRefraction: string;
  20878. /** @hidden */
  20879. _defineOppositeZ: string;
  20880. /** @hidden */
  20881. _cubeSamplerName: string;
  20882. /** @hidden */
  20883. _2DSamplerName: string;
  20884. /** @hidden */
  20885. _vRefractionMicrosurfaceInfosName: string;
  20886. /** @hidden */
  20887. _vRefractionInfosName: string;
  20888. private _scene;
  20889. /**
  20890. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20891. * Materials half opaque for instance using refraction could benefit from this control.
  20892. */
  20893. linkRefractionWithTransparency: boolean;
  20894. /**
  20895. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20896. */
  20897. invertRefractionY: boolean;
  20898. /**
  20899. * Gets or sets the texture associated with the node
  20900. */
  20901. texture: Nullable<BaseTexture>;
  20902. /**
  20903. * Create a new RefractionBlock
  20904. * @param name defines the block name
  20905. */
  20906. constructor(name: string);
  20907. /**
  20908. * Gets the current class name
  20909. * @returns the class name
  20910. */
  20911. getClassName(): string;
  20912. /**
  20913. * Gets the intensity input component
  20914. */
  20915. get intensity(): NodeMaterialConnectionPoint;
  20916. /**
  20917. * Gets the index of refraction input component
  20918. */
  20919. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20920. /**
  20921. * Gets the tint at distance input component
  20922. */
  20923. get tintAtDistance(): NodeMaterialConnectionPoint;
  20924. /**
  20925. * Gets the view input component
  20926. */
  20927. get view(): NodeMaterialConnectionPoint;
  20928. /**
  20929. * Gets the refraction object output component
  20930. */
  20931. get refraction(): NodeMaterialConnectionPoint;
  20932. /**
  20933. * Returns true if the block has a texture
  20934. */
  20935. get hasTexture(): boolean;
  20936. protected _getTexture(): Nullable<BaseTexture>;
  20937. autoConfigure(material: NodeMaterial): void;
  20938. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20939. isReady(): boolean;
  20940. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20941. /**
  20942. * Gets the main code of the block (fragment side)
  20943. * @param state current state of the node material building
  20944. * @returns the shader code
  20945. */
  20946. getCode(state: NodeMaterialBuildState): string;
  20947. protected _buildBlock(state: NodeMaterialBuildState): this;
  20948. protected _dumpPropertiesCode(): string;
  20949. serialize(): any;
  20950. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20951. }
  20952. }
  20953. declare module BABYLON {
  20954. /**
  20955. * Base block used as input for post process
  20956. */
  20957. export class CurrentScreenBlock extends NodeMaterialBlock {
  20958. private _samplerName;
  20959. private _linearDefineName;
  20960. private _gammaDefineName;
  20961. private _mainUVName;
  20962. private _tempTextureRead;
  20963. /**
  20964. * Gets or sets the texture associated with the node
  20965. */
  20966. texture: Nullable<BaseTexture>;
  20967. /**
  20968. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20969. */
  20970. convertToGammaSpace: boolean;
  20971. /**
  20972. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20973. */
  20974. convertToLinearSpace: boolean;
  20975. /**
  20976. * Create a new CurrentScreenBlock
  20977. * @param name defines the block name
  20978. */
  20979. constructor(name: string);
  20980. /**
  20981. * Gets the current class name
  20982. * @returns the class name
  20983. */
  20984. getClassName(): string;
  20985. /**
  20986. * Gets the uv input component
  20987. */
  20988. get uv(): NodeMaterialConnectionPoint;
  20989. /**
  20990. * Gets the rgba output component
  20991. */
  20992. get rgba(): NodeMaterialConnectionPoint;
  20993. /**
  20994. * Gets the rgb output component
  20995. */
  20996. get rgb(): NodeMaterialConnectionPoint;
  20997. /**
  20998. * Gets the r output component
  20999. */
  21000. get r(): NodeMaterialConnectionPoint;
  21001. /**
  21002. * Gets the g output component
  21003. */
  21004. get g(): NodeMaterialConnectionPoint;
  21005. /**
  21006. * Gets the b output component
  21007. */
  21008. get b(): NodeMaterialConnectionPoint;
  21009. /**
  21010. * Gets the a output component
  21011. */
  21012. get a(): NodeMaterialConnectionPoint;
  21013. /**
  21014. * Initialize the block and prepare the context for build
  21015. * @param state defines the state that will be used for the build
  21016. */
  21017. initialize(state: NodeMaterialBuildState): void;
  21018. get target(): NodeMaterialBlockTargets;
  21019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21020. isReady(): boolean;
  21021. private _injectVertexCode;
  21022. private _writeTextureRead;
  21023. private _writeOutput;
  21024. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21025. serialize(): any;
  21026. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21027. }
  21028. }
  21029. declare module BABYLON {
  21030. /**
  21031. * Base block used for the particle texture
  21032. */
  21033. export class ParticleTextureBlock extends NodeMaterialBlock {
  21034. private _samplerName;
  21035. private _linearDefineName;
  21036. private _gammaDefineName;
  21037. private _tempTextureRead;
  21038. /**
  21039. * Gets or sets the texture associated with the node
  21040. */
  21041. texture: Nullable<BaseTexture>;
  21042. /**
  21043. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21044. */
  21045. convertToGammaSpace: boolean;
  21046. /**
  21047. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21048. */
  21049. convertToLinearSpace: boolean;
  21050. /**
  21051. * Create a new ParticleTextureBlock
  21052. * @param name defines the block name
  21053. */
  21054. constructor(name: string);
  21055. /**
  21056. * Gets the current class name
  21057. * @returns the class name
  21058. */
  21059. getClassName(): string;
  21060. /**
  21061. * Gets the uv input component
  21062. */
  21063. get uv(): NodeMaterialConnectionPoint;
  21064. /**
  21065. * Gets the rgba output component
  21066. */
  21067. get rgba(): NodeMaterialConnectionPoint;
  21068. /**
  21069. * Gets the rgb output component
  21070. */
  21071. get rgb(): NodeMaterialConnectionPoint;
  21072. /**
  21073. * Gets the r output component
  21074. */
  21075. get r(): NodeMaterialConnectionPoint;
  21076. /**
  21077. * Gets the g output component
  21078. */
  21079. get g(): NodeMaterialConnectionPoint;
  21080. /**
  21081. * Gets the b output component
  21082. */
  21083. get b(): NodeMaterialConnectionPoint;
  21084. /**
  21085. * Gets the a output component
  21086. */
  21087. get a(): NodeMaterialConnectionPoint;
  21088. /**
  21089. * Initialize the block and prepare the context for build
  21090. * @param state defines the state that will be used for the build
  21091. */
  21092. initialize(state: NodeMaterialBuildState): void;
  21093. autoConfigure(material: NodeMaterial): void;
  21094. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21095. isReady(): boolean;
  21096. private _writeOutput;
  21097. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21098. serialize(): any;
  21099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21100. }
  21101. }
  21102. declare module BABYLON {
  21103. /**
  21104. * Class used to store shared data between 2 NodeMaterialBuildState
  21105. */
  21106. export class NodeMaterialBuildStateSharedData {
  21107. /**
  21108. * Gets the list of emitted varyings
  21109. */
  21110. temps: string[];
  21111. /**
  21112. * Gets the list of emitted varyings
  21113. */
  21114. varyings: string[];
  21115. /**
  21116. * Gets the varying declaration string
  21117. */
  21118. varyingDeclaration: string;
  21119. /**
  21120. * Input blocks
  21121. */
  21122. inputBlocks: InputBlock[];
  21123. /**
  21124. * Input blocks
  21125. */
  21126. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21127. /**
  21128. * Bindable blocks (Blocks that need to set data to the effect)
  21129. */
  21130. bindableBlocks: NodeMaterialBlock[];
  21131. /**
  21132. * List of blocks that can provide a compilation fallback
  21133. */
  21134. blocksWithFallbacks: NodeMaterialBlock[];
  21135. /**
  21136. * List of blocks that can provide a define update
  21137. */
  21138. blocksWithDefines: NodeMaterialBlock[];
  21139. /**
  21140. * List of blocks that can provide a repeatable content
  21141. */
  21142. repeatableContentBlocks: NodeMaterialBlock[];
  21143. /**
  21144. * List of blocks that can provide a dynamic list of uniforms
  21145. */
  21146. dynamicUniformBlocks: NodeMaterialBlock[];
  21147. /**
  21148. * List of blocks that can block the isReady function for the material
  21149. */
  21150. blockingBlocks: NodeMaterialBlock[];
  21151. /**
  21152. * Gets the list of animated inputs
  21153. */
  21154. animatedInputs: InputBlock[];
  21155. /**
  21156. * Build Id used to avoid multiple recompilations
  21157. */
  21158. buildId: number;
  21159. /** List of emitted variables */
  21160. variableNames: {
  21161. [key: string]: number;
  21162. };
  21163. /** List of emitted defines */
  21164. defineNames: {
  21165. [key: string]: number;
  21166. };
  21167. /** Should emit comments? */
  21168. emitComments: boolean;
  21169. /** Emit build activity */
  21170. verbose: boolean;
  21171. /** Gets or sets the hosting scene */
  21172. scene: Scene;
  21173. /**
  21174. * Gets the compilation hints emitted at compilation time
  21175. */
  21176. hints: {
  21177. needWorldViewMatrix: boolean;
  21178. needWorldViewProjectionMatrix: boolean;
  21179. needAlphaBlending: boolean;
  21180. needAlphaTesting: boolean;
  21181. };
  21182. /**
  21183. * List of compilation checks
  21184. */
  21185. checks: {
  21186. emitVertex: boolean;
  21187. emitFragment: boolean;
  21188. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21189. };
  21190. /**
  21191. * Is vertex program allowed to be empty?
  21192. */
  21193. allowEmptyVertexProgram: boolean;
  21194. /** Creates a new shared data */
  21195. constructor();
  21196. /**
  21197. * Emits console errors and exceptions if there is a failing check
  21198. */
  21199. emitErrors(): void;
  21200. }
  21201. }
  21202. declare module BABYLON {
  21203. /**
  21204. * Class used to store node based material build state
  21205. */
  21206. export class NodeMaterialBuildState {
  21207. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21208. supportUniformBuffers: boolean;
  21209. /**
  21210. * Gets the list of emitted attributes
  21211. */
  21212. attributes: string[];
  21213. /**
  21214. * Gets the list of emitted uniforms
  21215. */
  21216. uniforms: string[];
  21217. /**
  21218. * Gets the list of emitted constants
  21219. */
  21220. constants: string[];
  21221. /**
  21222. * Gets the list of emitted samplers
  21223. */
  21224. samplers: string[];
  21225. /**
  21226. * Gets the list of emitted functions
  21227. */
  21228. functions: {
  21229. [key: string]: string;
  21230. };
  21231. /**
  21232. * Gets the list of emitted extensions
  21233. */
  21234. extensions: {
  21235. [key: string]: string;
  21236. };
  21237. /**
  21238. * Gets the target of the compilation state
  21239. */
  21240. target: NodeMaterialBlockTargets;
  21241. /**
  21242. * Gets the list of emitted counters
  21243. */
  21244. counters: {
  21245. [key: string]: number;
  21246. };
  21247. /**
  21248. * Shared data between multiple NodeMaterialBuildState instances
  21249. */
  21250. sharedData: NodeMaterialBuildStateSharedData;
  21251. /** @hidden */
  21252. _vertexState: NodeMaterialBuildState;
  21253. /** @hidden */
  21254. _attributeDeclaration: string;
  21255. /** @hidden */
  21256. _uniformDeclaration: string;
  21257. /** @hidden */
  21258. _constantDeclaration: string;
  21259. /** @hidden */
  21260. _samplerDeclaration: string;
  21261. /** @hidden */
  21262. _varyingTransfer: string;
  21263. /** @hidden */
  21264. _injectAtEnd: string;
  21265. private _repeatableContentAnchorIndex;
  21266. /** @hidden */
  21267. _builtCompilationString: string;
  21268. /**
  21269. * Gets the emitted compilation strings
  21270. */
  21271. compilationString: string;
  21272. /**
  21273. * Finalize the compilation strings
  21274. * @param state defines the current compilation state
  21275. */
  21276. finalize(state: NodeMaterialBuildState): void;
  21277. /** @hidden */
  21278. get _repeatableContentAnchor(): string;
  21279. /** @hidden */
  21280. _getFreeVariableName(prefix: string): string;
  21281. /** @hidden */
  21282. _getFreeDefineName(prefix: string): string;
  21283. /** @hidden */
  21284. _excludeVariableName(name: string): void;
  21285. /** @hidden */
  21286. _emit2DSampler(name: string): void;
  21287. /** @hidden */
  21288. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21289. /** @hidden */
  21290. _emitExtension(name: string, extension: string, define?: string): void;
  21291. /** @hidden */
  21292. _emitFunction(name: string, code: string, comments: string): void;
  21293. /** @hidden */
  21294. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21295. replaceStrings?: {
  21296. search: RegExp;
  21297. replace: string;
  21298. }[];
  21299. repeatKey?: string;
  21300. }): string;
  21301. /** @hidden */
  21302. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21303. repeatKey?: string;
  21304. removeAttributes?: boolean;
  21305. removeUniforms?: boolean;
  21306. removeVaryings?: boolean;
  21307. removeIfDef?: boolean;
  21308. replaceStrings?: {
  21309. search: RegExp;
  21310. replace: string;
  21311. }[];
  21312. }, storeKey?: string): void;
  21313. /** @hidden */
  21314. _registerTempVariable(name: string): boolean;
  21315. /** @hidden */
  21316. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21317. /** @hidden */
  21318. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21319. /** @hidden */
  21320. _emitFloat(value: number): string;
  21321. }
  21322. }
  21323. declare module BABYLON {
  21324. /**
  21325. * Helper class used to generate session unique ID
  21326. */
  21327. export class UniqueIdGenerator {
  21328. private static _UniqueIdCounter;
  21329. /**
  21330. * Gets an unique (relatively to the current scene) Id
  21331. */
  21332. static get UniqueId(): number;
  21333. }
  21334. }
  21335. declare module BABYLON {
  21336. /**
  21337. * Defines a block that can be used inside a node based material
  21338. */
  21339. export class NodeMaterialBlock {
  21340. private _buildId;
  21341. private _buildTarget;
  21342. private _target;
  21343. private _isFinalMerger;
  21344. private _isInput;
  21345. protected _isUnique: boolean;
  21346. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21347. inputsAreExclusive: boolean;
  21348. /** @hidden */
  21349. _codeVariableName: string;
  21350. /** @hidden */
  21351. _inputs: NodeMaterialConnectionPoint[];
  21352. /** @hidden */
  21353. _outputs: NodeMaterialConnectionPoint[];
  21354. /** @hidden */
  21355. _preparationId: number;
  21356. /**
  21357. * Gets or sets the name of the block
  21358. */
  21359. name: string;
  21360. /**
  21361. * Gets or sets the unique id of the node
  21362. */
  21363. uniqueId: number;
  21364. /**
  21365. * Gets or sets the comments associated with this block
  21366. */
  21367. comments: string;
  21368. /**
  21369. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21370. */
  21371. get isUnique(): boolean;
  21372. /**
  21373. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21374. */
  21375. get isFinalMerger(): boolean;
  21376. /**
  21377. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21378. */
  21379. get isInput(): boolean;
  21380. /**
  21381. * Gets or sets the build Id
  21382. */
  21383. get buildId(): number;
  21384. set buildId(value: number);
  21385. /**
  21386. * Gets or sets the target of the block
  21387. */
  21388. get target(): NodeMaterialBlockTargets;
  21389. set target(value: NodeMaterialBlockTargets);
  21390. /**
  21391. * Gets the list of input points
  21392. */
  21393. get inputs(): NodeMaterialConnectionPoint[];
  21394. /** Gets the list of output points */
  21395. get outputs(): NodeMaterialConnectionPoint[];
  21396. /**
  21397. * Find an input by its name
  21398. * @param name defines the name of the input to look for
  21399. * @returns the input or null if not found
  21400. */
  21401. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21402. /**
  21403. * Find an output by its name
  21404. * @param name defines the name of the outputto look for
  21405. * @returns the output or null if not found
  21406. */
  21407. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21408. /**
  21409. * Creates a new NodeMaterialBlock
  21410. * @param name defines the block name
  21411. * @param target defines the target of that block (Vertex by default)
  21412. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21413. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21414. */
  21415. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21416. /**
  21417. * Initialize the block and prepare the context for build
  21418. * @param state defines the state that will be used for the build
  21419. */
  21420. initialize(state: NodeMaterialBuildState): void;
  21421. /**
  21422. * Bind data to effect. Will only be called for blocks with isBindable === true
  21423. * @param effect defines the effect to bind data to
  21424. * @param nodeMaterial defines the hosting NodeMaterial
  21425. * @param mesh defines the mesh that will be rendered
  21426. * @param subMesh defines the submesh that will be rendered
  21427. */
  21428. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21429. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21430. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21431. protected _writeFloat(value: number): string;
  21432. /**
  21433. * Gets the current class name e.g. "NodeMaterialBlock"
  21434. * @returns the class name
  21435. */
  21436. getClassName(): string;
  21437. /**
  21438. * Register a new input. Must be called inside a block constructor
  21439. * @param name defines the connection point name
  21440. * @param type defines the connection point type
  21441. * @param isOptional defines a boolean indicating that this input can be omitted
  21442. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21443. * @param point an already created connection point. If not provided, create a new one
  21444. * @returns the current block
  21445. */
  21446. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21447. /**
  21448. * Register a new output. Must be called inside a block constructor
  21449. * @param name defines the connection point name
  21450. * @param type defines the connection point type
  21451. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21452. * @param point an already created connection point. If not provided, create a new one
  21453. * @returns the current block
  21454. */
  21455. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21456. /**
  21457. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21458. * @param forOutput defines an optional connection point to check compatibility with
  21459. * @returns the first available input or null
  21460. */
  21461. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21462. /**
  21463. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21464. * @param forBlock defines an optional block to check compatibility with
  21465. * @returns the first available input or null
  21466. */
  21467. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21468. /**
  21469. * Gets the sibling of the given output
  21470. * @param current defines the current output
  21471. * @returns the next output in the list or null
  21472. */
  21473. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21474. /**
  21475. * Connect current block with another block
  21476. * @param other defines the block to connect with
  21477. * @param options define the various options to help pick the right connections
  21478. * @returns the current block
  21479. */
  21480. connectTo(other: NodeMaterialBlock, options?: {
  21481. input?: string;
  21482. output?: string;
  21483. outputSwizzle?: string;
  21484. }): this | undefined;
  21485. protected _buildBlock(state: NodeMaterialBuildState): void;
  21486. /**
  21487. * Add uniforms, samplers and uniform buffers at compilation time
  21488. * @param state defines the state to update
  21489. * @param nodeMaterial defines the node material requesting the update
  21490. * @param defines defines the material defines to update
  21491. * @param uniformBuffers defines the list of uniform buffer names
  21492. */
  21493. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21494. /**
  21495. * Add potential fallbacks if shader compilation fails
  21496. * @param mesh defines the mesh to be rendered
  21497. * @param fallbacks defines the current prioritized list of fallbacks
  21498. */
  21499. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21500. /**
  21501. * Initialize defines for shader compilation
  21502. * @param mesh defines the mesh to be rendered
  21503. * @param nodeMaterial defines the node material requesting the update
  21504. * @param defines defines the material defines to update
  21505. * @param useInstances specifies that instances should be used
  21506. */
  21507. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21508. /**
  21509. * Update defines for shader compilation
  21510. * @param mesh defines the mesh to be rendered
  21511. * @param nodeMaterial defines the node material requesting the update
  21512. * @param defines defines the material defines to update
  21513. * @param useInstances specifies that instances should be used
  21514. * @param subMesh defines which submesh to render
  21515. */
  21516. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21517. /**
  21518. * Lets the block try to connect some inputs automatically
  21519. * @param material defines the hosting NodeMaterial
  21520. */
  21521. autoConfigure(material: NodeMaterial): void;
  21522. /**
  21523. * Function called when a block is declared as repeatable content generator
  21524. * @param vertexShaderState defines the current compilation state for the vertex shader
  21525. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21526. * @param mesh defines the mesh to be rendered
  21527. * @param defines defines the material defines to update
  21528. */
  21529. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21530. /**
  21531. * Checks if the block is ready
  21532. * @param mesh defines the mesh to be rendered
  21533. * @param nodeMaterial defines the node material requesting the update
  21534. * @param defines defines the material defines to update
  21535. * @param useInstances specifies that instances should be used
  21536. * @returns true if the block is ready
  21537. */
  21538. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21539. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21540. private _processBuild;
  21541. /**
  21542. * Compile the current node and generate the shader code
  21543. * @param state defines the current compilation state (uniforms, samplers, current string)
  21544. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21545. * @returns true if already built
  21546. */
  21547. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21548. protected _inputRename(name: string): string;
  21549. protected _outputRename(name: string): string;
  21550. protected _dumpPropertiesCode(): string;
  21551. /** @hidden */
  21552. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21553. /** @hidden */
  21554. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21555. /**
  21556. * Clone the current block to a new identical block
  21557. * @param scene defines the hosting scene
  21558. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21559. * @returns a copy of the current block
  21560. */
  21561. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21562. /**
  21563. * Serializes this block in a JSON representation
  21564. * @returns the serialized block object
  21565. */
  21566. serialize(): any;
  21567. /** @hidden */
  21568. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21569. private _deserializePortDisplayNamesAndExposedOnFrame;
  21570. /**
  21571. * Release resources
  21572. */
  21573. dispose(): void;
  21574. }
  21575. }
  21576. declare module BABYLON {
  21577. /**
  21578. * Base class of materials working in push mode in babylon JS
  21579. * @hidden
  21580. */
  21581. export class PushMaterial extends Material {
  21582. protected _activeEffect: Effect;
  21583. protected _normalMatrix: Matrix;
  21584. constructor(name: string, scene: Scene);
  21585. getEffect(): Effect;
  21586. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21587. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21588. /**
  21589. * Binds the given world matrix to the active effect
  21590. *
  21591. * @param world the matrix to bind
  21592. */
  21593. bindOnlyWorldMatrix(world: Matrix): void;
  21594. /**
  21595. * Binds the given normal matrix to the active effect
  21596. *
  21597. * @param normalMatrix the matrix to bind
  21598. */
  21599. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21600. bind(world: Matrix, mesh?: Mesh): void;
  21601. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21602. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21603. }
  21604. }
  21605. declare module BABYLON {
  21606. /**
  21607. * Root class for all node material optimizers
  21608. */
  21609. export class NodeMaterialOptimizer {
  21610. /**
  21611. * Function used to optimize a NodeMaterial graph
  21612. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21613. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21614. */
  21615. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21616. }
  21617. }
  21618. declare module BABYLON {
  21619. /**
  21620. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21621. */
  21622. export class TransformBlock extends NodeMaterialBlock {
  21623. /**
  21624. * Defines the value to use to complement W value to transform it to a Vector4
  21625. */
  21626. complementW: number;
  21627. /**
  21628. * Defines the value to use to complement z value to transform it to a Vector4
  21629. */
  21630. complementZ: number;
  21631. /**
  21632. * Creates a new TransformBlock
  21633. * @param name defines the block name
  21634. */
  21635. constructor(name: string);
  21636. /**
  21637. * Gets the current class name
  21638. * @returns the class name
  21639. */
  21640. getClassName(): string;
  21641. /**
  21642. * Gets the vector input
  21643. */
  21644. get vector(): NodeMaterialConnectionPoint;
  21645. /**
  21646. * Gets the output component
  21647. */
  21648. get output(): NodeMaterialConnectionPoint;
  21649. /**
  21650. * Gets the xyz output component
  21651. */
  21652. get xyz(): NodeMaterialConnectionPoint;
  21653. /**
  21654. * Gets the matrix transform input
  21655. */
  21656. get transform(): NodeMaterialConnectionPoint;
  21657. protected _buildBlock(state: NodeMaterialBuildState): this;
  21658. /**
  21659. * Update defines for shader compilation
  21660. * @param mesh defines the mesh to be rendered
  21661. * @param nodeMaterial defines the node material requesting the update
  21662. * @param defines defines the material defines to update
  21663. * @param useInstances specifies that instances should be used
  21664. * @param subMesh defines which submesh to render
  21665. */
  21666. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21667. serialize(): any;
  21668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21669. protected _dumpPropertiesCode(): string;
  21670. }
  21671. }
  21672. declare module BABYLON {
  21673. /**
  21674. * Block used to output the vertex position
  21675. */
  21676. export class VertexOutputBlock extends NodeMaterialBlock {
  21677. /**
  21678. * Creates a new VertexOutputBlock
  21679. * @param name defines the block name
  21680. */
  21681. constructor(name: string);
  21682. /**
  21683. * Gets the current class name
  21684. * @returns the class name
  21685. */
  21686. getClassName(): string;
  21687. /**
  21688. * Gets the vector input component
  21689. */
  21690. get vector(): NodeMaterialConnectionPoint;
  21691. protected _buildBlock(state: NodeMaterialBuildState): this;
  21692. }
  21693. }
  21694. declare module BABYLON {
  21695. /**
  21696. * Block used to output the final color
  21697. */
  21698. export class FragmentOutputBlock extends NodeMaterialBlock {
  21699. /**
  21700. * Create a new FragmentOutputBlock
  21701. * @param name defines the block name
  21702. */
  21703. constructor(name: string);
  21704. /**
  21705. * Gets the current class name
  21706. * @returns the class name
  21707. */
  21708. getClassName(): string;
  21709. /**
  21710. * Gets the rgba input component
  21711. */
  21712. get rgba(): NodeMaterialConnectionPoint;
  21713. /**
  21714. * Gets the rgb input component
  21715. */
  21716. get rgb(): NodeMaterialConnectionPoint;
  21717. /**
  21718. * Gets the a input component
  21719. */
  21720. get a(): NodeMaterialConnectionPoint;
  21721. protected _buildBlock(state: NodeMaterialBuildState): this;
  21722. }
  21723. }
  21724. declare module BABYLON {
  21725. /**
  21726. * Block used for the particle ramp gradient section
  21727. */
  21728. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21729. /**
  21730. * Create a new ParticleRampGradientBlock
  21731. * @param name defines the block name
  21732. */
  21733. constructor(name: string);
  21734. /**
  21735. * Gets the current class name
  21736. * @returns the class name
  21737. */
  21738. getClassName(): string;
  21739. /**
  21740. * Gets the color input component
  21741. */
  21742. get color(): NodeMaterialConnectionPoint;
  21743. /**
  21744. * Gets the rampColor output component
  21745. */
  21746. get rampColor(): NodeMaterialConnectionPoint;
  21747. /**
  21748. * Initialize the block and prepare the context for build
  21749. * @param state defines the state that will be used for the build
  21750. */
  21751. initialize(state: NodeMaterialBuildState): void;
  21752. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21753. }
  21754. }
  21755. declare module BABYLON {
  21756. /**
  21757. * Block used for the particle blend multiply section
  21758. */
  21759. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21760. /**
  21761. * Create a new ParticleBlendMultiplyBlock
  21762. * @param name defines the block name
  21763. */
  21764. constructor(name: string);
  21765. /**
  21766. * Gets the current class name
  21767. * @returns the class name
  21768. */
  21769. getClassName(): string;
  21770. /**
  21771. * Gets the color input component
  21772. */
  21773. get color(): NodeMaterialConnectionPoint;
  21774. /**
  21775. * Gets the alphaTexture input component
  21776. */
  21777. get alphaTexture(): NodeMaterialConnectionPoint;
  21778. /**
  21779. * Gets the alphaColor input component
  21780. */
  21781. get alphaColor(): NodeMaterialConnectionPoint;
  21782. /**
  21783. * Gets the blendColor output component
  21784. */
  21785. get blendColor(): NodeMaterialConnectionPoint;
  21786. /**
  21787. * Initialize the block and prepare the context for build
  21788. * @param state defines the state that will be used for the build
  21789. */
  21790. initialize(state: NodeMaterialBuildState): void;
  21791. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21792. }
  21793. }
  21794. declare module BABYLON {
  21795. /**
  21796. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21797. */
  21798. export class VectorMergerBlock extends NodeMaterialBlock {
  21799. /**
  21800. * Create a new VectorMergerBlock
  21801. * @param name defines the block name
  21802. */
  21803. constructor(name: string);
  21804. /**
  21805. * Gets the current class name
  21806. * @returns the class name
  21807. */
  21808. getClassName(): string;
  21809. /**
  21810. * Gets the xyz component (input)
  21811. */
  21812. get xyzIn(): NodeMaterialConnectionPoint;
  21813. /**
  21814. * Gets the xy component (input)
  21815. */
  21816. get xyIn(): NodeMaterialConnectionPoint;
  21817. /**
  21818. * Gets the x component (input)
  21819. */
  21820. get x(): NodeMaterialConnectionPoint;
  21821. /**
  21822. * Gets the y component (input)
  21823. */
  21824. get y(): NodeMaterialConnectionPoint;
  21825. /**
  21826. * Gets the z component (input)
  21827. */
  21828. get z(): NodeMaterialConnectionPoint;
  21829. /**
  21830. * Gets the w component (input)
  21831. */
  21832. get w(): NodeMaterialConnectionPoint;
  21833. /**
  21834. * Gets the xyzw component (output)
  21835. */
  21836. get xyzw(): NodeMaterialConnectionPoint;
  21837. /**
  21838. * Gets the xyz component (output)
  21839. */
  21840. get xyzOut(): NodeMaterialConnectionPoint;
  21841. /**
  21842. * Gets the xy component (output)
  21843. */
  21844. get xyOut(): NodeMaterialConnectionPoint;
  21845. /**
  21846. * Gets the xy component (output)
  21847. * @deprecated Please use xyOut instead.
  21848. */
  21849. get xy(): NodeMaterialConnectionPoint;
  21850. /**
  21851. * Gets the xyz component (output)
  21852. * @deprecated Please use xyzOut instead.
  21853. */
  21854. get xyz(): NodeMaterialConnectionPoint;
  21855. protected _buildBlock(state: NodeMaterialBuildState): this;
  21856. }
  21857. }
  21858. declare module BABYLON {
  21859. /**
  21860. * Block used to remap a float from a range to a new one
  21861. */
  21862. export class RemapBlock extends NodeMaterialBlock {
  21863. /**
  21864. * Gets or sets the source range
  21865. */
  21866. sourceRange: Vector2;
  21867. /**
  21868. * Gets or sets the target range
  21869. */
  21870. targetRange: Vector2;
  21871. /**
  21872. * Creates a new RemapBlock
  21873. * @param name defines the block name
  21874. */
  21875. constructor(name: string);
  21876. /**
  21877. * Gets the current class name
  21878. * @returns the class name
  21879. */
  21880. getClassName(): string;
  21881. /**
  21882. * Gets the input component
  21883. */
  21884. get input(): NodeMaterialConnectionPoint;
  21885. /**
  21886. * Gets the source min input component
  21887. */
  21888. get sourceMin(): NodeMaterialConnectionPoint;
  21889. /**
  21890. * Gets the source max input component
  21891. */
  21892. get sourceMax(): NodeMaterialConnectionPoint;
  21893. /**
  21894. * Gets the target min input component
  21895. */
  21896. get targetMin(): NodeMaterialConnectionPoint;
  21897. /**
  21898. * Gets the target max input component
  21899. */
  21900. get targetMax(): NodeMaterialConnectionPoint;
  21901. /**
  21902. * Gets the output component
  21903. */
  21904. get output(): NodeMaterialConnectionPoint;
  21905. protected _buildBlock(state: NodeMaterialBuildState): this;
  21906. protected _dumpPropertiesCode(): string;
  21907. serialize(): any;
  21908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21909. }
  21910. }
  21911. declare module BABYLON {
  21912. /**
  21913. * Block used to multiply 2 values
  21914. */
  21915. export class MultiplyBlock extends NodeMaterialBlock {
  21916. /**
  21917. * Creates a new MultiplyBlock
  21918. * @param name defines the block name
  21919. */
  21920. constructor(name: string);
  21921. /**
  21922. * Gets the current class name
  21923. * @returns the class name
  21924. */
  21925. getClassName(): string;
  21926. /**
  21927. * Gets the left operand input component
  21928. */
  21929. get left(): NodeMaterialConnectionPoint;
  21930. /**
  21931. * Gets the right operand input component
  21932. */
  21933. get right(): NodeMaterialConnectionPoint;
  21934. /**
  21935. * Gets the output component
  21936. */
  21937. get output(): NodeMaterialConnectionPoint;
  21938. protected _buildBlock(state: NodeMaterialBuildState): this;
  21939. }
  21940. }
  21941. declare module BABYLON {
  21942. /**
  21943. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21944. */
  21945. export class ColorSplitterBlock extends NodeMaterialBlock {
  21946. /**
  21947. * Create a new ColorSplitterBlock
  21948. * @param name defines the block name
  21949. */
  21950. constructor(name: string);
  21951. /**
  21952. * Gets the current class name
  21953. * @returns the class name
  21954. */
  21955. getClassName(): string;
  21956. /**
  21957. * Gets the rgba component (input)
  21958. */
  21959. get rgba(): NodeMaterialConnectionPoint;
  21960. /**
  21961. * Gets the rgb component (input)
  21962. */
  21963. get rgbIn(): NodeMaterialConnectionPoint;
  21964. /**
  21965. * Gets the rgb component (output)
  21966. */
  21967. get rgbOut(): NodeMaterialConnectionPoint;
  21968. /**
  21969. * Gets the r component (output)
  21970. */
  21971. get r(): NodeMaterialConnectionPoint;
  21972. /**
  21973. * Gets the g component (output)
  21974. */
  21975. get g(): NodeMaterialConnectionPoint;
  21976. /**
  21977. * Gets the b component (output)
  21978. */
  21979. get b(): NodeMaterialConnectionPoint;
  21980. /**
  21981. * Gets the a component (output)
  21982. */
  21983. get a(): NodeMaterialConnectionPoint;
  21984. protected _inputRename(name: string): string;
  21985. protected _outputRename(name: string): string;
  21986. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21987. }
  21988. }
  21989. declare module BABYLON {
  21990. /**
  21991. * Interface used to configure the node material editor
  21992. */
  21993. export interface INodeMaterialEditorOptions {
  21994. /** Define the URl to load node editor script */
  21995. editorURL?: string;
  21996. }
  21997. /** @hidden */
  21998. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21999. NORMAL: boolean;
  22000. TANGENT: boolean;
  22001. UV1: boolean;
  22002. /** BONES */
  22003. NUM_BONE_INFLUENCERS: number;
  22004. BonesPerMesh: number;
  22005. BONETEXTURE: boolean;
  22006. /** MORPH TARGETS */
  22007. MORPHTARGETS: boolean;
  22008. MORPHTARGETS_NORMAL: boolean;
  22009. MORPHTARGETS_TANGENT: boolean;
  22010. MORPHTARGETS_UV: boolean;
  22011. NUM_MORPH_INFLUENCERS: number;
  22012. /** IMAGE PROCESSING */
  22013. IMAGEPROCESSING: boolean;
  22014. VIGNETTE: boolean;
  22015. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22016. VIGNETTEBLENDMODEOPAQUE: boolean;
  22017. TONEMAPPING: boolean;
  22018. TONEMAPPING_ACES: boolean;
  22019. CONTRAST: boolean;
  22020. EXPOSURE: boolean;
  22021. COLORCURVES: boolean;
  22022. COLORGRADING: boolean;
  22023. COLORGRADING3D: boolean;
  22024. SAMPLER3DGREENDEPTH: boolean;
  22025. SAMPLER3DBGRMAP: boolean;
  22026. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22027. /** MISC. */
  22028. BUMPDIRECTUV: number;
  22029. constructor();
  22030. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22031. }
  22032. /**
  22033. * Class used to configure NodeMaterial
  22034. */
  22035. export interface INodeMaterialOptions {
  22036. /**
  22037. * Defines if blocks should emit comments
  22038. */
  22039. emitComments: boolean;
  22040. }
  22041. /**
  22042. * Class used to create a node based material built by assembling shader blocks
  22043. */
  22044. export class NodeMaterial extends PushMaterial {
  22045. private static _BuildIdGenerator;
  22046. private _options;
  22047. private _vertexCompilationState;
  22048. private _fragmentCompilationState;
  22049. private _sharedData;
  22050. private _buildId;
  22051. private _buildWasSuccessful;
  22052. private _cachedWorldViewMatrix;
  22053. private _cachedWorldViewProjectionMatrix;
  22054. private _optimizers;
  22055. private _animationFrame;
  22056. /** Define the Url to load node editor script */
  22057. static EditorURL: string;
  22058. /** Define the Url to load snippets */
  22059. static SnippetUrl: string;
  22060. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22061. static IgnoreTexturesAtLoadTime: boolean;
  22062. private BJSNODEMATERIALEDITOR;
  22063. /** Get the inspector from bundle or global */
  22064. private _getGlobalNodeMaterialEditor;
  22065. /**
  22066. * Snippet ID if the material was created from the snippet server
  22067. */
  22068. snippetId: string;
  22069. /**
  22070. * Gets or sets data used by visual editor
  22071. * @see https://nme.babylonjs.com
  22072. */
  22073. editorData: any;
  22074. /**
  22075. * 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)
  22076. */
  22077. ignoreAlpha: boolean;
  22078. /**
  22079. * Defines the maximum number of lights that can be used in the material
  22080. */
  22081. maxSimultaneousLights: number;
  22082. /**
  22083. * Observable raised when the material is built
  22084. */
  22085. onBuildObservable: Observable<NodeMaterial>;
  22086. /**
  22087. * Gets or sets the root nodes of the material vertex shader
  22088. */
  22089. _vertexOutputNodes: NodeMaterialBlock[];
  22090. /**
  22091. * Gets or sets the root nodes of the material fragment (pixel) shader
  22092. */
  22093. _fragmentOutputNodes: NodeMaterialBlock[];
  22094. /** Gets or sets options to control the node material overall behavior */
  22095. get options(): INodeMaterialOptions;
  22096. set options(options: INodeMaterialOptions);
  22097. /**
  22098. * Default configuration related to image processing available in the standard Material.
  22099. */
  22100. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22101. /**
  22102. * Gets the image processing configuration used either in this material.
  22103. */
  22104. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22105. /**
  22106. * Sets the Default image processing configuration used either in the this material.
  22107. *
  22108. * If sets to null, the scene one is in use.
  22109. */
  22110. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22111. /**
  22112. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22113. */
  22114. attachedBlocks: NodeMaterialBlock[];
  22115. /**
  22116. * Specifies the mode of the node material
  22117. * @hidden
  22118. */
  22119. _mode: NodeMaterialModes;
  22120. /**
  22121. * Gets the mode property
  22122. */
  22123. get mode(): NodeMaterialModes;
  22124. /**
  22125. * Create a new node based material
  22126. * @param name defines the material name
  22127. * @param scene defines the hosting scene
  22128. * @param options defines creation option
  22129. */
  22130. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22131. /**
  22132. * Gets the current class name of the material e.g. "NodeMaterial"
  22133. * @returns the class name
  22134. */
  22135. getClassName(): string;
  22136. /**
  22137. * Keep track of the image processing observer to allow dispose and replace.
  22138. */
  22139. private _imageProcessingObserver;
  22140. /**
  22141. * Attaches a new image processing configuration to the Standard Material.
  22142. * @param configuration
  22143. */
  22144. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22145. /**
  22146. * Get a block by its name
  22147. * @param name defines the name of the block to retrieve
  22148. * @returns the required block or null if not found
  22149. */
  22150. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22151. /**
  22152. * Get a block by its name
  22153. * @param predicate defines the predicate used to find the good candidate
  22154. * @returns the required block or null if not found
  22155. */
  22156. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22157. /**
  22158. * Get an input block by its name
  22159. * @param predicate defines the predicate used to find the good candidate
  22160. * @returns the required input block or null if not found
  22161. */
  22162. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22163. /**
  22164. * Gets the list of input blocks attached to this material
  22165. * @returns an array of InputBlocks
  22166. */
  22167. getInputBlocks(): InputBlock[];
  22168. /**
  22169. * Adds a new optimizer to the list of optimizers
  22170. * @param optimizer defines the optimizers to add
  22171. * @returns the current material
  22172. */
  22173. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22174. /**
  22175. * Remove an optimizer from the list of optimizers
  22176. * @param optimizer defines the optimizers to remove
  22177. * @returns the current material
  22178. */
  22179. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22180. /**
  22181. * Add a new block to the list of output nodes
  22182. * @param node defines the node to add
  22183. * @returns the current material
  22184. */
  22185. addOutputNode(node: NodeMaterialBlock): this;
  22186. /**
  22187. * Remove a block from the list of root nodes
  22188. * @param node defines the node to remove
  22189. * @returns the current material
  22190. */
  22191. removeOutputNode(node: NodeMaterialBlock): this;
  22192. private _addVertexOutputNode;
  22193. private _removeVertexOutputNode;
  22194. private _addFragmentOutputNode;
  22195. private _removeFragmentOutputNode;
  22196. /**
  22197. * Specifies if the material will require alpha blending
  22198. * @returns a boolean specifying if alpha blending is needed
  22199. */
  22200. needAlphaBlending(): boolean;
  22201. /**
  22202. * Specifies if this material should be rendered in alpha test mode
  22203. * @returns a boolean specifying if an alpha test is needed.
  22204. */
  22205. needAlphaTesting(): boolean;
  22206. private _initializeBlock;
  22207. private _resetDualBlocks;
  22208. /**
  22209. * Remove a block from the current node material
  22210. * @param block defines the block to remove
  22211. */
  22212. removeBlock(block: NodeMaterialBlock): void;
  22213. /**
  22214. * Build the material and generates the inner effect
  22215. * @param verbose defines if the build should log activity
  22216. */
  22217. build(verbose?: boolean): void;
  22218. /**
  22219. * Runs an otpimization phase to try to improve the shader code
  22220. */
  22221. optimize(): void;
  22222. private _prepareDefinesForAttributes;
  22223. /**
  22224. * Create a post process from the material
  22225. * @param camera The camera to apply the render pass to.
  22226. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22228. * @param engine The engine which the post process will be applied. (default: current engine)
  22229. * @param reusable If the post process can be reused on the same frame. (default: false)
  22230. * @param textureType Type of textures used when performing the post process. (default: 0)
  22231. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22232. * @returns the post process created
  22233. */
  22234. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22235. /**
  22236. * Create the post process effect from the material
  22237. * @param postProcess The post process to create the effect for
  22238. */
  22239. createEffectForPostProcess(postProcess: PostProcess): void;
  22240. private _createEffectOrPostProcess;
  22241. private _createEffectForParticles;
  22242. /**
  22243. * Create the effect to be used as the custom effect for a particle system
  22244. * @param particleSystem Particle system to create the effect for
  22245. * @param onCompiled defines a function to call when the effect creation is successful
  22246. * @param onError defines a function to call when the effect creation has failed
  22247. */
  22248. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22249. private _processDefines;
  22250. /**
  22251. * Get if the submesh is ready to be used and all its information available.
  22252. * Child classes can use it to update shaders
  22253. * @param mesh defines the mesh to check
  22254. * @param subMesh defines which submesh to check
  22255. * @param useInstances specifies that instances should be used
  22256. * @returns a boolean indicating that the submesh is ready or not
  22257. */
  22258. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22259. /**
  22260. * Get a string representing the shaders built by the current node graph
  22261. */
  22262. get compiledShaders(): string;
  22263. /**
  22264. * Binds the world matrix to the material
  22265. * @param world defines the world transformation matrix
  22266. */
  22267. bindOnlyWorldMatrix(world: Matrix): void;
  22268. /**
  22269. * Binds the submesh to this material by preparing the effect and shader to draw
  22270. * @param world defines the world transformation matrix
  22271. * @param mesh defines the mesh containing the submesh
  22272. * @param subMesh defines the submesh to bind the material to
  22273. */
  22274. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22275. /**
  22276. * Gets the active textures from the material
  22277. * @returns an array of textures
  22278. */
  22279. getActiveTextures(): BaseTexture[];
  22280. /**
  22281. * Gets the list of texture blocks
  22282. * @returns an array of texture blocks
  22283. */
  22284. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22285. /**
  22286. * Specifies if the material uses a texture
  22287. * @param texture defines the texture to check against the material
  22288. * @returns a boolean specifying if the material uses the texture
  22289. */
  22290. hasTexture(texture: BaseTexture): boolean;
  22291. /**
  22292. * Disposes the material
  22293. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22294. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22295. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22296. */
  22297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22298. /** Creates the node editor window. */
  22299. private _createNodeEditor;
  22300. /**
  22301. * Launch the node material editor
  22302. * @param config Define the configuration of the editor
  22303. * @return a promise fulfilled when the node editor is visible
  22304. */
  22305. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22306. /**
  22307. * Clear the current material
  22308. */
  22309. clear(): void;
  22310. /**
  22311. * Clear the current material and set it to a default state
  22312. */
  22313. setToDefault(): void;
  22314. /**
  22315. * Clear the current material and set it to a default state for post process
  22316. */
  22317. setToDefaultPostProcess(): void;
  22318. /**
  22319. * Clear the current material and set it to a default state for particle
  22320. */
  22321. setToDefaultParticle(): void;
  22322. /**
  22323. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22324. * @param url defines the url to load from
  22325. * @returns a promise that will fullfil when the material is fully loaded
  22326. */
  22327. loadAsync(url: string): Promise<void>;
  22328. private _gatherBlocks;
  22329. /**
  22330. * Generate a string containing the code declaration required to create an equivalent of this material
  22331. * @returns a string
  22332. */
  22333. generateCode(): string;
  22334. /**
  22335. * Serializes this material in a JSON representation
  22336. * @returns the serialized material object
  22337. */
  22338. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22339. private _restoreConnections;
  22340. /**
  22341. * Clear the current graph and load a new one from a serialization object
  22342. * @param source defines the JSON representation of the material
  22343. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22344. * @param merge defines whether or not the source must be merged or replace the current content
  22345. */
  22346. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22347. /**
  22348. * Makes a duplicate of the current material.
  22349. * @param name - name to use for the new material.
  22350. */
  22351. clone(name: string): NodeMaterial;
  22352. /**
  22353. * Creates a node material from parsed material data
  22354. * @param source defines the JSON representation of the material
  22355. * @param scene defines the hosting scene
  22356. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22357. * @returns a new node material
  22358. */
  22359. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22360. /**
  22361. * Creates a node material from a snippet saved in a remote file
  22362. * @param name defines the name of the material to create
  22363. * @param url defines the url to load from
  22364. * @param scene defines the hosting scene
  22365. * @returns a promise that will resolve to the new node material
  22366. */
  22367. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22368. /**
  22369. * Creates a node material from a snippet saved by the node material editor
  22370. * @param snippetId defines the snippet to load
  22371. * @param scene defines the hosting scene
  22372. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22373. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22374. * @returns a promise that will resolve to the new node material
  22375. */
  22376. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22377. /**
  22378. * Creates a new node material set to default basic configuration
  22379. * @param name defines the name of the material
  22380. * @param scene defines the hosting scene
  22381. * @returns a new NodeMaterial
  22382. */
  22383. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22384. }
  22385. }
  22386. declare module BABYLON {
  22387. /**
  22388. * Size options for a post process
  22389. */
  22390. export type PostProcessOptions = {
  22391. width: number;
  22392. height: number;
  22393. };
  22394. /**
  22395. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22396. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22397. */
  22398. export class PostProcess {
  22399. /** Name of the PostProcess. */
  22400. name: string;
  22401. /**
  22402. * Gets or sets the unique id of the post process
  22403. */
  22404. uniqueId: number;
  22405. /**
  22406. * Width of the texture to apply the post process on
  22407. */
  22408. width: number;
  22409. /**
  22410. * Height of the texture to apply the post process on
  22411. */
  22412. height: number;
  22413. /**
  22414. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22415. */
  22416. nodeMaterialSource: Nullable<NodeMaterial>;
  22417. /**
  22418. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22419. * @hidden
  22420. */
  22421. _outputTexture: Nullable<InternalTexture>;
  22422. /**
  22423. * Sampling mode used by the shader
  22424. * See https://doc.babylonjs.com/classes/3.1/texture
  22425. */
  22426. renderTargetSamplingMode: number;
  22427. /**
  22428. * Clear color to use when screen clearing
  22429. */
  22430. clearColor: Color4;
  22431. /**
  22432. * If the buffer needs to be cleared before applying the post process. (default: true)
  22433. * Should be set to false if shader will overwrite all previous pixels.
  22434. */
  22435. autoClear: boolean;
  22436. /**
  22437. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22438. */
  22439. alphaMode: number;
  22440. /**
  22441. * Sets the setAlphaBlendConstants of the babylon engine
  22442. */
  22443. alphaConstants: Color4;
  22444. /**
  22445. * Animations to be used for the post processing
  22446. */
  22447. animations: Animation[];
  22448. /**
  22449. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22450. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22451. */
  22452. enablePixelPerfectMode: boolean;
  22453. /**
  22454. * Force the postprocess to be applied without taking in account viewport
  22455. */
  22456. forceFullscreenViewport: boolean;
  22457. /**
  22458. * List of inspectable custom properties (used by the Inspector)
  22459. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22460. */
  22461. inspectableCustomProperties: IInspectable[];
  22462. /**
  22463. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22464. *
  22465. * | Value | Type | Description |
  22466. * | ----- | ----------------------------------- | ----------- |
  22467. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22468. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22469. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22470. *
  22471. */
  22472. scaleMode: number;
  22473. /**
  22474. * Force textures to be a power of two (default: false)
  22475. */
  22476. alwaysForcePOT: boolean;
  22477. private _samples;
  22478. /**
  22479. * Number of sample textures (default: 1)
  22480. */
  22481. get samples(): number;
  22482. set samples(n: number);
  22483. /**
  22484. * Modify the scale of the post process to be the same as the viewport (default: false)
  22485. */
  22486. adaptScaleToCurrentViewport: boolean;
  22487. private _camera;
  22488. private _scene;
  22489. private _engine;
  22490. private _options;
  22491. private _reusable;
  22492. private _textureType;
  22493. private _textureFormat;
  22494. /**
  22495. * Smart array of input and output textures for the post process.
  22496. * @hidden
  22497. */
  22498. _textures: SmartArray<InternalTexture>;
  22499. /**
  22500. * The index in _textures that corresponds to the output texture.
  22501. * @hidden
  22502. */
  22503. _currentRenderTextureInd: number;
  22504. private _effect;
  22505. private _samplers;
  22506. private _fragmentUrl;
  22507. private _vertexUrl;
  22508. private _parameters;
  22509. private _scaleRatio;
  22510. protected _indexParameters: any;
  22511. private _shareOutputWithPostProcess;
  22512. private _texelSize;
  22513. private _forcedOutputTexture;
  22514. /**
  22515. * Returns the fragment url or shader name used in the post process.
  22516. * @returns the fragment url or name in the shader store.
  22517. */
  22518. getEffectName(): string;
  22519. /**
  22520. * An event triggered when the postprocess is activated.
  22521. */
  22522. onActivateObservable: Observable<Camera>;
  22523. private _onActivateObserver;
  22524. /**
  22525. * A function that is added to the onActivateObservable
  22526. */
  22527. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22528. /**
  22529. * An event triggered when the postprocess changes its size.
  22530. */
  22531. onSizeChangedObservable: Observable<PostProcess>;
  22532. private _onSizeChangedObserver;
  22533. /**
  22534. * A function that is added to the onSizeChangedObservable
  22535. */
  22536. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22537. /**
  22538. * An event triggered when the postprocess applies its effect.
  22539. */
  22540. onApplyObservable: Observable<Effect>;
  22541. private _onApplyObserver;
  22542. /**
  22543. * A function that is added to the onApplyObservable
  22544. */
  22545. set onApply(callback: (effect: Effect) => void);
  22546. /**
  22547. * An event triggered before rendering the postprocess
  22548. */
  22549. onBeforeRenderObservable: Observable<Effect>;
  22550. private _onBeforeRenderObserver;
  22551. /**
  22552. * A function that is added to the onBeforeRenderObservable
  22553. */
  22554. set onBeforeRender(callback: (effect: Effect) => void);
  22555. /**
  22556. * An event triggered after rendering the postprocess
  22557. */
  22558. onAfterRenderObservable: Observable<Effect>;
  22559. private _onAfterRenderObserver;
  22560. /**
  22561. * A function that is added to the onAfterRenderObservable
  22562. */
  22563. set onAfterRender(callback: (efect: Effect) => void);
  22564. /**
  22565. * 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
  22566. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22567. */
  22568. get inputTexture(): InternalTexture;
  22569. set inputTexture(value: InternalTexture);
  22570. /**
  22571. * Gets the camera which post process is applied to.
  22572. * @returns The camera the post process is applied to.
  22573. */
  22574. getCamera(): Camera;
  22575. /**
  22576. * Gets the texel size of the postprocess.
  22577. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22578. */
  22579. get texelSize(): Vector2;
  22580. /**
  22581. * Creates a new instance PostProcess
  22582. * @param name The name of the PostProcess.
  22583. * @param fragmentUrl The url of the fragment shader to be used.
  22584. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22585. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22586. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22587. * @param camera The camera to apply the render pass to.
  22588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22589. * @param engine The engine which the post process will be applied. (default: current engine)
  22590. * @param reusable If the post process can be reused on the same frame. (default: false)
  22591. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22592. * @param textureType Type of textures used when performing the post process. (default: 0)
  22593. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22594. * @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
  22595. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22596. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22597. */
  22598. constructor(
  22599. /** Name of the PostProcess. */
  22600. 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);
  22601. /**
  22602. * Gets a string idenfifying the name of the class
  22603. * @returns "PostProcess" string
  22604. */
  22605. getClassName(): string;
  22606. /**
  22607. * Gets the engine which this post process belongs to.
  22608. * @returns The engine the post process was enabled with.
  22609. */
  22610. getEngine(): Engine;
  22611. /**
  22612. * The effect that is created when initializing the post process.
  22613. * @returns The created effect corresponding the the postprocess.
  22614. */
  22615. getEffect(): Effect;
  22616. /**
  22617. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22618. * @param postProcess The post process to share the output with.
  22619. * @returns This post process.
  22620. */
  22621. shareOutputWith(postProcess: PostProcess): PostProcess;
  22622. /**
  22623. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22624. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22625. */
  22626. useOwnOutput(): void;
  22627. /**
  22628. * Updates the effect with the current post process compile time values and recompiles the shader.
  22629. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22630. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22631. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22632. * @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
  22633. * @param onCompiled Called when the shader has been compiled.
  22634. * @param onError Called if there is an error when compiling a shader.
  22635. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22636. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22637. */
  22638. 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;
  22639. /**
  22640. * The post process is reusable if it can be used multiple times within one frame.
  22641. * @returns If the post process is reusable
  22642. */
  22643. isReusable(): boolean;
  22644. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22645. markTextureDirty(): void;
  22646. /**
  22647. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22648. * 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.
  22649. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22650. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22651. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22652. * @returns The target texture that was bound to be written to.
  22653. */
  22654. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22655. /**
  22656. * If the post process is supported.
  22657. */
  22658. get isSupported(): boolean;
  22659. /**
  22660. * The aspect ratio of the output texture.
  22661. */
  22662. get aspectRatio(): number;
  22663. /**
  22664. * Get a value indicating if the post-process is ready to be used
  22665. * @returns true if the post-process is ready (shader is compiled)
  22666. */
  22667. isReady(): boolean;
  22668. /**
  22669. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22670. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22671. */
  22672. apply(): Nullable<Effect>;
  22673. private _disposeTextures;
  22674. /**
  22675. * Disposes the post process.
  22676. * @param camera The camera to dispose the post process on.
  22677. */
  22678. dispose(camera?: Camera): void;
  22679. }
  22680. }
  22681. declare module BABYLON {
  22682. /** @hidden */
  22683. export var kernelBlurVaryingDeclaration: {
  22684. name: string;
  22685. shader: string;
  22686. };
  22687. }
  22688. declare module BABYLON {
  22689. /** @hidden */
  22690. export var kernelBlurFragment: {
  22691. name: string;
  22692. shader: string;
  22693. };
  22694. }
  22695. declare module BABYLON {
  22696. /** @hidden */
  22697. export var kernelBlurFragment2: {
  22698. name: string;
  22699. shader: string;
  22700. };
  22701. }
  22702. declare module BABYLON {
  22703. /** @hidden */
  22704. export var kernelBlurPixelShader: {
  22705. name: string;
  22706. shader: string;
  22707. };
  22708. }
  22709. declare module BABYLON {
  22710. /** @hidden */
  22711. export var kernelBlurVertex: {
  22712. name: string;
  22713. shader: string;
  22714. };
  22715. }
  22716. declare module BABYLON {
  22717. /** @hidden */
  22718. export var kernelBlurVertexShader: {
  22719. name: string;
  22720. shader: string;
  22721. };
  22722. }
  22723. declare module BABYLON {
  22724. /**
  22725. * The Blur Post Process which blurs an image based on a kernel and direction.
  22726. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22727. */
  22728. export class BlurPostProcess extends PostProcess {
  22729. /** The direction in which to blur the image. */
  22730. direction: Vector2;
  22731. private blockCompilation;
  22732. protected _kernel: number;
  22733. protected _idealKernel: number;
  22734. protected _packedFloat: boolean;
  22735. private _staticDefines;
  22736. /**
  22737. * Sets the length in pixels of the blur sample region
  22738. */
  22739. set kernel(v: number);
  22740. /**
  22741. * Gets the length in pixels of the blur sample region
  22742. */
  22743. get kernel(): number;
  22744. /**
  22745. * Sets wether or not the blur needs to unpack/repack floats
  22746. */
  22747. set packedFloat(v: boolean);
  22748. /**
  22749. * Gets wether or not the blur is unpacking/repacking floats
  22750. */
  22751. get packedFloat(): boolean;
  22752. /**
  22753. * Creates a new instance BlurPostProcess
  22754. * @param name The name of the effect.
  22755. * @param direction The direction in which to blur the image.
  22756. * @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.
  22757. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22758. * @param camera The camera to apply the render pass to.
  22759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22760. * @param engine The engine which the post process will be applied. (default: current engine)
  22761. * @param reusable If the post process can be reused on the same frame. (default: false)
  22762. * @param textureType Type of textures used when performing the post process. (default: 0)
  22763. * @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)
  22764. */
  22765. constructor(name: string,
  22766. /** The direction in which to blur the image. */
  22767. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22768. /**
  22769. * Updates the effect with the current post process compile time values and recompiles the shader.
  22770. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22771. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22772. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22773. * @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
  22774. * @param onCompiled Called when the shader has been compiled.
  22775. * @param onError Called if there is an error when compiling a shader.
  22776. */
  22777. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22778. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22779. /**
  22780. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22781. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22782. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22783. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22784. * The gaps between physical kernels are compensated for in the weighting of the samples
  22785. * @param idealKernel Ideal blur kernel.
  22786. * @return Nearest best kernel.
  22787. */
  22788. protected _nearestBestKernel(idealKernel: number): number;
  22789. /**
  22790. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22791. * @param x The point on the Gaussian distribution to sample.
  22792. * @return the value of the Gaussian function at x.
  22793. */
  22794. protected _gaussianWeight(x: number): number;
  22795. /**
  22796. * Generates a string that can be used as a floating point number in GLSL.
  22797. * @param x Value to print.
  22798. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22799. * @return GLSL float string.
  22800. */
  22801. protected _glslFloat(x: number, decimalFigures?: number): string;
  22802. }
  22803. }
  22804. declare module BABYLON {
  22805. /**
  22806. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22807. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22808. * You can then easily use it as a reflectionTexture on a flat surface.
  22809. * In case the surface is not a plane, please consider relying on reflection probes.
  22810. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22811. */
  22812. export class MirrorTexture extends RenderTargetTexture {
  22813. private scene;
  22814. /**
  22815. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22816. * 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.
  22817. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22818. */
  22819. mirrorPlane: Plane;
  22820. /**
  22821. * Define the blur ratio used to blur the reflection if needed.
  22822. */
  22823. set blurRatio(value: number);
  22824. get blurRatio(): number;
  22825. /**
  22826. * Define the adaptive blur kernel used to blur the reflection if needed.
  22827. * This will autocompute the closest best match for the `blurKernel`
  22828. */
  22829. set adaptiveBlurKernel(value: number);
  22830. /**
  22831. * Define the blur kernel used to blur the reflection if needed.
  22832. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22833. */
  22834. set blurKernel(value: number);
  22835. /**
  22836. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22837. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22838. */
  22839. set blurKernelX(value: number);
  22840. get blurKernelX(): number;
  22841. /**
  22842. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22843. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22844. */
  22845. set blurKernelY(value: number);
  22846. get blurKernelY(): number;
  22847. private _autoComputeBlurKernel;
  22848. protected _onRatioRescale(): void;
  22849. private _updateGammaSpace;
  22850. private _imageProcessingConfigChangeObserver;
  22851. private _transformMatrix;
  22852. private _mirrorMatrix;
  22853. private _savedViewMatrix;
  22854. private _blurX;
  22855. private _blurY;
  22856. private _adaptiveBlurKernel;
  22857. private _blurKernelX;
  22858. private _blurKernelY;
  22859. private _blurRatio;
  22860. /**
  22861. * Instantiates a Mirror Texture.
  22862. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22863. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22864. * You can then easily use it as a reflectionTexture on a flat surface.
  22865. * In case the surface is not a plane, please consider relying on reflection probes.
  22866. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22867. * @param name
  22868. * @param size
  22869. * @param scene
  22870. * @param generateMipMaps
  22871. * @param type
  22872. * @param samplingMode
  22873. * @param generateDepthBuffer
  22874. */
  22875. constructor(name: string, size: number | {
  22876. width: number;
  22877. height: number;
  22878. } | {
  22879. ratio: number;
  22880. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22881. private _preparePostProcesses;
  22882. /**
  22883. * Clone the mirror texture.
  22884. * @returns the cloned texture
  22885. */
  22886. clone(): MirrorTexture;
  22887. /**
  22888. * Serialize the texture to a JSON representation you could use in Parse later on
  22889. * @returns the serialized JSON representation
  22890. */
  22891. serialize(): any;
  22892. /**
  22893. * Dispose the texture and release its associated resources.
  22894. */
  22895. dispose(): void;
  22896. }
  22897. }
  22898. declare module BABYLON {
  22899. /**
  22900. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22901. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22902. */
  22903. export class Texture extends BaseTexture {
  22904. /**
  22905. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22906. */
  22907. static SerializeBuffers: boolean;
  22908. /** @hidden */
  22909. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22910. /** @hidden */
  22911. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22912. /** @hidden */
  22913. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22914. /** nearest is mag = nearest and min = nearest and mip = linear */
  22915. static readonly NEAREST_SAMPLINGMODE: number;
  22916. /** nearest is mag = nearest and min = nearest and mip = linear */
  22917. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22918. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22919. static readonly BILINEAR_SAMPLINGMODE: number;
  22920. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22921. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22922. /** Trilinear is mag = linear and min = linear and mip = linear */
  22923. static readonly TRILINEAR_SAMPLINGMODE: number;
  22924. /** Trilinear is mag = linear and min = linear and mip = linear */
  22925. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22926. /** mag = nearest and min = nearest and mip = nearest */
  22927. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22928. /** mag = nearest and min = linear and mip = nearest */
  22929. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22930. /** mag = nearest and min = linear and mip = linear */
  22931. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22932. /** mag = nearest and min = linear and mip = none */
  22933. static readonly NEAREST_LINEAR: number;
  22934. /** mag = nearest and min = nearest and mip = none */
  22935. static readonly NEAREST_NEAREST: number;
  22936. /** mag = linear and min = nearest and mip = nearest */
  22937. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22938. /** mag = linear and min = nearest and mip = linear */
  22939. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22940. /** mag = linear and min = linear and mip = none */
  22941. static readonly LINEAR_LINEAR: number;
  22942. /** mag = linear and min = nearest and mip = none */
  22943. static readonly LINEAR_NEAREST: number;
  22944. /** Explicit coordinates mode */
  22945. static readonly EXPLICIT_MODE: number;
  22946. /** Spherical coordinates mode */
  22947. static readonly SPHERICAL_MODE: number;
  22948. /** Planar coordinates mode */
  22949. static readonly PLANAR_MODE: number;
  22950. /** Cubic coordinates mode */
  22951. static readonly CUBIC_MODE: number;
  22952. /** Projection coordinates mode */
  22953. static readonly PROJECTION_MODE: number;
  22954. /** Inverse Cubic coordinates mode */
  22955. static readonly SKYBOX_MODE: number;
  22956. /** Inverse Cubic coordinates mode */
  22957. static readonly INVCUBIC_MODE: number;
  22958. /** Equirectangular coordinates mode */
  22959. static readonly EQUIRECTANGULAR_MODE: number;
  22960. /** Equirectangular Fixed coordinates mode */
  22961. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22962. /** Equirectangular Fixed Mirrored coordinates mode */
  22963. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22964. /** Texture is not repeating outside of 0..1 UVs */
  22965. static readonly CLAMP_ADDRESSMODE: number;
  22966. /** Texture is repeating outside of 0..1 UVs */
  22967. static readonly WRAP_ADDRESSMODE: number;
  22968. /** Texture is repeating and mirrored */
  22969. static readonly MIRROR_ADDRESSMODE: number;
  22970. /**
  22971. * 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
  22972. */
  22973. static UseSerializedUrlIfAny: boolean;
  22974. /**
  22975. * Define the url of the texture.
  22976. */
  22977. url: Nullable<string>;
  22978. /**
  22979. * Define an offset on the texture to offset the u coordinates of the UVs
  22980. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22981. */
  22982. uOffset: number;
  22983. /**
  22984. * Define an offset on the texture to offset the v coordinates of the UVs
  22985. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22986. */
  22987. vOffset: number;
  22988. /**
  22989. * Define an offset on the texture to scale the u coordinates of the UVs
  22990. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22991. */
  22992. uScale: number;
  22993. /**
  22994. * Define an offset on the texture to scale the v coordinates of the UVs
  22995. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22996. */
  22997. vScale: number;
  22998. /**
  22999. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23000. * @see http://doc.babylonjs.com/how_to/more_materials
  23001. */
  23002. uAng: number;
  23003. /**
  23004. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23005. * @see http://doc.babylonjs.com/how_to/more_materials
  23006. */
  23007. vAng: number;
  23008. /**
  23009. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23010. * @see http://doc.babylonjs.com/how_to/more_materials
  23011. */
  23012. wAng: number;
  23013. /**
  23014. * Defines the center of rotation (U)
  23015. */
  23016. uRotationCenter: number;
  23017. /**
  23018. * Defines the center of rotation (V)
  23019. */
  23020. vRotationCenter: number;
  23021. /**
  23022. * Defines the center of rotation (W)
  23023. */
  23024. wRotationCenter: number;
  23025. /**
  23026. * Are mip maps generated for this texture or not.
  23027. */
  23028. get noMipmap(): boolean;
  23029. /**
  23030. * List of inspectable custom properties (used by the Inspector)
  23031. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23032. */
  23033. inspectableCustomProperties: Nullable<IInspectable[]>;
  23034. private _noMipmap;
  23035. /** @hidden */
  23036. _invertY: boolean;
  23037. private _rowGenerationMatrix;
  23038. private _cachedTextureMatrix;
  23039. private _projectionModeMatrix;
  23040. private _t0;
  23041. private _t1;
  23042. private _t2;
  23043. private _cachedUOffset;
  23044. private _cachedVOffset;
  23045. private _cachedUScale;
  23046. private _cachedVScale;
  23047. private _cachedUAng;
  23048. private _cachedVAng;
  23049. private _cachedWAng;
  23050. private _cachedProjectionMatrixId;
  23051. private _cachedCoordinatesMode;
  23052. /** @hidden */
  23053. protected _initialSamplingMode: number;
  23054. /** @hidden */
  23055. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23056. private _deleteBuffer;
  23057. protected _format: Nullable<number>;
  23058. private _delayedOnLoad;
  23059. private _delayedOnError;
  23060. private _mimeType?;
  23061. /**
  23062. * Observable triggered once the texture has been loaded.
  23063. */
  23064. onLoadObservable: Observable<Texture>;
  23065. protected _isBlocking: boolean;
  23066. /**
  23067. * Is the texture preventing material to render while loading.
  23068. * If false, a default texture will be used instead of the loading one during the preparation step.
  23069. */
  23070. set isBlocking(value: boolean);
  23071. get isBlocking(): boolean;
  23072. /**
  23073. * Get the current sampling mode associated with the texture.
  23074. */
  23075. get samplingMode(): number;
  23076. /**
  23077. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23078. */
  23079. get invertY(): boolean;
  23080. /**
  23081. * Instantiates a new texture.
  23082. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23083. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23084. * @param url defines the url of the picture to load as a texture
  23085. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23086. * @param noMipmap defines if the texture will require mip maps or not
  23087. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23088. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23089. * @param onLoad defines a callback triggered when the texture has been loaded
  23090. * @param onError defines a callback triggered when an error occurred during the loading session
  23091. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23092. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23093. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23094. * @param mimeType defines an optional mime type information
  23095. */
  23096. 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);
  23097. /**
  23098. * Update the url (and optional buffer) of this texture if url was null during construction.
  23099. * @param url the url of the texture
  23100. * @param buffer the buffer of the texture (defaults to null)
  23101. * @param onLoad callback called when the texture is loaded (defaults to null)
  23102. */
  23103. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23104. /**
  23105. * Finish the loading sequence of a texture flagged as delayed load.
  23106. * @hidden
  23107. */
  23108. delayLoad(): void;
  23109. private _prepareRowForTextureGeneration;
  23110. /**
  23111. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23112. * @returns the transform matrix of the texture.
  23113. */
  23114. getTextureMatrix(uBase?: number): Matrix;
  23115. /**
  23116. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23117. * @returns The reflection texture transform
  23118. */
  23119. getReflectionTextureMatrix(): Matrix;
  23120. /**
  23121. * Clones the texture.
  23122. * @returns the cloned texture
  23123. */
  23124. clone(): Texture;
  23125. /**
  23126. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23127. * @returns The JSON representation of the texture
  23128. */
  23129. serialize(): any;
  23130. /**
  23131. * Get the current class name of the texture useful for serialization or dynamic coding.
  23132. * @returns "Texture"
  23133. */
  23134. getClassName(): string;
  23135. /**
  23136. * Dispose the texture and release its associated resources.
  23137. */
  23138. dispose(): void;
  23139. /**
  23140. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23141. * @param parsedTexture Define the JSON representation of the texture
  23142. * @param scene Define the scene the parsed texture should be instantiated in
  23143. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23144. * @returns The parsed texture if successful
  23145. */
  23146. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23147. /**
  23148. * Creates a texture from its base 64 representation.
  23149. * @param data Define the base64 payload without the data: prefix
  23150. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23151. * @param scene Define the scene the texture should belong to
  23152. * @param noMipmap Forces the texture to not create mip map information if true
  23153. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23154. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23155. * @param onLoad define a callback triggered when the texture has been loaded
  23156. * @param onError define a callback triggered when an error occurred during the loading session
  23157. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23158. * @returns the created texture
  23159. */
  23160. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23161. /**
  23162. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23163. * @param data Define the base64 payload without the data: prefix
  23164. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23165. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23166. * @param scene Define the scene the texture should belong to
  23167. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23168. * @param noMipmap Forces the texture to not create mip map information if true
  23169. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23170. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23171. * @param onLoad define a callback triggered when the texture has been loaded
  23172. * @param onError define a callback triggered when an error occurred during the loading session
  23173. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23174. * @returns the created texture
  23175. */
  23176. 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;
  23177. }
  23178. }
  23179. declare module BABYLON {
  23180. /**
  23181. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23182. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23183. */
  23184. export class PostProcessManager {
  23185. private _scene;
  23186. private _indexBuffer;
  23187. private _vertexBuffers;
  23188. /**
  23189. * Creates a new instance PostProcess
  23190. * @param scene The scene that the post process is associated with.
  23191. */
  23192. constructor(scene: Scene);
  23193. private _prepareBuffers;
  23194. private _buildIndexBuffer;
  23195. /**
  23196. * Rebuilds the vertex buffers of the manager.
  23197. * @hidden
  23198. */
  23199. _rebuild(): void;
  23200. /**
  23201. * Prepares a frame to be run through a post process.
  23202. * @param sourceTexture The input texture to the post procesess. (default: null)
  23203. * @param postProcesses An array of post processes to be run. (default: null)
  23204. * @returns True if the post processes were able to be run.
  23205. * @hidden
  23206. */
  23207. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23208. /**
  23209. * Manually render a set of post processes to a texture.
  23210. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23211. * @param postProcesses An array of post processes to be run.
  23212. * @param targetTexture The target texture to render to.
  23213. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23214. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23215. * @param lodLevel defines which lod of the texture to render to
  23216. */
  23217. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23218. /**
  23219. * Finalize the result of the output of the postprocesses.
  23220. * @param doNotPresent If true the result will not be displayed to the screen.
  23221. * @param targetTexture The target texture to render to.
  23222. * @param faceIndex The index of the face to bind the target texture to.
  23223. * @param postProcesses The array of post processes to render.
  23224. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23225. * @hidden
  23226. */
  23227. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23228. /**
  23229. * Disposes of the post process manager.
  23230. */
  23231. dispose(): void;
  23232. }
  23233. }
  23234. declare module BABYLON {
  23235. /**
  23236. * This Helps creating a texture that will be created from a camera in your scene.
  23237. * It is basically a dynamic texture that could be used to create special effects for instance.
  23238. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23239. */
  23240. export class RenderTargetTexture extends Texture {
  23241. isCube: boolean;
  23242. /**
  23243. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23244. */
  23245. static readonly REFRESHRATE_RENDER_ONCE: number;
  23246. /**
  23247. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23248. */
  23249. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23250. /**
  23251. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23252. * the central point of your effect and can save a lot of performances.
  23253. */
  23254. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23255. /**
  23256. * Use this predicate to dynamically define the list of mesh you want to render.
  23257. * If set, the renderList property will be overwritten.
  23258. */
  23259. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23260. private _renderList;
  23261. /**
  23262. * Use this list to define the list of mesh you want to render.
  23263. */
  23264. get renderList(): Nullable<Array<AbstractMesh>>;
  23265. set renderList(value: Nullable<Array<AbstractMesh>>);
  23266. /**
  23267. * Use this function to overload the renderList array at rendering time.
  23268. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23269. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23270. * the cube (if the RTT is a cube, else layerOrFace=0).
  23271. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23272. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23273. * hold dummy elements!
  23274. */
  23275. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23276. private _hookArray;
  23277. /**
  23278. * Define if particles should be rendered in your texture.
  23279. */
  23280. renderParticles: boolean;
  23281. /**
  23282. * Define if sprites should be rendered in your texture.
  23283. */
  23284. renderSprites: boolean;
  23285. /**
  23286. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23287. */
  23288. coordinatesMode: number;
  23289. /**
  23290. * Define the camera used to render the texture.
  23291. */
  23292. activeCamera: Nullable<Camera>;
  23293. /**
  23294. * Override the mesh isReady function with your own one.
  23295. */
  23296. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23297. /**
  23298. * Override the render function of the texture with your own one.
  23299. */
  23300. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23301. /**
  23302. * Define if camera post processes should be use while rendering the texture.
  23303. */
  23304. useCameraPostProcesses: boolean;
  23305. /**
  23306. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23307. */
  23308. ignoreCameraViewport: boolean;
  23309. private _postProcessManager;
  23310. private _postProcesses;
  23311. private _resizeObserver;
  23312. /**
  23313. * An event triggered when the texture is unbind.
  23314. */
  23315. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23316. /**
  23317. * An event triggered when the texture is unbind.
  23318. */
  23319. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23320. private _onAfterUnbindObserver;
  23321. /**
  23322. * Set a after unbind callback in the texture.
  23323. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23324. */
  23325. set onAfterUnbind(callback: () => void);
  23326. /**
  23327. * An event triggered before rendering the texture
  23328. */
  23329. onBeforeRenderObservable: Observable<number>;
  23330. private _onBeforeRenderObserver;
  23331. /**
  23332. * Set a before render callback in the texture.
  23333. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23334. */
  23335. set onBeforeRender(callback: (faceIndex: number) => void);
  23336. /**
  23337. * An event triggered after rendering the texture
  23338. */
  23339. onAfterRenderObservable: Observable<number>;
  23340. private _onAfterRenderObserver;
  23341. /**
  23342. * Set a after render callback in the texture.
  23343. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23344. */
  23345. set onAfterRender(callback: (faceIndex: number) => void);
  23346. /**
  23347. * An event triggered after the texture clear
  23348. */
  23349. onClearObservable: Observable<Engine>;
  23350. private _onClearObserver;
  23351. /**
  23352. * Set a clear callback in the texture.
  23353. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23354. */
  23355. set onClear(callback: (Engine: Engine) => void);
  23356. /**
  23357. * An event triggered when the texture is resized.
  23358. */
  23359. onResizeObservable: Observable<RenderTargetTexture>;
  23360. /**
  23361. * Define the clear color of the Render Target if it should be different from the scene.
  23362. */
  23363. clearColor: Color4;
  23364. protected _size: number | {
  23365. width: number;
  23366. height: number;
  23367. layers?: number;
  23368. };
  23369. protected _initialSizeParameter: number | {
  23370. width: number;
  23371. height: number;
  23372. } | {
  23373. ratio: number;
  23374. };
  23375. protected _sizeRatio: Nullable<number>;
  23376. /** @hidden */
  23377. _generateMipMaps: boolean;
  23378. protected _renderingManager: RenderingManager;
  23379. /** @hidden */
  23380. _waitingRenderList: string[];
  23381. protected _doNotChangeAspectRatio: boolean;
  23382. protected _currentRefreshId: number;
  23383. protected _refreshRate: number;
  23384. protected _textureMatrix: Matrix;
  23385. protected _samples: number;
  23386. protected _renderTargetOptions: RenderTargetCreationOptions;
  23387. /**
  23388. * Gets render target creation options that were used.
  23389. */
  23390. get renderTargetOptions(): RenderTargetCreationOptions;
  23391. protected _onRatioRescale(): void;
  23392. /**
  23393. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23394. * It must define where the camera used to render the texture is set
  23395. */
  23396. boundingBoxPosition: Vector3;
  23397. private _boundingBoxSize;
  23398. /**
  23399. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23400. * When defined, the cubemap will switch to local mode
  23401. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23402. * @example https://www.babylonjs-playground.com/#RNASML
  23403. */
  23404. set boundingBoxSize(value: Vector3);
  23405. get boundingBoxSize(): Vector3;
  23406. /**
  23407. * In case the RTT has been created with a depth texture, get the associated
  23408. * depth texture.
  23409. * Otherwise, return null.
  23410. */
  23411. get depthStencilTexture(): Nullable<InternalTexture>;
  23412. /**
  23413. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23414. * or used a shadow, depth texture...
  23415. * @param name The friendly name of the texture
  23416. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  23417. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23418. * @param generateMipMaps True if mip maps need to be generated after render.
  23419. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23420. * @param type The type of the buffer in the RTT (int, half float, float...)
  23421. * @param isCube True if a cube texture needs to be created
  23422. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23423. * @param generateDepthBuffer True to generate a depth buffer
  23424. * @param generateStencilBuffer True to generate a stencil buffer
  23425. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23426. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23427. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23428. */
  23429. constructor(name: string, size: number | {
  23430. width: number;
  23431. height: number;
  23432. layers?: number;
  23433. } | {
  23434. ratio: number;
  23435. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23436. /**
  23437. * Creates a depth stencil texture.
  23438. * This is only available in WebGL 2 or with the depth texture extension available.
  23439. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23440. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23441. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23442. */
  23443. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23444. private _processSizeParameter;
  23445. /**
  23446. * Define the number of samples to use in case of MSAA.
  23447. * It defaults to one meaning no MSAA has been enabled.
  23448. */
  23449. get samples(): number;
  23450. set samples(value: number);
  23451. /**
  23452. * Resets the refresh counter of the texture and start bak from scratch.
  23453. * Could be useful to regenerate the texture if it is setup to render only once.
  23454. */
  23455. resetRefreshCounter(): void;
  23456. /**
  23457. * Define the refresh rate of the texture or the rendering frequency.
  23458. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23459. */
  23460. get refreshRate(): number;
  23461. set refreshRate(value: number);
  23462. /**
  23463. * Adds a post process to the render target rendering passes.
  23464. * @param postProcess define the post process to add
  23465. */
  23466. addPostProcess(postProcess: PostProcess): void;
  23467. /**
  23468. * Clear all the post processes attached to the render target
  23469. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23470. */
  23471. clearPostProcesses(dispose?: boolean): void;
  23472. /**
  23473. * Remove one of the post process from the list of attached post processes to the texture
  23474. * @param postProcess define the post process to remove from the list
  23475. */
  23476. removePostProcess(postProcess: PostProcess): void;
  23477. /** @hidden */
  23478. _shouldRender(): boolean;
  23479. /**
  23480. * Gets the actual render size of the texture.
  23481. * @returns the width of the render size
  23482. */
  23483. getRenderSize(): number;
  23484. /**
  23485. * Gets the actual render width of the texture.
  23486. * @returns the width of the render size
  23487. */
  23488. getRenderWidth(): number;
  23489. /**
  23490. * Gets the actual render height of the texture.
  23491. * @returns the height of the render size
  23492. */
  23493. getRenderHeight(): number;
  23494. /**
  23495. * Gets the actual number of layers of the texture.
  23496. * @returns the number of layers
  23497. */
  23498. getRenderLayers(): number;
  23499. /**
  23500. * Get if the texture can be rescaled or not.
  23501. */
  23502. get canRescale(): boolean;
  23503. /**
  23504. * Resize the texture using a ratio.
  23505. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23506. */
  23507. scale(ratio: number): void;
  23508. /**
  23509. * Get the texture reflection matrix used to rotate/transform the reflection.
  23510. * @returns the reflection matrix
  23511. */
  23512. getReflectionTextureMatrix(): Matrix;
  23513. /**
  23514. * Resize the texture to a new desired size.
  23515. * Be carrefull as it will recreate all the data in the new texture.
  23516. * @param size Define the new size. It can be:
  23517. * - a number for squared texture,
  23518. * - an object containing { width: number, height: number }
  23519. * - or an object containing a ratio { ratio: number }
  23520. */
  23521. resize(size: number | {
  23522. width: number;
  23523. height: number;
  23524. } | {
  23525. ratio: number;
  23526. }): void;
  23527. private _defaultRenderListPrepared;
  23528. /**
  23529. * Renders all the objects from the render list into the texture.
  23530. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23531. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23532. */
  23533. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23534. private _bestReflectionRenderTargetDimension;
  23535. private _prepareRenderingManager;
  23536. /**
  23537. * @hidden
  23538. * @param faceIndex face index to bind to if this is a cubetexture
  23539. * @param layer defines the index of the texture to bind in the array
  23540. */
  23541. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23542. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23543. private renderToTarget;
  23544. /**
  23545. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23546. * This allowed control for front to back rendering or reversly depending of the special needs.
  23547. *
  23548. * @param renderingGroupId The rendering group id corresponding to its index
  23549. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23550. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23551. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23552. */
  23553. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  23554. /**
  23555. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23556. *
  23557. * @param renderingGroupId The rendering group id corresponding to its index
  23558. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23559. */
  23560. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23561. /**
  23562. * Clones the texture.
  23563. * @returns the cloned texture
  23564. */
  23565. clone(): RenderTargetTexture;
  23566. /**
  23567. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23568. * @returns The JSON representation of the texture
  23569. */
  23570. serialize(): any;
  23571. /**
  23572. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23573. */
  23574. disposeFramebufferObjects(): void;
  23575. /**
  23576. * Dispose the texture and release its associated resources.
  23577. */
  23578. dispose(): void;
  23579. /** @hidden */
  23580. _rebuild(): void;
  23581. /**
  23582. * Clear the info related to rendering groups preventing retention point in material dispose.
  23583. */
  23584. freeRenderingGroups(): void;
  23585. /**
  23586. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23587. * @returns the view count
  23588. */
  23589. getViewCount(): number;
  23590. }
  23591. }
  23592. declare module BABYLON {
  23593. /**
  23594. * Class used to manipulate GUIDs
  23595. */
  23596. export class GUID {
  23597. /**
  23598. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23599. * Be aware Math.random() could cause collisions, but:
  23600. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  23601. * @returns a pseudo random id
  23602. */
  23603. static RandomId(): string;
  23604. }
  23605. }
  23606. declare module BABYLON {
  23607. /**
  23608. * Options to be used when creating a shadow depth material
  23609. */
  23610. export interface IIOptionShadowDepthMaterial {
  23611. /** Variables in the vertex shader code that need to have their names remapped.
  23612. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23613. * "var_name" should be either: worldPos or vNormalW
  23614. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23615. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23616. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23617. */
  23618. remappedVariables?: string[];
  23619. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23620. standalone?: boolean;
  23621. }
  23622. /**
  23623. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23624. */
  23625. export class ShadowDepthWrapper {
  23626. private _scene;
  23627. private _options?;
  23628. private _baseMaterial;
  23629. private _onEffectCreatedObserver;
  23630. private _subMeshToEffect;
  23631. private _subMeshToDepthEffect;
  23632. private _meshes;
  23633. /** @hidden */
  23634. _matriceNames: any;
  23635. /** Gets the standalone status of the wrapper */
  23636. get standalone(): boolean;
  23637. /** Gets the base material the wrapper is built upon */
  23638. get baseMaterial(): Material;
  23639. /**
  23640. * Instantiate a new shadow depth wrapper.
  23641. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23642. * generate the shadow depth map. For more information, please refer to the documentation:
  23643. * https://doc.babylonjs.com/babylon101/shadows
  23644. * @param baseMaterial Material to wrap
  23645. * @param scene Define the scene the material belongs to
  23646. * @param options Options used to create the wrapper
  23647. */
  23648. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23649. /**
  23650. * Gets the effect to use to generate the depth map
  23651. * @param subMesh subMesh to get the effect for
  23652. * @param shadowGenerator shadow generator to get the effect for
  23653. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23654. */
  23655. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23656. /**
  23657. * Specifies that the submesh is ready to be used for depth rendering
  23658. * @param subMesh submesh to check
  23659. * @param defines the list of defines to take into account when checking the effect
  23660. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23661. * @param useInstances specifies that instances should be used
  23662. * @returns a boolean indicating that the submesh is ready or not
  23663. */
  23664. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23665. /**
  23666. * Disposes the resources
  23667. */
  23668. dispose(): void;
  23669. private _makeEffect;
  23670. }
  23671. }
  23672. declare module BABYLON {
  23673. /**
  23674. * Options for compiling materials.
  23675. */
  23676. export interface IMaterialCompilationOptions {
  23677. /**
  23678. * Defines whether clip planes are enabled.
  23679. */
  23680. clipPlane: boolean;
  23681. /**
  23682. * Defines whether instances are enabled.
  23683. */
  23684. useInstances: boolean;
  23685. }
  23686. /**
  23687. * Options passed when calling customShaderNameResolve
  23688. */
  23689. export interface ICustomShaderNameResolveOptions {
  23690. /**
  23691. * 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
  23692. */
  23693. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23694. }
  23695. /**
  23696. * Base class for the main features of a material in Babylon.js
  23697. */
  23698. export class Material implements IAnimatable {
  23699. /**
  23700. * Returns the triangle fill mode
  23701. */
  23702. static readonly TriangleFillMode: number;
  23703. /**
  23704. * Returns the wireframe mode
  23705. */
  23706. static readonly WireFrameFillMode: number;
  23707. /**
  23708. * Returns the point fill mode
  23709. */
  23710. static readonly PointFillMode: number;
  23711. /**
  23712. * Returns the point list draw mode
  23713. */
  23714. static readonly PointListDrawMode: number;
  23715. /**
  23716. * Returns the line list draw mode
  23717. */
  23718. static readonly LineListDrawMode: number;
  23719. /**
  23720. * Returns the line loop draw mode
  23721. */
  23722. static readonly LineLoopDrawMode: number;
  23723. /**
  23724. * Returns the line strip draw mode
  23725. */
  23726. static readonly LineStripDrawMode: number;
  23727. /**
  23728. * Returns the triangle strip draw mode
  23729. */
  23730. static readonly TriangleStripDrawMode: number;
  23731. /**
  23732. * Returns the triangle fan draw mode
  23733. */
  23734. static readonly TriangleFanDrawMode: number;
  23735. /**
  23736. * Stores the clock-wise side orientation
  23737. */
  23738. static readonly ClockWiseSideOrientation: number;
  23739. /**
  23740. * Stores the counter clock-wise side orientation
  23741. */
  23742. static readonly CounterClockWiseSideOrientation: number;
  23743. /**
  23744. * The dirty texture flag value
  23745. */
  23746. static readonly TextureDirtyFlag: number;
  23747. /**
  23748. * The dirty light flag value
  23749. */
  23750. static readonly LightDirtyFlag: number;
  23751. /**
  23752. * The dirty fresnel flag value
  23753. */
  23754. static readonly FresnelDirtyFlag: number;
  23755. /**
  23756. * The dirty attribute flag value
  23757. */
  23758. static readonly AttributesDirtyFlag: number;
  23759. /**
  23760. * The dirty misc flag value
  23761. */
  23762. static readonly MiscDirtyFlag: number;
  23763. /**
  23764. * The all dirty flag value
  23765. */
  23766. static readonly AllDirtyFlag: number;
  23767. /**
  23768. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23769. */
  23770. static readonly MATERIAL_OPAQUE: number;
  23771. /**
  23772. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23773. */
  23774. static readonly MATERIAL_ALPHATEST: number;
  23775. /**
  23776. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23777. */
  23778. static readonly MATERIAL_ALPHABLEND: number;
  23779. /**
  23780. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23781. * They are also discarded below the alpha cutoff threshold to improve performances.
  23782. */
  23783. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23784. /**
  23785. * The Whiteout method is used to blend normals.
  23786. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23787. */
  23788. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  23789. /**
  23790. * The Reoriented Normal Mapping method is used to blend normals.
  23791. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23792. */
  23793. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  23794. /**
  23795. * Custom callback helping to override the default shader used in the material.
  23796. */
  23797. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23798. /**
  23799. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23800. */
  23801. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23802. /**
  23803. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23804. * This means that the material can keep using a previous shader while a new one is being compiled.
  23805. * This is mostly used when shader parallel compilation is supported (true by default)
  23806. */
  23807. allowShaderHotSwapping: boolean;
  23808. /**
  23809. * The ID of the material
  23810. */
  23811. id: string;
  23812. /**
  23813. * Gets or sets the unique id of the material
  23814. */
  23815. uniqueId: number;
  23816. /**
  23817. * The name of the material
  23818. */
  23819. name: string;
  23820. /**
  23821. * Gets or sets user defined metadata
  23822. */
  23823. metadata: any;
  23824. /**
  23825. * For internal use only. Please do not use.
  23826. */
  23827. reservedDataStore: any;
  23828. /**
  23829. * Specifies if the ready state should be checked on each call
  23830. */
  23831. checkReadyOnEveryCall: boolean;
  23832. /**
  23833. * Specifies if the ready state should be checked once
  23834. */
  23835. checkReadyOnlyOnce: boolean;
  23836. /**
  23837. * The state of the material
  23838. */
  23839. state: string;
  23840. /**
  23841. * The alpha value of the material
  23842. */
  23843. protected _alpha: number;
  23844. /**
  23845. * List of inspectable custom properties (used by the Inspector)
  23846. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23847. */
  23848. inspectableCustomProperties: IInspectable[];
  23849. /**
  23850. * Sets the alpha value of the material
  23851. */
  23852. set alpha(value: number);
  23853. /**
  23854. * Gets the alpha value of the material
  23855. */
  23856. get alpha(): number;
  23857. /**
  23858. * Specifies if back face culling is enabled
  23859. */
  23860. protected _backFaceCulling: boolean;
  23861. /**
  23862. * Sets the back-face culling state
  23863. */
  23864. set backFaceCulling(value: boolean);
  23865. /**
  23866. * Gets the back-face culling state
  23867. */
  23868. get backFaceCulling(): boolean;
  23869. /**
  23870. * Stores the value for side orientation
  23871. */
  23872. sideOrientation: number;
  23873. /**
  23874. * Callback triggered when the material is compiled
  23875. */
  23876. onCompiled: Nullable<(effect: Effect) => void>;
  23877. /**
  23878. * Callback triggered when an error occurs
  23879. */
  23880. onError: Nullable<(effect: Effect, errors: string) => void>;
  23881. /**
  23882. * Callback triggered to get the render target textures
  23883. */
  23884. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23885. /**
  23886. * Gets a boolean indicating that current material needs to register RTT
  23887. */
  23888. get hasRenderTargetTextures(): boolean;
  23889. /**
  23890. * Specifies if the material should be serialized
  23891. */
  23892. doNotSerialize: boolean;
  23893. /**
  23894. * @hidden
  23895. */
  23896. _storeEffectOnSubMeshes: boolean;
  23897. /**
  23898. * Stores the animations for the material
  23899. */
  23900. animations: Nullable<Array<Animation>>;
  23901. /**
  23902. * An event triggered when the material is disposed
  23903. */
  23904. onDisposeObservable: Observable<Material>;
  23905. /**
  23906. * An observer which watches for dispose events
  23907. */
  23908. private _onDisposeObserver;
  23909. private _onUnBindObservable;
  23910. /**
  23911. * Called during a dispose event
  23912. */
  23913. set onDispose(callback: () => void);
  23914. private _onBindObservable;
  23915. /**
  23916. * An event triggered when the material is bound
  23917. */
  23918. get onBindObservable(): Observable<AbstractMesh>;
  23919. /**
  23920. * An observer which watches for bind events
  23921. */
  23922. private _onBindObserver;
  23923. /**
  23924. * Called during a bind event
  23925. */
  23926. set onBind(callback: (Mesh: AbstractMesh) => void);
  23927. /**
  23928. * An event triggered when the material is unbound
  23929. */
  23930. get onUnBindObservable(): Observable<Material>;
  23931. protected _onEffectCreatedObservable: Nullable<Observable<{
  23932. effect: Effect;
  23933. subMesh: Nullable<SubMesh>;
  23934. }>>;
  23935. /**
  23936. * An event triggered when the effect is (re)created
  23937. */
  23938. get onEffectCreatedObservable(): Observable<{
  23939. effect: Effect;
  23940. subMesh: Nullable<SubMesh>;
  23941. }>;
  23942. /**
  23943. * Stores the value of the alpha mode
  23944. */
  23945. private _alphaMode;
  23946. /**
  23947. * Sets the value of the alpha mode.
  23948. *
  23949. * | Value | Type | Description |
  23950. * | --- | --- | --- |
  23951. * | 0 | ALPHA_DISABLE | |
  23952. * | 1 | ALPHA_ADD | |
  23953. * | 2 | ALPHA_COMBINE | |
  23954. * | 3 | ALPHA_SUBTRACT | |
  23955. * | 4 | ALPHA_MULTIPLY | |
  23956. * | 5 | ALPHA_MAXIMIZED | |
  23957. * | 6 | ALPHA_ONEONE | |
  23958. * | 7 | ALPHA_PREMULTIPLIED | |
  23959. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23960. * | 9 | ALPHA_INTERPOLATE | |
  23961. * | 10 | ALPHA_SCREENMODE | |
  23962. *
  23963. */
  23964. set alphaMode(value: number);
  23965. /**
  23966. * Gets the value of the alpha mode
  23967. */
  23968. get alphaMode(): number;
  23969. /**
  23970. * Stores the state of the need depth pre-pass value
  23971. */
  23972. private _needDepthPrePass;
  23973. /**
  23974. * Sets the need depth pre-pass value
  23975. */
  23976. set needDepthPrePass(value: boolean);
  23977. /**
  23978. * Gets the depth pre-pass value
  23979. */
  23980. get needDepthPrePass(): boolean;
  23981. /**
  23982. * Specifies if depth writing should be disabled
  23983. */
  23984. disableDepthWrite: boolean;
  23985. /**
  23986. * Specifies if color writing should be disabled
  23987. */
  23988. disableColorWrite: boolean;
  23989. /**
  23990. * Specifies if depth writing should be forced
  23991. */
  23992. forceDepthWrite: boolean;
  23993. /**
  23994. * Specifies the depth function that should be used. 0 means the default engine function
  23995. */
  23996. depthFunction: number;
  23997. /**
  23998. * Specifies if there should be a separate pass for culling
  23999. */
  24000. separateCullingPass: boolean;
  24001. /**
  24002. * Stores the state specifing if fog should be enabled
  24003. */
  24004. private _fogEnabled;
  24005. /**
  24006. * Sets the state for enabling fog
  24007. */
  24008. set fogEnabled(value: boolean);
  24009. /**
  24010. * Gets the value of the fog enabled state
  24011. */
  24012. get fogEnabled(): boolean;
  24013. /**
  24014. * Stores the size of points
  24015. */
  24016. pointSize: number;
  24017. /**
  24018. * Stores the z offset value
  24019. */
  24020. zOffset: number;
  24021. get wireframe(): boolean;
  24022. /**
  24023. * Sets the state of wireframe mode
  24024. */
  24025. set wireframe(value: boolean);
  24026. /**
  24027. * Gets the value specifying if point clouds are enabled
  24028. */
  24029. get pointsCloud(): boolean;
  24030. /**
  24031. * Sets the state of point cloud mode
  24032. */
  24033. set pointsCloud(value: boolean);
  24034. /**
  24035. * Gets the material fill mode
  24036. */
  24037. get fillMode(): number;
  24038. /**
  24039. * Sets the material fill mode
  24040. */
  24041. set fillMode(value: number);
  24042. /**
  24043. * @hidden
  24044. * Stores the effects for the material
  24045. */
  24046. _effect: Nullable<Effect>;
  24047. /**
  24048. * Specifies if uniform buffers should be used
  24049. */
  24050. private _useUBO;
  24051. /**
  24052. * Stores a reference to the scene
  24053. */
  24054. private _scene;
  24055. /**
  24056. * Stores the fill mode state
  24057. */
  24058. private _fillMode;
  24059. /**
  24060. * Specifies if the depth write state should be cached
  24061. */
  24062. private _cachedDepthWriteState;
  24063. /**
  24064. * Specifies if the color write state should be cached
  24065. */
  24066. private _cachedColorWriteState;
  24067. /**
  24068. * Specifies if the depth function state should be cached
  24069. */
  24070. private _cachedDepthFunctionState;
  24071. /**
  24072. * Stores the uniform buffer
  24073. */
  24074. protected _uniformBuffer: UniformBuffer;
  24075. /** @hidden */
  24076. _indexInSceneMaterialArray: number;
  24077. /** @hidden */
  24078. meshMap: Nullable<{
  24079. [id: string]: AbstractMesh | undefined;
  24080. }>;
  24081. /**
  24082. * Creates a material instance
  24083. * @param name defines the name of the material
  24084. * @param scene defines the scene to reference
  24085. * @param doNotAdd specifies if the material should be added to the scene
  24086. */
  24087. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24088. /**
  24089. * Returns a string representation of the current material
  24090. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24091. * @returns a string with material information
  24092. */
  24093. toString(fullDetails?: boolean): string;
  24094. /**
  24095. * Gets the class name of the material
  24096. * @returns a string with the class name of the material
  24097. */
  24098. getClassName(): string;
  24099. /**
  24100. * Specifies if updates for the material been locked
  24101. */
  24102. get isFrozen(): boolean;
  24103. /**
  24104. * Locks updates for the material
  24105. */
  24106. freeze(): void;
  24107. /**
  24108. * Unlocks updates for the material
  24109. */
  24110. unfreeze(): void;
  24111. /**
  24112. * Specifies if the material is ready to be used
  24113. * @param mesh defines the mesh to check
  24114. * @param useInstances specifies if instances should be used
  24115. * @returns a boolean indicating if the material is ready to be used
  24116. */
  24117. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24118. /**
  24119. * Specifies that the submesh is ready to be used
  24120. * @param mesh defines the mesh to check
  24121. * @param subMesh defines which submesh to check
  24122. * @param useInstances specifies that instances should be used
  24123. * @returns a boolean indicating that the submesh is ready or not
  24124. */
  24125. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24126. /**
  24127. * Returns the material effect
  24128. * @returns the effect associated with the material
  24129. */
  24130. getEffect(): Nullable<Effect>;
  24131. /**
  24132. * Returns the current scene
  24133. * @returns a Scene
  24134. */
  24135. getScene(): Scene;
  24136. /**
  24137. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24138. */
  24139. protected _forceAlphaTest: boolean;
  24140. /**
  24141. * The transparency mode of the material.
  24142. */
  24143. protected _transparencyMode: Nullable<number>;
  24144. /**
  24145. * Gets the current transparency mode.
  24146. */
  24147. get transparencyMode(): Nullable<number>;
  24148. /**
  24149. * Sets the transparency mode of the material.
  24150. *
  24151. * | Value | Type | Description |
  24152. * | ----- | ----------------------------------- | ----------- |
  24153. * | 0 | OPAQUE | |
  24154. * | 1 | ALPHATEST | |
  24155. * | 2 | ALPHABLEND | |
  24156. * | 3 | ALPHATESTANDBLEND | |
  24157. *
  24158. */
  24159. set transparencyMode(value: Nullable<number>);
  24160. /**
  24161. * Returns true if alpha blending should be disabled.
  24162. */
  24163. protected get _disableAlphaBlending(): boolean;
  24164. /**
  24165. * Specifies whether or not this material should be rendered in alpha blend mode.
  24166. * @returns a boolean specifying if alpha blending is needed
  24167. */
  24168. needAlphaBlending(): boolean;
  24169. /**
  24170. * Specifies if the mesh will require alpha blending
  24171. * @param mesh defines the mesh to check
  24172. * @returns a boolean specifying if alpha blending is needed for the mesh
  24173. */
  24174. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24175. /**
  24176. * Specifies whether or not this material should be rendered in alpha test mode.
  24177. * @returns a boolean specifying if an alpha test is needed.
  24178. */
  24179. needAlphaTesting(): boolean;
  24180. /**
  24181. * Specifies if material alpha testing should be turned on for the mesh
  24182. * @param mesh defines the mesh to check
  24183. */
  24184. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24185. /**
  24186. * Gets the texture used for the alpha test
  24187. * @returns the texture to use for alpha testing
  24188. */
  24189. getAlphaTestTexture(): Nullable<BaseTexture>;
  24190. /**
  24191. * Marks the material to indicate that it needs to be re-calculated
  24192. */
  24193. markDirty(): void;
  24194. /** @hidden */
  24195. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24196. /**
  24197. * Binds the material to the mesh
  24198. * @param world defines the world transformation matrix
  24199. * @param mesh defines the mesh to bind the material to
  24200. */
  24201. bind(world: Matrix, mesh?: Mesh): void;
  24202. /**
  24203. * Binds the submesh to the material
  24204. * @param world defines the world transformation matrix
  24205. * @param mesh defines the mesh containing the submesh
  24206. * @param subMesh defines the submesh to bind the material to
  24207. */
  24208. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24209. /**
  24210. * Binds the world matrix to the material
  24211. * @param world defines the world transformation matrix
  24212. */
  24213. bindOnlyWorldMatrix(world: Matrix): void;
  24214. /**
  24215. * Binds the scene's uniform buffer to the effect.
  24216. * @param effect defines the effect to bind to the scene uniform buffer
  24217. * @param sceneUbo defines the uniform buffer storing scene data
  24218. */
  24219. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24220. /**
  24221. * Binds the view matrix to the effect
  24222. * @param effect defines the effect to bind the view matrix to
  24223. */
  24224. bindView(effect: Effect): void;
  24225. /**
  24226. * Binds the view projection matrix to the effect
  24227. * @param effect defines the effect to bind the view projection matrix to
  24228. */
  24229. bindViewProjection(effect: Effect): void;
  24230. /**
  24231. * Processes to execute after binding the material to a mesh
  24232. * @param mesh defines the rendered mesh
  24233. */
  24234. protected _afterBind(mesh?: Mesh): void;
  24235. /**
  24236. * Unbinds the material from the mesh
  24237. */
  24238. unbind(): void;
  24239. /**
  24240. * Gets the active textures from the material
  24241. * @returns an array of textures
  24242. */
  24243. getActiveTextures(): BaseTexture[];
  24244. /**
  24245. * Specifies if the material uses a texture
  24246. * @param texture defines the texture to check against the material
  24247. * @returns a boolean specifying if the material uses the texture
  24248. */
  24249. hasTexture(texture: BaseTexture): boolean;
  24250. /**
  24251. * Makes a duplicate of the material, and gives it a new name
  24252. * @param name defines the new name for the duplicated material
  24253. * @returns the cloned material
  24254. */
  24255. clone(name: string): Nullable<Material>;
  24256. /**
  24257. * Gets the meshes bound to the material
  24258. * @returns an array of meshes bound to the material
  24259. */
  24260. getBindedMeshes(): AbstractMesh[];
  24261. /**
  24262. * Force shader compilation
  24263. * @param mesh defines the mesh associated with this material
  24264. * @param onCompiled defines a function to execute once the material is compiled
  24265. * @param options defines the options to configure the compilation
  24266. * @param onError defines a function to execute if the material fails compiling
  24267. */
  24268. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24269. /**
  24270. * Force shader compilation
  24271. * @param mesh defines the mesh that will use this material
  24272. * @param options defines additional options for compiling the shaders
  24273. * @returns a promise that resolves when the compilation completes
  24274. */
  24275. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24276. private static readonly _AllDirtyCallBack;
  24277. private static readonly _ImageProcessingDirtyCallBack;
  24278. private static readonly _TextureDirtyCallBack;
  24279. private static readonly _FresnelDirtyCallBack;
  24280. private static readonly _MiscDirtyCallBack;
  24281. private static readonly _LightsDirtyCallBack;
  24282. private static readonly _AttributeDirtyCallBack;
  24283. private static _FresnelAndMiscDirtyCallBack;
  24284. private static _TextureAndMiscDirtyCallBack;
  24285. private static readonly _DirtyCallbackArray;
  24286. private static readonly _RunDirtyCallBacks;
  24287. /**
  24288. * Marks a define in the material to indicate that it needs to be re-computed
  24289. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24290. */
  24291. markAsDirty(flag: number): void;
  24292. /**
  24293. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24294. * @param func defines a function which checks material defines against the submeshes
  24295. */
  24296. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24297. /**
  24298. * Indicates that we need to re-calculated for all submeshes
  24299. */
  24300. protected _markAllSubMeshesAsAllDirty(): void;
  24301. /**
  24302. * Indicates that image processing needs to be re-calculated for all submeshes
  24303. */
  24304. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24305. /**
  24306. * Indicates that textures need to be re-calculated for all submeshes
  24307. */
  24308. protected _markAllSubMeshesAsTexturesDirty(): void;
  24309. /**
  24310. * Indicates that fresnel needs to be re-calculated for all submeshes
  24311. */
  24312. protected _markAllSubMeshesAsFresnelDirty(): void;
  24313. /**
  24314. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24315. */
  24316. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24317. /**
  24318. * Indicates that lights need to be re-calculated for all submeshes
  24319. */
  24320. protected _markAllSubMeshesAsLightsDirty(): void;
  24321. /**
  24322. * Indicates that attributes need to be re-calculated for all submeshes
  24323. */
  24324. protected _markAllSubMeshesAsAttributesDirty(): void;
  24325. /**
  24326. * Indicates that misc needs to be re-calculated for all submeshes
  24327. */
  24328. protected _markAllSubMeshesAsMiscDirty(): void;
  24329. /**
  24330. * Indicates that textures and misc need to be re-calculated for all submeshes
  24331. */
  24332. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24333. /**
  24334. * Disposes the material
  24335. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24336. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24337. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24338. */
  24339. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24340. /** @hidden */
  24341. private releaseVertexArrayObject;
  24342. /**
  24343. * Serializes this material
  24344. * @returns the serialized material object
  24345. */
  24346. serialize(): any;
  24347. /**
  24348. * Creates a material from parsed material data
  24349. * @param parsedMaterial defines parsed material data
  24350. * @param scene defines the hosting scene
  24351. * @param rootUrl defines the root URL to use to load textures
  24352. * @returns a new material
  24353. */
  24354. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24355. }
  24356. }
  24357. declare module BABYLON {
  24358. /**
  24359. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24360. * separate meshes. This can be use to improve performances.
  24361. * @see http://doc.babylonjs.com/how_to/multi_materials
  24362. */
  24363. export class MultiMaterial extends Material {
  24364. private _subMaterials;
  24365. /**
  24366. * Gets or Sets the list of Materials used within the multi material.
  24367. * They need to be ordered according to the submeshes order in the associated mesh
  24368. */
  24369. get subMaterials(): Nullable<Material>[];
  24370. set subMaterials(value: Nullable<Material>[]);
  24371. /**
  24372. * Function used to align with Node.getChildren()
  24373. * @returns the list of Materials used within the multi material
  24374. */
  24375. getChildren(): Nullable<Material>[];
  24376. /**
  24377. * Instantiates a new Multi Material
  24378. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24379. * separate meshes. This can be use to improve performances.
  24380. * @see http://doc.babylonjs.com/how_to/multi_materials
  24381. * @param name Define the name in the scene
  24382. * @param scene Define the scene the material belongs to
  24383. */
  24384. constructor(name: string, scene: Scene);
  24385. private _hookArray;
  24386. /**
  24387. * Get one of the submaterial by its index in the submaterials array
  24388. * @param index The index to look the sub material at
  24389. * @returns The Material if the index has been defined
  24390. */
  24391. getSubMaterial(index: number): Nullable<Material>;
  24392. /**
  24393. * Get the list of active textures for the whole sub materials list.
  24394. * @returns All the textures that will be used during the rendering
  24395. */
  24396. getActiveTextures(): BaseTexture[];
  24397. /**
  24398. * Gets the current class name of the material e.g. "MultiMaterial"
  24399. * Mainly use in serialization.
  24400. * @returns the class name
  24401. */
  24402. getClassName(): string;
  24403. /**
  24404. * Checks if the material is ready to render the requested sub mesh
  24405. * @param mesh Define the mesh the submesh belongs to
  24406. * @param subMesh Define the sub mesh to look readyness for
  24407. * @param useInstances Define whether or not the material is used with instances
  24408. * @returns true if ready, otherwise false
  24409. */
  24410. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24411. /**
  24412. * Clones the current material and its related sub materials
  24413. * @param name Define the name of the newly cloned material
  24414. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24415. * @returns the cloned material
  24416. */
  24417. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24418. /**
  24419. * Serializes the materials into a JSON representation.
  24420. * @returns the JSON representation
  24421. */
  24422. serialize(): any;
  24423. /**
  24424. * Dispose the material and release its associated resources
  24425. * @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)
  24426. * @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)
  24427. * @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)
  24428. */
  24429. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24430. /**
  24431. * Creates a MultiMaterial from parsed MultiMaterial data.
  24432. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24433. * @param scene defines the hosting scene
  24434. * @returns a new MultiMaterial
  24435. */
  24436. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24437. }
  24438. }
  24439. declare module BABYLON {
  24440. /**
  24441. * Defines a subdivision inside a mesh
  24442. */
  24443. export class SubMesh implements ICullable {
  24444. /** the material index to use */
  24445. materialIndex: number;
  24446. /** vertex index start */
  24447. verticesStart: number;
  24448. /** vertices count */
  24449. verticesCount: number;
  24450. /** index start */
  24451. indexStart: number;
  24452. /** indices count */
  24453. indexCount: number;
  24454. /** @hidden */
  24455. _materialDefines: Nullable<MaterialDefines>;
  24456. /** @hidden */
  24457. _materialEffect: Nullable<Effect>;
  24458. /** @hidden */
  24459. _effectOverride: Nullable<Effect>;
  24460. /**
  24461. * Gets material defines used by the effect associated to the sub mesh
  24462. */
  24463. get materialDefines(): Nullable<MaterialDefines>;
  24464. /**
  24465. * Sets material defines used by the effect associated to the sub mesh
  24466. */
  24467. set materialDefines(defines: Nullable<MaterialDefines>);
  24468. /**
  24469. * Gets associated effect
  24470. */
  24471. get effect(): Nullable<Effect>;
  24472. /**
  24473. * Sets associated effect (effect used to render this submesh)
  24474. * @param effect defines the effect to associate with
  24475. * @param defines defines the set of defines used to compile this effect
  24476. */
  24477. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24478. /** @hidden */
  24479. _linesIndexCount: number;
  24480. private _mesh;
  24481. private _renderingMesh;
  24482. private _boundingInfo;
  24483. private _linesIndexBuffer;
  24484. /** @hidden */
  24485. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24486. /** @hidden */
  24487. _trianglePlanes: Plane[];
  24488. /** @hidden */
  24489. _lastColliderTransformMatrix: Nullable<Matrix>;
  24490. /** @hidden */
  24491. _renderId: number;
  24492. /** @hidden */
  24493. _alphaIndex: number;
  24494. /** @hidden */
  24495. _distanceToCamera: number;
  24496. /** @hidden */
  24497. _id: number;
  24498. private _currentMaterial;
  24499. /**
  24500. * Add a new submesh to a mesh
  24501. * @param materialIndex defines the material index to use
  24502. * @param verticesStart defines vertex index start
  24503. * @param verticesCount defines vertices count
  24504. * @param indexStart defines index start
  24505. * @param indexCount defines indices count
  24506. * @param mesh defines the parent mesh
  24507. * @param renderingMesh defines an optional rendering mesh
  24508. * @param createBoundingBox defines if bounding box should be created for this submesh
  24509. * @returns the new submesh
  24510. */
  24511. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24512. /**
  24513. * Creates a new submesh
  24514. * @param materialIndex defines the material index to use
  24515. * @param verticesStart defines vertex index start
  24516. * @param verticesCount defines vertices count
  24517. * @param indexStart defines index start
  24518. * @param indexCount defines indices count
  24519. * @param mesh defines the parent mesh
  24520. * @param renderingMesh defines an optional rendering mesh
  24521. * @param createBoundingBox defines if bounding box should be created for this submesh
  24522. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24523. */
  24524. constructor(
  24525. /** the material index to use */
  24526. materialIndex: number,
  24527. /** vertex index start */
  24528. verticesStart: number,
  24529. /** vertices count */
  24530. verticesCount: number,
  24531. /** index start */
  24532. indexStart: number,
  24533. /** indices count */
  24534. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24535. /**
  24536. * Returns true if this submesh covers the entire parent mesh
  24537. * @ignorenaming
  24538. */
  24539. get IsGlobal(): boolean;
  24540. /**
  24541. * Returns the submesh BoudingInfo object
  24542. * @returns current bounding info (or mesh's one if the submesh is global)
  24543. */
  24544. getBoundingInfo(): BoundingInfo;
  24545. /**
  24546. * Sets the submesh BoundingInfo
  24547. * @param boundingInfo defines the new bounding info to use
  24548. * @returns the SubMesh
  24549. */
  24550. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24551. /**
  24552. * Returns the mesh of the current submesh
  24553. * @return the parent mesh
  24554. */
  24555. getMesh(): AbstractMesh;
  24556. /**
  24557. * Returns the rendering mesh of the submesh
  24558. * @returns the rendering mesh (could be different from parent mesh)
  24559. */
  24560. getRenderingMesh(): Mesh;
  24561. /**
  24562. * Returns the replacement mesh of the submesh
  24563. * @returns the replacement mesh (could be different from parent mesh)
  24564. */
  24565. getReplacementMesh(): Nullable<AbstractMesh>;
  24566. /**
  24567. * Returns the effective mesh of the submesh
  24568. * @returns the effective mesh (could be different from parent mesh)
  24569. */
  24570. getEffectiveMesh(): AbstractMesh;
  24571. /**
  24572. * Returns the submesh material
  24573. * @returns null or the current material
  24574. */
  24575. getMaterial(): Nullable<Material>;
  24576. /**
  24577. * Sets a new updated BoundingInfo object to the submesh
  24578. * @param data defines an optional position array to use to determine the bounding info
  24579. * @returns the SubMesh
  24580. */
  24581. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24582. /** @hidden */
  24583. _checkCollision(collider: Collider): boolean;
  24584. /**
  24585. * Updates the submesh BoundingInfo
  24586. * @param world defines the world matrix to use to update the bounding info
  24587. * @returns the submesh
  24588. */
  24589. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24590. /**
  24591. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24592. * @param frustumPlanes defines the frustum planes
  24593. * @returns true if the submesh is intersecting with the frustum
  24594. */
  24595. isInFrustum(frustumPlanes: Plane[]): boolean;
  24596. /**
  24597. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24598. * @param frustumPlanes defines the frustum planes
  24599. * @returns true if the submesh is inside the frustum
  24600. */
  24601. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24602. /**
  24603. * Renders the submesh
  24604. * @param enableAlphaMode defines if alpha needs to be used
  24605. * @returns the submesh
  24606. */
  24607. render(enableAlphaMode: boolean): SubMesh;
  24608. /**
  24609. * @hidden
  24610. */
  24611. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24612. /**
  24613. * Checks if the submesh intersects with a ray
  24614. * @param ray defines the ray to test
  24615. * @returns true is the passed ray intersects the submesh bounding box
  24616. */
  24617. canIntersects(ray: Ray): boolean;
  24618. /**
  24619. * Intersects current submesh with a ray
  24620. * @param ray defines the ray to test
  24621. * @param positions defines mesh's positions array
  24622. * @param indices defines mesh's indices array
  24623. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24624. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24625. * @returns intersection info or null if no intersection
  24626. */
  24627. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24628. /** @hidden */
  24629. private _intersectLines;
  24630. /** @hidden */
  24631. private _intersectUnIndexedLines;
  24632. /** @hidden */
  24633. private _intersectTriangles;
  24634. /** @hidden */
  24635. private _intersectUnIndexedTriangles;
  24636. /** @hidden */
  24637. _rebuild(): void;
  24638. /**
  24639. * Creates a new submesh from the passed mesh
  24640. * @param newMesh defines the new hosting mesh
  24641. * @param newRenderingMesh defines an optional rendering mesh
  24642. * @returns the new submesh
  24643. */
  24644. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24645. /**
  24646. * Release associated resources
  24647. */
  24648. dispose(): void;
  24649. /**
  24650. * Gets the class name
  24651. * @returns the string "SubMesh".
  24652. */
  24653. getClassName(): string;
  24654. /**
  24655. * Creates a new submesh from indices data
  24656. * @param materialIndex the index of the main mesh material
  24657. * @param startIndex the index where to start the copy in the mesh indices array
  24658. * @param indexCount the number of indices to copy then from the startIndex
  24659. * @param mesh the main mesh to create the submesh from
  24660. * @param renderingMesh the optional rendering mesh
  24661. * @returns a new submesh
  24662. */
  24663. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24664. }
  24665. }
  24666. declare module BABYLON {
  24667. /**
  24668. * Class used to represent data loading progression
  24669. */
  24670. export class SceneLoaderFlags {
  24671. private static _ForceFullSceneLoadingForIncremental;
  24672. private static _ShowLoadingScreen;
  24673. private static _CleanBoneMatrixWeights;
  24674. private static _loggingLevel;
  24675. /**
  24676. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24677. */
  24678. static get ForceFullSceneLoadingForIncremental(): boolean;
  24679. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24680. /**
  24681. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24682. */
  24683. static get ShowLoadingScreen(): boolean;
  24684. static set ShowLoadingScreen(value: boolean);
  24685. /**
  24686. * Defines the current logging level (while loading the scene)
  24687. * @ignorenaming
  24688. */
  24689. static get loggingLevel(): number;
  24690. static set loggingLevel(value: number);
  24691. /**
  24692. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24693. */
  24694. static get CleanBoneMatrixWeights(): boolean;
  24695. static set CleanBoneMatrixWeights(value: boolean);
  24696. }
  24697. }
  24698. declare module BABYLON {
  24699. /**
  24700. * Class used to store geometry data (vertex buffers + index buffer)
  24701. */
  24702. export class Geometry implements IGetSetVerticesData {
  24703. /**
  24704. * Gets or sets the ID of the geometry
  24705. */
  24706. id: string;
  24707. /**
  24708. * Gets or sets the unique ID of the geometry
  24709. */
  24710. uniqueId: number;
  24711. /**
  24712. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24713. */
  24714. delayLoadState: number;
  24715. /**
  24716. * Gets the file containing the data to load when running in delay load state
  24717. */
  24718. delayLoadingFile: Nullable<string>;
  24719. /**
  24720. * Callback called when the geometry is updated
  24721. */
  24722. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24723. private _scene;
  24724. private _engine;
  24725. private _meshes;
  24726. private _totalVertices;
  24727. /** @hidden */
  24728. _indices: IndicesArray;
  24729. /** @hidden */
  24730. _vertexBuffers: {
  24731. [key: string]: VertexBuffer;
  24732. };
  24733. private _isDisposed;
  24734. private _extend;
  24735. private _boundingBias;
  24736. /** @hidden */
  24737. _delayInfo: Array<string>;
  24738. private _indexBuffer;
  24739. private _indexBufferIsUpdatable;
  24740. /** @hidden */
  24741. _boundingInfo: Nullable<BoundingInfo>;
  24742. /** @hidden */
  24743. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24744. /** @hidden */
  24745. _softwareSkinningFrameId: number;
  24746. private _vertexArrayObjects;
  24747. private _updatable;
  24748. /** @hidden */
  24749. _positions: Nullable<Vector3[]>;
  24750. /**
  24751. * 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
  24752. */
  24753. get boundingBias(): Vector2;
  24754. /**
  24755. * 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
  24756. */
  24757. set boundingBias(value: Vector2);
  24758. /**
  24759. * Static function used to attach a new empty geometry to a mesh
  24760. * @param mesh defines the mesh to attach the geometry to
  24761. * @returns the new Geometry
  24762. */
  24763. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24764. /** Get the list of meshes using this geometry */
  24765. get meshes(): Mesh[];
  24766. /**
  24767. * Creates a new geometry
  24768. * @param id defines the unique ID
  24769. * @param scene defines the hosting scene
  24770. * @param vertexData defines the VertexData used to get geometry data
  24771. * @param updatable defines if geometry must be updatable (false by default)
  24772. * @param mesh defines the mesh that will be associated with the geometry
  24773. */
  24774. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24775. /**
  24776. * Gets the current extend of the geometry
  24777. */
  24778. get extend(): {
  24779. minimum: Vector3;
  24780. maximum: Vector3;
  24781. };
  24782. /**
  24783. * Gets the hosting scene
  24784. * @returns the hosting Scene
  24785. */
  24786. getScene(): Scene;
  24787. /**
  24788. * Gets the hosting engine
  24789. * @returns the hosting Engine
  24790. */
  24791. getEngine(): Engine;
  24792. /**
  24793. * Defines if the geometry is ready to use
  24794. * @returns true if the geometry is ready to be used
  24795. */
  24796. isReady(): boolean;
  24797. /**
  24798. * Gets a value indicating that the geometry should not be serialized
  24799. */
  24800. get doNotSerialize(): boolean;
  24801. /** @hidden */
  24802. _rebuild(): void;
  24803. /**
  24804. * Affects all geometry data in one call
  24805. * @param vertexData defines the geometry data
  24806. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24807. */
  24808. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24809. /**
  24810. * Set specific vertex data
  24811. * @param kind defines the data kind (Position, normal, etc...)
  24812. * @param data defines the vertex data to use
  24813. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24814. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24815. */
  24816. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24817. /**
  24818. * Removes a specific vertex data
  24819. * @param kind defines the data kind (Position, normal, etc...)
  24820. */
  24821. removeVerticesData(kind: string): void;
  24822. /**
  24823. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24824. * @param buffer defines the vertex buffer to use
  24825. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24826. */
  24827. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24828. /**
  24829. * Update a specific vertex buffer
  24830. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24831. * It will do nothing if the buffer is not updatable
  24832. * @param kind defines the data kind (Position, normal, etc...)
  24833. * @param data defines the data to use
  24834. * @param offset defines the offset in the target buffer where to store the data
  24835. * @param useBytes set to true if the offset is in bytes
  24836. */
  24837. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24838. /**
  24839. * Update a specific vertex buffer
  24840. * This function will create a new buffer if the current one is not updatable
  24841. * @param kind defines the data kind (Position, normal, etc...)
  24842. * @param data defines the data to use
  24843. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24844. */
  24845. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24846. private _updateBoundingInfo;
  24847. /** @hidden */
  24848. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24849. /**
  24850. * Gets total number of vertices
  24851. * @returns the total number of vertices
  24852. */
  24853. getTotalVertices(): number;
  24854. /**
  24855. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24856. * @param kind defines the data kind (Position, normal, etc...)
  24857. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24858. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24859. * @returns a float array containing vertex data
  24860. */
  24861. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24862. /**
  24863. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24864. * @param kind defines the data kind (Position, normal, etc...)
  24865. * @returns true if the vertex buffer with the specified kind is updatable
  24866. */
  24867. isVertexBufferUpdatable(kind: string): boolean;
  24868. /**
  24869. * Gets a specific vertex buffer
  24870. * @param kind defines the data kind (Position, normal, etc...)
  24871. * @returns a VertexBuffer
  24872. */
  24873. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24874. /**
  24875. * Returns all vertex buffers
  24876. * @return an object holding all vertex buffers indexed by kind
  24877. */
  24878. getVertexBuffers(): Nullable<{
  24879. [key: string]: VertexBuffer;
  24880. }>;
  24881. /**
  24882. * Gets a boolean indicating if specific vertex buffer is present
  24883. * @param kind defines the data kind (Position, normal, etc...)
  24884. * @returns true if data is present
  24885. */
  24886. isVerticesDataPresent(kind: string): boolean;
  24887. /**
  24888. * Gets a list of all attached data kinds (Position, normal, etc...)
  24889. * @returns a list of string containing all kinds
  24890. */
  24891. getVerticesDataKinds(): string[];
  24892. /**
  24893. * Update index buffer
  24894. * @param indices defines the indices to store in the index buffer
  24895. * @param offset defines the offset in the target buffer where to store the data
  24896. * @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)
  24897. */
  24898. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24899. /**
  24900. * Creates a new index buffer
  24901. * @param indices defines the indices to store in the index buffer
  24902. * @param totalVertices defines the total number of vertices (could be null)
  24903. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24904. */
  24905. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24906. /**
  24907. * Return the total number of indices
  24908. * @returns the total number of indices
  24909. */
  24910. getTotalIndices(): number;
  24911. /**
  24912. * Gets the index buffer array
  24913. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24914. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24915. * @returns the index buffer array
  24916. */
  24917. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24918. /**
  24919. * Gets the index buffer
  24920. * @return the index buffer
  24921. */
  24922. getIndexBuffer(): Nullable<DataBuffer>;
  24923. /** @hidden */
  24924. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24925. /**
  24926. * Release the associated resources for a specific mesh
  24927. * @param mesh defines the source mesh
  24928. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24929. */
  24930. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24931. /**
  24932. * Apply current geometry to a given mesh
  24933. * @param mesh defines the mesh to apply geometry to
  24934. */
  24935. applyToMesh(mesh: Mesh): void;
  24936. private _updateExtend;
  24937. private _applyToMesh;
  24938. private notifyUpdate;
  24939. /**
  24940. * Load the geometry if it was flagged as delay loaded
  24941. * @param scene defines the hosting scene
  24942. * @param onLoaded defines a callback called when the geometry is loaded
  24943. */
  24944. load(scene: Scene, onLoaded?: () => void): void;
  24945. private _queueLoad;
  24946. /**
  24947. * Invert the geometry to move from a right handed system to a left handed one.
  24948. */
  24949. toLeftHanded(): void;
  24950. /** @hidden */
  24951. _resetPointsArrayCache(): void;
  24952. /** @hidden */
  24953. _generatePointsArray(): boolean;
  24954. /**
  24955. * Gets a value indicating if the geometry is disposed
  24956. * @returns true if the geometry was disposed
  24957. */
  24958. isDisposed(): boolean;
  24959. private _disposeVertexArrayObjects;
  24960. /**
  24961. * Free all associated resources
  24962. */
  24963. dispose(): void;
  24964. /**
  24965. * Clone the current geometry into a new geometry
  24966. * @param id defines the unique ID of the new geometry
  24967. * @returns a new geometry object
  24968. */
  24969. copy(id: string): Geometry;
  24970. /**
  24971. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24972. * @return a JSON representation of the current geometry data (without the vertices data)
  24973. */
  24974. serialize(): any;
  24975. private toNumberArray;
  24976. /**
  24977. * Serialize all vertices data into a JSON oject
  24978. * @returns a JSON representation of the current geometry data
  24979. */
  24980. serializeVerticeData(): any;
  24981. /**
  24982. * Extracts a clone of a mesh geometry
  24983. * @param mesh defines the source mesh
  24984. * @param id defines the unique ID of the new geometry object
  24985. * @returns the new geometry object
  24986. */
  24987. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24988. /**
  24989. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24990. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24991. * Be aware Math.random() could cause collisions, but:
  24992. * "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"
  24993. * @returns a string containing a new GUID
  24994. */
  24995. static RandomId(): string;
  24996. /** @hidden */
  24997. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24998. private static _CleanMatricesWeights;
  24999. /**
  25000. * Create a new geometry from persisted data (Using .babylon file format)
  25001. * @param parsedVertexData defines the persisted data
  25002. * @param scene defines the hosting scene
  25003. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25004. * @returns the new geometry object
  25005. */
  25006. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25007. }
  25008. }
  25009. declare module BABYLON {
  25010. /**
  25011. * Define an interface for all classes that will get and set the data on vertices
  25012. */
  25013. export interface IGetSetVerticesData {
  25014. /**
  25015. * Gets a boolean indicating if specific vertex data is present
  25016. * @param kind defines the vertex data kind to use
  25017. * @returns true is data kind is present
  25018. */
  25019. isVerticesDataPresent(kind: string): boolean;
  25020. /**
  25021. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25022. * @param kind defines the data kind (Position, normal, etc...)
  25023. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25024. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25025. * @returns a float array containing vertex data
  25026. */
  25027. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25028. /**
  25029. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25030. * @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.
  25031. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25032. * @returns the indices array or an empty array if the mesh has no geometry
  25033. */
  25034. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25035. /**
  25036. * Set specific vertex data
  25037. * @param kind defines the data kind (Position, normal, etc...)
  25038. * @param data defines the vertex data to use
  25039. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25040. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25041. */
  25042. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25043. /**
  25044. * Update a specific associated vertex buffer
  25045. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25046. * - VertexBuffer.PositionKind
  25047. * - VertexBuffer.UVKind
  25048. * - VertexBuffer.UV2Kind
  25049. * - VertexBuffer.UV3Kind
  25050. * - VertexBuffer.UV4Kind
  25051. * - VertexBuffer.UV5Kind
  25052. * - VertexBuffer.UV6Kind
  25053. * - VertexBuffer.ColorKind
  25054. * - VertexBuffer.MatricesIndicesKind
  25055. * - VertexBuffer.MatricesIndicesExtraKind
  25056. * - VertexBuffer.MatricesWeightsKind
  25057. * - VertexBuffer.MatricesWeightsExtraKind
  25058. * @param data defines the data source
  25059. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25060. * @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)
  25061. */
  25062. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25063. /**
  25064. * Creates a new index buffer
  25065. * @param indices defines the indices to store in the index buffer
  25066. * @param totalVertices defines the total number of vertices (could be null)
  25067. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25068. */
  25069. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25070. }
  25071. /**
  25072. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25073. */
  25074. export class VertexData {
  25075. /**
  25076. * Mesh side orientation : usually the external or front surface
  25077. */
  25078. static readonly FRONTSIDE: number;
  25079. /**
  25080. * Mesh side orientation : usually the internal or back surface
  25081. */
  25082. static readonly BACKSIDE: number;
  25083. /**
  25084. * Mesh side orientation : both internal and external or front and back surfaces
  25085. */
  25086. static readonly DOUBLESIDE: number;
  25087. /**
  25088. * Mesh side orientation : by default, `FRONTSIDE`
  25089. */
  25090. static readonly DEFAULTSIDE: number;
  25091. /**
  25092. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25093. */
  25094. positions: Nullable<FloatArray>;
  25095. /**
  25096. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25097. */
  25098. normals: Nullable<FloatArray>;
  25099. /**
  25100. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25101. */
  25102. tangents: Nullable<FloatArray>;
  25103. /**
  25104. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25105. */
  25106. uvs: Nullable<FloatArray>;
  25107. /**
  25108. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25109. */
  25110. uvs2: Nullable<FloatArray>;
  25111. /**
  25112. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25113. */
  25114. uvs3: Nullable<FloatArray>;
  25115. /**
  25116. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25117. */
  25118. uvs4: Nullable<FloatArray>;
  25119. /**
  25120. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25121. */
  25122. uvs5: Nullable<FloatArray>;
  25123. /**
  25124. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25125. */
  25126. uvs6: Nullable<FloatArray>;
  25127. /**
  25128. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25129. */
  25130. colors: Nullable<FloatArray>;
  25131. /**
  25132. * 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).
  25133. */
  25134. matricesIndices: Nullable<FloatArray>;
  25135. /**
  25136. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25137. */
  25138. matricesWeights: Nullable<FloatArray>;
  25139. /**
  25140. * An array extending the number of possible indices
  25141. */
  25142. matricesIndicesExtra: Nullable<FloatArray>;
  25143. /**
  25144. * An array extending the number of possible weights when the number of indices is extended
  25145. */
  25146. matricesWeightsExtra: Nullable<FloatArray>;
  25147. /**
  25148. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25149. */
  25150. indices: Nullable<IndicesArray>;
  25151. /**
  25152. * Uses the passed data array to set the set the values for the specified kind of data
  25153. * @param data a linear array of floating numbers
  25154. * @param kind the type of data that is being set, eg positions, colors etc
  25155. */
  25156. set(data: FloatArray, kind: string): void;
  25157. /**
  25158. * Associates the vertexData to the passed Mesh.
  25159. * Sets it as updatable or not (default `false`)
  25160. * @param mesh the mesh the vertexData is applied to
  25161. * @param updatable when used and having the value true allows new data to update the vertexData
  25162. * @returns the VertexData
  25163. */
  25164. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25165. /**
  25166. * Associates the vertexData to the passed Geometry.
  25167. * Sets it as updatable or not (default `false`)
  25168. * @param geometry the geometry the vertexData is applied to
  25169. * @param updatable when used and having the value true allows new data to update the vertexData
  25170. * @returns VertexData
  25171. */
  25172. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25173. /**
  25174. * Updates the associated mesh
  25175. * @param mesh the mesh to be updated
  25176. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25177. * @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
  25178. * @returns VertexData
  25179. */
  25180. updateMesh(mesh: Mesh): VertexData;
  25181. /**
  25182. * Updates the associated geometry
  25183. * @param geometry the geometry to be updated
  25184. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25185. * @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
  25186. * @returns VertexData.
  25187. */
  25188. updateGeometry(geometry: Geometry): VertexData;
  25189. private _applyTo;
  25190. private _update;
  25191. /**
  25192. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25193. * @param matrix the transforming matrix
  25194. * @returns the VertexData
  25195. */
  25196. transform(matrix: Matrix): VertexData;
  25197. /**
  25198. * Merges the passed VertexData into the current one
  25199. * @param other the VertexData to be merged into the current one
  25200. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25201. * @returns the modified VertexData
  25202. */
  25203. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25204. private _mergeElement;
  25205. private _validate;
  25206. /**
  25207. * Serializes the VertexData
  25208. * @returns a serialized object
  25209. */
  25210. serialize(): any;
  25211. /**
  25212. * Extracts the vertexData from a mesh
  25213. * @param mesh the mesh from which to extract the VertexData
  25214. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25215. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25216. * @returns the object VertexData associated to the passed mesh
  25217. */
  25218. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25219. /**
  25220. * Extracts the vertexData from the geometry
  25221. * @param geometry the geometry from which to extract the VertexData
  25222. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25223. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25224. * @returns the object VertexData associated to the passed mesh
  25225. */
  25226. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25227. private static _ExtractFrom;
  25228. /**
  25229. * Creates the VertexData for a Ribbon
  25230. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25231. * * pathArray array of paths, each of which an array of successive Vector3
  25232. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25233. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25234. * * 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
  25235. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25236. * * 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)
  25237. * * 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)
  25238. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25239. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25240. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25241. * @returns the VertexData of the ribbon
  25242. */
  25243. static CreateRibbon(options: {
  25244. pathArray: Vector3[][];
  25245. closeArray?: boolean;
  25246. closePath?: boolean;
  25247. offset?: number;
  25248. sideOrientation?: number;
  25249. frontUVs?: Vector4;
  25250. backUVs?: Vector4;
  25251. invertUV?: boolean;
  25252. uvs?: Vector2[];
  25253. colors?: Color4[];
  25254. }): VertexData;
  25255. /**
  25256. * Creates the VertexData for a box
  25257. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25258. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25259. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25260. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25261. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25262. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25263. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25265. * * 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)
  25266. * * 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)
  25267. * @returns the VertexData of the box
  25268. */
  25269. static CreateBox(options: {
  25270. size?: number;
  25271. width?: number;
  25272. height?: number;
  25273. depth?: number;
  25274. faceUV?: Vector4[];
  25275. faceColors?: Color4[];
  25276. sideOrientation?: number;
  25277. frontUVs?: Vector4;
  25278. backUVs?: Vector4;
  25279. }): VertexData;
  25280. /**
  25281. * Creates the VertexData for a tiled box
  25282. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25283. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25284. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25285. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25287. * @returns the VertexData of the box
  25288. */
  25289. static CreateTiledBox(options: {
  25290. pattern?: number;
  25291. width?: number;
  25292. height?: number;
  25293. depth?: number;
  25294. tileSize?: number;
  25295. tileWidth?: number;
  25296. tileHeight?: number;
  25297. alignHorizontal?: number;
  25298. alignVertical?: number;
  25299. faceUV?: Vector4[];
  25300. faceColors?: Color4[];
  25301. sideOrientation?: number;
  25302. }): VertexData;
  25303. /**
  25304. * Creates the VertexData for a tiled plane
  25305. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25306. * * pattern a limited pattern arrangement depending on the number
  25307. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25308. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25309. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25310. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25311. * * 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)
  25312. * * 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)
  25313. * @returns the VertexData of the tiled plane
  25314. */
  25315. static CreateTiledPlane(options: {
  25316. pattern?: number;
  25317. tileSize?: number;
  25318. tileWidth?: number;
  25319. tileHeight?: number;
  25320. size?: number;
  25321. width?: number;
  25322. height?: number;
  25323. alignHorizontal?: number;
  25324. alignVertical?: number;
  25325. sideOrientation?: number;
  25326. frontUVs?: Vector4;
  25327. backUVs?: Vector4;
  25328. }): VertexData;
  25329. /**
  25330. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25331. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25332. * * segments sets the number of horizontal strips optional, default 32
  25333. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25334. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25335. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25336. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25337. * * 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
  25338. * * 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
  25339. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25340. * * 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)
  25341. * * 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)
  25342. * @returns the VertexData of the ellipsoid
  25343. */
  25344. static CreateSphere(options: {
  25345. segments?: number;
  25346. diameter?: number;
  25347. diameterX?: number;
  25348. diameterY?: number;
  25349. diameterZ?: number;
  25350. arc?: number;
  25351. slice?: number;
  25352. sideOrientation?: number;
  25353. frontUVs?: Vector4;
  25354. backUVs?: Vector4;
  25355. }): VertexData;
  25356. /**
  25357. * Creates the VertexData for a cylinder, cone or prism
  25358. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25359. * * height sets the height (y direction) of the cylinder, optional, default 2
  25360. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25361. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25362. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25363. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25364. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25365. * * 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
  25366. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25367. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25368. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25369. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25371. * * 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)
  25372. * * 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)
  25373. * @returns the VertexData of the cylinder, cone or prism
  25374. */
  25375. static CreateCylinder(options: {
  25376. height?: number;
  25377. diameterTop?: number;
  25378. diameterBottom?: number;
  25379. diameter?: number;
  25380. tessellation?: number;
  25381. subdivisions?: number;
  25382. arc?: number;
  25383. faceColors?: Color4[];
  25384. faceUV?: Vector4[];
  25385. hasRings?: boolean;
  25386. enclose?: boolean;
  25387. sideOrientation?: number;
  25388. frontUVs?: Vector4;
  25389. backUVs?: Vector4;
  25390. }): VertexData;
  25391. /**
  25392. * Creates the VertexData for a torus
  25393. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25394. * * diameter the diameter of the torus, optional default 1
  25395. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25396. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25397. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25398. * * 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)
  25399. * * 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)
  25400. * @returns the VertexData of the torus
  25401. */
  25402. static CreateTorus(options: {
  25403. diameter?: number;
  25404. thickness?: number;
  25405. tessellation?: number;
  25406. sideOrientation?: number;
  25407. frontUVs?: Vector4;
  25408. backUVs?: Vector4;
  25409. }): VertexData;
  25410. /**
  25411. * Creates the VertexData of the LineSystem
  25412. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25413. * - lines an array of lines, each line being an array of successive Vector3
  25414. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25415. * @returns the VertexData of the LineSystem
  25416. */
  25417. static CreateLineSystem(options: {
  25418. lines: Vector3[][];
  25419. colors?: Nullable<Color4[][]>;
  25420. }): VertexData;
  25421. /**
  25422. * Create the VertexData for a DashedLines
  25423. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25424. * - points an array successive Vector3
  25425. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25426. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25427. * - dashNb the intended total number of dashes, optional, default 200
  25428. * @returns the VertexData for the DashedLines
  25429. */
  25430. static CreateDashedLines(options: {
  25431. points: Vector3[];
  25432. dashSize?: number;
  25433. gapSize?: number;
  25434. dashNb?: number;
  25435. }): VertexData;
  25436. /**
  25437. * Creates the VertexData for a Ground
  25438. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25439. * - width the width (x direction) of the ground, optional, default 1
  25440. * - height the height (z direction) of the ground, optional, default 1
  25441. * - subdivisions the number of subdivisions per side, optional, default 1
  25442. * @returns the VertexData of the Ground
  25443. */
  25444. static CreateGround(options: {
  25445. width?: number;
  25446. height?: number;
  25447. subdivisions?: number;
  25448. subdivisionsX?: number;
  25449. subdivisionsY?: number;
  25450. }): VertexData;
  25451. /**
  25452. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25453. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25454. * * xmin the ground minimum X coordinate, optional, default -1
  25455. * * zmin the ground minimum Z coordinate, optional, default -1
  25456. * * xmax the ground maximum X coordinate, optional, default 1
  25457. * * zmax the ground maximum Z coordinate, optional, default 1
  25458. * * 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}
  25459. * * 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}
  25460. * @returns the VertexData of the TiledGround
  25461. */
  25462. static CreateTiledGround(options: {
  25463. xmin: number;
  25464. zmin: number;
  25465. xmax: number;
  25466. zmax: number;
  25467. subdivisions?: {
  25468. w: number;
  25469. h: number;
  25470. };
  25471. precision?: {
  25472. w: number;
  25473. h: number;
  25474. };
  25475. }): VertexData;
  25476. /**
  25477. * Creates the VertexData of the Ground designed from a heightmap
  25478. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25479. * * width the width (x direction) of the ground
  25480. * * height the height (z direction) of the ground
  25481. * * subdivisions the number of subdivisions per side
  25482. * * minHeight the minimum altitude on the ground, optional, default 0
  25483. * * maxHeight the maximum altitude on the ground, optional default 1
  25484. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25485. * * buffer the array holding the image color data
  25486. * * bufferWidth the width of image
  25487. * * bufferHeight the height of image
  25488. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25489. * @returns the VertexData of the Ground designed from a heightmap
  25490. */
  25491. static CreateGroundFromHeightMap(options: {
  25492. width: number;
  25493. height: number;
  25494. subdivisions: number;
  25495. minHeight: number;
  25496. maxHeight: number;
  25497. colorFilter: Color3;
  25498. buffer: Uint8Array;
  25499. bufferWidth: number;
  25500. bufferHeight: number;
  25501. alphaFilter: number;
  25502. }): VertexData;
  25503. /**
  25504. * Creates the VertexData for a Plane
  25505. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25506. * * size sets the width and height of the plane to the value of size, optional default 1
  25507. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25508. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25509. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25510. * * 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)
  25511. * * 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)
  25512. * @returns the VertexData of the box
  25513. */
  25514. static CreatePlane(options: {
  25515. size?: number;
  25516. width?: number;
  25517. height?: number;
  25518. sideOrientation?: number;
  25519. frontUVs?: Vector4;
  25520. backUVs?: Vector4;
  25521. }): VertexData;
  25522. /**
  25523. * Creates the VertexData of the Disc or regular Polygon
  25524. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25525. * * radius the radius of the disc, optional default 0.5
  25526. * * tessellation the number of polygon sides, optional, default 64
  25527. * * 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
  25528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25529. * * 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)
  25530. * * 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)
  25531. * @returns the VertexData of the box
  25532. */
  25533. static CreateDisc(options: {
  25534. radius?: number;
  25535. tessellation?: number;
  25536. arc?: number;
  25537. sideOrientation?: number;
  25538. frontUVs?: Vector4;
  25539. backUVs?: Vector4;
  25540. }): VertexData;
  25541. /**
  25542. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25543. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25544. * @param polygon a mesh built from polygonTriangulation.build()
  25545. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25546. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25547. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25548. * @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)
  25549. * @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)
  25550. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25551. * @returns the VertexData of the Polygon
  25552. */
  25553. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25554. /**
  25555. * Creates the VertexData of the IcoSphere
  25556. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25557. * * radius the radius of the IcoSphere, optional default 1
  25558. * * radiusX allows stretching in the x direction, optional, default radius
  25559. * * radiusY allows stretching in the y direction, optional, default radius
  25560. * * radiusZ allows stretching in the z direction, optional, default radius
  25561. * * flat when true creates a flat shaded mesh, optional, default true
  25562. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25563. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25564. * * 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)
  25565. * * 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)
  25566. * @returns the VertexData of the IcoSphere
  25567. */
  25568. static CreateIcoSphere(options: {
  25569. radius?: number;
  25570. radiusX?: number;
  25571. radiusY?: number;
  25572. radiusZ?: number;
  25573. flat?: boolean;
  25574. subdivisions?: number;
  25575. sideOrientation?: number;
  25576. frontUVs?: Vector4;
  25577. backUVs?: Vector4;
  25578. }): VertexData;
  25579. /**
  25580. * Creates the VertexData for a Polyhedron
  25581. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25582. * * type provided types are:
  25583. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25584. * * 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)
  25585. * * size the size of the IcoSphere, optional default 1
  25586. * * sizeX allows stretching in the x direction, optional, default size
  25587. * * sizeY allows stretching in the y direction, optional, default size
  25588. * * sizeZ allows stretching in the z direction, optional, default size
  25589. * * 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
  25590. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25591. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25592. * * flat when true creates a flat shaded mesh, optional, default true
  25593. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25594. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25595. * * 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)
  25596. * * 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)
  25597. * @returns the VertexData of the Polyhedron
  25598. */
  25599. static CreatePolyhedron(options: {
  25600. type?: number;
  25601. size?: number;
  25602. sizeX?: number;
  25603. sizeY?: number;
  25604. sizeZ?: number;
  25605. custom?: any;
  25606. faceUV?: Vector4[];
  25607. faceColors?: Color4[];
  25608. flat?: boolean;
  25609. sideOrientation?: number;
  25610. frontUVs?: Vector4;
  25611. backUVs?: Vector4;
  25612. }): VertexData;
  25613. /**
  25614. * Creates the VertexData for a TorusKnot
  25615. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25616. * * radius the radius of the torus knot, optional, default 2
  25617. * * tube the thickness of the tube, optional, default 0.5
  25618. * * radialSegments the number of sides on each tube segments, optional, default 32
  25619. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25620. * * p the number of windings around the z axis, optional, default 2
  25621. * * q the number of windings around the x axis, optional, default 3
  25622. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25623. * * 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)
  25624. * * 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)
  25625. * @returns the VertexData of the Torus Knot
  25626. */
  25627. static CreateTorusKnot(options: {
  25628. radius?: number;
  25629. tube?: number;
  25630. radialSegments?: number;
  25631. tubularSegments?: number;
  25632. p?: number;
  25633. q?: number;
  25634. sideOrientation?: number;
  25635. frontUVs?: Vector4;
  25636. backUVs?: Vector4;
  25637. }): VertexData;
  25638. /**
  25639. * Compute normals for given positions and indices
  25640. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25641. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25642. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25643. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25644. * * facetNormals : optional array of facet normals (vector3)
  25645. * * facetPositions : optional array of facet positions (vector3)
  25646. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25647. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25648. * * bInfo : optional bounding info, required for facetPartitioning computation
  25649. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25650. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25651. * * useRightHandedSystem: optional boolean to for right handed system computation
  25652. * * depthSort : optional boolean to enable the facet depth sort computation
  25653. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25654. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25655. */
  25656. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25657. facetNormals?: any;
  25658. facetPositions?: any;
  25659. facetPartitioning?: any;
  25660. ratio?: number;
  25661. bInfo?: any;
  25662. bbSize?: Vector3;
  25663. subDiv?: any;
  25664. useRightHandedSystem?: boolean;
  25665. depthSort?: boolean;
  25666. distanceTo?: Vector3;
  25667. depthSortedFacets?: any;
  25668. }): void;
  25669. /** @hidden */
  25670. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25671. /**
  25672. * Applies VertexData created from the imported parameters to the geometry
  25673. * @param parsedVertexData the parsed data from an imported file
  25674. * @param geometry the geometry to apply the VertexData to
  25675. */
  25676. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25677. }
  25678. }
  25679. declare module BABYLON {
  25680. /**
  25681. * Defines a target to use with MorphTargetManager
  25682. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25683. */
  25684. export class MorphTarget implements IAnimatable {
  25685. /** defines the name of the target */
  25686. name: string;
  25687. /**
  25688. * Gets or sets the list of animations
  25689. */
  25690. animations: Animation[];
  25691. private _scene;
  25692. private _positions;
  25693. private _normals;
  25694. private _tangents;
  25695. private _uvs;
  25696. private _influence;
  25697. private _uniqueId;
  25698. /**
  25699. * Observable raised when the influence changes
  25700. */
  25701. onInfluenceChanged: Observable<boolean>;
  25702. /** @hidden */
  25703. _onDataLayoutChanged: Observable<void>;
  25704. /**
  25705. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25706. */
  25707. get influence(): number;
  25708. set influence(influence: number);
  25709. /**
  25710. * Gets or sets the id of the morph Target
  25711. */
  25712. id: string;
  25713. private _animationPropertiesOverride;
  25714. /**
  25715. * Gets or sets the animation properties override
  25716. */
  25717. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25718. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25719. /**
  25720. * Creates a new MorphTarget
  25721. * @param name defines the name of the target
  25722. * @param influence defines the influence to use
  25723. * @param scene defines the scene the morphtarget belongs to
  25724. */
  25725. constructor(
  25726. /** defines the name of the target */
  25727. name: string, influence?: number, scene?: Nullable<Scene>);
  25728. /**
  25729. * Gets the unique ID of this manager
  25730. */
  25731. get uniqueId(): number;
  25732. /**
  25733. * Gets a boolean defining if the target contains position data
  25734. */
  25735. get hasPositions(): boolean;
  25736. /**
  25737. * Gets a boolean defining if the target contains normal data
  25738. */
  25739. get hasNormals(): boolean;
  25740. /**
  25741. * Gets a boolean defining if the target contains tangent data
  25742. */
  25743. get hasTangents(): boolean;
  25744. /**
  25745. * Gets a boolean defining if the target contains texture coordinates data
  25746. */
  25747. get hasUVs(): boolean;
  25748. /**
  25749. * Affects position data to this target
  25750. * @param data defines the position data to use
  25751. */
  25752. setPositions(data: Nullable<FloatArray>): void;
  25753. /**
  25754. * Gets the position data stored in this target
  25755. * @returns a FloatArray containing the position data (or null if not present)
  25756. */
  25757. getPositions(): Nullable<FloatArray>;
  25758. /**
  25759. * Affects normal data to this target
  25760. * @param data defines the normal data to use
  25761. */
  25762. setNormals(data: Nullable<FloatArray>): void;
  25763. /**
  25764. * Gets the normal data stored in this target
  25765. * @returns a FloatArray containing the normal data (or null if not present)
  25766. */
  25767. getNormals(): Nullable<FloatArray>;
  25768. /**
  25769. * Affects tangent data to this target
  25770. * @param data defines the tangent data to use
  25771. */
  25772. setTangents(data: Nullable<FloatArray>): void;
  25773. /**
  25774. * Gets the tangent data stored in this target
  25775. * @returns a FloatArray containing the tangent data (or null if not present)
  25776. */
  25777. getTangents(): Nullable<FloatArray>;
  25778. /**
  25779. * Affects texture coordinates data to this target
  25780. * @param data defines the texture coordinates data to use
  25781. */
  25782. setUVs(data: Nullable<FloatArray>): void;
  25783. /**
  25784. * Gets the texture coordinates data stored in this target
  25785. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25786. */
  25787. getUVs(): Nullable<FloatArray>;
  25788. /**
  25789. * Clone the current target
  25790. * @returns a new MorphTarget
  25791. */
  25792. clone(): MorphTarget;
  25793. /**
  25794. * Serializes the current target into a Serialization object
  25795. * @returns the serialized object
  25796. */
  25797. serialize(): any;
  25798. /**
  25799. * Returns the string "MorphTarget"
  25800. * @returns "MorphTarget"
  25801. */
  25802. getClassName(): string;
  25803. /**
  25804. * Creates a new target from serialized data
  25805. * @param serializationObject defines the serialized data to use
  25806. * @returns a new MorphTarget
  25807. */
  25808. static Parse(serializationObject: any): MorphTarget;
  25809. /**
  25810. * Creates a MorphTarget from mesh data
  25811. * @param mesh defines the source mesh
  25812. * @param name defines the name to use for the new target
  25813. * @param influence defines the influence to attach to the target
  25814. * @returns a new MorphTarget
  25815. */
  25816. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25817. }
  25818. }
  25819. declare module BABYLON {
  25820. /**
  25821. * This class is used to deform meshes using morphing between different targets
  25822. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25823. */
  25824. export class MorphTargetManager {
  25825. private _targets;
  25826. private _targetInfluenceChangedObservers;
  25827. private _targetDataLayoutChangedObservers;
  25828. private _activeTargets;
  25829. private _scene;
  25830. private _influences;
  25831. private _supportsNormals;
  25832. private _supportsTangents;
  25833. private _supportsUVs;
  25834. private _vertexCount;
  25835. private _uniqueId;
  25836. private _tempInfluences;
  25837. /**
  25838. * Gets or sets a boolean indicating if normals must be morphed
  25839. */
  25840. enableNormalMorphing: boolean;
  25841. /**
  25842. * Gets or sets a boolean indicating if tangents must be morphed
  25843. */
  25844. enableTangentMorphing: boolean;
  25845. /**
  25846. * Gets or sets a boolean indicating if UV must be morphed
  25847. */
  25848. enableUVMorphing: boolean;
  25849. /**
  25850. * Creates a new MorphTargetManager
  25851. * @param scene defines the current scene
  25852. */
  25853. constructor(scene?: Nullable<Scene>);
  25854. /**
  25855. * Gets the unique ID of this manager
  25856. */
  25857. get uniqueId(): number;
  25858. /**
  25859. * Gets the number of vertices handled by this manager
  25860. */
  25861. get vertexCount(): number;
  25862. /**
  25863. * Gets a boolean indicating if this manager supports morphing of normals
  25864. */
  25865. get supportsNormals(): boolean;
  25866. /**
  25867. * Gets a boolean indicating if this manager supports morphing of tangents
  25868. */
  25869. get supportsTangents(): boolean;
  25870. /**
  25871. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25872. */
  25873. get supportsUVs(): boolean;
  25874. /**
  25875. * Gets the number of targets stored in this manager
  25876. */
  25877. get numTargets(): number;
  25878. /**
  25879. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25880. */
  25881. get numInfluencers(): number;
  25882. /**
  25883. * Gets the list of influences (one per target)
  25884. */
  25885. get influences(): Float32Array;
  25886. /**
  25887. * Gets the active target at specified index. An active target is a target with an influence > 0
  25888. * @param index defines the index to check
  25889. * @returns the requested target
  25890. */
  25891. getActiveTarget(index: number): MorphTarget;
  25892. /**
  25893. * Gets the target at specified index
  25894. * @param index defines the index to check
  25895. * @returns the requested target
  25896. */
  25897. getTarget(index: number): MorphTarget;
  25898. /**
  25899. * Add a new target to this manager
  25900. * @param target defines the target to add
  25901. */
  25902. addTarget(target: MorphTarget): void;
  25903. /**
  25904. * Removes a target from the manager
  25905. * @param target defines the target to remove
  25906. */
  25907. removeTarget(target: MorphTarget): void;
  25908. /**
  25909. * Clone the current manager
  25910. * @returns a new MorphTargetManager
  25911. */
  25912. clone(): MorphTargetManager;
  25913. /**
  25914. * Serializes the current manager into a Serialization object
  25915. * @returns the serialized object
  25916. */
  25917. serialize(): any;
  25918. private _syncActiveTargets;
  25919. /**
  25920. * Syncrhonize the targets with all the meshes using this morph target manager
  25921. */
  25922. synchronize(): void;
  25923. /**
  25924. * Creates a new MorphTargetManager from serialized data
  25925. * @param serializationObject defines the serialized data
  25926. * @param scene defines the hosting scene
  25927. * @returns the new MorphTargetManager
  25928. */
  25929. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25930. }
  25931. }
  25932. declare module BABYLON {
  25933. /**
  25934. * Class used to represent a specific level of detail of a mesh
  25935. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25936. */
  25937. export class MeshLODLevel {
  25938. /** Defines the distance where this level should start being displayed */
  25939. distance: number;
  25940. /** Defines the mesh to use to render this level */
  25941. mesh: Nullable<Mesh>;
  25942. /**
  25943. * Creates a new LOD level
  25944. * @param distance defines the distance where this level should star being displayed
  25945. * @param mesh defines the mesh to use to render this level
  25946. */
  25947. constructor(
  25948. /** Defines the distance where this level should start being displayed */
  25949. distance: number,
  25950. /** Defines the mesh to use to render this level */
  25951. mesh: Nullable<Mesh>);
  25952. }
  25953. }
  25954. declare module BABYLON {
  25955. /**
  25956. * Mesh representing the gorund
  25957. */
  25958. export class GroundMesh extends Mesh {
  25959. /** If octree should be generated */
  25960. generateOctree: boolean;
  25961. private _heightQuads;
  25962. /** @hidden */
  25963. _subdivisionsX: number;
  25964. /** @hidden */
  25965. _subdivisionsY: number;
  25966. /** @hidden */
  25967. _width: number;
  25968. /** @hidden */
  25969. _height: number;
  25970. /** @hidden */
  25971. _minX: number;
  25972. /** @hidden */
  25973. _maxX: number;
  25974. /** @hidden */
  25975. _minZ: number;
  25976. /** @hidden */
  25977. _maxZ: number;
  25978. constructor(name: string, scene: Scene);
  25979. /**
  25980. * "GroundMesh"
  25981. * @returns "GroundMesh"
  25982. */
  25983. getClassName(): string;
  25984. /**
  25985. * The minimum of x and y subdivisions
  25986. */
  25987. get subdivisions(): number;
  25988. /**
  25989. * X subdivisions
  25990. */
  25991. get subdivisionsX(): number;
  25992. /**
  25993. * Y subdivisions
  25994. */
  25995. get subdivisionsY(): number;
  25996. /**
  25997. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25998. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25999. * @param chunksCount the number of subdivisions for x and y
  26000. * @param octreeBlocksSize (Default: 32)
  26001. */
  26002. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26003. /**
  26004. * Returns a height (y) value in the Worl system :
  26005. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26006. * @param x x coordinate
  26007. * @param z z coordinate
  26008. * @returns the ground y position if (x, z) are outside the ground surface.
  26009. */
  26010. getHeightAtCoordinates(x: number, z: number): number;
  26011. /**
  26012. * Returns a normalized vector (Vector3) orthogonal to the ground
  26013. * at the ground coordinates (x, z) expressed in the World system.
  26014. * @param x x coordinate
  26015. * @param z z coordinate
  26016. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26017. */
  26018. getNormalAtCoordinates(x: number, z: number): Vector3;
  26019. /**
  26020. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26021. * at the ground coordinates (x, z) expressed in the World system.
  26022. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26023. * @param x x coordinate
  26024. * @param z z coordinate
  26025. * @param ref vector to store the result
  26026. * @returns the GroundMesh.
  26027. */
  26028. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26029. /**
  26030. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26031. * if the ground has been updated.
  26032. * This can be used in the render loop.
  26033. * @returns the GroundMesh.
  26034. */
  26035. updateCoordinateHeights(): GroundMesh;
  26036. private _getFacetAt;
  26037. private _initHeightQuads;
  26038. private _computeHeightQuads;
  26039. /**
  26040. * Serializes this ground mesh
  26041. * @param serializationObject object to write serialization to
  26042. */
  26043. serialize(serializationObject: any): void;
  26044. /**
  26045. * Parses a serialized ground mesh
  26046. * @param parsedMesh the serialized mesh
  26047. * @param scene the scene to create the ground mesh in
  26048. * @returns the created ground mesh
  26049. */
  26050. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26051. }
  26052. }
  26053. declare module BABYLON {
  26054. /**
  26055. * Interface for Physics-Joint data
  26056. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26057. */
  26058. export interface PhysicsJointData {
  26059. /**
  26060. * The main pivot of the joint
  26061. */
  26062. mainPivot?: Vector3;
  26063. /**
  26064. * The connected pivot of the joint
  26065. */
  26066. connectedPivot?: Vector3;
  26067. /**
  26068. * The main axis of the joint
  26069. */
  26070. mainAxis?: Vector3;
  26071. /**
  26072. * The connected axis of the joint
  26073. */
  26074. connectedAxis?: Vector3;
  26075. /**
  26076. * The collision of the joint
  26077. */
  26078. collision?: boolean;
  26079. /**
  26080. * Native Oimo/Cannon/Energy data
  26081. */
  26082. nativeParams?: any;
  26083. }
  26084. /**
  26085. * This is a holder class for the physics joint created by the physics plugin
  26086. * It holds a set of functions to control the underlying joint
  26087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26088. */
  26089. export class PhysicsJoint {
  26090. /**
  26091. * The type of the physics joint
  26092. */
  26093. type: number;
  26094. /**
  26095. * The data for the physics joint
  26096. */
  26097. jointData: PhysicsJointData;
  26098. private _physicsJoint;
  26099. protected _physicsPlugin: IPhysicsEnginePlugin;
  26100. /**
  26101. * Initializes the physics joint
  26102. * @param type The type of the physics joint
  26103. * @param jointData The data for the physics joint
  26104. */
  26105. constructor(
  26106. /**
  26107. * The type of the physics joint
  26108. */
  26109. type: number,
  26110. /**
  26111. * The data for the physics joint
  26112. */
  26113. jointData: PhysicsJointData);
  26114. /**
  26115. * Gets the physics joint
  26116. */
  26117. get physicsJoint(): any;
  26118. /**
  26119. * Sets the physics joint
  26120. */
  26121. set physicsJoint(newJoint: any);
  26122. /**
  26123. * Sets the physics plugin
  26124. */
  26125. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26126. /**
  26127. * Execute a function that is physics-plugin specific.
  26128. * @param {Function} func the function that will be executed.
  26129. * It accepts two parameters: the physics world and the physics joint
  26130. */
  26131. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26132. /**
  26133. * Distance-Joint type
  26134. */
  26135. static DistanceJoint: number;
  26136. /**
  26137. * Hinge-Joint type
  26138. */
  26139. static HingeJoint: number;
  26140. /**
  26141. * Ball-and-Socket joint type
  26142. */
  26143. static BallAndSocketJoint: number;
  26144. /**
  26145. * Wheel-Joint type
  26146. */
  26147. static WheelJoint: number;
  26148. /**
  26149. * Slider-Joint type
  26150. */
  26151. static SliderJoint: number;
  26152. /**
  26153. * Prismatic-Joint type
  26154. */
  26155. static PrismaticJoint: number;
  26156. /**
  26157. * Universal-Joint type
  26158. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26159. */
  26160. static UniversalJoint: number;
  26161. /**
  26162. * Hinge-Joint 2 type
  26163. */
  26164. static Hinge2Joint: number;
  26165. /**
  26166. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26167. */
  26168. static PointToPointJoint: number;
  26169. /**
  26170. * Spring-Joint type
  26171. */
  26172. static SpringJoint: number;
  26173. /**
  26174. * Lock-Joint type
  26175. */
  26176. static LockJoint: number;
  26177. }
  26178. /**
  26179. * A class representing a physics distance joint
  26180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26181. */
  26182. export class DistanceJoint extends PhysicsJoint {
  26183. /**
  26184. *
  26185. * @param jointData The data for the Distance-Joint
  26186. */
  26187. constructor(jointData: DistanceJointData);
  26188. /**
  26189. * Update the predefined distance.
  26190. * @param maxDistance The maximum preferred distance
  26191. * @param minDistance The minimum preferred distance
  26192. */
  26193. updateDistance(maxDistance: number, minDistance?: number): void;
  26194. }
  26195. /**
  26196. * Represents a Motor-Enabled Joint
  26197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26198. */
  26199. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26200. /**
  26201. * Initializes the Motor-Enabled Joint
  26202. * @param type The type of the joint
  26203. * @param jointData The physica joint data for the joint
  26204. */
  26205. constructor(type: number, jointData: PhysicsJointData);
  26206. /**
  26207. * Set the motor values.
  26208. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26209. * @param force the force to apply
  26210. * @param maxForce max force for this motor.
  26211. */
  26212. setMotor(force?: number, maxForce?: number): void;
  26213. /**
  26214. * Set the motor's limits.
  26215. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26216. * @param upperLimit The upper limit of the motor
  26217. * @param lowerLimit The lower limit of the motor
  26218. */
  26219. setLimit(upperLimit: number, lowerLimit?: number): void;
  26220. }
  26221. /**
  26222. * This class represents a single physics Hinge-Joint
  26223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26224. */
  26225. export class HingeJoint extends MotorEnabledJoint {
  26226. /**
  26227. * Initializes the Hinge-Joint
  26228. * @param jointData The joint data for the Hinge-Joint
  26229. */
  26230. constructor(jointData: PhysicsJointData);
  26231. /**
  26232. * Set the motor values.
  26233. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26234. * @param {number} force the force to apply
  26235. * @param {number} maxForce max force for this motor.
  26236. */
  26237. setMotor(force?: number, maxForce?: number): void;
  26238. /**
  26239. * Set the motor's limits.
  26240. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26241. * @param upperLimit The upper limit of the motor
  26242. * @param lowerLimit The lower limit of the motor
  26243. */
  26244. setLimit(upperLimit: number, lowerLimit?: number): void;
  26245. }
  26246. /**
  26247. * This class represents a dual hinge physics joint (same as wheel joint)
  26248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26249. */
  26250. export class Hinge2Joint extends MotorEnabledJoint {
  26251. /**
  26252. * Initializes the Hinge2-Joint
  26253. * @param jointData The joint data for the Hinge2-Joint
  26254. */
  26255. constructor(jointData: PhysicsJointData);
  26256. /**
  26257. * Set the motor values.
  26258. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26259. * @param {number} targetSpeed the speed the motor is to reach
  26260. * @param {number} maxForce max force for this motor.
  26261. * @param {motorIndex} the motor's index, 0 or 1.
  26262. */
  26263. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26264. /**
  26265. * Set the motor limits.
  26266. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26267. * @param {number} upperLimit the upper limit
  26268. * @param {number} lowerLimit lower limit
  26269. * @param {motorIndex} the motor's index, 0 or 1.
  26270. */
  26271. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26272. }
  26273. /**
  26274. * Interface for a motor enabled joint
  26275. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26276. */
  26277. export interface IMotorEnabledJoint {
  26278. /**
  26279. * Physics joint
  26280. */
  26281. physicsJoint: any;
  26282. /**
  26283. * Sets the motor of the motor-enabled joint
  26284. * @param force The force of the motor
  26285. * @param maxForce The maximum force of the motor
  26286. * @param motorIndex The index of the motor
  26287. */
  26288. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26289. /**
  26290. * Sets the limit of the motor
  26291. * @param upperLimit The upper limit of the motor
  26292. * @param lowerLimit The lower limit of the motor
  26293. * @param motorIndex The index of the motor
  26294. */
  26295. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26296. }
  26297. /**
  26298. * Joint data for a Distance-Joint
  26299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26300. */
  26301. export interface DistanceJointData extends PhysicsJointData {
  26302. /**
  26303. * Max distance the 2 joint objects can be apart
  26304. */
  26305. maxDistance: number;
  26306. }
  26307. /**
  26308. * Joint data from a spring joint
  26309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26310. */
  26311. export interface SpringJointData extends PhysicsJointData {
  26312. /**
  26313. * Length of the spring
  26314. */
  26315. length: number;
  26316. /**
  26317. * Stiffness of the spring
  26318. */
  26319. stiffness: number;
  26320. /**
  26321. * Damping of the spring
  26322. */
  26323. damping: number;
  26324. /** this callback will be called when applying the force to the impostors. */
  26325. forceApplicationCallback: () => void;
  26326. }
  26327. }
  26328. declare module BABYLON {
  26329. /**
  26330. * Holds the data for the raycast result
  26331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26332. */
  26333. export class PhysicsRaycastResult {
  26334. private _hasHit;
  26335. private _hitDistance;
  26336. private _hitNormalWorld;
  26337. private _hitPointWorld;
  26338. private _rayFromWorld;
  26339. private _rayToWorld;
  26340. /**
  26341. * Gets if there was a hit
  26342. */
  26343. get hasHit(): boolean;
  26344. /**
  26345. * Gets the distance from the hit
  26346. */
  26347. get hitDistance(): number;
  26348. /**
  26349. * Gets the hit normal/direction in the world
  26350. */
  26351. get hitNormalWorld(): Vector3;
  26352. /**
  26353. * Gets the hit point in the world
  26354. */
  26355. get hitPointWorld(): Vector3;
  26356. /**
  26357. * Gets the ray "start point" of the ray in the world
  26358. */
  26359. get rayFromWorld(): Vector3;
  26360. /**
  26361. * Gets the ray "end point" of the ray in the world
  26362. */
  26363. get rayToWorld(): Vector3;
  26364. /**
  26365. * Sets the hit data (normal & point in world space)
  26366. * @param hitNormalWorld defines the normal in world space
  26367. * @param hitPointWorld defines the point in world space
  26368. */
  26369. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26370. /**
  26371. * Sets the distance from the start point to the hit point
  26372. * @param distance
  26373. */
  26374. setHitDistance(distance: number): void;
  26375. /**
  26376. * Calculates the distance manually
  26377. */
  26378. calculateHitDistance(): void;
  26379. /**
  26380. * Resets all the values to default
  26381. * @param from The from point on world space
  26382. * @param to The to point on world space
  26383. */
  26384. reset(from?: Vector3, to?: Vector3): void;
  26385. }
  26386. /**
  26387. * Interface for the size containing width and height
  26388. */
  26389. interface IXYZ {
  26390. /**
  26391. * X
  26392. */
  26393. x: number;
  26394. /**
  26395. * Y
  26396. */
  26397. y: number;
  26398. /**
  26399. * Z
  26400. */
  26401. z: number;
  26402. }
  26403. }
  26404. declare module BABYLON {
  26405. /**
  26406. * Interface used to describe a physics joint
  26407. */
  26408. export interface PhysicsImpostorJoint {
  26409. /** Defines the main impostor to which the joint is linked */
  26410. mainImpostor: PhysicsImpostor;
  26411. /** Defines the impostor that is connected to the main impostor using this joint */
  26412. connectedImpostor: PhysicsImpostor;
  26413. /** Defines the joint itself */
  26414. joint: PhysicsJoint;
  26415. }
  26416. /** @hidden */
  26417. export interface IPhysicsEnginePlugin {
  26418. world: any;
  26419. name: string;
  26420. setGravity(gravity: Vector3): void;
  26421. setTimeStep(timeStep: number): void;
  26422. getTimeStep(): number;
  26423. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26424. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26425. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26426. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26427. removePhysicsBody(impostor: PhysicsImpostor): void;
  26428. generateJoint(joint: PhysicsImpostorJoint): void;
  26429. removeJoint(joint: PhysicsImpostorJoint): void;
  26430. isSupported(): boolean;
  26431. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26432. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26433. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26434. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26435. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26436. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26437. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26438. getBodyMass(impostor: PhysicsImpostor): number;
  26439. getBodyFriction(impostor: PhysicsImpostor): number;
  26440. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26441. getBodyRestitution(impostor: PhysicsImpostor): number;
  26442. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26443. getBodyPressure?(impostor: PhysicsImpostor): number;
  26444. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26445. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26446. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26447. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26448. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26449. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26450. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26451. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26452. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26453. sleepBody(impostor: PhysicsImpostor): void;
  26454. wakeUpBody(impostor: PhysicsImpostor): void;
  26455. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26456. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26457. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26458. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26459. getRadius(impostor: PhysicsImpostor): number;
  26460. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26461. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26462. dispose(): void;
  26463. }
  26464. /**
  26465. * Interface used to define a physics engine
  26466. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26467. */
  26468. export interface IPhysicsEngine {
  26469. /**
  26470. * Gets the gravity vector used by the simulation
  26471. */
  26472. gravity: Vector3;
  26473. /**
  26474. * Sets the gravity vector used by the simulation
  26475. * @param gravity defines the gravity vector to use
  26476. */
  26477. setGravity(gravity: Vector3): void;
  26478. /**
  26479. * Set the time step of the physics engine.
  26480. * Default is 1/60.
  26481. * To slow it down, enter 1/600 for example.
  26482. * To speed it up, 1/30
  26483. * @param newTimeStep the new timestep to apply to this world.
  26484. */
  26485. setTimeStep(newTimeStep: number): void;
  26486. /**
  26487. * Get the time step of the physics engine.
  26488. * @returns the current time step
  26489. */
  26490. getTimeStep(): number;
  26491. /**
  26492. * Set the sub time step of the physics engine.
  26493. * Default is 0 meaning there is no sub steps
  26494. * To increase physics resolution precision, set a small value (like 1 ms)
  26495. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26496. */
  26497. setSubTimeStep(subTimeStep: number): void;
  26498. /**
  26499. * Get the sub time step of the physics engine.
  26500. * @returns the current sub time step
  26501. */
  26502. getSubTimeStep(): number;
  26503. /**
  26504. * Release all resources
  26505. */
  26506. dispose(): void;
  26507. /**
  26508. * Gets the name of the current physics plugin
  26509. * @returns the name of the plugin
  26510. */
  26511. getPhysicsPluginName(): string;
  26512. /**
  26513. * Adding a new impostor for the impostor tracking.
  26514. * This will be done by the impostor itself.
  26515. * @param impostor the impostor to add
  26516. */
  26517. addImpostor(impostor: PhysicsImpostor): void;
  26518. /**
  26519. * Remove an impostor from the engine.
  26520. * This impostor and its mesh will not longer be updated by the physics engine.
  26521. * @param impostor the impostor to remove
  26522. */
  26523. removeImpostor(impostor: PhysicsImpostor): void;
  26524. /**
  26525. * Add a joint to the physics engine
  26526. * @param mainImpostor defines the main impostor to which the joint is added.
  26527. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26528. * @param joint defines the joint that will connect both impostors.
  26529. */
  26530. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26531. /**
  26532. * Removes a joint from the simulation
  26533. * @param mainImpostor defines the impostor used with the joint
  26534. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26535. * @param joint defines the joint to remove
  26536. */
  26537. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26538. /**
  26539. * Gets the current plugin used to run the simulation
  26540. * @returns current plugin
  26541. */
  26542. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26543. /**
  26544. * Gets the list of physic impostors
  26545. * @returns an array of PhysicsImpostor
  26546. */
  26547. getImpostors(): Array<PhysicsImpostor>;
  26548. /**
  26549. * Gets the impostor for a physics enabled object
  26550. * @param object defines the object impersonated by the impostor
  26551. * @returns the PhysicsImpostor or null if not found
  26552. */
  26553. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26554. /**
  26555. * Gets the impostor for a physics body object
  26556. * @param body defines physics body used by the impostor
  26557. * @returns the PhysicsImpostor or null if not found
  26558. */
  26559. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26560. /**
  26561. * Does a raycast in the physics world
  26562. * @param from when should the ray start?
  26563. * @param to when should the ray end?
  26564. * @returns PhysicsRaycastResult
  26565. */
  26566. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26567. /**
  26568. * Called by the scene. No need to call it.
  26569. * @param delta defines the timespam between frames
  26570. */
  26571. _step(delta: number): void;
  26572. }
  26573. }
  26574. declare module BABYLON {
  26575. /**
  26576. * The interface for the physics imposter parameters
  26577. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26578. */
  26579. export interface PhysicsImpostorParameters {
  26580. /**
  26581. * The mass of the physics imposter
  26582. */
  26583. mass: number;
  26584. /**
  26585. * The friction of the physics imposter
  26586. */
  26587. friction?: number;
  26588. /**
  26589. * The coefficient of restitution of the physics imposter
  26590. */
  26591. restitution?: number;
  26592. /**
  26593. * The native options of the physics imposter
  26594. */
  26595. nativeOptions?: any;
  26596. /**
  26597. * Specifies if the parent should be ignored
  26598. */
  26599. ignoreParent?: boolean;
  26600. /**
  26601. * Specifies if bi-directional transformations should be disabled
  26602. */
  26603. disableBidirectionalTransformation?: boolean;
  26604. /**
  26605. * The pressure inside the physics imposter, soft object only
  26606. */
  26607. pressure?: number;
  26608. /**
  26609. * The stiffness the physics imposter, soft object only
  26610. */
  26611. stiffness?: number;
  26612. /**
  26613. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26614. */
  26615. velocityIterations?: number;
  26616. /**
  26617. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26618. */
  26619. positionIterations?: number;
  26620. /**
  26621. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26622. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26623. * Add to fix multiple points
  26624. */
  26625. fixedPoints?: number;
  26626. /**
  26627. * The collision margin around a soft object
  26628. */
  26629. margin?: number;
  26630. /**
  26631. * The collision margin around a soft object
  26632. */
  26633. damping?: number;
  26634. /**
  26635. * The path for a rope based on an extrusion
  26636. */
  26637. path?: any;
  26638. /**
  26639. * The shape of an extrusion used for a rope based on an extrusion
  26640. */
  26641. shape?: any;
  26642. }
  26643. /**
  26644. * Interface for a physics-enabled object
  26645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26646. */
  26647. export interface IPhysicsEnabledObject {
  26648. /**
  26649. * The position of the physics-enabled object
  26650. */
  26651. position: Vector3;
  26652. /**
  26653. * The rotation of the physics-enabled object
  26654. */
  26655. rotationQuaternion: Nullable<Quaternion>;
  26656. /**
  26657. * The scale of the physics-enabled object
  26658. */
  26659. scaling: Vector3;
  26660. /**
  26661. * The rotation of the physics-enabled object
  26662. */
  26663. rotation?: Vector3;
  26664. /**
  26665. * The parent of the physics-enabled object
  26666. */
  26667. parent?: any;
  26668. /**
  26669. * The bounding info of the physics-enabled object
  26670. * @returns The bounding info of the physics-enabled object
  26671. */
  26672. getBoundingInfo(): BoundingInfo;
  26673. /**
  26674. * Computes the world matrix
  26675. * @param force Specifies if the world matrix should be computed by force
  26676. * @returns A world matrix
  26677. */
  26678. computeWorldMatrix(force: boolean): Matrix;
  26679. /**
  26680. * Gets the world matrix
  26681. * @returns A world matrix
  26682. */
  26683. getWorldMatrix?(): Matrix;
  26684. /**
  26685. * Gets the child meshes
  26686. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26687. * @returns An array of abstract meshes
  26688. */
  26689. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26690. /**
  26691. * Gets the vertex data
  26692. * @param kind The type of vertex data
  26693. * @returns A nullable array of numbers, or a float32 array
  26694. */
  26695. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26696. /**
  26697. * Gets the indices from the mesh
  26698. * @returns A nullable array of index arrays
  26699. */
  26700. getIndices?(): Nullable<IndicesArray>;
  26701. /**
  26702. * Gets the scene from the mesh
  26703. * @returns the indices array or null
  26704. */
  26705. getScene?(): Scene;
  26706. /**
  26707. * Gets the absolute position from the mesh
  26708. * @returns the absolute position
  26709. */
  26710. getAbsolutePosition(): Vector3;
  26711. /**
  26712. * Gets the absolute pivot point from the mesh
  26713. * @returns the absolute pivot point
  26714. */
  26715. getAbsolutePivotPoint(): Vector3;
  26716. /**
  26717. * Rotates the mesh
  26718. * @param axis The axis of rotation
  26719. * @param amount The amount of rotation
  26720. * @param space The space of the rotation
  26721. * @returns The rotation transform node
  26722. */
  26723. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26724. /**
  26725. * Translates the mesh
  26726. * @param axis The axis of translation
  26727. * @param distance The distance of translation
  26728. * @param space The space of the translation
  26729. * @returns The transform node
  26730. */
  26731. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26732. /**
  26733. * Sets the absolute position of the mesh
  26734. * @param absolutePosition The absolute position of the mesh
  26735. * @returns The transform node
  26736. */
  26737. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26738. /**
  26739. * Gets the class name of the mesh
  26740. * @returns The class name
  26741. */
  26742. getClassName(): string;
  26743. }
  26744. /**
  26745. * Represents a physics imposter
  26746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26747. */
  26748. export class PhysicsImpostor {
  26749. /**
  26750. * The physics-enabled object used as the physics imposter
  26751. */
  26752. object: IPhysicsEnabledObject;
  26753. /**
  26754. * The type of the physics imposter
  26755. */
  26756. type: number;
  26757. private _options;
  26758. private _scene?;
  26759. /**
  26760. * The default object size of the imposter
  26761. */
  26762. static DEFAULT_OBJECT_SIZE: Vector3;
  26763. /**
  26764. * The identity quaternion of the imposter
  26765. */
  26766. static IDENTITY_QUATERNION: Quaternion;
  26767. /** @hidden */
  26768. _pluginData: any;
  26769. private _physicsEngine;
  26770. private _physicsBody;
  26771. private _bodyUpdateRequired;
  26772. private _onBeforePhysicsStepCallbacks;
  26773. private _onAfterPhysicsStepCallbacks;
  26774. /** @hidden */
  26775. _onPhysicsCollideCallbacks: Array<{
  26776. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26777. otherImpostors: Array<PhysicsImpostor>;
  26778. }>;
  26779. private _deltaPosition;
  26780. private _deltaRotation;
  26781. private _deltaRotationConjugated;
  26782. /** @hidden */
  26783. _isFromLine: boolean;
  26784. private _parent;
  26785. private _isDisposed;
  26786. private static _tmpVecs;
  26787. private static _tmpQuat;
  26788. /**
  26789. * Specifies if the physics imposter is disposed
  26790. */
  26791. get isDisposed(): boolean;
  26792. /**
  26793. * Gets the mass of the physics imposter
  26794. */
  26795. get mass(): number;
  26796. set mass(value: number);
  26797. /**
  26798. * Gets the coefficient of friction
  26799. */
  26800. get friction(): number;
  26801. /**
  26802. * Sets the coefficient of friction
  26803. */
  26804. set friction(value: number);
  26805. /**
  26806. * Gets the coefficient of restitution
  26807. */
  26808. get restitution(): number;
  26809. /**
  26810. * Sets the coefficient of restitution
  26811. */
  26812. set restitution(value: number);
  26813. /**
  26814. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26815. */
  26816. get pressure(): number;
  26817. /**
  26818. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26819. */
  26820. set pressure(value: number);
  26821. /**
  26822. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26823. */
  26824. get stiffness(): number;
  26825. /**
  26826. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26827. */
  26828. set stiffness(value: number);
  26829. /**
  26830. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26831. */
  26832. get velocityIterations(): number;
  26833. /**
  26834. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26835. */
  26836. set velocityIterations(value: number);
  26837. /**
  26838. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26839. */
  26840. get positionIterations(): number;
  26841. /**
  26842. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26843. */
  26844. set positionIterations(value: number);
  26845. /**
  26846. * The unique id of the physics imposter
  26847. * set by the physics engine when adding this impostor to the array
  26848. */
  26849. uniqueId: number;
  26850. /**
  26851. * @hidden
  26852. */
  26853. soft: boolean;
  26854. /**
  26855. * @hidden
  26856. */
  26857. segments: number;
  26858. private _joints;
  26859. /**
  26860. * Initializes the physics imposter
  26861. * @param object The physics-enabled object used as the physics imposter
  26862. * @param type The type of the physics imposter
  26863. * @param _options The options for the physics imposter
  26864. * @param _scene The Babylon scene
  26865. */
  26866. constructor(
  26867. /**
  26868. * The physics-enabled object used as the physics imposter
  26869. */
  26870. object: IPhysicsEnabledObject,
  26871. /**
  26872. * The type of the physics imposter
  26873. */
  26874. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26875. /**
  26876. * This function will completly initialize this impostor.
  26877. * It will create a new body - but only if this mesh has no parent.
  26878. * If it has, this impostor will not be used other than to define the impostor
  26879. * of the child mesh.
  26880. * @hidden
  26881. */
  26882. _init(): void;
  26883. private _getPhysicsParent;
  26884. /**
  26885. * Should a new body be generated.
  26886. * @returns boolean specifying if body initialization is required
  26887. */
  26888. isBodyInitRequired(): boolean;
  26889. /**
  26890. * Sets the updated scaling
  26891. * @param updated Specifies if the scaling is updated
  26892. */
  26893. setScalingUpdated(): void;
  26894. /**
  26895. * Force a regeneration of this or the parent's impostor's body.
  26896. * Use under cautious - This will remove all joints already implemented.
  26897. */
  26898. forceUpdate(): void;
  26899. /**
  26900. * Gets the body that holds this impostor. Either its own, or its parent.
  26901. */
  26902. get physicsBody(): any;
  26903. /**
  26904. * Get the parent of the physics imposter
  26905. * @returns Physics imposter or null
  26906. */
  26907. get parent(): Nullable<PhysicsImpostor>;
  26908. /**
  26909. * Sets the parent of the physics imposter
  26910. */
  26911. set parent(value: Nullable<PhysicsImpostor>);
  26912. /**
  26913. * Set the physics body. Used mainly by the physics engine/plugin
  26914. */
  26915. set physicsBody(physicsBody: any);
  26916. /**
  26917. * Resets the update flags
  26918. */
  26919. resetUpdateFlags(): void;
  26920. /**
  26921. * Gets the object extend size
  26922. * @returns the object extend size
  26923. */
  26924. getObjectExtendSize(): Vector3;
  26925. /**
  26926. * Gets the object center
  26927. * @returns The object center
  26928. */
  26929. getObjectCenter(): Vector3;
  26930. /**
  26931. * Get a specific parameter from the options parameters
  26932. * @param paramName The object parameter name
  26933. * @returns The object parameter
  26934. */
  26935. getParam(paramName: string): any;
  26936. /**
  26937. * Sets a specific parameter in the options given to the physics plugin
  26938. * @param paramName The parameter name
  26939. * @param value The value of the parameter
  26940. */
  26941. setParam(paramName: string, value: number): void;
  26942. /**
  26943. * Specifically change the body's mass option. Won't recreate the physics body object
  26944. * @param mass The mass of the physics imposter
  26945. */
  26946. setMass(mass: number): void;
  26947. /**
  26948. * Gets the linear velocity
  26949. * @returns linear velocity or null
  26950. */
  26951. getLinearVelocity(): Nullable<Vector3>;
  26952. /**
  26953. * Sets the linear velocity
  26954. * @param velocity linear velocity or null
  26955. */
  26956. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26957. /**
  26958. * Gets the angular velocity
  26959. * @returns angular velocity or null
  26960. */
  26961. getAngularVelocity(): Nullable<Vector3>;
  26962. /**
  26963. * Sets the angular velocity
  26964. * @param velocity The velocity or null
  26965. */
  26966. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26967. /**
  26968. * Execute a function with the physics plugin native code
  26969. * Provide a function the will have two variables - the world object and the physics body object
  26970. * @param func The function to execute with the physics plugin native code
  26971. */
  26972. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26973. /**
  26974. * Register a function that will be executed before the physics world is stepping forward
  26975. * @param func The function to execute before the physics world is stepped forward
  26976. */
  26977. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26978. /**
  26979. * Unregister a function that will be executed before the physics world is stepping forward
  26980. * @param func The function to execute before the physics world is stepped forward
  26981. */
  26982. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26983. /**
  26984. * Register a function that will be executed after the physics step
  26985. * @param func The function to execute after physics step
  26986. */
  26987. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26988. /**
  26989. * Unregisters a function that will be executed after the physics step
  26990. * @param func The function to execute after physics step
  26991. */
  26992. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26993. /**
  26994. * register a function that will be executed when this impostor collides against a different body
  26995. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26996. * @param func Callback that is executed on collision
  26997. */
  26998. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26999. /**
  27000. * Unregisters the physics imposter on contact
  27001. * @param collideAgainst The physics object to collide against
  27002. * @param func Callback to execute on collision
  27003. */
  27004. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27005. private _tmpQuat;
  27006. private _tmpQuat2;
  27007. /**
  27008. * Get the parent rotation
  27009. * @returns The parent rotation
  27010. */
  27011. getParentsRotation(): Quaternion;
  27012. /**
  27013. * this function is executed by the physics engine.
  27014. */
  27015. beforeStep: () => void;
  27016. /**
  27017. * this function is executed by the physics engine
  27018. */
  27019. afterStep: () => void;
  27020. /**
  27021. * Legacy collision detection event support
  27022. */
  27023. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27024. /**
  27025. * event and body object due to cannon's event-based architecture.
  27026. */
  27027. onCollide: (e: {
  27028. body: any;
  27029. }) => void;
  27030. /**
  27031. * Apply a force
  27032. * @param force The force to apply
  27033. * @param contactPoint The contact point for the force
  27034. * @returns The physics imposter
  27035. */
  27036. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27037. /**
  27038. * Apply an impulse
  27039. * @param force The impulse force
  27040. * @param contactPoint The contact point for the impulse force
  27041. * @returns The physics imposter
  27042. */
  27043. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27044. /**
  27045. * A help function to create a joint
  27046. * @param otherImpostor A physics imposter used to create a joint
  27047. * @param jointType The type of joint
  27048. * @param jointData The data for the joint
  27049. * @returns The physics imposter
  27050. */
  27051. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27052. /**
  27053. * Add a joint to this impostor with a different impostor
  27054. * @param otherImpostor A physics imposter used to add a joint
  27055. * @param joint The joint to add
  27056. * @returns The physics imposter
  27057. */
  27058. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27059. /**
  27060. * Add an anchor to a cloth impostor
  27061. * @param otherImpostor rigid impostor to anchor to
  27062. * @param width ratio across width from 0 to 1
  27063. * @param height ratio up height from 0 to 1
  27064. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27065. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27066. * @returns impostor the soft imposter
  27067. */
  27068. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27069. /**
  27070. * Add a hook to a rope impostor
  27071. * @param otherImpostor rigid impostor to anchor to
  27072. * @param length ratio across rope from 0 to 1
  27073. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27074. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27075. * @returns impostor the rope imposter
  27076. */
  27077. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27078. /**
  27079. * Will keep this body still, in a sleep mode.
  27080. * @returns the physics imposter
  27081. */
  27082. sleep(): PhysicsImpostor;
  27083. /**
  27084. * Wake the body up.
  27085. * @returns The physics imposter
  27086. */
  27087. wakeUp(): PhysicsImpostor;
  27088. /**
  27089. * Clones the physics imposter
  27090. * @param newObject The physics imposter clones to this physics-enabled object
  27091. * @returns A nullable physics imposter
  27092. */
  27093. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27094. /**
  27095. * Disposes the physics imposter
  27096. */
  27097. dispose(): void;
  27098. /**
  27099. * Sets the delta position
  27100. * @param position The delta position amount
  27101. */
  27102. setDeltaPosition(position: Vector3): void;
  27103. /**
  27104. * Sets the delta rotation
  27105. * @param rotation The delta rotation amount
  27106. */
  27107. setDeltaRotation(rotation: Quaternion): void;
  27108. /**
  27109. * Gets the box size of the physics imposter and stores the result in the input parameter
  27110. * @param result Stores the box size
  27111. * @returns The physics imposter
  27112. */
  27113. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27114. /**
  27115. * Gets the radius of the physics imposter
  27116. * @returns Radius of the physics imposter
  27117. */
  27118. getRadius(): number;
  27119. /**
  27120. * Sync a bone with this impostor
  27121. * @param bone The bone to sync to the impostor.
  27122. * @param boneMesh The mesh that the bone is influencing.
  27123. * @param jointPivot The pivot of the joint / bone in local space.
  27124. * @param distToJoint Optional distance from the impostor to the joint.
  27125. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27126. */
  27127. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27128. /**
  27129. * Sync impostor to a bone
  27130. * @param bone The bone that the impostor will be synced to.
  27131. * @param boneMesh The mesh that the bone is influencing.
  27132. * @param jointPivot The pivot of the joint / bone in local space.
  27133. * @param distToJoint Optional distance from the impostor to the joint.
  27134. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27135. * @param boneAxis Optional vector3 axis the bone is aligned with
  27136. */
  27137. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27138. /**
  27139. * No-Imposter type
  27140. */
  27141. static NoImpostor: number;
  27142. /**
  27143. * Sphere-Imposter type
  27144. */
  27145. static SphereImpostor: number;
  27146. /**
  27147. * Box-Imposter type
  27148. */
  27149. static BoxImpostor: number;
  27150. /**
  27151. * Plane-Imposter type
  27152. */
  27153. static PlaneImpostor: number;
  27154. /**
  27155. * Mesh-imposter type
  27156. */
  27157. static MeshImpostor: number;
  27158. /**
  27159. * Capsule-Impostor type (Ammo.js plugin only)
  27160. */
  27161. static CapsuleImpostor: number;
  27162. /**
  27163. * Cylinder-Imposter type
  27164. */
  27165. static CylinderImpostor: number;
  27166. /**
  27167. * Particle-Imposter type
  27168. */
  27169. static ParticleImpostor: number;
  27170. /**
  27171. * Heightmap-Imposter type
  27172. */
  27173. static HeightmapImpostor: number;
  27174. /**
  27175. * ConvexHull-Impostor type (Ammo.js plugin only)
  27176. */
  27177. static ConvexHullImpostor: number;
  27178. /**
  27179. * Custom-Imposter type (Ammo.js plugin only)
  27180. */
  27181. static CustomImpostor: number;
  27182. /**
  27183. * Rope-Imposter type
  27184. */
  27185. static RopeImpostor: number;
  27186. /**
  27187. * Cloth-Imposter type
  27188. */
  27189. static ClothImpostor: number;
  27190. /**
  27191. * Softbody-Imposter type
  27192. */
  27193. static SoftbodyImpostor: number;
  27194. }
  27195. }
  27196. declare module BABYLON {
  27197. /**
  27198. * @hidden
  27199. **/
  27200. export class _CreationDataStorage {
  27201. closePath?: boolean;
  27202. closeArray?: boolean;
  27203. idx: number[];
  27204. dashSize: number;
  27205. gapSize: number;
  27206. path3D: Path3D;
  27207. pathArray: Vector3[][];
  27208. arc: number;
  27209. radius: number;
  27210. cap: number;
  27211. tessellation: number;
  27212. }
  27213. /**
  27214. * @hidden
  27215. **/
  27216. class _InstanceDataStorage {
  27217. visibleInstances: any;
  27218. batchCache: _InstancesBatch;
  27219. instancesBufferSize: number;
  27220. instancesBuffer: Nullable<Buffer>;
  27221. instancesData: Float32Array;
  27222. overridenInstanceCount: number;
  27223. isFrozen: boolean;
  27224. previousBatch: Nullable<_InstancesBatch>;
  27225. hardwareInstancedRendering: boolean;
  27226. sideOrientation: number;
  27227. manualUpdate: boolean;
  27228. }
  27229. /**
  27230. * @hidden
  27231. **/
  27232. export class _InstancesBatch {
  27233. mustReturn: boolean;
  27234. visibleInstances: Nullable<InstancedMesh[]>[];
  27235. renderSelf: boolean[];
  27236. hardwareInstancedRendering: boolean[];
  27237. }
  27238. /**
  27239. * @hidden
  27240. **/
  27241. class _ThinInstanceDataStorage {
  27242. instancesCount: number;
  27243. matrixBuffer: Nullable<Buffer>;
  27244. matrixBufferSize: number;
  27245. matrixData: Nullable<Float32Array>;
  27246. boundingVectors: Array<Vector3>;
  27247. }
  27248. /**
  27249. * Class used to represent renderable models
  27250. */
  27251. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27252. /**
  27253. * Mesh side orientation : usually the external or front surface
  27254. */
  27255. static readonly FRONTSIDE: number;
  27256. /**
  27257. * Mesh side orientation : usually the internal or back surface
  27258. */
  27259. static readonly BACKSIDE: number;
  27260. /**
  27261. * Mesh side orientation : both internal and external or front and back surfaces
  27262. */
  27263. static readonly DOUBLESIDE: number;
  27264. /**
  27265. * Mesh side orientation : by default, `FRONTSIDE`
  27266. */
  27267. static readonly DEFAULTSIDE: number;
  27268. /**
  27269. * Mesh cap setting : no cap
  27270. */
  27271. static readonly NO_CAP: number;
  27272. /**
  27273. * Mesh cap setting : one cap at the beginning of the mesh
  27274. */
  27275. static readonly CAP_START: number;
  27276. /**
  27277. * Mesh cap setting : one cap at the end of the mesh
  27278. */
  27279. static readonly CAP_END: number;
  27280. /**
  27281. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27282. */
  27283. static readonly CAP_ALL: number;
  27284. /**
  27285. * Mesh pattern setting : no flip or rotate
  27286. */
  27287. static readonly NO_FLIP: number;
  27288. /**
  27289. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27290. */
  27291. static readonly FLIP_TILE: number;
  27292. /**
  27293. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27294. */
  27295. static readonly ROTATE_TILE: number;
  27296. /**
  27297. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27298. */
  27299. static readonly FLIP_ROW: number;
  27300. /**
  27301. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27302. */
  27303. static readonly ROTATE_ROW: number;
  27304. /**
  27305. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27306. */
  27307. static readonly FLIP_N_ROTATE_TILE: number;
  27308. /**
  27309. * Mesh pattern setting : rotate pattern and rotate
  27310. */
  27311. static readonly FLIP_N_ROTATE_ROW: number;
  27312. /**
  27313. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27314. */
  27315. static readonly CENTER: number;
  27316. /**
  27317. * Mesh tile positioning : part tiles on left
  27318. */
  27319. static readonly LEFT: number;
  27320. /**
  27321. * Mesh tile positioning : part tiles on right
  27322. */
  27323. static readonly RIGHT: number;
  27324. /**
  27325. * Mesh tile positioning : part tiles on top
  27326. */
  27327. static readonly TOP: number;
  27328. /**
  27329. * Mesh tile positioning : part tiles on bottom
  27330. */
  27331. static readonly BOTTOM: number;
  27332. /**
  27333. * Gets the default side orientation.
  27334. * @param orientation the orientation to value to attempt to get
  27335. * @returns the default orientation
  27336. * @hidden
  27337. */
  27338. static _GetDefaultSideOrientation(orientation?: number): number;
  27339. private _internalMeshDataInfo;
  27340. /**
  27341. * An event triggered before rendering the mesh
  27342. */
  27343. get onBeforeRenderObservable(): Observable<Mesh>;
  27344. /**
  27345. * An event triggered before binding the mesh
  27346. */
  27347. get onBeforeBindObservable(): Observable<Mesh>;
  27348. /**
  27349. * An event triggered after rendering the mesh
  27350. */
  27351. get onAfterRenderObservable(): Observable<Mesh>;
  27352. /**
  27353. * An event triggered before drawing the mesh
  27354. */
  27355. get onBeforeDrawObservable(): Observable<Mesh>;
  27356. private _onBeforeDrawObserver;
  27357. /**
  27358. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27359. */
  27360. set onBeforeDraw(callback: () => void);
  27361. get hasInstances(): boolean;
  27362. get hasThinInstances(): boolean;
  27363. /**
  27364. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27365. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27366. */
  27367. delayLoadState: number;
  27368. /**
  27369. * Gets the list of instances created from this mesh
  27370. * it is not supposed to be modified manually.
  27371. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27372. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27373. */
  27374. instances: InstancedMesh[];
  27375. /**
  27376. * Gets the file containing delay loading data for this mesh
  27377. */
  27378. delayLoadingFile: string;
  27379. /** @hidden */
  27380. _binaryInfo: any;
  27381. /**
  27382. * User defined function used to change how LOD level selection is done
  27383. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27384. */
  27385. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27386. /**
  27387. * Gets or sets the morph target manager
  27388. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27389. */
  27390. get morphTargetManager(): Nullable<MorphTargetManager>;
  27391. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27392. /** @hidden */
  27393. _creationDataStorage: Nullable<_CreationDataStorage>;
  27394. /** @hidden */
  27395. _geometry: Nullable<Geometry>;
  27396. /** @hidden */
  27397. _delayInfo: Array<string>;
  27398. /** @hidden */
  27399. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27400. /** @hidden */
  27401. _instanceDataStorage: _InstanceDataStorage;
  27402. /** @hidden */
  27403. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27404. private _effectiveMaterial;
  27405. /** @hidden */
  27406. _shouldGenerateFlatShading: boolean;
  27407. /** @hidden */
  27408. _originalBuilderSideOrientation: number;
  27409. /**
  27410. * Use this property to change the original side orientation defined at construction time
  27411. */
  27412. overrideMaterialSideOrientation: Nullable<number>;
  27413. /**
  27414. * Gets the source mesh (the one used to clone this one from)
  27415. */
  27416. get source(): Nullable<Mesh>;
  27417. /**
  27418. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27419. */
  27420. get isUnIndexed(): boolean;
  27421. set isUnIndexed(value: boolean);
  27422. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27423. get worldMatrixInstancedBuffer(): Float32Array;
  27424. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27425. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27426. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27427. /**
  27428. * @constructor
  27429. * @param name The value used by scene.getMeshByName() to do a lookup.
  27430. * @param scene The scene to add this mesh to.
  27431. * @param parent The parent of this mesh, if it has one
  27432. * @param source An optional Mesh from which geometry is shared, cloned.
  27433. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27434. * When false, achieved by calling a clone(), also passing False.
  27435. * This will make creation of children, recursive.
  27436. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27437. */
  27438. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27439. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27440. doNotInstantiate: boolean;
  27441. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27442. /**
  27443. * Gets the class name
  27444. * @returns the string "Mesh".
  27445. */
  27446. getClassName(): string;
  27447. /** @hidden */
  27448. get _isMesh(): boolean;
  27449. /**
  27450. * Returns a description of this mesh
  27451. * @param fullDetails define if full details about this mesh must be used
  27452. * @returns a descriptive string representing this mesh
  27453. */
  27454. toString(fullDetails?: boolean): string;
  27455. /** @hidden */
  27456. _unBindEffect(): void;
  27457. /**
  27458. * Gets a boolean indicating if this mesh has LOD
  27459. */
  27460. get hasLODLevels(): boolean;
  27461. /**
  27462. * Gets the list of MeshLODLevel associated with the current mesh
  27463. * @returns an array of MeshLODLevel
  27464. */
  27465. getLODLevels(): MeshLODLevel[];
  27466. private _sortLODLevels;
  27467. /**
  27468. * Add a mesh as LOD level triggered at the given distance.
  27469. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27470. * @param distance The distance from the center of the object to show this level
  27471. * @param mesh The mesh to be added as LOD level (can be null)
  27472. * @return This mesh (for chaining)
  27473. */
  27474. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27475. /**
  27476. * Returns the LOD level mesh at the passed distance or null if not found.
  27477. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27478. * @param distance The distance from the center of the object to show this level
  27479. * @returns a Mesh or `null`
  27480. */
  27481. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27482. /**
  27483. * Remove a mesh from the LOD array
  27484. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27485. * @param mesh defines the mesh to be removed
  27486. * @return This mesh (for chaining)
  27487. */
  27488. removeLODLevel(mesh: Mesh): Mesh;
  27489. /**
  27490. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27491. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27492. * @param camera defines the camera to use to compute distance
  27493. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27494. * @return This mesh (for chaining)
  27495. */
  27496. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27497. /**
  27498. * Gets the mesh internal Geometry object
  27499. */
  27500. get geometry(): Nullable<Geometry>;
  27501. /**
  27502. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27503. * @returns the total number of vertices
  27504. */
  27505. getTotalVertices(): number;
  27506. /**
  27507. * Returns the content of an associated vertex buffer
  27508. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27509. * - VertexBuffer.PositionKind
  27510. * - VertexBuffer.UVKind
  27511. * - VertexBuffer.UV2Kind
  27512. * - VertexBuffer.UV3Kind
  27513. * - VertexBuffer.UV4Kind
  27514. * - VertexBuffer.UV5Kind
  27515. * - VertexBuffer.UV6Kind
  27516. * - VertexBuffer.ColorKind
  27517. * - VertexBuffer.MatricesIndicesKind
  27518. * - VertexBuffer.MatricesIndicesExtraKind
  27519. * - VertexBuffer.MatricesWeightsKind
  27520. * - VertexBuffer.MatricesWeightsExtraKind
  27521. * @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
  27522. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27523. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27524. */
  27525. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27526. /**
  27527. * Returns the mesh VertexBuffer object from the requested `kind`
  27528. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27529. * - VertexBuffer.PositionKind
  27530. * - VertexBuffer.NormalKind
  27531. * - VertexBuffer.UVKind
  27532. * - VertexBuffer.UV2Kind
  27533. * - VertexBuffer.UV3Kind
  27534. * - VertexBuffer.UV4Kind
  27535. * - VertexBuffer.UV5Kind
  27536. * - VertexBuffer.UV6Kind
  27537. * - VertexBuffer.ColorKind
  27538. * - VertexBuffer.MatricesIndicesKind
  27539. * - VertexBuffer.MatricesIndicesExtraKind
  27540. * - VertexBuffer.MatricesWeightsKind
  27541. * - VertexBuffer.MatricesWeightsExtraKind
  27542. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27543. */
  27544. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27545. /**
  27546. * Tests if a specific vertex buffer is associated with this mesh
  27547. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27548. * - VertexBuffer.PositionKind
  27549. * - VertexBuffer.NormalKind
  27550. * - VertexBuffer.UVKind
  27551. * - VertexBuffer.UV2Kind
  27552. * - VertexBuffer.UV3Kind
  27553. * - VertexBuffer.UV4Kind
  27554. * - VertexBuffer.UV5Kind
  27555. * - VertexBuffer.UV6Kind
  27556. * - VertexBuffer.ColorKind
  27557. * - VertexBuffer.MatricesIndicesKind
  27558. * - VertexBuffer.MatricesIndicesExtraKind
  27559. * - VertexBuffer.MatricesWeightsKind
  27560. * - VertexBuffer.MatricesWeightsExtraKind
  27561. * @returns a boolean
  27562. */
  27563. isVerticesDataPresent(kind: string): boolean;
  27564. /**
  27565. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27566. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27567. * - VertexBuffer.PositionKind
  27568. * - VertexBuffer.UVKind
  27569. * - VertexBuffer.UV2Kind
  27570. * - VertexBuffer.UV3Kind
  27571. * - VertexBuffer.UV4Kind
  27572. * - VertexBuffer.UV5Kind
  27573. * - VertexBuffer.UV6Kind
  27574. * - VertexBuffer.ColorKind
  27575. * - VertexBuffer.MatricesIndicesKind
  27576. * - VertexBuffer.MatricesIndicesExtraKind
  27577. * - VertexBuffer.MatricesWeightsKind
  27578. * - VertexBuffer.MatricesWeightsExtraKind
  27579. * @returns a boolean
  27580. */
  27581. isVertexBufferUpdatable(kind: string): boolean;
  27582. /**
  27583. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27584. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27585. * - VertexBuffer.PositionKind
  27586. * - VertexBuffer.NormalKind
  27587. * - VertexBuffer.UVKind
  27588. * - VertexBuffer.UV2Kind
  27589. * - VertexBuffer.UV3Kind
  27590. * - VertexBuffer.UV4Kind
  27591. * - VertexBuffer.UV5Kind
  27592. * - VertexBuffer.UV6Kind
  27593. * - VertexBuffer.ColorKind
  27594. * - VertexBuffer.MatricesIndicesKind
  27595. * - VertexBuffer.MatricesIndicesExtraKind
  27596. * - VertexBuffer.MatricesWeightsKind
  27597. * - VertexBuffer.MatricesWeightsExtraKind
  27598. * @returns an array of strings
  27599. */
  27600. getVerticesDataKinds(): string[];
  27601. /**
  27602. * Returns a positive integer : the total number of indices in this mesh geometry.
  27603. * @returns the numner of indices or zero if the mesh has no geometry.
  27604. */
  27605. getTotalIndices(): number;
  27606. /**
  27607. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27608. * @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.
  27609. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27610. * @returns the indices array or an empty array if the mesh has no geometry
  27611. */
  27612. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27613. get isBlocked(): boolean;
  27614. /**
  27615. * Determine if the current mesh is ready to be rendered
  27616. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27617. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27618. * @returns true if all associated assets are ready (material, textures, shaders)
  27619. */
  27620. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27621. /**
  27622. * 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.
  27623. */
  27624. get areNormalsFrozen(): boolean;
  27625. /**
  27626. * 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.
  27627. * @returns the current mesh
  27628. */
  27629. freezeNormals(): Mesh;
  27630. /**
  27631. * 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
  27632. * @returns the current mesh
  27633. */
  27634. unfreezeNormals(): Mesh;
  27635. /**
  27636. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27637. */
  27638. set overridenInstanceCount(count: number);
  27639. /** @hidden */
  27640. _preActivate(): Mesh;
  27641. /** @hidden */
  27642. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27643. /** @hidden */
  27644. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27645. protected _afterComputeWorldMatrix(): void;
  27646. /** @hidden */
  27647. _postActivate(): void;
  27648. /**
  27649. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27650. * This means the mesh underlying bounding box and sphere are recomputed.
  27651. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27652. * @returns the current mesh
  27653. */
  27654. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27655. /** @hidden */
  27656. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27657. /**
  27658. * This function will subdivide the mesh into multiple submeshes
  27659. * @param count defines the expected number of submeshes
  27660. */
  27661. subdivide(count: number): void;
  27662. /**
  27663. * Copy a FloatArray into a specific associated vertex buffer
  27664. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27665. * - VertexBuffer.PositionKind
  27666. * - VertexBuffer.UVKind
  27667. * - VertexBuffer.UV2Kind
  27668. * - VertexBuffer.UV3Kind
  27669. * - VertexBuffer.UV4Kind
  27670. * - VertexBuffer.UV5Kind
  27671. * - VertexBuffer.UV6Kind
  27672. * - VertexBuffer.ColorKind
  27673. * - VertexBuffer.MatricesIndicesKind
  27674. * - VertexBuffer.MatricesIndicesExtraKind
  27675. * - VertexBuffer.MatricesWeightsKind
  27676. * - VertexBuffer.MatricesWeightsExtraKind
  27677. * @param data defines the data source
  27678. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27679. * @param stride defines the data stride size (can be null)
  27680. * @returns the current mesh
  27681. */
  27682. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27683. /**
  27684. * Delete a vertex buffer associated with this mesh
  27685. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27686. * - VertexBuffer.PositionKind
  27687. * - VertexBuffer.UVKind
  27688. * - VertexBuffer.UV2Kind
  27689. * - VertexBuffer.UV3Kind
  27690. * - VertexBuffer.UV4Kind
  27691. * - VertexBuffer.UV5Kind
  27692. * - VertexBuffer.UV6Kind
  27693. * - VertexBuffer.ColorKind
  27694. * - VertexBuffer.MatricesIndicesKind
  27695. * - VertexBuffer.MatricesIndicesExtraKind
  27696. * - VertexBuffer.MatricesWeightsKind
  27697. * - VertexBuffer.MatricesWeightsExtraKind
  27698. */
  27699. removeVerticesData(kind: string): void;
  27700. /**
  27701. * Flags an associated vertex buffer as updatable
  27702. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27703. * - VertexBuffer.PositionKind
  27704. * - VertexBuffer.UVKind
  27705. * - VertexBuffer.UV2Kind
  27706. * - VertexBuffer.UV3Kind
  27707. * - VertexBuffer.UV4Kind
  27708. * - VertexBuffer.UV5Kind
  27709. * - VertexBuffer.UV6Kind
  27710. * - VertexBuffer.ColorKind
  27711. * - VertexBuffer.MatricesIndicesKind
  27712. * - VertexBuffer.MatricesIndicesExtraKind
  27713. * - VertexBuffer.MatricesWeightsKind
  27714. * - VertexBuffer.MatricesWeightsExtraKind
  27715. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27716. */
  27717. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27718. /**
  27719. * Sets the mesh global Vertex Buffer
  27720. * @param buffer defines the buffer to use
  27721. * @returns the current mesh
  27722. */
  27723. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27724. /**
  27725. * Update a specific associated vertex buffer
  27726. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27727. * - VertexBuffer.PositionKind
  27728. * - VertexBuffer.UVKind
  27729. * - VertexBuffer.UV2Kind
  27730. * - VertexBuffer.UV3Kind
  27731. * - VertexBuffer.UV4Kind
  27732. * - VertexBuffer.UV5Kind
  27733. * - VertexBuffer.UV6Kind
  27734. * - VertexBuffer.ColorKind
  27735. * - VertexBuffer.MatricesIndicesKind
  27736. * - VertexBuffer.MatricesIndicesExtraKind
  27737. * - VertexBuffer.MatricesWeightsKind
  27738. * - VertexBuffer.MatricesWeightsExtraKind
  27739. * @param data defines the data source
  27740. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27741. * @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)
  27742. * @returns the current mesh
  27743. */
  27744. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27745. /**
  27746. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27747. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27748. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27749. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27750. * @returns the current mesh
  27751. */
  27752. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27753. /**
  27754. * Creates a un-shared specific occurence of the geometry for the mesh.
  27755. * @returns the current mesh
  27756. */
  27757. makeGeometryUnique(): Mesh;
  27758. /**
  27759. * Set the index buffer of this mesh
  27760. * @param indices defines the source data
  27761. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27762. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27763. * @returns the current mesh
  27764. */
  27765. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27766. /**
  27767. * Update the current index buffer
  27768. * @param indices defines the source data
  27769. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27770. * @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)
  27771. * @returns the current mesh
  27772. */
  27773. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27774. /**
  27775. * Invert the geometry to move from a right handed system to a left handed one.
  27776. * @returns the current mesh
  27777. */
  27778. toLeftHanded(): Mesh;
  27779. /** @hidden */
  27780. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27781. /** @hidden */
  27782. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27783. /**
  27784. * Registers for this mesh a javascript function called just before the rendering process
  27785. * @param func defines the function to call before rendering this mesh
  27786. * @returns the current mesh
  27787. */
  27788. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27789. /**
  27790. * Disposes a previously registered javascript function called before the rendering
  27791. * @param func defines the function to remove
  27792. * @returns the current mesh
  27793. */
  27794. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27795. /**
  27796. * Registers for this mesh a javascript function called just after the rendering is complete
  27797. * @param func defines the function to call after rendering this mesh
  27798. * @returns the current mesh
  27799. */
  27800. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27801. /**
  27802. * Disposes a previously registered javascript function called after the rendering.
  27803. * @param func defines the function to remove
  27804. * @returns the current mesh
  27805. */
  27806. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27807. /** @hidden */
  27808. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27809. /** @hidden */
  27810. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27811. /** @hidden */
  27812. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27813. /** @hidden */
  27814. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27815. /** @hidden */
  27816. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27817. /** @hidden */
  27818. _rebuild(): void;
  27819. /** @hidden */
  27820. _freeze(): void;
  27821. /** @hidden */
  27822. _unFreeze(): void;
  27823. /**
  27824. * 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
  27825. * @param subMesh defines the subMesh to render
  27826. * @param enableAlphaMode defines if alpha mode can be changed
  27827. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27828. * @returns the current mesh
  27829. */
  27830. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27831. private _onBeforeDraw;
  27832. /**
  27833. * Renormalize the mesh and patch it up if there are no weights
  27834. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27835. * However in the case of zero weights then we set just a single influence to 1.
  27836. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27837. */
  27838. cleanMatrixWeights(): void;
  27839. private normalizeSkinFourWeights;
  27840. private normalizeSkinWeightsAndExtra;
  27841. /**
  27842. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27843. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27844. * the user know there was an issue with importing the mesh
  27845. * @returns a validation object with skinned, valid and report string
  27846. */
  27847. validateSkinning(): {
  27848. skinned: boolean;
  27849. valid: boolean;
  27850. report: string;
  27851. };
  27852. /** @hidden */
  27853. _checkDelayState(): Mesh;
  27854. private _queueLoad;
  27855. /**
  27856. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27857. * A mesh is in the frustum if its bounding box intersects the frustum
  27858. * @param frustumPlanes defines the frustum to test
  27859. * @returns true if the mesh is in the frustum planes
  27860. */
  27861. isInFrustum(frustumPlanes: Plane[]): boolean;
  27862. /**
  27863. * Sets the mesh material by the material or multiMaterial `id` property
  27864. * @param id is a string identifying the material or the multiMaterial
  27865. * @returns the current mesh
  27866. */
  27867. setMaterialByID(id: string): Mesh;
  27868. /**
  27869. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27870. * @returns an array of IAnimatable
  27871. */
  27872. getAnimatables(): IAnimatable[];
  27873. /**
  27874. * Modifies the mesh geometry according to the passed transformation matrix.
  27875. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27876. * The mesh normals are modified using the same transformation.
  27877. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27878. * @param transform defines the transform matrix to use
  27879. * @see http://doc.babylonjs.com/resources/baking_transformations
  27880. * @returns the current mesh
  27881. */
  27882. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27883. /**
  27884. * Modifies the mesh geometry according to its own current World Matrix.
  27885. * The mesh World Matrix is then reset.
  27886. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27887. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27888. * @see http://doc.babylonjs.com/resources/baking_transformations
  27889. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27890. * @returns the current mesh
  27891. */
  27892. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27893. /** @hidden */
  27894. get _positions(): Nullable<Vector3[]>;
  27895. /** @hidden */
  27896. _resetPointsArrayCache(): Mesh;
  27897. /** @hidden */
  27898. _generatePointsArray(): boolean;
  27899. /**
  27900. * Returns a new Mesh object generated from the current mesh properties.
  27901. * This method must not get confused with createInstance()
  27902. * @param name is a string, the name given to the new mesh
  27903. * @param newParent can be any Node object (default `null`)
  27904. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27905. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27906. * @returns a new mesh
  27907. */
  27908. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27909. /**
  27910. * Releases resources associated with this mesh.
  27911. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27912. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27913. */
  27914. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27915. /** @hidden */
  27916. _disposeInstanceSpecificData(): void;
  27917. /** @hidden */
  27918. _disposeThinInstanceSpecificData(): void;
  27919. /**
  27920. * Modifies the mesh geometry according to a displacement map.
  27921. * 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.
  27922. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27923. * @param url is a string, the URL from the image file is to be downloaded.
  27924. * @param minHeight is the lower limit of the displacement.
  27925. * @param maxHeight is the upper limit of the displacement.
  27926. * @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.
  27927. * @param uvOffset is an optional vector2 used to offset UV.
  27928. * @param uvScale is an optional vector2 used to scale UV.
  27929. * @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.
  27930. * @returns the Mesh.
  27931. */
  27932. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27933. /**
  27934. * Modifies the mesh geometry according to a displacementMap buffer.
  27935. * 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.
  27936. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27937. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27938. * @param heightMapWidth is the width of the buffer image.
  27939. * @param heightMapHeight is the height of the buffer image.
  27940. * @param minHeight is the lower limit of the displacement.
  27941. * @param maxHeight is the upper limit of the displacement.
  27942. * @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.
  27943. * @param uvOffset is an optional vector2 used to offset UV.
  27944. * @param uvScale is an optional vector2 used to scale UV.
  27945. * @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.
  27946. * @returns the Mesh.
  27947. */
  27948. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27949. /**
  27950. * Modify the mesh to get a flat shading rendering.
  27951. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27952. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27953. * @returns current mesh
  27954. */
  27955. convertToFlatShadedMesh(): Mesh;
  27956. /**
  27957. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27958. * In other words, more vertices, no more indices and a single bigger VBO.
  27959. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27960. * @returns current mesh
  27961. */
  27962. convertToUnIndexedMesh(): Mesh;
  27963. /**
  27964. * Inverses facet orientations.
  27965. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27966. * @param flipNormals will also inverts the normals
  27967. * @returns current mesh
  27968. */
  27969. flipFaces(flipNormals?: boolean): Mesh;
  27970. /**
  27971. * Increase the number of facets and hence vertices in a mesh
  27972. * Vertex normals are interpolated from existing vertex normals
  27973. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27974. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27975. */
  27976. increaseVertices(numberPerEdge: number): void;
  27977. /**
  27978. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27979. * This will undo any application of covertToFlatShadedMesh
  27980. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27981. */
  27982. forceSharedVertices(): void;
  27983. /** @hidden */
  27984. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27985. /** @hidden */
  27986. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27987. /**
  27988. * Creates a new InstancedMesh object from the mesh model.
  27989. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27990. * @param name defines the name of the new instance
  27991. * @returns a new InstancedMesh
  27992. */
  27993. createInstance(name: string): InstancedMesh;
  27994. /**
  27995. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27996. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27997. * @returns the current mesh
  27998. */
  27999. synchronizeInstances(): Mesh;
  28000. /**
  28001. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28002. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28003. * This should be used together with the simplification to avoid disappearing triangles.
  28004. * @param successCallback an optional success callback to be called after the optimization finished.
  28005. * @returns the current mesh
  28006. */
  28007. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28008. /**
  28009. * Serialize current mesh
  28010. * @param serializationObject defines the object which will receive the serialization data
  28011. */
  28012. serialize(serializationObject: any): void;
  28013. /** @hidden */
  28014. _syncGeometryWithMorphTargetManager(): void;
  28015. /** @hidden */
  28016. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28017. /**
  28018. * Returns a new Mesh object parsed from the source provided.
  28019. * @param parsedMesh is the source
  28020. * @param scene defines the hosting scene
  28021. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28022. * @returns a new Mesh
  28023. */
  28024. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28025. /**
  28026. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28027. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28028. * @param name defines the name of the mesh to create
  28029. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28030. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28031. * @param closePath creates a seam between the first and the last points of each path of the path array
  28032. * @param offset is taken in account only if the `pathArray` is containing a single path
  28033. * @param scene defines the hosting scene
  28034. * @param updatable defines if the mesh must be flagged as updatable
  28035. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28036. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  28037. * @returns a new Mesh
  28038. */
  28039. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28040. /**
  28041. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28042. * @param name defines the name of the mesh to create
  28043. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28044. * @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
  28045. * @param scene defines the hosting scene
  28046. * @param updatable defines if the mesh must be flagged as updatable
  28047. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28048. * @returns a new Mesh
  28049. */
  28050. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28051. /**
  28052. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28053. * @param name defines the name of the mesh to create
  28054. * @param size sets the size (float) of each box side (default 1)
  28055. * @param scene defines the hosting scene
  28056. * @param updatable defines if the mesh must be flagged as updatable
  28057. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28058. * @returns a new Mesh
  28059. */
  28060. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28061. /**
  28062. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28063. * @param name defines the name of the mesh to create
  28064. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28065. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28066. * @param scene defines the hosting scene
  28067. * @param updatable defines if the mesh must be flagged as updatable
  28068. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28069. * @returns a new Mesh
  28070. */
  28071. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28072. /**
  28073. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28074. * @param name defines the name of the mesh to create
  28075. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28076. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28077. * @param scene defines the hosting scene
  28078. * @returns a new Mesh
  28079. */
  28080. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28081. /**
  28082. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28083. * @param name defines the name of the mesh to create
  28084. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28085. * @param diameterTop set the top cap diameter (floats, default 1)
  28086. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28087. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28088. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28089. * @param scene defines the hosting scene
  28090. * @param updatable defines if the mesh must be flagged as updatable
  28091. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28092. * @returns a new Mesh
  28093. */
  28094. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28095. /**
  28096. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28097. * @param name defines the name of the mesh to create
  28098. * @param diameter sets the diameter size (float) of the torus (default 1)
  28099. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28100. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28101. * @param scene defines the hosting scene
  28102. * @param updatable defines if the mesh must be flagged as updatable
  28103. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28104. * @returns a new Mesh
  28105. */
  28106. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28107. /**
  28108. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28109. * @param name defines the name of the mesh to create
  28110. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28111. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28112. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28113. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28114. * @param p the number of windings on X axis (positive integers, default 2)
  28115. * @param q the number of windings on Y axis (positive integers, default 3)
  28116. * @param scene defines the hosting scene
  28117. * @param updatable defines if the mesh must be flagged as updatable
  28118. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28119. * @returns a new Mesh
  28120. */
  28121. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28122. /**
  28123. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28124. * @param name defines the name of the mesh to create
  28125. * @param points is an array successive Vector3
  28126. * @param scene defines the hosting scene
  28127. * @param updatable defines if the mesh must be flagged as updatable
  28128. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  28129. * @returns a new Mesh
  28130. */
  28131. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28132. /**
  28133. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28134. * @param name defines the name of the mesh to create
  28135. * @param points is an array successive Vector3
  28136. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28137. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28138. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28139. * @param scene defines the hosting scene
  28140. * @param updatable defines if the mesh must be flagged as updatable
  28141. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  28142. * @returns a new Mesh
  28143. */
  28144. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28145. /**
  28146. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28147. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28148. * 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.
  28149. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28150. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28151. * Remember you can only change the shape positions, not their number when updating a polygon.
  28152. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28153. * @param name defines the name of the mesh to create
  28154. * @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
  28155. * @param scene defines the hosting scene
  28156. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28157. * @param updatable defines if the mesh must be flagged as updatable
  28158. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28159. * @param earcutInjection can be used to inject your own earcut reference
  28160. * @returns a new Mesh
  28161. */
  28162. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28163. /**
  28164. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28165. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28166. * @param name defines the name of the mesh to create
  28167. * @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
  28168. * @param depth defines the height of extrusion
  28169. * @param scene defines the hosting scene
  28170. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28171. * @param updatable defines if the mesh must be flagged as updatable
  28172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28173. * @param earcutInjection can be used to inject your own earcut reference
  28174. * @returns a new Mesh
  28175. */
  28176. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28177. /**
  28178. * Creates an extruded shape mesh.
  28179. * 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
  28180. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28181. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28182. * @param name defines the name of the mesh to create
  28183. * @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
  28184. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28185. * @param scale is the value to scale the shape
  28186. * @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
  28187. * @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
  28188. * @param scene defines the hosting scene
  28189. * @param updatable defines if the mesh must be flagged as updatable
  28190. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28191. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  28192. * @returns a new Mesh
  28193. */
  28194. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28195. /**
  28196. * Creates an custom extruded shape mesh.
  28197. * The custom extrusion is a parametric shape.
  28198. * It has no predefined shape. Its final shape will depend on the input parameters.
  28199. * Please consider using the same method from the MeshBuilder class instead
  28200. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28201. * @param name defines the name of the mesh to create
  28202. * @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
  28203. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28204. * @param scaleFunction is a custom Javascript function called on each path point
  28205. * @param rotationFunction is a custom Javascript function called on each path point
  28206. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28207. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28208. * @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
  28209. * @param scene defines the hosting scene
  28210. * @param updatable defines if the mesh must be flagged as updatable
  28211. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28212. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  28213. * @returns a new Mesh
  28214. */
  28215. 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;
  28216. /**
  28217. * Creates lathe mesh.
  28218. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28219. * Please consider using the same method from the MeshBuilder class instead
  28220. * @param name defines the name of the mesh to create
  28221. * @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
  28222. * @param radius is the radius value of the lathe
  28223. * @param tessellation is the side number of the lathe.
  28224. * @param scene defines the hosting scene
  28225. * @param updatable defines if the mesh must be flagged as updatable
  28226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28227. * @returns a new Mesh
  28228. */
  28229. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28230. /**
  28231. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28232. * @param name defines the name of the mesh to create
  28233. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28234. * @param scene defines the hosting scene
  28235. * @param updatable defines if the mesh must be flagged as updatable
  28236. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28237. * @returns a new Mesh
  28238. */
  28239. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28240. /**
  28241. * Creates a ground mesh.
  28242. * Please consider using the same method from the MeshBuilder class instead
  28243. * @param name defines the name of the mesh to create
  28244. * @param width set the width of the ground
  28245. * @param height set the height of the ground
  28246. * @param subdivisions sets the number of subdivisions per side
  28247. * @param scene defines the hosting scene
  28248. * @param updatable defines if the mesh must be flagged as updatable
  28249. * @returns a new Mesh
  28250. */
  28251. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28252. /**
  28253. * Creates a tiled ground mesh.
  28254. * Please consider using the same method from the MeshBuilder class instead
  28255. * @param name defines the name of the mesh to create
  28256. * @param xmin set the ground minimum X coordinate
  28257. * @param zmin set the ground minimum Y coordinate
  28258. * @param xmax set the ground maximum X coordinate
  28259. * @param zmax set the ground maximum Z coordinate
  28260. * @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
  28261. * @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
  28262. * @param scene defines the hosting scene
  28263. * @param updatable defines if the mesh must be flagged as updatable
  28264. * @returns a new Mesh
  28265. */
  28266. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28267. w: number;
  28268. h: number;
  28269. }, precision: {
  28270. w: number;
  28271. h: number;
  28272. }, scene: Scene, updatable?: boolean): Mesh;
  28273. /**
  28274. * Creates a ground mesh from a height map.
  28275. * Please consider using the same method from the MeshBuilder class instead
  28276. * @see http://doc.babylonjs.com/babylon101/height_map
  28277. * @param name defines the name of the mesh to create
  28278. * @param url sets the URL of the height map image resource
  28279. * @param width set the ground width size
  28280. * @param height set the ground height size
  28281. * @param subdivisions sets the number of subdivision per side
  28282. * @param minHeight is the minimum altitude on the ground
  28283. * @param maxHeight is the maximum altitude on the ground
  28284. * @param scene defines the hosting scene
  28285. * @param updatable defines if the mesh must be flagged as updatable
  28286. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28287. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28288. * @returns a new Mesh
  28289. */
  28290. 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;
  28291. /**
  28292. * Creates a tube mesh.
  28293. * The tube is a parametric shape.
  28294. * It has no predefined shape. Its final shape will depend on the input parameters.
  28295. * Please consider using the same method from the MeshBuilder class instead
  28296. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28297. * @param name defines the name of the mesh to create
  28298. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28299. * @param radius sets the tube radius size
  28300. * @param tessellation is the number of sides on the tubular surface
  28301. * @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
  28302. * @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
  28303. * @param scene defines the hosting scene
  28304. * @param updatable defines if the mesh must be flagged as updatable
  28305. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28306. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  28307. * @returns a new Mesh
  28308. */
  28309. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28310. (i: number, distance: number): number;
  28311. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28312. /**
  28313. * Creates a polyhedron mesh.
  28314. * Please consider using the same method from the MeshBuilder class instead.
  28315. * * 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
  28316. * * The parameter `size` (positive float, default 1) sets the polygon size
  28317. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28318. * * 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`
  28319. * * 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
  28320. * * 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)`)
  28321. * * 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
  28322. * * 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
  28323. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28324. * * 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 : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28326. * @param name defines the name of the mesh to create
  28327. * @param options defines the options used to create the mesh
  28328. * @param scene defines the hosting scene
  28329. * @returns a new Mesh
  28330. */
  28331. static CreatePolyhedron(name: string, options: {
  28332. type?: number;
  28333. size?: number;
  28334. sizeX?: number;
  28335. sizeY?: number;
  28336. sizeZ?: number;
  28337. custom?: any;
  28338. faceUV?: Vector4[];
  28339. faceColors?: Color4[];
  28340. updatable?: boolean;
  28341. sideOrientation?: number;
  28342. }, scene: Scene): Mesh;
  28343. /**
  28344. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28345. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28346. * * 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`)
  28347. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28348. * * 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
  28349. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28350. * * 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 : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  28351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28352. * @param name defines the name of the mesh
  28353. * @param options defines the options used to create the mesh
  28354. * @param scene defines the hosting scene
  28355. * @returns a new Mesh
  28356. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28357. */
  28358. static CreateIcoSphere(name: string, options: {
  28359. radius?: number;
  28360. flat?: boolean;
  28361. subdivisions?: number;
  28362. sideOrientation?: number;
  28363. updatable?: boolean;
  28364. }, scene: Scene): Mesh;
  28365. /**
  28366. * Creates a decal mesh.
  28367. * Please consider using the same method from the MeshBuilder class instead.
  28368. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28369. * @param name defines the name of the mesh
  28370. * @param sourceMesh defines the mesh receiving the decal
  28371. * @param position sets the position of the decal in world coordinates
  28372. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28373. * @param size sets the decal scaling
  28374. * @param angle sets the angle to rotate the decal
  28375. * @returns a new Mesh
  28376. */
  28377. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28378. /**
  28379. * Prepare internal position array for software CPU skinning
  28380. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28381. */
  28382. setPositionsForCPUSkinning(): Float32Array;
  28383. /**
  28384. * Prepare internal normal array for software CPU skinning
  28385. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28386. */
  28387. setNormalsForCPUSkinning(): Float32Array;
  28388. /**
  28389. * Updates the vertex buffer by applying transformation from the bones
  28390. * @param skeleton defines the skeleton to apply to current mesh
  28391. * @returns the current mesh
  28392. */
  28393. applySkeleton(skeleton: Skeleton): Mesh;
  28394. /**
  28395. * 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
  28396. * @param meshes defines the list of meshes to scan
  28397. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28398. */
  28399. static MinMax(meshes: AbstractMesh[]): {
  28400. min: Vector3;
  28401. max: Vector3;
  28402. };
  28403. /**
  28404. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28405. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28406. * @returns a vector3
  28407. */
  28408. static Center(meshesOrMinMaxVector: {
  28409. min: Vector3;
  28410. max: Vector3;
  28411. } | AbstractMesh[]): Vector3;
  28412. /**
  28413. * Merge the array of meshes into a single mesh for performance reasons.
  28414. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28415. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28416. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28417. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28418. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28419. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28420. * @returns a new mesh
  28421. */
  28422. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28423. /** @hidden */
  28424. addInstance(instance: InstancedMesh): void;
  28425. /** @hidden */
  28426. removeInstance(instance: InstancedMesh): void;
  28427. }
  28428. }
  28429. declare module BABYLON {
  28430. /**
  28431. * This is the base class of all the camera used in the application.
  28432. * @see http://doc.babylonjs.com/features/cameras
  28433. */
  28434. export class Camera extends Node {
  28435. /** @hidden */
  28436. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28437. /**
  28438. * This is the default projection mode used by the cameras.
  28439. * It helps recreating a feeling of perspective and better appreciate depth.
  28440. * This is the best way to simulate real life cameras.
  28441. */
  28442. static readonly PERSPECTIVE_CAMERA: number;
  28443. /**
  28444. * This helps creating camera with an orthographic mode.
  28445. * 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.
  28446. */
  28447. static readonly ORTHOGRAPHIC_CAMERA: number;
  28448. /**
  28449. * This is the default FOV mode for perspective cameras.
  28450. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28451. */
  28452. static readonly FOVMODE_VERTICAL_FIXED: number;
  28453. /**
  28454. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28455. */
  28456. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28457. /**
  28458. * This specifies ther is no need for a camera rig.
  28459. * Basically only one eye is rendered corresponding to the camera.
  28460. */
  28461. static readonly RIG_MODE_NONE: number;
  28462. /**
  28463. * Simulates a camera Rig with one blue eye and one red eye.
  28464. * This can be use with 3d blue and red glasses.
  28465. */
  28466. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28467. /**
  28468. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28469. */
  28470. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28471. /**
  28472. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28473. */
  28474. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28475. /**
  28476. * Defines that both eyes of the camera will be rendered over under each other.
  28477. */
  28478. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28479. /**
  28480. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28481. */
  28482. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28483. /**
  28484. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28485. */
  28486. static readonly RIG_MODE_VR: number;
  28487. /**
  28488. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28489. */
  28490. static readonly RIG_MODE_WEBVR: number;
  28491. /**
  28492. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28493. */
  28494. static readonly RIG_MODE_CUSTOM: number;
  28495. /**
  28496. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28497. */
  28498. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28499. /**
  28500. * Define the input manager associated with the camera.
  28501. */
  28502. inputs: CameraInputsManager<Camera>;
  28503. /** @hidden */
  28504. _position: Vector3;
  28505. /**
  28506. * Define the current local position of the camera in the scene
  28507. */
  28508. get position(): Vector3;
  28509. set position(newPosition: Vector3);
  28510. /**
  28511. * The vector the camera should consider as up.
  28512. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28513. */
  28514. upVector: Vector3;
  28515. /**
  28516. * Define the current limit on the left side for an orthographic camera
  28517. * In scene unit
  28518. */
  28519. orthoLeft: Nullable<number>;
  28520. /**
  28521. * Define the current limit on the right side for an orthographic camera
  28522. * In scene unit
  28523. */
  28524. orthoRight: Nullable<number>;
  28525. /**
  28526. * Define the current limit on the bottom side for an orthographic camera
  28527. * In scene unit
  28528. */
  28529. orthoBottom: Nullable<number>;
  28530. /**
  28531. * Define the current limit on the top side for an orthographic camera
  28532. * In scene unit
  28533. */
  28534. orthoTop: Nullable<number>;
  28535. /**
  28536. * Field Of View is set in Radians. (default is 0.8)
  28537. */
  28538. fov: number;
  28539. /**
  28540. * Define the minimum distance the camera can see from.
  28541. * This is important to note that the depth buffer are not infinite and the closer it starts
  28542. * the more your scene might encounter depth fighting issue.
  28543. */
  28544. minZ: number;
  28545. /**
  28546. * Define the maximum distance the camera can see to.
  28547. * This is important to note that the depth buffer are not infinite and the further it end
  28548. * the more your scene might encounter depth fighting issue.
  28549. */
  28550. maxZ: number;
  28551. /**
  28552. * Define the default inertia of the camera.
  28553. * This helps giving a smooth feeling to the camera movement.
  28554. */
  28555. inertia: number;
  28556. /**
  28557. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28558. */
  28559. mode: number;
  28560. /**
  28561. * Define whether the camera is intermediate.
  28562. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28563. */
  28564. isIntermediate: boolean;
  28565. /**
  28566. * Define the viewport of the camera.
  28567. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28568. */
  28569. viewport: Viewport;
  28570. /**
  28571. * Restricts the camera to viewing objects with the same layerMask.
  28572. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28573. */
  28574. layerMask: number;
  28575. /**
  28576. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28577. */
  28578. fovMode: number;
  28579. /**
  28580. * Rig mode of the camera.
  28581. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28582. * This is normally controlled byt the camera themselves as internal use.
  28583. */
  28584. cameraRigMode: number;
  28585. /**
  28586. * Defines the distance between both "eyes" in case of a RIG
  28587. */
  28588. interaxialDistance: number;
  28589. /**
  28590. * Defines if stereoscopic rendering is done side by side or over under.
  28591. */
  28592. isStereoscopicSideBySide: boolean;
  28593. /**
  28594. * 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
  28595. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28596. * else in the scene. (Eg. security camera)
  28597. *
  28598. * 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)
  28599. */
  28600. customRenderTargets: RenderTargetTexture[];
  28601. /**
  28602. * When set, the camera will render to this render target instead of the default canvas
  28603. *
  28604. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28605. */
  28606. outputRenderTarget: Nullable<RenderTargetTexture>;
  28607. /**
  28608. * Observable triggered when the camera view matrix has changed.
  28609. */
  28610. onViewMatrixChangedObservable: Observable<Camera>;
  28611. /**
  28612. * Observable triggered when the camera Projection matrix has changed.
  28613. */
  28614. onProjectionMatrixChangedObservable: Observable<Camera>;
  28615. /**
  28616. * Observable triggered when the inputs have been processed.
  28617. */
  28618. onAfterCheckInputsObservable: Observable<Camera>;
  28619. /**
  28620. * Observable triggered when reset has been called and applied to the camera.
  28621. */
  28622. onRestoreStateObservable: Observable<Camera>;
  28623. /**
  28624. * Is this camera a part of a rig system?
  28625. */
  28626. isRigCamera: boolean;
  28627. /**
  28628. * If isRigCamera set to true this will be set with the parent camera.
  28629. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28630. */
  28631. rigParent?: Camera;
  28632. /** @hidden */
  28633. _cameraRigParams: any;
  28634. /** @hidden */
  28635. _rigCameras: Camera[];
  28636. /** @hidden */
  28637. _rigPostProcess: Nullable<PostProcess>;
  28638. protected _webvrViewMatrix: Matrix;
  28639. /** @hidden */
  28640. _skipRendering: boolean;
  28641. /** @hidden */
  28642. _projectionMatrix: Matrix;
  28643. /** @hidden */
  28644. _postProcesses: Nullable<PostProcess>[];
  28645. /** @hidden */
  28646. _activeMeshes: SmartArray<AbstractMesh>;
  28647. protected _globalPosition: Vector3;
  28648. /** @hidden */
  28649. _computedViewMatrix: Matrix;
  28650. private _doNotComputeProjectionMatrix;
  28651. private _transformMatrix;
  28652. private _frustumPlanes;
  28653. private _refreshFrustumPlanes;
  28654. private _storedFov;
  28655. private _stateStored;
  28656. /**
  28657. * Instantiates a new camera object.
  28658. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28659. * @see http://doc.babylonjs.com/features/cameras
  28660. * @param name Defines the name of the camera in the scene
  28661. * @param position Defines the position of the camera
  28662. * @param scene Defines the scene the camera belongs too
  28663. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28664. */
  28665. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28666. /**
  28667. * Store current camera state (fov, position, etc..)
  28668. * @returns the camera
  28669. */
  28670. storeState(): Camera;
  28671. /**
  28672. * Restores the camera state values if it has been stored. You must call storeState() first
  28673. */
  28674. protected _restoreStateValues(): boolean;
  28675. /**
  28676. * Restored camera state. You must call storeState() first.
  28677. * @returns true if restored and false otherwise
  28678. */
  28679. restoreState(): boolean;
  28680. /**
  28681. * Gets the class name of the camera.
  28682. * @returns the class name
  28683. */
  28684. getClassName(): string;
  28685. /** @hidden */
  28686. readonly _isCamera: boolean;
  28687. /**
  28688. * Gets a string representation of the camera useful for debug purpose.
  28689. * @param fullDetails Defines that a more verboe level of logging is required
  28690. * @returns the string representation
  28691. */
  28692. toString(fullDetails?: boolean): string;
  28693. /**
  28694. * Gets the current world space position of the camera.
  28695. */
  28696. get globalPosition(): Vector3;
  28697. /**
  28698. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28699. * @returns the active meshe list
  28700. */
  28701. getActiveMeshes(): SmartArray<AbstractMesh>;
  28702. /**
  28703. * Check whether a mesh is part of the current active mesh list of the camera
  28704. * @param mesh Defines the mesh to check
  28705. * @returns true if active, false otherwise
  28706. */
  28707. isActiveMesh(mesh: Mesh): boolean;
  28708. /**
  28709. * Is this camera ready to be used/rendered
  28710. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28711. * @return true if the camera is ready
  28712. */
  28713. isReady(completeCheck?: boolean): boolean;
  28714. /** @hidden */
  28715. _initCache(): void;
  28716. /** @hidden */
  28717. _updateCache(ignoreParentClass?: boolean): void;
  28718. /** @hidden */
  28719. _isSynchronized(): boolean;
  28720. /** @hidden */
  28721. _isSynchronizedViewMatrix(): boolean;
  28722. /** @hidden */
  28723. _isSynchronizedProjectionMatrix(): boolean;
  28724. /**
  28725. * Attach the input controls to a specific dom element to get the input from.
  28726. * @param element Defines the element the controls should be listened from
  28727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28728. */
  28729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28730. /**
  28731. * Detach the current controls from the specified dom element.
  28732. * @param element Defines the element to stop listening the inputs from
  28733. */
  28734. detachControl(element: HTMLElement): void;
  28735. /**
  28736. * Update the camera state according to the different inputs gathered during the frame.
  28737. */
  28738. update(): void;
  28739. /** @hidden */
  28740. _checkInputs(): void;
  28741. /** @hidden */
  28742. get rigCameras(): Camera[];
  28743. /**
  28744. * Gets the post process used by the rig cameras
  28745. */
  28746. get rigPostProcess(): Nullable<PostProcess>;
  28747. /**
  28748. * Internal, gets the first post proces.
  28749. * @returns the first post process to be run on this camera.
  28750. */
  28751. _getFirstPostProcess(): Nullable<PostProcess>;
  28752. private _cascadePostProcessesToRigCams;
  28753. /**
  28754. * Attach a post process to the camera.
  28755. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28756. * @param postProcess The post process to attach to the camera
  28757. * @param insertAt The position of the post process in case several of them are in use in the scene
  28758. * @returns the position the post process has been inserted at
  28759. */
  28760. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28761. /**
  28762. * Detach a post process to the camera.
  28763. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28764. * @param postProcess The post process to detach from the camera
  28765. */
  28766. detachPostProcess(postProcess: PostProcess): void;
  28767. /**
  28768. * Gets the current world matrix of the camera
  28769. */
  28770. getWorldMatrix(): Matrix;
  28771. /** @hidden */
  28772. _getViewMatrix(): Matrix;
  28773. /**
  28774. * Gets the current view matrix of the camera.
  28775. * @param force forces the camera to recompute the matrix without looking at the cached state
  28776. * @returns the view matrix
  28777. */
  28778. getViewMatrix(force?: boolean): Matrix;
  28779. /**
  28780. * Freeze the projection matrix.
  28781. * It will prevent the cache check of the camera projection compute and can speed up perf
  28782. * if no parameter of the camera are meant to change
  28783. * @param projection Defines manually a projection if necessary
  28784. */
  28785. freezeProjectionMatrix(projection?: Matrix): void;
  28786. /**
  28787. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28788. */
  28789. unfreezeProjectionMatrix(): void;
  28790. /**
  28791. * Gets the current projection matrix of the camera.
  28792. * @param force forces the camera to recompute the matrix without looking at the cached state
  28793. * @returns the projection matrix
  28794. */
  28795. getProjectionMatrix(force?: boolean): Matrix;
  28796. /**
  28797. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28798. * @returns a Matrix
  28799. */
  28800. getTransformationMatrix(): Matrix;
  28801. private _updateFrustumPlanes;
  28802. /**
  28803. * Checks if a cullable object (mesh...) is in the camera frustum
  28804. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28805. * @param target The object to check
  28806. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28807. * @returns true if the object is in frustum otherwise false
  28808. */
  28809. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28810. /**
  28811. * Checks if a cullable object (mesh...) is in the camera frustum
  28812. * Unlike isInFrustum this cheks the full bounding box
  28813. * @param target The object to check
  28814. * @returns true if the object is in frustum otherwise false
  28815. */
  28816. isCompletelyInFrustum(target: ICullable): boolean;
  28817. /**
  28818. * Gets a ray in the forward direction from the camera.
  28819. * @param length Defines the length of the ray to create
  28820. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28821. * @param origin Defines the start point of the ray which defaults to the camera position
  28822. * @returns the forward ray
  28823. */
  28824. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28825. /**
  28826. * Releases resources associated with this node.
  28827. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28828. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28829. */
  28830. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28831. /** @hidden */
  28832. _isLeftCamera: boolean;
  28833. /**
  28834. * Gets the left camera of a rig setup in case of Rigged Camera
  28835. */
  28836. get isLeftCamera(): boolean;
  28837. /** @hidden */
  28838. _isRightCamera: boolean;
  28839. /**
  28840. * Gets the right camera of a rig setup in case of Rigged Camera
  28841. */
  28842. get isRightCamera(): boolean;
  28843. /**
  28844. * Gets the left camera of a rig setup in case of Rigged Camera
  28845. */
  28846. get leftCamera(): Nullable<FreeCamera>;
  28847. /**
  28848. * Gets the right camera of a rig setup in case of Rigged Camera
  28849. */
  28850. get rightCamera(): Nullable<FreeCamera>;
  28851. /**
  28852. * Gets the left camera target of a rig setup in case of Rigged Camera
  28853. * @returns the target position
  28854. */
  28855. getLeftTarget(): Nullable<Vector3>;
  28856. /**
  28857. * Gets the right camera target of a rig setup in case of Rigged Camera
  28858. * @returns the target position
  28859. */
  28860. getRightTarget(): Nullable<Vector3>;
  28861. /**
  28862. * @hidden
  28863. */
  28864. setCameraRigMode(mode: number, rigParams: any): void;
  28865. /** @hidden */
  28866. static _setStereoscopicRigMode(camera: Camera): void;
  28867. /** @hidden */
  28868. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28869. /** @hidden */
  28870. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28871. /** @hidden */
  28872. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28873. /** @hidden */
  28874. _getVRProjectionMatrix(): Matrix;
  28875. protected _updateCameraRotationMatrix(): void;
  28876. protected _updateWebVRCameraRotationMatrix(): void;
  28877. /**
  28878. * This function MUST be overwritten by the different WebVR cameras available.
  28879. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28880. * @hidden
  28881. */
  28882. _getWebVRProjectionMatrix(): Matrix;
  28883. /**
  28884. * This function MUST be overwritten by the different WebVR cameras available.
  28885. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28886. * @hidden
  28887. */
  28888. _getWebVRViewMatrix(): Matrix;
  28889. /** @hidden */
  28890. setCameraRigParameter(name: string, value: any): void;
  28891. /**
  28892. * needs to be overridden by children so sub has required properties to be copied
  28893. * @hidden
  28894. */
  28895. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28896. /**
  28897. * May need to be overridden by children
  28898. * @hidden
  28899. */
  28900. _updateRigCameras(): void;
  28901. /** @hidden */
  28902. _setupInputs(): void;
  28903. /**
  28904. * Serialiaze the camera setup to a json represention
  28905. * @returns the JSON representation
  28906. */
  28907. serialize(): any;
  28908. /**
  28909. * Clones the current camera.
  28910. * @param name The cloned camera name
  28911. * @returns the cloned camera
  28912. */
  28913. clone(name: string): Camera;
  28914. /**
  28915. * Gets the direction of the camera relative to a given local axis.
  28916. * @param localAxis Defines the reference axis to provide a relative direction.
  28917. * @return the direction
  28918. */
  28919. getDirection(localAxis: Vector3): Vector3;
  28920. /**
  28921. * Returns the current camera absolute rotation
  28922. */
  28923. get absoluteRotation(): Quaternion;
  28924. /**
  28925. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28926. * @param localAxis Defines the reference axis to provide a relative direction.
  28927. * @param result Defines the vector to store the result in
  28928. */
  28929. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28930. /**
  28931. * Gets a camera constructor for a given camera type
  28932. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28933. * @param name The name of the camera the result will be able to instantiate
  28934. * @param scene The scene the result will construct the camera in
  28935. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28936. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28937. * @returns a factory method to construc the camera
  28938. */
  28939. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28940. /**
  28941. * Compute the world matrix of the camera.
  28942. * @returns the camera world matrix
  28943. */
  28944. computeWorldMatrix(): Matrix;
  28945. /**
  28946. * Parse a JSON and creates the camera from the parsed information
  28947. * @param parsedCamera The JSON to parse
  28948. * @param scene The scene to instantiate the camera in
  28949. * @returns the newly constructed camera
  28950. */
  28951. static Parse(parsedCamera: any, scene: Scene): Camera;
  28952. }
  28953. }
  28954. declare module BABYLON {
  28955. /**
  28956. * Class containing static functions to help procedurally build meshes
  28957. */
  28958. export class DiscBuilder {
  28959. /**
  28960. * Creates a plane polygonal mesh. By default, this is a disc
  28961. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28962. * * 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
  28963. * * 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
  28964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28965. * * 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
  28966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28967. * @param name defines the name of the mesh
  28968. * @param options defines the options used to create the mesh
  28969. * @param scene defines the hosting scene
  28970. * @returns the plane polygonal mesh
  28971. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28972. */
  28973. static CreateDisc(name: string, options: {
  28974. radius?: number;
  28975. tessellation?: number;
  28976. arc?: number;
  28977. updatable?: boolean;
  28978. sideOrientation?: number;
  28979. frontUVs?: Vector4;
  28980. backUVs?: Vector4;
  28981. }, scene?: Nullable<Scene>): Mesh;
  28982. }
  28983. }
  28984. declare module BABYLON {
  28985. /**
  28986. * Options to be used when creating a FresnelParameters.
  28987. */
  28988. export type IFresnelParametersCreationOptions = {
  28989. /**
  28990. * Define the color used on edges (grazing angle)
  28991. */
  28992. leftColor?: Color3;
  28993. /**
  28994. * Define the color used on center
  28995. */
  28996. rightColor?: Color3;
  28997. /**
  28998. * Define bias applied to computed fresnel term
  28999. */
  29000. bias?: number;
  29001. /**
  29002. * Defined the power exponent applied to fresnel term
  29003. */
  29004. power?: number;
  29005. /**
  29006. * Define if the fresnel effect is enable or not.
  29007. */
  29008. isEnabled?: boolean;
  29009. };
  29010. /**
  29011. * Serialized format for FresnelParameters.
  29012. */
  29013. export type IFresnelParametersSerialized = {
  29014. /**
  29015. * Define the color used on edges (grazing angle) [as an array]
  29016. */
  29017. leftColor: number[];
  29018. /**
  29019. * Define the color used on center [as an array]
  29020. */
  29021. rightColor: number[];
  29022. /**
  29023. * Define bias applied to computed fresnel term
  29024. */
  29025. bias: number;
  29026. /**
  29027. * Defined the power exponent applied to fresnel term
  29028. */
  29029. power?: number;
  29030. /**
  29031. * Define if the fresnel effect is enable or not.
  29032. */
  29033. isEnabled: boolean;
  29034. };
  29035. /**
  29036. * This represents all the required information to add a fresnel effect on a material:
  29037. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29038. */
  29039. export class FresnelParameters {
  29040. private _isEnabled;
  29041. /**
  29042. * Define if the fresnel effect is enable or not.
  29043. */
  29044. get isEnabled(): boolean;
  29045. set isEnabled(value: boolean);
  29046. /**
  29047. * Define the color used on edges (grazing angle)
  29048. */
  29049. leftColor: Color3;
  29050. /**
  29051. * Define the color used on center
  29052. */
  29053. rightColor: Color3;
  29054. /**
  29055. * Define bias applied to computed fresnel term
  29056. */
  29057. bias: number;
  29058. /**
  29059. * Defined the power exponent applied to fresnel term
  29060. */
  29061. power: number;
  29062. /**
  29063. * Creates a new FresnelParameters object.
  29064. *
  29065. * @param options provide your own settings to optionally to override defaults
  29066. */
  29067. constructor(options?: IFresnelParametersCreationOptions);
  29068. /**
  29069. * Clones the current fresnel and its valuues
  29070. * @returns a clone fresnel configuration
  29071. */
  29072. clone(): FresnelParameters;
  29073. /**
  29074. * Determines equality between FresnelParameters objects
  29075. * @param otherFresnelParameters defines the second operand
  29076. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29077. */
  29078. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29079. /**
  29080. * Serializes the current fresnel parameters to a JSON representation.
  29081. * @return the JSON serialization
  29082. */
  29083. serialize(): IFresnelParametersSerialized;
  29084. /**
  29085. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29086. * @param parsedFresnelParameters Define the JSON representation
  29087. * @returns the parsed parameters
  29088. */
  29089. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29090. }
  29091. }
  29092. declare module BABYLON {
  29093. /**
  29094. * This groups all the flags used to control the materials channel.
  29095. */
  29096. export class MaterialFlags {
  29097. private static _DiffuseTextureEnabled;
  29098. /**
  29099. * Are diffuse textures enabled in the application.
  29100. */
  29101. static get DiffuseTextureEnabled(): boolean;
  29102. static set DiffuseTextureEnabled(value: boolean);
  29103. private static _DetailTextureEnabled;
  29104. /**
  29105. * Are detail textures enabled in the application.
  29106. */
  29107. static get DetailTextureEnabled(): boolean;
  29108. static set DetailTextureEnabled(value: boolean);
  29109. private static _AmbientTextureEnabled;
  29110. /**
  29111. * Are ambient textures enabled in the application.
  29112. */
  29113. static get AmbientTextureEnabled(): boolean;
  29114. static set AmbientTextureEnabled(value: boolean);
  29115. private static _OpacityTextureEnabled;
  29116. /**
  29117. * Are opacity textures enabled in the application.
  29118. */
  29119. static get OpacityTextureEnabled(): boolean;
  29120. static set OpacityTextureEnabled(value: boolean);
  29121. private static _ReflectionTextureEnabled;
  29122. /**
  29123. * Are reflection textures enabled in the application.
  29124. */
  29125. static get ReflectionTextureEnabled(): boolean;
  29126. static set ReflectionTextureEnabled(value: boolean);
  29127. private static _EmissiveTextureEnabled;
  29128. /**
  29129. * Are emissive textures enabled in the application.
  29130. */
  29131. static get EmissiveTextureEnabled(): boolean;
  29132. static set EmissiveTextureEnabled(value: boolean);
  29133. private static _SpecularTextureEnabled;
  29134. /**
  29135. * Are specular textures enabled in the application.
  29136. */
  29137. static get SpecularTextureEnabled(): boolean;
  29138. static set SpecularTextureEnabled(value: boolean);
  29139. private static _BumpTextureEnabled;
  29140. /**
  29141. * Are bump textures enabled in the application.
  29142. */
  29143. static get BumpTextureEnabled(): boolean;
  29144. static set BumpTextureEnabled(value: boolean);
  29145. private static _LightmapTextureEnabled;
  29146. /**
  29147. * Are lightmap textures enabled in the application.
  29148. */
  29149. static get LightmapTextureEnabled(): boolean;
  29150. static set LightmapTextureEnabled(value: boolean);
  29151. private static _RefractionTextureEnabled;
  29152. /**
  29153. * Are refraction textures enabled in the application.
  29154. */
  29155. static get RefractionTextureEnabled(): boolean;
  29156. static set RefractionTextureEnabled(value: boolean);
  29157. private static _ColorGradingTextureEnabled;
  29158. /**
  29159. * Are color grading textures enabled in the application.
  29160. */
  29161. static get ColorGradingTextureEnabled(): boolean;
  29162. static set ColorGradingTextureEnabled(value: boolean);
  29163. private static _FresnelEnabled;
  29164. /**
  29165. * Are fresnels enabled in the application.
  29166. */
  29167. static get FresnelEnabled(): boolean;
  29168. static set FresnelEnabled(value: boolean);
  29169. private static _ClearCoatTextureEnabled;
  29170. /**
  29171. * Are clear coat textures enabled in the application.
  29172. */
  29173. static get ClearCoatTextureEnabled(): boolean;
  29174. static set ClearCoatTextureEnabled(value: boolean);
  29175. private static _ClearCoatBumpTextureEnabled;
  29176. /**
  29177. * Are clear coat bump textures enabled in the application.
  29178. */
  29179. static get ClearCoatBumpTextureEnabled(): boolean;
  29180. static set ClearCoatBumpTextureEnabled(value: boolean);
  29181. private static _ClearCoatTintTextureEnabled;
  29182. /**
  29183. * Are clear coat tint textures enabled in the application.
  29184. */
  29185. static get ClearCoatTintTextureEnabled(): boolean;
  29186. static set ClearCoatTintTextureEnabled(value: boolean);
  29187. private static _SheenTextureEnabled;
  29188. /**
  29189. * Are sheen textures enabled in the application.
  29190. */
  29191. static get SheenTextureEnabled(): boolean;
  29192. static set SheenTextureEnabled(value: boolean);
  29193. private static _AnisotropicTextureEnabled;
  29194. /**
  29195. * Are anisotropic textures enabled in the application.
  29196. */
  29197. static get AnisotropicTextureEnabled(): boolean;
  29198. static set AnisotropicTextureEnabled(value: boolean);
  29199. private static _ThicknessTextureEnabled;
  29200. /**
  29201. * Are thickness textures enabled in the application.
  29202. */
  29203. static get ThicknessTextureEnabled(): boolean;
  29204. static set ThicknessTextureEnabled(value: boolean);
  29205. }
  29206. }
  29207. declare module BABYLON {
  29208. /** @hidden */
  29209. export var defaultFragmentDeclaration: {
  29210. name: string;
  29211. shader: string;
  29212. };
  29213. }
  29214. declare module BABYLON {
  29215. /** @hidden */
  29216. export var defaultUboDeclaration: {
  29217. name: string;
  29218. shader: string;
  29219. };
  29220. }
  29221. declare module BABYLON {
  29222. /** @hidden */
  29223. export var lightFragmentDeclaration: {
  29224. name: string;
  29225. shader: string;
  29226. };
  29227. }
  29228. declare module BABYLON {
  29229. /** @hidden */
  29230. export var lightUboDeclaration: {
  29231. name: string;
  29232. shader: string;
  29233. };
  29234. }
  29235. declare module BABYLON {
  29236. /** @hidden */
  29237. export var lightsFragmentFunctions: {
  29238. name: string;
  29239. shader: string;
  29240. };
  29241. }
  29242. declare module BABYLON {
  29243. /** @hidden */
  29244. export var shadowsFragmentFunctions: {
  29245. name: string;
  29246. shader: string;
  29247. };
  29248. }
  29249. declare module BABYLON {
  29250. /** @hidden */
  29251. export var fresnelFunction: {
  29252. name: string;
  29253. shader: string;
  29254. };
  29255. }
  29256. declare module BABYLON {
  29257. /** @hidden */
  29258. export var bumpFragmentMainFunctions: {
  29259. name: string;
  29260. shader: string;
  29261. };
  29262. }
  29263. declare module BABYLON {
  29264. /** @hidden */
  29265. export var bumpFragmentFunctions: {
  29266. name: string;
  29267. shader: string;
  29268. };
  29269. }
  29270. declare module BABYLON {
  29271. /** @hidden */
  29272. export var logDepthDeclaration: {
  29273. name: string;
  29274. shader: string;
  29275. };
  29276. }
  29277. declare module BABYLON {
  29278. /** @hidden */
  29279. export var bumpFragment: {
  29280. name: string;
  29281. shader: string;
  29282. };
  29283. }
  29284. declare module BABYLON {
  29285. /** @hidden */
  29286. export var depthPrePass: {
  29287. name: string;
  29288. shader: string;
  29289. };
  29290. }
  29291. declare module BABYLON {
  29292. /** @hidden */
  29293. export var lightFragment: {
  29294. name: string;
  29295. shader: string;
  29296. };
  29297. }
  29298. declare module BABYLON {
  29299. /** @hidden */
  29300. export var logDepthFragment: {
  29301. name: string;
  29302. shader: string;
  29303. };
  29304. }
  29305. declare module BABYLON {
  29306. /** @hidden */
  29307. export var defaultPixelShader: {
  29308. name: string;
  29309. shader: string;
  29310. };
  29311. }
  29312. declare module BABYLON {
  29313. /** @hidden */
  29314. export var defaultVertexDeclaration: {
  29315. name: string;
  29316. shader: string;
  29317. };
  29318. }
  29319. declare module BABYLON {
  29320. /** @hidden */
  29321. export var bumpVertexDeclaration: {
  29322. name: string;
  29323. shader: string;
  29324. };
  29325. }
  29326. declare module BABYLON {
  29327. /** @hidden */
  29328. export var bumpVertex: {
  29329. name: string;
  29330. shader: string;
  29331. };
  29332. }
  29333. declare module BABYLON {
  29334. /** @hidden */
  29335. export var fogVertex: {
  29336. name: string;
  29337. shader: string;
  29338. };
  29339. }
  29340. declare module BABYLON {
  29341. /** @hidden */
  29342. export var shadowsVertex: {
  29343. name: string;
  29344. shader: string;
  29345. };
  29346. }
  29347. declare module BABYLON {
  29348. /** @hidden */
  29349. export var pointCloudVertex: {
  29350. name: string;
  29351. shader: string;
  29352. };
  29353. }
  29354. declare module BABYLON {
  29355. /** @hidden */
  29356. export var logDepthVertex: {
  29357. name: string;
  29358. shader: string;
  29359. };
  29360. }
  29361. declare module BABYLON {
  29362. /** @hidden */
  29363. export var defaultVertexShader: {
  29364. name: string;
  29365. shader: string;
  29366. };
  29367. }
  29368. declare module BABYLON {
  29369. /**
  29370. * @hidden
  29371. */
  29372. export interface IMaterialDetailMapDefines {
  29373. DETAIL: boolean;
  29374. DETAILDIRECTUV: number;
  29375. DETAIL_NORMALBLENDMETHOD: number;
  29376. /** @hidden */
  29377. _areTexturesDirty: boolean;
  29378. }
  29379. /**
  29380. * Define the code related to the detail map parameters of a material
  29381. *
  29382. * Inspired from:
  29383. * 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
  29384. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  29385. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  29386. */
  29387. export class DetailMapConfiguration {
  29388. private _texture;
  29389. /**
  29390. * The detail texture of the material.
  29391. */
  29392. texture: Nullable<BaseTexture>;
  29393. /**
  29394. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  29395. * Bigger values mean stronger blending
  29396. */
  29397. diffuseBlendLevel: number;
  29398. /**
  29399. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  29400. * Bigger values mean stronger blending. Only used with PBR materials
  29401. */
  29402. roughnessBlendLevel: number;
  29403. /**
  29404. * Defines how strong the bump effect from the detail map is
  29405. * Bigger values mean stronger effect
  29406. */
  29407. bumpLevel: number;
  29408. private _normalBlendMethod;
  29409. /**
  29410. * The method used to blend the bump and detail normals together
  29411. */
  29412. normalBlendMethod: number;
  29413. private _isEnabled;
  29414. /**
  29415. * Enable or disable the detail map on this material
  29416. */
  29417. isEnabled: boolean;
  29418. /** @hidden */
  29419. private _internalMarkAllSubMeshesAsTexturesDirty;
  29420. /** @hidden */
  29421. _markAllSubMeshesAsTexturesDirty(): void;
  29422. /**
  29423. * Instantiate a new detail map
  29424. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  29425. */
  29426. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  29427. /**
  29428. * Gets whether the submesh is ready to be used or not.
  29429. * @param defines the list of "defines" to update.
  29430. * @param scene defines the scene the material belongs to.
  29431. * @returns - boolean indicating that the submesh is ready or not.
  29432. */
  29433. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  29434. /**
  29435. * Update the defines for detail map usage
  29436. * @param defines the list of "defines" to update.
  29437. * @param scene defines the scene the material belongs to.
  29438. */
  29439. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  29440. /**
  29441. * Binds the material data.
  29442. * @param uniformBuffer defines the Uniform buffer to fill in.
  29443. * @param scene defines the scene the material belongs to.
  29444. * @param isFrozen defines whether the material is frozen or not.
  29445. */
  29446. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  29447. /**
  29448. * Checks to see if a texture is used in the material.
  29449. * @param texture - Base texture to use.
  29450. * @returns - Boolean specifying if a texture is used in the material.
  29451. */
  29452. hasTexture(texture: BaseTexture): boolean;
  29453. /**
  29454. * Returns an array of the actively used textures.
  29455. * @param activeTextures Array of BaseTextures
  29456. */
  29457. getActiveTextures(activeTextures: BaseTexture[]): void;
  29458. /**
  29459. * Returns the animatable textures.
  29460. * @param animatables Array of animatable textures.
  29461. */
  29462. getAnimatables(animatables: IAnimatable[]): void;
  29463. /**
  29464. * Disposes the resources of the material.
  29465. * @param forceDisposeTextures - Forces the disposal of all textures.
  29466. */
  29467. dispose(forceDisposeTextures?: boolean): void;
  29468. /**
  29469. * Get the current class name useful for serialization or dynamic coding.
  29470. * @returns "DetailMap"
  29471. */
  29472. getClassName(): string;
  29473. /**
  29474. * Add the required uniforms to the current list.
  29475. * @param uniforms defines the current uniform list.
  29476. */
  29477. static AddUniforms(uniforms: string[]): void;
  29478. /**
  29479. * Add the required samplers to the current list.
  29480. * @param samplers defines the current sampler list.
  29481. */
  29482. static AddSamplers(samplers: string[]): void;
  29483. /**
  29484. * Add the required uniforms to the current buffer.
  29485. * @param uniformBuffer defines the current uniform buffer.
  29486. */
  29487. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  29488. /**
  29489. * Makes a duplicate of the current instance into another one.
  29490. * @param detailMap define the instance where to copy the info
  29491. */
  29492. copyTo(detailMap: DetailMapConfiguration): void;
  29493. /**
  29494. * Serializes this detail map instance
  29495. * @returns - An object with the serialized instance.
  29496. */
  29497. serialize(): any;
  29498. /**
  29499. * Parses a detail map setting from a serialized object.
  29500. * @param source - Serialized object.
  29501. * @param scene Defines the scene we are parsing for
  29502. * @param rootUrl Defines the rootUrl to load from
  29503. */
  29504. parse(source: any, scene: Scene, rootUrl: string): void;
  29505. }
  29506. }
  29507. declare module BABYLON {
  29508. /** @hidden */
  29509. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  29510. MAINUV1: boolean;
  29511. MAINUV2: boolean;
  29512. DIFFUSE: boolean;
  29513. DIFFUSEDIRECTUV: number;
  29514. DETAIL: boolean;
  29515. DETAILDIRECTUV: number;
  29516. DETAIL_NORMALBLENDMETHOD: number;
  29517. AMBIENT: boolean;
  29518. AMBIENTDIRECTUV: number;
  29519. OPACITY: boolean;
  29520. OPACITYDIRECTUV: number;
  29521. OPACITYRGB: boolean;
  29522. REFLECTION: boolean;
  29523. EMISSIVE: boolean;
  29524. EMISSIVEDIRECTUV: number;
  29525. SPECULAR: boolean;
  29526. SPECULARDIRECTUV: number;
  29527. BUMP: boolean;
  29528. BUMPDIRECTUV: number;
  29529. PARALLAX: boolean;
  29530. PARALLAXOCCLUSION: boolean;
  29531. SPECULAROVERALPHA: boolean;
  29532. CLIPPLANE: boolean;
  29533. CLIPPLANE2: boolean;
  29534. CLIPPLANE3: boolean;
  29535. CLIPPLANE4: boolean;
  29536. CLIPPLANE5: boolean;
  29537. CLIPPLANE6: boolean;
  29538. ALPHATEST: boolean;
  29539. DEPTHPREPASS: boolean;
  29540. ALPHAFROMDIFFUSE: boolean;
  29541. POINTSIZE: boolean;
  29542. FOG: boolean;
  29543. SPECULARTERM: boolean;
  29544. DIFFUSEFRESNEL: boolean;
  29545. OPACITYFRESNEL: boolean;
  29546. REFLECTIONFRESNEL: boolean;
  29547. REFRACTIONFRESNEL: boolean;
  29548. EMISSIVEFRESNEL: boolean;
  29549. FRESNEL: boolean;
  29550. NORMAL: boolean;
  29551. UV1: boolean;
  29552. UV2: boolean;
  29553. VERTEXCOLOR: boolean;
  29554. VERTEXALPHA: boolean;
  29555. NUM_BONE_INFLUENCERS: number;
  29556. BonesPerMesh: number;
  29557. BONETEXTURE: boolean;
  29558. INSTANCES: boolean;
  29559. THIN_INSTANCES: boolean;
  29560. GLOSSINESS: boolean;
  29561. ROUGHNESS: boolean;
  29562. EMISSIVEASILLUMINATION: boolean;
  29563. LINKEMISSIVEWITHDIFFUSE: boolean;
  29564. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29565. LIGHTMAP: boolean;
  29566. LIGHTMAPDIRECTUV: number;
  29567. OBJECTSPACE_NORMALMAP: boolean;
  29568. USELIGHTMAPASSHADOWMAP: boolean;
  29569. REFLECTIONMAP_3D: boolean;
  29570. REFLECTIONMAP_SPHERICAL: boolean;
  29571. REFLECTIONMAP_PLANAR: boolean;
  29572. REFLECTIONMAP_CUBIC: boolean;
  29573. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29574. REFLECTIONMAP_PROJECTION: boolean;
  29575. REFLECTIONMAP_SKYBOX: boolean;
  29576. REFLECTIONMAP_EXPLICIT: boolean;
  29577. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29578. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29579. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29580. INVERTCUBICMAP: boolean;
  29581. LOGARITHMICDEPTH: boolean;
  29582. REFRACTION: boolean;
  29583. REFRACTIONMAP_3D: boolean;
  29584. REFLECTIONOVERALPHA: boolean;
  29585. TWOSIDEDLIGHTING: boolean;
  29586. SHADOWFLOAT: boolean;
  29587. MORPHTARGETS: boolean;
  29588. MORPHTARGETS_NORMAL: boolean;
  29589. MORPHTARGETS_TANGENT: boolean;
  29590. MORPHTARGETS_UV: boolean;
  29591. NUM_MORPH_INFLUENCERS: number;
  29592. NONUNIFORMSCALING: boolean;
  29593. PREMULTIPLYALPHA: boolean;
  29594. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29595. ALPHABLEND: boolean;
  29596. RGBDLIGHTMAP: boolean;
  29597. RGBDREFLECTION: boolean;
  29598. RGBDREFRACTION: boolean;
  29599. IMAGEPROCESSING: boolean;
  29600. VIGNETTE: boolean;
  29601. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29602. VIGNETTEBLENDMODEOPAQUE: boolean;
  29603. TONEMAPPING: boolean;
  29604. TONEMAPPING_ACES: boolean;
  29605. CONTRAST: boolean;
  29606. COLORCURVES: boolean;
  29607. COLORGRADING: boolean;
  29608. COLORGRADING3D: boolean;
  29609. SAMPLER3DGREENDEPTH: boolean;
  29610. SAMPLER3DBGRMAP: boolean;
  29611. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29612. MULTIVIEW: boolean;
  29613. /**
  29614. * If the reflection texture on this material is in linear color space
  29615. * @hidden
  29616. */
  29617. IS_REFLECTION_LINEAR: boolean;
  29618. /**
  29619. * If the refraction texture on this material is in linear color space
  29620. * @hidden
  29621. */
  29622. IS_REFRACTION_LINEAR: boolean;
  29623. EXPOSURE: boolean;
  29624. constructor();
  29625. setReflectionMode(modeToEnable: string): void;
  29626. }
  29627. /**
  29628. * This is the default material used in Babylon. It is the best trade off between quality
  29629. * and performances.
  29630. * @see http://doc.babylonjs.com/babylon101/materials
  29631. */
  29632. export class StandardMaterial extends PushMaterial {
  29633. private _diffuseTexture;
  29634. /**
  29635. * The basic texture of the material as viewed under a light.
  29636. */
  29637. diffuseTexture: Nullable<BaseTexture>;
  29638. private _ambientTexture;
  29639. /**
  29640. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29641. */
  29642. ambientTexture: Nullable<BaseTexture>;
  29643. private _opacityTexture;
  29644. /**
  29645. * Define the transparency of the material from a texture.
  29646. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29647. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29648. */
  29649. opacityTexture: Nullable<BaseTexture>;
  29650. private _reflectionTexture;
  29651. /**
  29652. * Define the texture used to display the reflection.
  29653. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29654. */
  29655. reflectionTexture: Nullable<BaseTexture>;
  29656. private _emissiveTexture;
  29657. /**
  29658. * Define texture of the material as if self lit.
  29659. * This will be mixed in the final result even in the absence of light.
  29660. */
  29661. emissiveTexture: Nullable<BaseTexture>;
  29662. private _specularTexture;
  29663. /**
  29664. * Define how the color and intensity of the highlight given by the light in the material.
  29665. */
  29666. specularTexture: Nullable<BaseTexture>;
  29667. private _bumpTexture;
  29668. /**
  29669. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29670. * 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.
  29671. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29672. */
  29673. bumpTexture: Nullable<BaseTexture>;
  29674. private _lightmapTexture;
  29675. /**
  29676. * Complex lighting can be computationally expensive to compute at runtime.
  29677. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29678. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29679. */
  29680. lightmapTexture: Nullable<BaseTexture>;
  29681. private _refractionTexture;
  29682. /**
  29683. * Define the texture used to display the refraction.
  29684. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29685. */
  29686. refractionTexture: Nullable<BaseTexture>;
  29687. /**
  29688. * The color of the material lit by the environmental background lighting.
  29689. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29690. */
  29691. ambientColor: Color3;
  29692. /**
  29693. * The basic color of the material as viewed under a light.
  29694. */
  29695. diffuseColor: Color3;
  29696. /**
  29697. * Define how the color and intensity of the highlight given by the light in the material.
  29698. */
  29699. specularColor: Color3;
  29700. /**
  29701. * Define the color of the material as if self lit.
  29702. * This will be mixed in the final result even in the absence of light.
  29703. */
  29704. emissiveColor: Color3;
  29705. /**
  29706. * Defines how sharp are the highlights in the material.
  29707. * The bigger the value the sharper giving a more glossy feeling to the result.
  29708. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29709. */
  29710. specularPower: number;
  29711. private _useAlphaFromDiffuseTexture;
  29712. /**
  29713. * Does the transparency come from the diffuse texture alpha channel.
  29714. */
  29715. useAlphaFromDiffuseTexture: boolean;
  29716. private _useEmissiveAsIllumination;
  29717. /**
  29718. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29719. */
  29720. useEmissiveAsIllumination: boolean;
  29721. private _linkEmissiveWithDiffuse;
  29722. /**
  29723. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29724. * the emissive level when the final color is close to one.
  29725. */
  29726. linkEmissiveWithDiffuse: boolean;
  29727. private _useSpecularOverAlpha;
  29728. /**
  29729. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29730. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29731. */
  29732. useSpecularOverAlpha: boolean;
  29733. private _useReflectionOverAlpha;
  29734. /**
  29735. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29736. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29737. */
  29738. useReflectionOverAlpha: boolean;
  29739. private _disableLighting;
  29740. /**
  29741. * Does lights from the scene impacts this material.
  29742. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29743. */
  29744. disableLighting: boolean;
  29745. private _useObjectSpaceNormalMap;
  29746. /**
  29747. * Allows using an object space normal map (instead of tangent space).
  29748. */
  29749. useObjectSpaceNormalMap: boolean;
  29750. private _useParallax;
  29751. /**
  29752. * Is parallax enabled or not.
  29753. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29754. */
  29755. useParallax: boolean;
  29756. private _useParallaxOcclusion;
  29757. /**
  29758. * Is parallax occlusion enabled or not.
  29759. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29760. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29761. */
  29762. useParallaxOcclusion: boolean;
  29763. /**
  29764. * 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.
  29765. */
  29766. parallaxScaleBias: number;
  29767. private _roughness;
  29768. /**
  29769. * Helps to define how blurry the reflections should appears in the material.
  29770. */
  29771. roughness: number;
  29772. /**
  29773. * In case of refraction, define the value of the index of refraction.
  29774. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29775. */
  29776. indexOfRefraction: number;
  29777. /**
  29778. * Invert the refraction texture alongside the y axis.
  29779. * It can be useful with procedural textures or probe for instance.
  29780. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29781. */
  29782. invertRefractionY: boolean;
  29783. /**
  29784. * Defines the alpha limits in alpha test mode.
  29785. */
  29786. alphaCutOff: number;
  29787. private _useLightmapAsShadowmap;
  29788. /**
  29789. * In case of light mapping, define whether the map contains light or shadow informations.
  29790. */
  29791. useLightmapAsShadowmap: boolean;
  29792. private _diffuseFresnelParameters;
  29793. /**
  29794. * Define the diffuse fresnel parameters of the material.
  29795. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29796. */
  29797. diffuseFresnelParameters: FresnelParameters;
  29798. private _opacityFresnelParameters;
  29799. /**
  29800. * Define the opacity fresnel parameters of the material.
  29801. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29802. */
  29803. opacityFresnelParameters: FresnelParameters;
  29804. private _reflectionFresnelParameters;
  29805. /**
  29806. * Define the reflection fresnel parameters of the material.
  29807. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29808. */
  29809. reflectionFresnelParameters: FresnelParameters;
  29810. private _refractionFresnelParameters;
  29811. /**
  29812. * Define the refraction fresnel parameters of the material.
  29813. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29814. */
  29815. refractionFresnelParameters: FresnelParameters;
  29816. private _emissiveFresnelParameters;
  29817. /**
  29818. * Define the emissive fresnel parameters of the material.
  29819. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29820. */
  29821. emissiveFresnelParameters: FresnelParameters;
  29822. private _useReflectionFresnelFromSpecular;
  29823. /**
  29824. * If true automatically deducts the fresnels values from the material specularity.
  29825. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29826. */
  29827. useReflectionFresnelFromSpecular: boolean;
  29828. private _useGlossinessFromSpecularMapAlpha;
  29829. /**
  29830. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29831. */
  29832. useGlossinessFromSpecularMapAlpha: boolean;
  29833. private _maxSimultaneousLights;
  29834. /**
  29835. * Defines the maximum number of lights that can be used in the material
  29836. */
  29837. maxSimultaneousLights: number;
  29838. private _invertNormalMapX;
  29839. /**
  29840. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29841. */
  29842. invertNormalMapX: boolean;
  29843. private _invertNormalMapY;
  29844. /**
  29845. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29846. */
  29847. invertNormalMapY: boolean;
  29848. private _twoSidedLighting;
  29849. /**
  29850. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29851. */
  29852. twoSidedLighting: boolean;
  29853. /**
  29854. * Default configuration related to image processing available in the standard Material.
  29855. */
  29856. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29857. /**
  29858. * Gets the image processing configuration used either in this material.
  29859. */
  29860. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29861. /**
  29862. * Sets the Default image processing configuration used either in the this material.
  29863. *
  29864. * If sets to null, the scene one is in use.
  29865. */
  29866. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29867. /**
  29868. * Keep track of the image processing observer to allow dispose and replace.
  29869. */
  29870. private _imageProcessingObserver;
  29871. /**
  29872. * Attaches a new image processing configuration to the Standard Material.
  29873. * @param configuration
  29874. */
  29875. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29876. /**
  29877. * Gets wether the color curves effect is enabled.
  29878. */
  29879. get cameraColorCurvesEnabled(): boolean;
  29880. /**
  29881. * Sets wether the color curves effect is enabled.
  29882. */
  29883. set cameraColorCurvesEnabled(value: boolean);
  29884. /**
  29885. * Gets wether the color grading effect is enabled.
  29886. */
  29887. get cameraColorGradingEnabled(): boolean;
  29888. /**
  29889. * Gets wether the color grading effect is enabled.
  29890. */
  29891. set cameraColorGradingEnabled(value: boolean);
  29892. /**
  29893. * Gets wether tonemapping is enabled or not.
  29894. */
  29895. get cameraToneMappingEnabled(): boolean;
  29896. /**
  29897. * Sets wether tonemapping is enabled or not
  29898. */
  29899. set cameraToneMappingEnabled(value: boolean);
  29900. /**
  29901. * The camera exposure used on this material.
  29902. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29903. * This corresponds to a photographic exposure.
  29904. */
  29905. get cameraExposure(): number;
  29906. /**
  29907. * The camera exposure used on this material.
  29908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29909. * This corresponds to a photographic exposure.
  29910. */
  29911. set cameraExposure(value: number);
  29912. /**
  29913. * Gets The camera contrast used on this material.
  29914. */
  29915. get cameraContrast(): number;
  29916. /**
  29917. * Sets The camera contrast used on this material.
  29918. */
  29919. set cameraContrast(value: number);
  29920. /**
  29921. * Gets the Color Grading 2D Lookup Texture.
  29922. */
  29923. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29924. /**
  29925. * Sets the Color Grading 2D Lookup Texture.
  29926. */
  29927. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29928. /**
  29929. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29930. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29931. * 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;
  29932. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29933. */
  29934. get cameraColorCurves(): Nullable<ColorCurves>;
  29935. /**
  29936. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29937. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29938. * 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;
  29939. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29940. */
  29941. set cameraColorCurves(value: Nullable<ColorCurves>);
  29942. /**
  29943. * Defines the detail map parameters for the material.
  29944. */
  29945. readonly detailMap: DetailMapConfiguration;
  29946. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29947. protected _worldViewProjectionMatrix: Matrix;
  29948. protected _globalAmbientColor: Color3;
  29949. protected _useLogarithmicDepth: boolean;
  29950. protected _rebuildInParallel: boolean;
  29951. /**
  29952. * Instantiates a new standard material.
  29953. * This is the default material used in Babylon. It is the best trade off between quality
  29954. * and performances.
  29955. * @see http://doc.babylonjs.com/babylon101/materials
  29956. * @param name Define the name of the material in the scene
  29957. * @param scene Define the scene the material belong to
  29958. */
  29959. constructor(name: string, scene: Scene);
  29960. /**
  29961. * Gets a boolean indicating that current material needs to register RTT
  29962. */
  29963. get hasRenderTargetTextures(): boolean;
  29964. /**
  29965. * Gets the current class name of the material e.g. "StandardMaterial"
  29966. * Mainly use in serialization.
  29967. * @returns the class name
  29968. */
  29969. getClassName(): string;
  29970. /**
  29971. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29972. * You can try switching to logarithmic depth.
  29973. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29974. */
  29975. get useLogarithmicDepth(): boolean;
  29976. set useLogarithmicDepth(value: boolean);
  29977. /**
  29978. * Specifies if the material will require alpha blending
  29979. * @returns a boolean specifying if alpha blending is needed
  29980. */
  29981. needAlphaBlending(): boolean;
  29982. /**
  29983. * Specifies if this material should be rendered in alpha test mode
  29984. * @returns a boolean specifying if an alpha test is needed.
  29985. */
  29986. needAlphaTesting(): boolean;
  29987. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29988. /**
  29989. * Get the texture used for alpha test purpose.
  29990. * @returns the diffuse texture in case of the standard material.
  29991. */
  29992. getAlphaTestTexture(): Nullable<BaseTexture>;
  29993. /**
  29994. * Get if the submesh is ready to be used and all its information available.
  29995. * Child classes can use it to update shaders
  29996. * @param mesh defines the mesh to check
  29997. * @param subMesh defines which submesh to check
  29998. * @param useInstances specifies that instances should be used
  29999. * @returns a boolean indicating that the submesh is ready or not
  30000. */
  30001. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30002. /**
  30003. * Builds the material UBO layouts.
  30004. * Used internally during the effect preparation.
  30005. */
  30006. buildUniformLayout(): void;
  30007. /**
  30008. * Unbinds the material from the mesh
  30009. */
  30010. unbind(): void;
  30011. /**
  30012. * Binds the submesh to this material by preparing the effect and shader to draw
  30013. * @param world defines the world transformation matrix
  30014. * @param mesh defines the mesh containing the submesh
  30015. * @param subMesh defines the submesh to bind the material to
  30016. */
  30017. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30018. /**
  30019. * Get the list of animatables in the material.
  30020. * @returns the list of animatables object used in the material
  30021. */
  30022. getAnimatables(): IAnimatable[];
  30023. /**
  30024. * Gets the active textures from the material
  30025. * @returns an array of textures
  30026. */
  30027. getActiveTextures(): BaseTexture[];
  30028. /**
  30029. * Specifies if the material uses a texture
  30030. * @param texture defines the texture to check against the material
  30031. * @returns a boolean specifying if the material uses the texture
  30032. */
  30033. hasTexture(texture: BaseTexture): boolean;
  30034. /**
  30035. * Disposes the material
  30036. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30037. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30038. */
  30039. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30040. /**
  30041. * Makes a duplicate of the material, and gives it a new name
  30042. * @param name defines the new name for the duplicated material
  30043. * @returns the cloned material
  30044. */
  30045. clone(name: string): StandardMaterial;
  30046. /**
  30047. * Serializes this material in a JSON representation
  30048. * @returns the serialized material object
  30049. */
  30050. serialize(): any;
  30051. /**
  30052. * Creates a standard material from parsed material data
  30053. * @param source defines the JSON representation of the material
  30054. * @param scene defines the hosting scene
  30055. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30056. * @returns a new standard material
  30057. */
  30058. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30059. /**
  30060. * Are diffuse textures enabled in the application.
  30061. */
  30062. static get DiffuseTextureEnabled(): boolean;
  30063. static set DiffuseTextureEnabled(value: boolean);
  30064. /**
  30065. * Are detail textures enabled in the application.
  30066. */
  30067. static get DetailTextureEnabled(): boolean;
  30068. static set DetailTextureEnabled(value: boolean);
  30069. /**
  30070. * Are ambient textures enabled in the application.
  30071. */
  30072. static get AmbientTextureEnabled(): boolean;
  30073. static set AmbientTextureEnabled(value: boolean);
  30074. /**
  30075. * Are opacity textures enabled in the application.
  30076. */
  30077. static get OpacityTextureEnabled(): boolean;
  30078. static set OpacityTextureEnabled(value: boolean);
  30079. /**
  30080. * Are reflection textures enabled in the application.
  30081. */
  30082. static get ReflectionTextureEnabled(): boolean;
  30083. static set ReflectionTextureEnabled(value: boolean);
  30084. /**
  30085. * Are emissive textures enabled in the application.
  30086. */
  30087. static get EmissiveTextureEnabled(): boolean;
  30088. static set EmissiveTextureEnabled(value: boolean);
  30089. /**
  30090. * Are specular textures enabled in the application.
  30091. */
  30092. static get SpecularTextureEnabled(): boolean;
  30093. static set SpecularTextureEnabled(value: boolean);
  30094. /**
  30095. * Are bump textures enabled in the application.
  30096. */
  30097. static get BumpTextureEnabled(): boolean;
  30098. static set BumpTextureEnabled(value: boolean);
  30099. /**
  30100. * Are lightmap textures enabled in the application.
  30101. */
  30102. static get LightmapTextureEnabled(): boolean;
  30103. static set LightmapTextureEnabled(value: boolean);
  30104. /**
  30105. * Are refraction textures enabled in the application.
  30106. */
  30107. static get RefractionTextureEnabled(): boolean;
  30108. static set RefractionTextureEnabled(value: boolean);
  30109. /**
  30110. * Are color grading textures enabled in the application.
  30111. */
  30112. static get ColorGradingTextureEnabled(): boolean;
  30113. static set ColorGradingTextureEnabled(value: boolean);
  30114. /**
  30115. * Are fresnels enabled in the application.
  30116. */
  30117. static get FresnelEnabled(): boolean;
  30118. static set FresnelEnabled(value: boolean);
  30119. }
  30120. }
  30121. declare module BABYLON {
  30122. /**
  30123. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30124. *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.
  30125. * The SPS is also a particle system. It provides some methods to manage the particles.
  30126. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30127. *
  30128. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30129. */
  30130. export class SolidParticleSystem implements IDisposable {
  30131. /**
  30132. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30133. * Example : var p = SPS.particles[i];
  30134. */
  30135. particles: SolidParticle[];
  30136. /**
  30137. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30138. */
  30139. nbParticles: number;
  30140. /**
  30141. * If the particles must ever face the camera (default false). Useful for planar particles.
  30142. */
  30143. billboard: boolean;
  30144. /**
  30145. * Recompute normals when adding a shape
  30146. */
  30147. recomputeNormals: boolean;
  30148. /**
  30149. * This a counter ofr your own usage. It's not set by any SPS functions.
  30150. */
  30151. counter: number;
  30152. /**
  30153. * The SPS name. This name is also given to the underlying mesh.
  30154. */
  30155. name: string;
  30156. /**
  30157. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30158. */
  30159. mesh: Mesh;
  30160. /**
  30161. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30162. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30163. */
  30164. vars: any;
  30165. /**
  30166. * This array is populated when the SPS is set as 'pickable'.
  30167. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30168. * Each element of this array is an object `{idx: int, faceId: int}`.
  30169. * `idx` is the picked particle index in the `SPS.particles` array
  30170. * `faceId` is the picked face index counted within this particle.
  30171. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30172. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30173. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30174. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30175. */
  30176. pickedParticles: {
  30177. idx: number;
  30178. faceId: number;
  30179. }[];
  30180. /**
  30181. * This array is populated when the SPS is set as 'pickable'
  30182. * Each key of this array is a submesh index.
  30183. * Each element of this array is a second array defined like this :
  30184. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30185. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30186. * `idx` is the picked particle index in the `SPS.particles` array
  30187. * `faceId` is the picked face index counted within this particle.
  30188. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30189. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30190. */
  30191. pickedBySubMesh: {
  30192. idx: number;
  30193. faceId: number;
  30194. }[][];
  30195. /**
  30196. * This array is populated when `enableDepthSort` is set to true.
  30197. * Each element of this array is an instance of the class DepthSortedParticle.
  30198. */
  30199. depthSortedParticles: DepthSortedParticle[];
  30200. /**
  30201. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30202. * @hidden
  30203. */
  30204. _bSphereOnly: boolean;
  30205. /**
  30206. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30207. * @hidden
  30208. */
  30209. _bSphereRadiusFactor: number;
  30210. private _scene;
  30211. private _positions;
  30212. private _indices;
  30213. private _normals;
  30214. private _colors;
  30215. private _uvs;
  30216. private _indices32;
  30217. private _positions32;
  30218. private _normals32;
  30219. private _fixedNormal32;
  30220. private _colors32;
  30221. private _uvs32;
  30222. private _index;
  30223. private _updatable;
  30224. private _pickable;
  30225. private _isVisibilityBoxLocked;
  30226. private _alwaysVisible;
  30227. private _depthSort;
  30228. private _expandable;
  30229. private _shapeCounter;
  30230. private _copy;
  30231. private _color;
  30232. private _computeParticleColor;
  30233. private _computeParticleTexture;
  30234. private _computeParticleRotation;
  30235. private _computeParticleVertex;
  30236. private _computeBoundingBox;
  30237. private _depthSortParticles;
  30238. private _camera;
  30239. private _mustUnrotateFixedNormals;
  30240. private _particlesIntersect;
  30241. private _needs32Bits;
  30242. private _isNotBuilt;
  30243. private _lastParticleId;
  30244. private _idxOfId;
  30245. private _multimaterialEnabled;
  30246. private _useModelMaterial;
  30247. private _indicesByMaterial;
  30248. private _materialIndexes;
  30249. private _depthSortFunction;
  30250. private _materialSortFunction;
  30251. private _materials;
  30252. private _multimaterial;
  30253. private _materialIndexesById;
  30254. private _defaultMaterial;
  30255. private _autoUpdateSubMeshes;
  30256. private _tmpVertex;
  30257. /**
  30258. * Creates a SPS (Solid Particle System) object.
  30259. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30260. * @param scene (Scene) is the scene in which the SPS is added.
  30261. * @param options defines the options of the sps e.g.
  30262. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30263. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30264. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30265. * * 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.
  30266. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30267. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30268. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30269. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30270. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30271. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30272. */
  30273. constructor(name: string, scene: Scene, options?: {
  30274. updatable?: boolean;
  30275. isPickable?: boolean;
  30276. enableDepthSort?: boolean;
  30277. particleIntersection?: boolean;
  30278. boundingSphereOnly?: boolean;
  30279. bSphereRadiusFactor?: number;
  30280. expandable?: boolean;
  30281. useModelMaterial?: boolean;
  30282. enableMultiMaterial?: boolean;
  30283. });
  30284. /**
  30285. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30286. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30287. * @returns the created mesh
  30288. */
  30289. buildMesh(): Mesh;
  30290. /**
  30291. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30292. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30293. * Thus the particles generated from `digest()` have their property `position` set yet.
  30294. * @param mesh ( Mesh ) is the mesh to be digested
  30295. * @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
  30296. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30297. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30298. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30299. * @returns the current SPS
  30300. */
  30301. digest(mesh: Mesh, options?: {
  30302. facetNb?: number;
  30303. number?: number;
  30304. delta?: number;
  30305. storage?: [];
  30306. }): SolidParticleSystem;
  30307. /**
  30308. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30309. * @hidden
  30310. */
  30311. private _unrotateFixedNormals;
  30312. /**
  30313. * Resets the temporary working copy particle
  30314. * @hidden
  30315. */
  30316. private _resetCopy;
  30317. /**
  30318. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30319. * @param p the current index in the positions array to be updated
  30320. * @param ind the current index in the indices array
  30321. * @param shape a Vector3 array, the shape geometry
  30322. * @param positions the positions array to be updated
  30323. * @param meshInd the shape indices array
  30324. * @param indices the indices array to be updated
  30325. * @param meshUV the shape uv array
  30326. * @param uvs the uv array to be updated
  30327. * @param meshCol the shape color array
  30328. * @param colors the color array to be updated
  30329. * @param meshNor the shape normals array
  30330. * @param normals the normals array to be updated
  30331. * @param idx the particle index
  30332. * @param idxInShape the particle index in its shape
  30333. * @param options the addShape() method passed options
  30334. * @model the particle model
  30335. * @hidden
  30336. */
  30337. private _meshBuilder;
  30338. /**
  30339. * Returns a shape Vector3 array from positions float array
  30340. * @param positions float array
  30341. * @returns a vector3 array
  30342. * @hidden
  30343. */
  30344. private _posToShape;
  30345. /**
  30346. * Returns a shapeUV array from a float uvs (array deep copy)
  30347. * @param uvs as a float array
  30348. * @returns a shapeUV array
  30349. * @hidden
  30350. */
  30351. private _uvsToShapeUV;
  30352. /**
  30353. * Adds a new particle object in the particles array
  30354. * @param idx particle index in particles array
  30355. * @param id particle id
  30356. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30357. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30358. * @param model particle ModelShape object
  30359. * @param shapeId model shape identifier
  30360. * @param idxInShape index of the particle in the current model
  30361. * @param bInfo model bounding info object
  30362. * @param storage target storage array, if any
  30363. * @hidden
  30364. */
  30365. private _addParticle;
  30366. /**
  30367. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30368. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30369. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30370. * @param nb (positive integer) the number of particles to be created from this model
  30371. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30372. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30373. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30374. * @returns the number of shapes in the system
  30375. */
  30376. addShape(mesh: Mesh, nb: number, options?: {
  30377. positionFunction?: any;
  30378. vertexFunction?: any;
  30379. storage?: [];
  30380. }): number;
  30381. /**
  30382. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30383. * @hidden
  30384. */
  30385. private _rebuildParticle;
  30386. /**
  30387. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30388. * @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.
  30389. * @returns the SPS.
  30390. */
  30391. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30392. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30393. * Returns an array with the removed particles.
  30394. * 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.
  30395. * The SPS can't be empty so at least one particle needs to remain in place.
  30396. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30397. * @param start index of the first particle to remove
  30398. * @param end index of the last particle to remove (included)
  30399. * @returns an array populated with the removed particles
  30400. */
  30401. removeParticles(start: number, end: number): SolidParticle[];
  30402. /**
  30403. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30404. * @param solidParticleArray an array populated with Solid Particles objects
  30405. * @returns the SPS
  30406. */
  30407. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30408. /**
  30409. * Creates a new particle and modifies the SPS mesh geometry :
  30410. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30411. * - calls _addParticle() to populate the particle array
  30412. * factorized code from addShape() and insertParticlesFromArray()
  30413. * @param idx particle index in the particles array
  30414. * @param i particle index in its shape
  30415. * @param modelShape particle ModelShape object
  30416. * @param shape shape vertex array
  30417. * @param meshInd shape indices array
  30418. * @param meshUV shape uv array
  30419. * @param meshCol shape color array
  30420. * @param meshNor shape normals array
  30421. * @param bbInfo shape bounding info
  30422. * @param storage target particle storage
  30423. * @options addShape() passed options
  30424. * @hidden
  30425. */
  30426. private _insertNewParticle;
  30427. /**
  30428. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30429. * This method calls `updateParticle()` for each particle of the SPS.
  30430. * For an animated SPS, it is usually called within the render loop.
  30431. * 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.
  30432. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30433. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30434. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30435. * @returns the SPS.
  30436. */
  30437. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30438. /**
  30439. * Disposes the SPS.
  30440. */
  30441. dispose(): void;
  30442. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30443. * idx is the particle index in the SPS
  30444. * faceId is the picked face index counted within this particle.
  30445. * Returns null if the pickInfo can't identify a picked particle.
  30446. * @param pickingInfo (PickingInfo object)
  30447. * @returns {idx: number, faceId: number} or null
  30448. */
  30449. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30450. idx: number;
  30451. faceId: number;
  30452. }>;
  30453. /**
  30454. * Returns a SolidParticle object from its identifier : particle.id
  30455. * @param id (integer) the particle Id
  30456. * @returns the searched particle or null if not found in the SPS.
  30457. */
  30458. getParticleById(id: number): Nullable<SolidParticle>;
  30459. /**
  30460. * Returns a new array populated with the particles having the passed shapeId.
  30461. * @param shapeId (integer) the shape identifier
  30462. * @returns a new solid particle array
  30463. */
  30464. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30465. /**
  30466. * Populates the passed array "ref" with the particles having the passed shapeId.
  30467. * @param shapeId the shape identifier
  30468. * @returns the SPS
  30469. * @param ref
  30470. */
  30471. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30472. /**
  30473. * Computes the required SubMeshes according the materials assigned to the particles.
  30474. * @returns the solid particle system.
  30475. * Does nothing if called before the SPS mesh is built.
  30476. */
  30477. computeSubMeshes(): SolidParticleSystem;
  30478. /**
  30479. * Sorts the solid particles by material when MultiMaterial is enabled.
  30480. * Updates the indices32 array.
  30481. * Updates the indicesByMaterial array.
  30482. * Updates the mesh indices array.
  30483. * @returns the SPS
  30484. * @hidden
  30485. */
  30486. private _sortParticlesByMaterial;
  30487. /**
  30488. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30489. * @hidden
  30490. */
  30491. private _setMaterialIndexesById;
  30492. /**
  30493. * Returns an array with unique values of Materials from the passed array
  30494. * @param array the material array to be checked and filtered
  30495. * @hidden
  30496. */
  30497. private _filterUniqueMaterialId;
  30498. /**
  30499. * Sets a new Standard Material as _defaultMaterial if not already set.
  30500. * @hidden
  30501. */
  30502. private _setDefaultMaterial;
  30503. /**
  30504. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30505. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30506. * @returns the SPS.
  30507. */
  30508. refreshVisibleSize(): SolidParticleSystem;
  30509. /**
  30510. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30511. * @param size the size (float) of the visibility box
  30512. * note : this doesn't lock the SPS mesh bounding box.
  30513. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30514. */
  30515. setVisibilityBox(size: number): void;
  30516. /**
  30517. * Gets whether the SPS as always visible or not
  30518. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30519. */
  30520. get isAlwaysVisible(): boolean;
  30521. /**
  30522. * Sets the SPS as always visible or not
  30523. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30524. */
  30525. set isAlwaysVisible(val: boolean);
  30526. /**
  30527. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30528. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30529. */
  30530. set isVisibilityBoxLocked(val: boolean);
  30531. /**
  30532. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30533. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30534. */
  30535. get isVisibilityBoxLocked(): boolean;
  30536. /**
  30537. * Tells to `setParticles()` to compute the particle rotations or not.
  30538. * Default value : true. The SPS is faster when it's set to false.
  30539. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30540. */
  30541. set computeParticleRotation(val: boolean);
  30542. /**
  30543. * Tells to `setParticles()` to compute the particle colors or not.
  30544. * Default value : true. The SPS is faster when it's set to false.
  30545. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30546. */
  30547. set computeParticleColor(val: boolean);
  30548. set computeParticleTexture(val: boolean);
  30549. /**
  30550. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30551. * Default value : false. The SPS is faster when it's set to false.
  30552. * Note : the particle custom vertex positions aren't stored values.
  30553. */
  30554. set computeParticleVertex(val: boolean);
  30555. /**
  30556. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30557. */
  30558. set computeBoundingBox(val: boolean);
  30559. /**
  30560. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30561. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30562. * Default : `true`
  30563. */
  30564. set depthSortParticles(val: boolean);
  30565. /**
  30566. * Gets if `setParticles()` computes the particle rotations or not.
  30567. * Default value : true. The SPS is faster when it's set to false.
  30568. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30569. */
  30570. get computeParticleRotation(): boolean;
  30571. /**
  30572. * Gets if `setParticles()` computes the particle colors or not.
  30573. * Default value : true. The SPS is faster when it's set to false.
  30574. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30575. */
  30576. get computeParticleColor(): boolean;
  30577. /**
  30578. * Gets if `setParticles()` computes the particle textures or not.
  30579. * Default value : true. The SPS is faster when it's set to false.
  30580. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30581. */
  30582. get computeParticleTexture(): boolean;
  30583. /**
  30584. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30585. * Default value : false. The SPS is faster when it's set to false.
  30586. * Note : the particle custom vertex positions aren't stored values.
  30587. */
  30588. get computeParticleVertex(): boolean;
  30589. /**
  30590. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30591. */
  30592. get computeBoundingBox(): boolean;
  30593. /**
  30594. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30595. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30596. * Default : `true`
  30597. */
  30598. get depthSortParticles(): boolean;
  30599. /**
  30600. * Gets if the SPS is created as expandable at construction time.
  30601. * Default : `false`
  30602. */
  30603. get expandable(): boolean;
  30604. /**
  30605. * Gets if the SPS supports the Multi Materials
  30606. */
  30607. get multimaterialEnabled(): boolean;
  30608. /**
  30609. * Gets if the SPS uses the model materials for its own multimaterial.
  30610. */
  30611. get useModelMaterial(): boolean;
  30612. /**
  30613. * The SPS used material array.
  30614. */
  30615. get materials(): Material[];
  30616. /**
  30617. * Sets the SPS MultiMaterial from the passed materials.
  30618. * Note : the passed array is internally copied and not used then by reference.
  30619. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30620. */
  30621. setMultiMaterial(materials: Material[]): void;
  30622. /**
  30623. * The SPS computed multimaterial object
  30624. */
  30625. get multimaterial(): MultiMaterial;
  30626. set multimaterial(mm: MultiMaterial);
  30627. /**
  30628. * If the subMeshes must be updated on the next call to setParticles()
  30629. */
  30630. get autoUpdateSubMeshes(): boolean;
  30631. set autoUpdateSubMeshes(val: boolean);
  30632. /**
  30633. * This function does nothing. It may be overwritten to set all the particle first values.
  30634. * The SPS doesn't call this function, you may have to call it by your own.
  30635. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30636. */
  30637. initParticles(): void;
  30638. /**
  30639. * This function does nothing. It may be overwritten to recycle a particle.
  30640. * The SPS doesn't call this function, you may have to call it by your own.
  30641. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30642. * @param particle The particle to recycle
  30643. * @returns the recycled particle
  30644. */
  30645. recycleParticle(particle: SolidParticle): SolidParticle;
  30646. /**
  30647. * Updates a particle : this function should be overwritten by the user.
  30648. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30649. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30650. * @example : just set a particle position or velocity and recycle conditions
  30651. * @param particle The particle to update
  30652. * @returns the updated particle
  30653. */
  30654. updateParticle(particle: SolidParticle): SolidParticle;
  30655. /**
  30656. * Updates a vertex of a particle : it can be overwritten by the user.
  30657. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30658. * @param particle the current particle
  30659. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30660. * @param pt the index of the current vertex in the particle shape
  30661. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30662. * @example : just set a vertex particle position or color
  30663. * @returns the sps
  30664. */
  30665. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30666. /**
  30667. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30668. * This does nothing and may be overwritten by the user.
  30669. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30670. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30671. * @param update the boolean update value actually passed to setParticles()
  30672. */
  30673. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30674. /**
  30675. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30676. * This will be passed three parameters.
  30677. * This does nothing and may be overwritten by the user.
  30678. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30679. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30680. * @param update the boolean update value actually passed to setParticles()
  30681. */
  30682. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30683. }
  30684. }
  30685. declare module BABYLON {
  30686. /**
  30687. * Represents one particle of a solid particle system.
  30688. */
  30689. export class SolidParticle {
  30690. /**
  30691. * particle global index
  30692. */
  30693. idx: number;
  30694. /**
  30695. * particle identifier
  30696. */
  30697. id: number;
  30698. /**
  30699. * The color of the particle
  30700. */
  30701. color: Nullable<Color4>;
  30702. /**
  30703. * The world space position of the particle.
  30704. */
  30705. position: Vector3;
  30706. /**
  30707. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30708. */
  30709. rotation: Vector3;
  30710. /**
  30711. * The world space rotation quaternion of the particle.
  30712. */
  30713. rotationQuaternion: Nullable<Quaternion>;
  30714. /**
  30715. * The scaling of the particle.
  30716. */
  30717. scaling: Vector3;
  30718. /**
  30719. * The uvs of the particle.
  30720. */
  30721. uvs: Vector4;
  30722. /**
  30723. * The current speed of the particle.
  30724. */
  30725. velocity: Vector3;
  30726. /**
  30727. * The pivot point in the particle local space.
  30728. */
  30729. pivot: Vector3;
  30730. /**
  30731. * Must the particle be translated from its pivot point in its local space ?
  30732. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30733. * Default : false
  30734. */
  30735. translateFromPivot: boolean;
  30736. /**
  30737. * Is the particle active or not ?
  30738. */
  30739. alive: boolean;
  30740. /**
  30741. * Is the particle visible or not ?
  30742. */
  30743. isVisible: boolean;
  30744. /**
  30745. * Index of this particle in the global "positions" array (Internal use)
  30746. * @hidden
  30747. */
  30748. _pos: number;
  30749. /**
  30750. * @hidden Index of this particle in the global "indices" array (Internal use)
  30751. */
  30752. _ind: number;
  30753. /**
  30754. * @hidden ModelShape of this particle (Internal use)
  30755. */
  30756. _model: ModelShape;
  30757. /**
  30758. * ModelShape id of this particle
  30759. */
  30760. shapeId: number;
  30761. /**
  30762. * Index of the particle in its shape id
  30763. */
  30764. idxInShape: number;
  30765. /**
  30766. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30767. */
  30768. _modelBoundingInfo: BoundingInfo;
  30769. /**
  30770. * @hidden Particle BoundingInfo object (Internal use)
  30771. */
  30772. _boundingInfo: BoundingInfo;
  30773. /**
  30774. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30775. */
  30776. _sps: SolidParticleSystem;
  30777. /**
  30778. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30779. */
  30780. _stillInvisible: boolean;
  30781. /**
  30782. * @hidden Last computed particle rotation matrix
  30783. */
  30784. _rotationMatrix: number[];
  30785. /**
  30786. * Parent particle Id, if any.
  30787. * Default null.
  30788. */
  30789. parentId: Nullable<number>;
  30790. /**
  30791. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30792. */
  30793. materialIndex: Nullable<number>;
  30794. /**
  30795. * Custom object or properties.
  30796. */
  30797. props: Nullable<any>;
  30798. /**
  30799. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30800. * The possible values are :
  30801. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30802. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30803. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30804. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30805. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30806. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30807. * */
  30808. cullingStrategy: number;
  30809. /**
  30810. * @hidden Internal global position in the SPS.
  30811. */
  30812. _globalPosition: Vector3;
  30813. /**
  30814. * Creates a Solid Particle object.
  30815. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30816. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30817. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30818. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30819. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30820. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30821. * @param shapeId (integer) is the model shape identifier in the SPS.
  30822. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30823. * @param sps defines the sps it is associated to
  30824. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30825. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30826. */
  30827. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30828. /**
  30829. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30830. * @param target the particle target
  30831. * @returns the current particle
  30832. */
  30833. copyToRef(target: SolidParticle): SolidParticle;
  30834. /**
  30835. * Legacy support, changed scale to scaling
  30836. */
  30837. get scale(): Vector3;
  30838. /**
  30839. * Legacy support, changed scale to scaling
  30840. */
  30841. set scale(scale: Vector3);
  30842. /**
  30843. * Legacy support, changed quaternion to rotationQuaternion
  30844. */
  30845. get quaternion(): Nullable<Quaternion>;
  30846. /**
  30847. * Legacy support, changed quaternion to rotationQuaternion
  30848. */
  30849. set quaternion(q: Nullable<Quaternion>);
  30850. /**
  30851. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30852. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30853. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30854. * @returns true if it intersects
  30855. */
  30856. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30857. /**
  30858. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30859. * A particle is in the frustum if its bounding box intersects the frustum
  30860. * @param frustumPlanes defines the frustum to test
  30861. * @returns true if the particle is in the frustum planes
  30862. */
  30863. isInFrustum(frustumPlanes: Plane[]): boolean;
  30864. /**
  30865. * get the rotation matrix of the particle
  30866. * @hidden
  30867. */
  30868. getRotationMatrix(m: Matrix): void;
  30869. }
  30870. /**
  30871. * Represents the shape of the model used by one particle of a solid particle system.
  30872. * SPS internal tool, don't use it manually.
  30873. */
  30874. export class ModelShape {
  30875. /**
  30876. * The shape id
  30877. * @hidden
  30878. */
  30879. shapeID: number;
  30880. /**
  30881. * flat array of model positions (internal use)
  30882. * @hidden
  30883. */
  30884. _shape: Vector3[];
  30885. /**
  30886. * flat array of model UVs (internal use)
  30887. * @hidden
  30888. */
  30889. _shapeUV: number[];
  30890. /**
  30891. * color array of the model
  30892. * @hidden
  30893. */
  30894. _shapeColors: number[];
  30895. /**
  30896. * indices array of the model
  30897. * @hidden
  30898. */
  30899. _indices: number[];
  30900. /**
  30901. * normals array of the model
  30902. * @hidden
  30903. */
  30904. _normals: number[];
  30905. /**
  30906. * length of the shape in the model indices array (internal use)
  30907. * @hidden
  30908. */
  30909. _indicesLength: number;
  30910. /**
  30911. * Custom position function (internal use)
  30912. * @hidden
  30913. */
  30914. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30915. /**
  30916. * Custom vertex function (internal use)
  30917. * @hidden
  30918. */
  30919. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30920. /**
  30921. * Model material (internal use)
  30922. * @hidden
  30923. */
  30924. _material: Nullable<Material>;
  30925. /**
  30926. * 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.
  30927. * SPS internal tool, don't use it manually.
  30928. * @hidden
  30929. */
  30930. 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>);
  30931. }
  30932. /**
  30933. * Represents a Depth Sorted Particle in the solid particle system.
  30934. * @hidden
  30935. */
  30936. export class DepthSortedParticle {
  30937. /**
  30938. * Particle index
  30939. */
  30940. idx: number;
  30941. /**
  30942. * Index of the particle in the "indices" array
  30943. */
  30944. ind: number;
  30945. /**
  30946. * Length of the particle shape in the "indices" array
  30947. */
  30948. indicesLength: number;
  30949. /**
  30950. * Squared distance from the particle to the camera
  30951. */
  30952. sqDistance: number;
  30953. /**
  30954. * Material index when used with MultiMaterials
  30955. */
  30956. materialIndex: number;
  30957. /**
  30958. * Creates a new sorted particle
  30959. * @param materialIndex
  30960. */
  30961. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30962. }
  30963. /**
  30964. * Represents a solid particle vertex
  30965. */
  30966. export class SolidParticleVertex {
  30967. /**
  30968. * Vertex position
  30969. */
  30970. position: Vector3;
  30971. /**
  30972. * Vertex color
  30973. */
  30974. color: Color4;
  30975. /**
  30976. * Vertex UV
  30977. */
  30978. uv: Vector2;
  30979. /**
  30980. * Creates a new solid particle vertex
  30981. */
  30982. constructor();
  30983. /** Vertex x coordinate */
  30984. get x(): number;
  30985. set x(val: number);
  30986. /** Vertex y coordinate */
  30987. get y(): number;
  30988. set y(val: number);
  30989. /** Vertex z coordinate */
  30990. get z(): number;
  30991. set z(val: number);
  30992. }
  30993. }
  30994. declare module BABYLON {
  30995. /**
  30996. * @hidden
  30997. */
  30998. export class _MeshCollisionData {
  30999. _checkCollisions: boolean;
  31000. _collisionMask: number;
  31001. _collisionGroup: number;
  31002. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31003. _collider: Nullable<Collider>;
  31004. _oldPositionForCollisions: Vector3;
  31005. _diffPositionForCollisions: Vector3;
  31006. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31007. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31008. }
  31009. }
  31010. declare module BABYLON {
  31011. /** @hidden */
  31012. class _FacetDataStorage {
  31013. facetPositions: Vector3[];
  31014. facetNormals: Vector3[];
  31015. facetPartitioning: number[][];
  31016. facetNb: number;
  31017. partitioningSubdivisions: number;
  31018. partitioningBBoxRatio: number;
  31019. facetDataEnabled: boolean;
  31020. facetParameters: any;
  31021. bbSize: Vector3;
  31022. subDiv: {
  31023. max: number;
  31024. X: number;
  31025. Y: number;
  31026. Z: number;
  31027. };
  31028. facetDepthSort: boolean;
  31029. facetDepthSortEnabled: boolean;
  31030. depthSortedIndices: IndicesArray;
  31031. depthSortedFacets: {
  31032. ind: number;
  31033. sqDistance: number;
  31034. }[];
  31035. facetDepthSortFunction: (f1: {
  31036. ind: number;
  31037. sqDistance: number;
  31038. }, f2: {
  31039. ind: number;
  31040. sqDistance: number;
  31041. }) => number;
  31042. facetDepthSortFrom: Vector3;
  31043. facetDepthSortOrigin: Vector3;
  31044. invertedMatrix: Matrix;
  31045. }
  31046. /**
  31047. * @hidden
  31048. **/
  31049. class _InternalAbstractMeshDataInfo {
  31050. _hasVertexAlpha: boolean;
  31051. _useVertexColors: boolean;
  31052. _numBoneInfluencers: number;
  31053. _applyFog: boolean;
  31054. _receiveShadows: boolean;
  31055. _facetData: _FacetDataStorage;
  31056. _visibility: number;
  31057. _skeleton: Nullable<Skeleton>;
  31058. _layerMask: number;
  31059. _computeBonesUsingShaders: boolean;
  31060. _isActive: boolean;
  31061. _onlyForInstances: boolean;
  31062. _isActiveIntermediate: boolean;
  31063. _onlyForInstancesIntermediate: boolean;
  31064. _actAsRegularMesh: boolean;
  31065. }
  31066. /**
  31067. * Class used to store all common mesh properties
  31068. */
  31069. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31070. /** No occlusion */
  31071. static OCCLUSION_TYPE_NONE: number;
  31072. /** Occlusion set to optimisitic */
  31073. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31074. /** Occlusion set to strict */
  31075. static OCCLUSION_TYPE_STRICT: number;
  31076. /** Use an accurante occlusion algorithm */
  31077. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31078. /** Use a conservative occlusion algorithm */
  31079. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31080. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31081. * Test order :
  31082. * Is the bounding sphere outside the frustum ?
  31083. * If not, are the bounding box vertices outside the frustum ?
  31084. * It not, then the cullable object is in the frustum.
  31085. */
  31086. static readonly CULLINGSTRATEGY_STANDARD: number;
  31087. /** Culling strategy : Bounding Sphere Only.
  31088. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31089. * It's also less accurate than the standard because some not visible objects can still be selected.
  31090. * Test : is the bounding sphere outside the frustum ?
  31091. * If not, then the cullable object is in the frustum.
  31092. */
  31093. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31094. /** Culling strategy : Optimistic Inclusion.
  31095. * This in an inclusion test first, then the standard exclusion test.
  31096. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31097. * 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.
  31098. * Anyway, it's as accurate as the standard strategy.
  31099. * Test :
  31100. * Is the cullable object bounding sphere center in the frustum ?
  31101. * If not, apply the default culling strategy.
  31102. */
  31103. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31104. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31105. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31106. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31107. * 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.
  31108. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31109. * Test :
  31110. * Is the cullable object bounding sphere center in the frustum ?
  31111. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31112. */
  31113. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31114. /**
  31115. * No billboard
  31116. */
  31117. static get BILLBOARDMODE_NONE(): number;
  31118. /** Billboard on X axis */
  31119. static get BILLBOARDMODE_X(): number;
  31120. /** Billboard on Y axis */
  31121. static get BILLBOARDMODE_Y(): number;
  31122. /** Billboard on Z axis */
  31123. static get BILLBOARDMODE_Z(): number;
  31124. /** Billboard on all axes */
  31125. static get BILLBOARDMODE_ALL(): number;
  31126. /** Billboard on using position instead of orientation */
  31127. static get BILLBOARDMODE_USE_POSITION(): number;
  31128. /** @hidden */
  31129. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31130. /**
  31131. * The culling strategy to use to check whether the mesh must be rendered or not.
  31132. * This value can be changed at any time and will be used on the next render mesh selection.
  31133. * The possible values are :
  31134. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31135. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31136. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31137. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31138. * Please read each static variable documentation to get details about the culling process.
  31139. * */
  31140. cullingStrategy: number;
  31141. /**
  31142. * Gets the number of facets in the mesh
  31143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31144. */
  31145. get facetNb(): number;
  31146. /**
  31147. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31149. */
  31150. get partitioningSubdivisions(): number;
  31151. set partitioningSubdivisions(nb: number);
  31152. /**
  31153. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31154. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31155. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31156. */
  31157. get partitioningBBoxRatio(): number;
  31158. set partitioningBBoxRatio(ratio: number);
  31159. /**
  31160. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31161. * Works only for updatable meshes.
  31162. * Doesn't work with multi-materials
  31163. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31164. */
  31165. get mustDepthSortFacets(): boolean;
  31166. set mustDepthSortFacets(sort: boolean);
  31167. /**
  31168. * The location (Vector3) where the facet depth sort must be computed from.
  31169. * By default, the active camera position.
  31170. * Used only when facet depth sort is enabled
  31171. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31172. */
  31173. get facetDepthSortFrom(): Vector3;
  31174. set facetDepthSortFrom(location: Vector3);
  31175. /**
  31176. * gets a boolean indicating if facetData is enabled
  31177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31178. */
  31179. get isFacetDataEnabled(): boolean;
  31180. /** @hidden */
  31181. _updateNonUniformScalingState(value: boolean): boolean;
  31182. /**
  31183. * An event triggered when this mesh collides with another one
  31184. */
  31185. onCollideObservable: Observable<AbstractMesh>;
  31186. /** Set a function to call when this mesh collides with another one */
  31187. set onCollide(callback: () => void);
  31188. /**
  31189. * An event triggered when the collision's position changes
  31190. */
  31191. onCollisionPositionChangeObservable: Observable<Vector3>;
  31192. /** Set a function to call when the collision's position changes */
  31193. set onCollisionPositionChange(callback: () => void);
  31194. /**
  31195. * An event triggered when material is changed
  31196. */
  31197. onMaterialChangedObservable: Observable<AbstractMesh>;
  31198. /**
  31199. * Gets or sets the orientation for POV movement & rotation
  31200. */
  31201. definedFacingForward: boolean;
  31202. /** @hidden */
  31203. _occlusionQuery: Nullable<WebGLQuery>;
  31204. /** @hidden */
  31205. _renderingGroup: Nullable<RenderingGroup>;
  31206. /**
  31207. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31208. */
  31209. get visibility(): number;
  31210. /**
  31211. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31212. */
  31213. set visibility(value: number);
  31214. /** Gets or sets the alpha index used to sort transparent meshes
  31215. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31216. */
  31217. alphaIndex: number;
  31218. /**
  31219. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31220. */
  31221. isVisible: boolean;
  31222. /**
  31223. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31224. */
  31225. isPickable: boolean;
  31226. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31227. showSubMeshesBoundingBox: boolean;
  31228. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31229. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31230. */
  31231. isBlocker: boolean;
  31232. /**
  31233. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31234. */
  31235. enablePointerMoveEvents: boolean;
  31236. /**
  31237. * Specifies the rendering group id for this mesh (0 by default)
  31238. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31239. */
  31240. renderingGroupId: number;
  31241. private _material;
  31242. /** Gets or sets current material */
  31243. get material(): Nullable<Material>;
  31244. set material(value: Nullable<Material>);
  31245. /**
  31246. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31247. * @see http://doc.babylonjs.com/babylon101/shadows
  31248. */
  31249. get receiveShadows(): boolean;
  31250. set receiveShadows(value: boolean);
  31251. /** Defines color to use when rendering outline */
  31252. outlineColor: Color3;
  31253. /** Define width to use when rendering outline */
  31254. outlineWidth: number;
  31255. /** Defines color to use when rendering overlay */
  31256. overlayColor: Color3;
  31257. /** Defines alpha to use when rendering overlay */
  31258. overlayAlpha: number;
  31259. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31260. get hasVertexAlpha(): boolean;
  31261. set hasVertexAlpha(value: boolean);
  31262. /** 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) */
  31263. get useVertexColors(): boolean;
  31264. set useVertexColors(value: boolean);
  31265. /**
  31266. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31267. */
  31268. get computeBonesUsingShaders(): boolean;
  31269. set computeBonesUsingShaders(value: boolean);
  31270. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31271. get numBoneInfluencers(): number;
  31272. set numBoneInfluencers(value: number);
  31273. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31274. get applyFog(): boolean;
  31275. set applyFog(value: boolean);
  31276. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31277. useOctreeForRenderingSelection: boolean;
  31278. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31279. useOctreeForPicking: boolean;
  31280. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31281. useOctreeForCollisions: boolean;
  31282. /**
  31283. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31284. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31285. */
  31286. get layerMask(): number;
  31287. set layerMask(value: number);
  31288. /**
  31289. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31290. */
  31291. alwaysSelectAsActiveMesh: boolean;
  31292. /**
  31293. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31294. */
  31295. doNotSyncBoundingInfo: boolean;
  31296. /**
  31297. * Gets or sets the current action manager
  31298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31299. */
  31300. actionManager: Nullable<AbstractActionManager>;
  31301. private _meshCollisionData;
  31302. /**
  31303. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31304. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31305. */
  31306. ellipsoid: Vector3;
  31307. /**
  31308. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31309. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31310. */
  31311. ellipsoidOffset: Vector3;
  31312. /**
  31313. * Gets or sets a collision mask used to mask collisions (default is -1).
  31314. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31315. */
  31316. get collisionMask(): number;
  31317. set collisionMask(mask: number);
  31318. /**
  31319. * Gets or sets the current collision group mask (-1 by default).
  31320. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31321. */
  31322. get collisionGroup(): number;
  31323. set collisionGroup(mask: number);
  31324. /**
  31325. * Gets or sets current surrounding meshes (null by default).
  31326. *
  31327. * By default collision detection is tested against every mesh in the scene.
  31328. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31329. * meshes will be tested for the collision.
  31330. *
  31331. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31332. */
  31333. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31334. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31335. /**
  31336. * Defines edge width used when edgesRenderer is enabled
  31337. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31338. */
  31339. edgesWidth: number;
  31340. /**
  31341. * Defines edge color used when edgesRenderer is enabled
  31342. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31343. */
  31344. edgesColor: Color4;
  31345. /** @hidden */
  31346. _edgesRenderer: Nullable<IEdgesRenderer>;
  31347. /** @hidden */
  31348. _masterMesh: Nullable<AbstractMesh>;
  31349. /** @hidden */
  31350. _boundingInfo: Nullable<BoundingInfo>;
  31351. /** @hidden */
  31352. _renderId: number;
  31353. /**
  31354. * Gets or sets the list of subMeshes
  31355. * @see http://doc.babylonjs.com/how_to/multi_materials
  31356. */
  31357. subMeshes: SubMesh[];
  31358. /** @hidden */
  31359. _intersectionsInProgress: AbstractMesh[];
  31360. /** @hidden */
  31361. _unIndexed: boolean;
  31362. /** @hidden */
  31363. _lightSources: Light[];
  31364. /** Gets the list of lights affecting that mesh */
  31365. get lightSources(): Light[];
  31366. /** @hidden */
  31367. get _positions(): Nullable<Vector3[]>;
  31368. /** @hidden */
  31369. _waitingData: {
  31370. lods: Nullable<any>;
  31371. actions: Nullable<any>;
  31372. freezeWorldMatrix: Nullable<boolean>;
  31373. };
  31374. /** @hidden */
  31375. _bonesTransformMatrices: Nullable<Float32Array>;
  31376. /** @hidden */
  31377. _transformMatrixTexture: Nullable<RawTexture>;
  31378. /**
  31379. * Gets or sets a skeleton to apply skining transformations
  31380. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31381. */
  31382. set skeleton(value: Nullable<Skeleton>);
  31383. get skeleton(): Nullable<Skeleton>;
  31384. /**
  31385. * An event triggered when the mesh is rebuilt.
  31386. */
  31387. onRebuildObservable: Observable<AbstractMesh>;
  31388. /**
  31389. * Creates a new AbstractMesh
  31390. * @param name defines the name of the mesh
  31391. * @param scene defines the hosting scene
  31392. */
  31393. constructor(name: string, scene?: Nullable<Scene>);
  31394. /**
  31395. * Returns the string "AbstractMesh"
  31396. * @returns "AbstractMesh"
  31397. */
  31398. getClassName(): string;
  31399. /**
  31400. * Gets a string representation of the current mesh
  31401. * @param fullDetails defines a boolean indicating if full details must be included
  31402. * @returns a string representation of the current mesh
  31403. */
  31404. toString(fullDetails?: boolean): string;
  31405. /**
  31406. * @hidden
  31407. */
  31408. protected _getEffectiveParent(): Nullable<Node>;
  31409. /** @hidden */
  31410. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31411. /** @hidden */
  31412. _rebuild(): void;
  31413. /** @hidden */
  31414. _resyncLightSources(): void;
  31415. /** @hidden */
  31416. _resyncLightSource(light: Light): void;
  31417. /** @hidden */
  31418. _unBindEffect(): void;
  31419. /** @hidden */
  31420. _removeLightSource(light: Light, dispose: boolean): void;
  31421. private _markSubMeshesAsDirty;
  31422. /** @hidden */
  31423. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31424. /** @hidden */
  31425. _markSubMeshesAsAttributesDirty(): void;
  31426. /** @hidden */
  31427. _markSubMeshesAsMiscDirty(): void;
  31428. /**
  31429. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31430. */
  31431. get scaling(): Vector3;
  31432. set scaling(newScaling: Vector3);
  31433. /**
  31434. * Returns true if the mesh is blocked. Implemented by child classes
  31435. */
  31436. get isBlocked(): boolean;
  31437. /**
  31438. * Returns the mesh itself by default. Implemented by child classes
  31439. * @param camera defines the camera to use to pick the right LOD level
  31440. * @returns the currentAbstractMesh
  31441. */
  31442. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31443. /**
  31444. * Returns 0 by default. Implemented by child classes
  31445. * @returns an integer
  31446. */
  31447. getTotalVertices(): number;
  31448. /**
  31449. * Returns a positive integer : the total number of indices in this mesh geometry.
  31450. * @returns the numner of indices or zero if the mesh has no geometry.
  31451. */
  31452. getTotalIndices(): number;
  31453. /**
  31454. * Returns null by default. Implemented by child classes
  31455. * @returns null
  31456. */
  31457. getIndices(): Nullable<IndicesArray>;
  31458. /**
  31459. * Returns the array of the requested vertex data kind. Implemented by child classes
  31460. * @param kind defines the vertex data kind to use
  31461. * @returns null
  31462. */
  31463. getVerticesData(kind: string): Nullable<FloatArray>;
  31464. /**
  31465. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31466. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31467. * Note that a new underlying VertexBuffer object is created each call.
  31468. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31469. * @param kind defines vertex data kind:
  31470. * * VertexBuffer.PositionKind
  31471. * * VertexBuffer.UVKind
  31472. * * VertexBuffer.UV2Kind
  31473. * * VertexBuffer.UV3Kind
  31474. * * VertexBuffer.UV4Kind
  31475. * * VertexBuffer.UV5Kind
  31476. * * VertexBuffer.UV6Kind
  31477. * * VertexBuffer.ColorKind
  31478. * * VertexBuffer.MatricesIndicesKind
  31479. * * VertexBuffer.MatricesIndicesExtraKind
  31480. * * VertexBuffer.MatricesWeightsKind
  31481. * * VertexBuffer.MatricesWeightsExtraKind
  31482. * @param data defines the data source
  31483. * @param updatable defines if the data must be flagged as updatable (or static)
  31484. * @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
  31485. * @returns the current mesh
  31486. */
  31487. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31488. /**
  31489. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31490. * If the mesh has no geometry, it is simply returned as it is.
  31491. * @param kind defines vertex data kind:
  31492. * * VertexBuffer.PositionKind
  31493. * * VertexBuffer.UVKind
  31494. * * VertexBuffer.UV2Kind
  31495. * * VertexBuffer.UV3Kind
  31496. * * VertexBuffer.UV4Kind
  31497. * * VertexBuffer.UV5Kind
  31498. * * VertexBuffer.UV6Kind
  31499. * * VertexBuffer.ColorKind
  31500. * * VertexBuffer.MatricesIndicesKind
  31501. * * VertexBuffer.MatricesIndicesExtraKind
  31502. * * VertexBuffer.MatricesWeightsKind
  31503. * * VertexBuffer.MatricesWeightsExtraKind
  31504. * @param data defines the data source
  31505. * @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
  31506. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31507. * @returns the current mesh
  31508. */
  31509. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31510. /**
  31511. * Sets the mesh indices,
  31512. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31513. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31514. * @param totalVertices Defines the total number of vertices
  31515. * @returns the current mesh
  31516. */
  31517. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31518. /**
  31519. * Gets a boolean indicating if specific vertex data is present
  31520. * @param kind defines the vertex data kind to use
  31521. * @returns true is data kind is present
  31522. */
  31523. isVerticesDataPresent(kind: string): boolean;
  31524. /**
  31525. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31526. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31527. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31528. * @returns a BoundingInfo
  31529. */
  31530. getBoundingInfo(): BoundingInfo;
  31531. /**
  31532. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31533. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31534. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31535. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31536. * @returns the current mesh
  31537. */
  31538. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31539. /**
  31540. * Overwrite the current bounding info
  31541. * @param boundingInfo defines the new bounding info
  31542. * @returns the current mesh
  31543. */
  31544. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31545. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31546. get useBones(): boolean;
  31547. /** @hidden */
  31548. _preActivate(): void;
  31549. /** @hidden */
  31550. _preActivateForIntermediateRendering(renderId: number): void;
  31551. /** @hidden */
  31552. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31553. /** @hidden */
  31554. _postActivate(): void;
  31555. /** @hidden */
  31556. _freeze(): void;
  31557. /** @hidden */
  31558. _unFreeze(): void;
  31559. /**
  31560. * Gets the current world matrix
  31561. * @returns a Matrix
  31562. */
  31563. getWorldMatrix(): Matrix;
  31564. /** @hidden */
  31565. _getWorldMatrixDeterminant(): number;
  31566. /**
  31567. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31568. */
  31569. get isAnInstance(): boolean;
  31570. /**
  31571. * Gets a boolean indicating if this mesh has instances
  31572. */
  31573. get hasInstances(): boolean;
  31574. /**
  31575. * Gets a boolean indicating if this mesh has thin instances
  31576. */
  31577. get hasThinInstances(): boolean;
  31578. /**
  31579. * Perform relative position change from the point of view of behind the front of the mesh.
  31580. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31581. * Supports definition of mesh facing forward or backward
  31582. * @param amountRight defines the distance on the right axis
  31583. * @param amountUp defines the distance on the up axis
  31584. * @param amountForward defines the distance on the forward axis
  31585. * @returns the current mesh
  31586. */
  31587. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31588. /**
  31589. * Calculate relative position change from the point of view of behind the front of the mesh.
  31590. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31591. * Supports definition of mesh facing forward or backward
  31592. * @param amountRight defines the distance on the right axis
  31593. * @param amountUp defines the distance on the up axis
  31594. * @param amountForward defines the distance on the forward axis
  31595. * @returns the new displacement vector
  31596. */
  31597. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31598. /**
  31599. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31600. * Supports definition of mesh facing forward or backward
  31601. * @param flipBack defines the flip
  31602. * @param twirlClockwise defines the twirl
  31603. * @param tiltRight defines the tilt
  31604. * @returns the current mesh
  31605. */
  31606. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31607. /**
  31608. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31609. * Supports definition of mesh facing forward or backward.
  31610. * @param flipBack defines the flip
  31611. * @param twirlClockwise defines the twirl
  31612. * @param tiltRight defines the tilt
  31613. * @returns the new rotation vector
  31614. */
  31615. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31616. /**
  31617. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31618. * This means the mesh underlying bounding box and sphere are recomputed.
  31619. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31620. * @returns the current mesh
  31621. */
  31622. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31623. /** @hidden */
  31624. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31625. /** @hidden */
  31626. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31627. /** @hidden */
  31628. _updateBoundingInfo(): AbstractMesh;
  31629. /** @hidden */
  31630. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31631. /** @hidden */
  31632. protected _afterComputeWorldMatrix(): void;
  31633. /** @hidden */
  31634. get _effectiveMesh(): AbstractMesh;
  31635. /**
  31636. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31637. * A mesh is in the frustum if its bounding box intersects the frustum
  31638. * @param frustumPlanes defines the frustum to test
  31639. * @returns true if the mesh is in the frustum planes
  31640. */
  31641. isInFrustum(frustumPlanes: Plane[]): boolean;
  31642. /**
  31643. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31644. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31645. * @param frustumPlanes defines the frustum to test
  31646. * @returns true if the mesh is completely in the frustum planes
  31647. */
  31648. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31649. /**
  31650. * True if the mesh intersects another mesh or a SolidParticle object
  31651. * @param mesh defines a target mesh or SolidParticle to test
  31652. * @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)
  31653. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31654. * @returns true if there is an intersection
  31655. */
  31656. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31657. /**
  31658. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31659. * @param point defines the point to test
  31660. * @returns true if there is an intersection
  31661. */
  31662. intersectsPoint(point: Vector3): boolean;
  31663. /**
  31664. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31665. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31666. */
  31667. get checkCollisions(): boolean;
  31668. set checkCollisions(collisionEnabled: boolean);
  31669. /**
  31670. * Gets Collider object used to compute collisions (not physics)
  31671. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31672. */
  31673. get collider(): Nullable<Collider>;
  31674. /**
  31675. * Move the mesh using collision engine
  31676. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31677. * @param displacement defines the requested displacement vector
  31678. * @returns the current mesh
  31679. */
  31680. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31681. private _onCollisionPositionChange;
  31682. /** @hidden */
  31683. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31684. /** @hidden */
  31685. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31686. /** @hidden */
  31687. _checkCollision(collider: Collider): AbstractMesh;
  31688. /** @hidden */
  31689. _generatePointsArray(): boolean;
  31690. /**
  31691. * Checks if the passed Ray intersects with the mesh
  31692. * @param ray defines the ray to use
  31693. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31694. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31695. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31696. * @returns the picking info
  31697. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31698. */
  31699. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31700. /**
  31701. * Clones the current mesh
  31702. * @param name defines the mesh name
  31703. * @param newParent defines the new mesh parent
  31704. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31705. * @returns the new mesh
  31706. */
  31707. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31708. /**
  31709. * Disposes all the submeshes of the current meshnp
  31710. * @returns the current mesh
  31711. */
  31712. releaseSubMeshes(): AbstractMesh;
  31713. /**
  31714. * Releases resources associated with this abstract mesh.
  31715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31717. */
  31718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31719. /**
  31720. * Adds the passed mesh as a child to the current mesh
  31721. * @param mesh defines the child mesh
  31722. * @returns the current mesh
  31723. */
  31724. addChild(mesh: AbstractMesh): AbstractMesh;
  31725. /**
  31726. * Removes the passed mesh from the current mesh children list
  31727. * @param mesh defines the child mesh
  31728. * @returns the current mesh
  31729. */
  31730. removeChild(mesh: AbstractMesh): AbstractMesh;
  31731. /** @hidden */
  31732. private _initFacetData;
  31733. /**
  31734. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31735. * This method can be called within the render loop.
  31736. * 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
  31737. * @returns the current mesh
  31738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31739. */
  31740. updateFacetData(): AbstractMesh;
  31741. /**
  31742. * Returns the facetLocalNormals array.
  31743. * The normals are expressed in the mesh local spac
  31744. * @returns an array of Vector3
  31745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31746. */
  31747. getFacetLocalNormals(): Vector3[];
  31748. /**
  31749. * Returns the facetLocalPositions array.
  31750. * The facet positions are expressed in the mesh local space
  31751. * @returns an array of Vector3
  31752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31753. */
  31754. getFacetLocalPositions(): Vector3[];
  31755. /**
  31756. * Returns the facetLocalPartioning array
  31757. * @returns an array of array of numbers
  31758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31759. */
  31760. getFacetLocalPartitioning(): number[][];
  31761. /**
  31762. * Returns the i-th facet position in the world system.
  31763. * This method allocates a new Vector3 per call
  31764. * @param i defines the facet index
  31765. * @returns a new Vector3
  31766. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31767. */
  31768. getFacetPosition(i: number): Vector3;
  31769. /**
  31770. * Sets the reference Vector3 with the i-th facet position in the world system
  31771. * @param i defines the facet index
  31772. * @param ref defines the target vector
  31773. * @returns the current mesh
  31774. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31775. */
  31776. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31777. /**
  31778. * Returns the i-th facet normal in the world system.
  31779. * This method allocates a new Vector3 per call
  31780. * @param i defines the facet index
  31781. * @returns a new Vector3
  31782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31783. */
  31784. getFacetNormal(i: number): Vector3;
  31785. /**
  31786. * Sets the reference Vector3 with the i-th facet normal in the world system
  31787. * @param i defines the facet index
  31788. * @param ref defines the target vector
  31789. * @returns the current mesh
  31790. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31791. */
  31792. getFacetNormalToRef(i: number, ref: Vector3): this;
  31793. /**
  31794. * 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)
  31795. * @param x defines x coordinate
  31796. * @param y defines y coordinate
  31797. * @param z defines z coordinate
  31798. * @returns the array of facet indexes
  31799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31800. */
  31801. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31802. /**
  31803. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31804. * @param projected sets as the (x,y,z) world projection on the facet
  31805. * @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
  31806. * @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
  31807. * @param x defines x coordinate
  31808. * @param y defines y coordinate
  31809. * @param z defines z coordinate
  31810. * @returns the face index if found (or null instead)
  31811. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31812. */
  31813. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31814. /**
  31815. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31816. * @param projected sets as the (x,y,z) local projection on the facet
  31817. * @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
  31818. * @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
  31819. * @param x defines x coordinate
  31820. * @param y defines y coordinate
  31821. * @param z defines z coordinate
  31822. * @returns the face index if found (or null instead)
  31823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31824. */
  31825. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31826. /**
  31827. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31828. * @returns the parameters
  31829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31830. */
  31831. getFacetDataParameters(): any;
  31832. /**
  31833. * Disables the feature FacetData and frees the related memory
  31834. * @returns the current mesh
  31835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31836. */
  31837. disableFacetData(): AbstractMesh;
  31838. /**
  31839. * Updates the AbstractMesh indices array
  31840. * @param indices defines the data source
  31841. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31842. * @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)
  31843. * @returns the current mesh
  31844. */
  31845. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31846. /**
  31847. * Creates new normals data for the mesh
  31848. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31849. * @returns the current mesh
  31850. */
  31851. createNormals(updatable: boolean): AbstractMesh;
  31852. /**
  31853. * Align the mesh with a normal
  31854. * @param normal defines the normal to use
  31855. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31856. * @returns the current mesh
  31857. */
  31858. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31859. /** @hidden */
  31860. _checkOcclusionQuery(): boolean;
  31861. /**
  31862. * Disables the mesh edge rendering mode
  31863. * @returns the currentAbstractMesh
  31864. */
  31865. disableEdgesRendering(): AbstractMesh;
  31866. /**
  31867. * Enables the edge rendering mode on the mesh.
  31868. * This mode makes the mesh edges visible
  31869. * @param epsilon defines the maximal distance between two angles to detect a face
  31870. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31871. * @returns the currentAbstractMesh
  31872. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31873. */
  31874. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31875. }
  31876. }
  31877. declare module BABYLON {
  31878. /**
  31879. * Interface used to define ActionEvent
  31880. */
  31881. export interface IActionEvent {
  31882. /** The mesh or sprite that triggered the action */
  31883. source: any;
  31884. /** The X mouse cursor position at the time of the event */
  31885. pointerX: number;
  31886. /** The Y mouse cursor position at the time of the event */
  31887. pointerY: number;
  31888. /** The mesh that is currently pointed at (can be null) */
  31889. meshUnderPointer: Nullable<AbstractMesh>;
  31890. /** the original (browser) event that triggered the ActionEvent */
  31891. sourceEvent?: any;
  31892. /** additional data for the event */
  31893. additionalData?: any;
  31894. }
  31895. /**
  31896. * ActionEvent is the event being sent when an action is triggered.
  31897. */
  31898. export class ActionEvent implements IActionEvent {
  31899. /** The mesh or sprite that triggered the action */
  31900. source: any;
  31901. /** The X mouse cursor position at the time of the event */
  31902. pointerX: number;
  31903. /** The Y mouse cursor position at the time of the event */
  31904. pointerY: number;
  31905. /** The mesh that is currently pointed at (can be null) */
  31906. meshUnderPointer: Nullable<AbstractMesh>;
  31907. /** the original (browser) event that triggered the ActionEvent */
  31908. sourceEvent?: any;
  31909. /** additional data for the event */
  31910. additionalData?: any;
  31911. /**
  31912. * Creates a new ActionEvent
  31913. * @param source The mesh or sprite that triggered the action
  31914. * @param pointerX The X mouse cursor position at the time of the event
  31915. * @param pointerY The Y mouse cursor position at the time of the event
  31916. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31917. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31918. * @param additionalData additional data for the event
  31919. */
  31920. constructor(
  31921. /** The mesh or sprite that triggered the action */
  31922. source: any,
  31923. /** The X mouse cursor position at the time of the event */
  31924. pointerX: number,
  31925. /** The Y mouse cursor position at the time of the event */
  31926. pointerY: number,
  31927. /** The mesh that is currently pointed at (can be null) */
  31928. meshUnderPointer: Nullable<AbstractMesh>,
  31929. /** the original (browser) event that triggered the ActionEvent */
  31930. sourceEvent?: any,
  31931. /** additional data for the event */
  31932. additionalData?: any);
  31933. /**
  31934. * Helper function to auto-create an ActionEvent from a source mesh.
  31935. * @param source The source mesh that triggered the event
  31936. * @param evt The original (browser) event
  31937. * @param additionalData additional data for the event
  31938. * @returns the new ActionEvent
  31939. */
  31940. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31941. /**
  31942. * Helper function to auto-create an ActionEvent from a source sprite
  31943. * @param source The source sprite that triggered the event
  31944. * @param scene Scene associated with the sprite
  31945. * @param evt The original (browser) event
  31946. * @param additionalData additional data for the event
  31947. * @returns the new ActionEvent
  31948. */
  31949. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31950. /**
  31951. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31952. * @param scene the scene where the event occurred
  31953. * @param evt The original (browser) event
  31954. * @returns the new ActionEvent
  31955. */
  31956. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31957. /**
  31958. * Helper function to auto-create an ActionEvent from a primitive
  31959. * @param prim defines the target primitive
  31960. * @param pointerPos defines the pointer position
  31961. * @param evt The original (browser) event
  31962. * @param additionalData additional data for the event
  31963. * @returns the new ActionEvent
  31964. */
  31965. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31966. }
  31967. }
  31968. declare module BABYLON {
  31969. /**
  31970. * Abstract class used to decouple action Manager from scene and meshes.
  31971. * Do not instantiate.
  31972. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31973. */
  31974. export abstract class AbstractActionManager implements IDisposable {
  31975. /** Gets the list of active triggers */
  31976. static Triggers: {
  31977. [key: string]: number;
  31978. };
  31979. /** Gets the cursor to use when hovering items */
  31980. hoverCursor: string;
  31981. /** Gets the list of actions */
  31982. actions: IAction[];
  31983. /**
  31984. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31985. */
  31986. isRecursive: boolean;
  31987. /**
  31988. * Releases all associated resources
  31989. */
  31990. abstract dispose(): void;
  31991. /**
  31992. * Does this action manager has pointer triggers
  31993. */
  31994. abstract get hasPointerTriggers(): boolean;
  31995. /**
  31996. * Does this action manager has pick triggers
  31997. */
  31998. abstract get hasPickTriggers(): boolean;
  31999. /**
  32000. * Process a specific trigger
  32001. * @param trigger defines the trigger to process
  32002. * @param evt defines the event details to be processed
  32003. */
  32004. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32005. /**
  32006. * Does this action manager handles actions of any of the given triggers
  32007. * @param triggers defines the triggers to be tested
  32008. * @return a boolean indicating whether one (or more) of the triggers is handled
  32009. */
  32010. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32011. /**
  32012. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32013. * speed.
  32014. * @param triggerA defines the trigger to be tested
  32015. * @param triggerB defines the trigger to be tested
  32016. * @return a boolean indicating whether one (or more) of the triggers is handled
  32017. */
  32018. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32019. /**
  32020. * Does this action manager handles actions of a given trigger
  32021. * @param trigger defines the trigger to be tested
  32022. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32023. * @return whether the trigger is handled
  32024. */
  32025. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32026. /**
  32027. * Serialize this manager to a JSON object
  32028. * @param name defines the property name to store this manager
  32029. * @returns a JSON representation of this manager
  32030. */
  32031. abstract serialize(name: string): any;
  32032. /**
  32033. * Registers an action to this action manager
  32034. * @param action defines the action to be registered
  32035. * @return the action amended (prepared) after registration
  32036. */
  32037. abstract registerAction(action: IAction): Nullable<IAction>;
  32038. /**
  32039. * Unregisters an action to this action manager
  32040. * @param action defines the action to be unregistered
  32041. * @return a boolean indicating whether the action has been unregistered
  32042. */
  32043. abstract unregisterAction(action: IAction): Boolean;
  32044. /**
  32045. * Does exist one action manager with at least one trigger
  32046. **/
  32047. static get HasTriggers(): boolean;
  32048. /**
  32049. * Does exist one action manager with at least one pick trigger
  32050. **/
  32051. static get HasPickTriggers(): boolean;
  32052. /**
  32053. * Does exist one action manager that handles actions of a given trigger
  32054. * @param trigger defines the trigger to be tested
  32055. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32056. **/
  32057. static HasSpecificTrigger(trigger: number): boolean;
  32058. }
  32059. }
  32060. declare module BABYLON {
  32061. /**
  32062. * Defines how a node can be built from a string name.
  32063. */
  32064. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32065. /**
  32066. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32067. */
  32068. export class Node implements IBehaviorAware<Node> {
  32069. /** @hidden */
  32070. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32071. private static _NodeConstructors;
  32072. /**
  32073. * Add a new node constructor
  32074. * @param type defines the type name of the node to construct
  32075. * @param constructorFunc defines the constructor function
  32076. */
  32077. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32078. /**
  32079. * Returns a node constructor based on type name
  32080. * @param type defines the type name
  32081. * @param name defines the new node name
  32082. * @param scene defines the hosting scene
  32083. * @param options defines optional options to transmit to constructors
  32084. * @returns the new constructor or null
  32085. */
  32086. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32087. /**
  32088. * Gets or sets the name of the node
  32089. */
  32090. name: string;
  32091. /**
  32092. * Gets or sets the id of the node
  32093. */
  32094. id: string;
  32095. /**
  32096. * Gets or sets the unique id of the node
  32097. */
  32098. uniqueId: number;
  32099. /**
  32100. * Gets or sets a string used to store user defined state for the node
  32101. */
  32102. state: string;
  32103. /**
  32104. * Gets or sets an object used to store user defined information for the node
  32105. */
  32106. metadata: any;
  32107. /**
  32108. * For internal use only. Please do not use.
  32109. */
  32110. reservedDataStore: any;
  32111. /**
  32112. * List of inspectable custom properties (used by the Inspector)
  32113. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32114. */
  32115. inspectableCustomProperties: IInspectable[];
  32116. private _doNotSerialize;
  32117. /**
  32118. * Gets or sets a boolean used to define if the node must be serialized
  32119. */
  32120. get doNotSerialize(): boolean;
  32121. set doNotSerialize(value: boolean);
  32122. /** @hidden */
  32123. _isDisposed: boolean;
  32124. /**
  32125. * Gets a list of Animations associated with the node
  32126. */
  32127. animations: Animation[];
  32128. protected _ranges: {
  32129. [name: string]: Nullable<AnimationRange>;
  32130. };
  32131. /**
  32132. * Callback raised when the node is ready to be used
  32133. */
  32134. onReady: Nullable<(node: Node) => void>;
  32135. private _isEnabled;
  32136. private _isParentEnabled;
  32137. private _isReady;
  32138. /** @hidden */
  32139. _currentRenderId: number;
  32140. private _parentUpdateId;
  32141. /** @hidden */
  32142. _childUpdateId: number;
  32143. /** @hidden */
  32144. _waitingParentId: Nullable<string>;
  32145. /** @hidden */
  32146. _scene: Scene;
  32147. /** @hidden */
  32148. _cache: any;
  32149. private _parentNode;
  32150. private _children;
  32151. /** @hidden */
  32152. _worldMatrix: Matrix;
  32153. /** @hidden */
  32154. _worldMatrixDeterminant: number;
  32155. /** @hidden */
  32156. _worldMatrixDeterminantIsDirty: boolean;
  32157. /** @hidden */
  32158. private _sceneRootNodesIndex;
  32159. /**
  32160. * Gets a boolean indicating if the node has been disposed
  32161. * @returns true if the node was disposed
  32162. */
  32163. isDisposed(): boolean;
  32164. /**
  32165. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32166. * @see https://doc.babylonjs.com/how_to/parenting
  32167. */
  32168. set parent(parent: Nullable<Node>);
  32169. get parent(): Nullable<Node>;
  32170. /** @hidden */
  32171. _addToSceneRootNodes(): void;
  32172. /** @hidden */
  32173. _removeFromSceneRootNodes(): void;
  32174. private _animationPropertiesOverride;
  32175. /**
  32176. * Gets or sets the animation properties override
  32177. */
  32178. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32179. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32180. /**
  32181. * Gets a string idenfifying the name of the class
  32182. * @returns "Node" string
  32183. */
  32184. getClassName(): string;
  32185. /** @hidden */
  32186. readonly _isNode: boolean;
  32187. /**
  32188. * An event triggered when the mesh is disposed
  32189. */
  32190. onDisposeObservable: Observable<Node>;
  32191. private _onDisposeObserver;
  32192. /**
  32193. * Sets a callback that will be raised when the node will be disposed
  32194. */
  32195. set onDispose(callback: () => void);
  32196. /**
  32197. * Creates a new Node
  32198. * @param name the name and id to be given to this node
  32199. * @param scene the scene this node will be added to
  32200. */
  32201. constructor(name: string, scene?: Nullable<Scene>);
  32202. /**
  32203. * Gets the scene of the node
  32204. * @returns a scene
  32205. */
  32206. getScene(): Scene;
  32207. /**
  32208. * Gets the engine of the node
  32209. * @returns a Engine
  32210. */
  32211. getEngine(): Engine;
  32212. private _behaviors;
  32213. /**
  32214. * Attach a behavior to the node
  32215. * @see http://doc.babylonjs.com/features/behaviour
  32216. * @param behavior defines the behavior to attach
  32217. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32218. * @returns the current Node
  32219. */
  32220. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32221. /**
  32222. * Remove an attached behavior
  32223. * @see http://doc.babylonjs.com/features/behaviour
  32224. * @param behavior defines the behavior to attach
  32225. * @returns the current Node
  32226. */
  32227. removeBehavior(behavior: Behavior<Node>): Node;
  32228. /**
  32229. * Gets the list of attached behaviors
  32230. * @see http://doc.babylonjs.com/features/behaviour
  32231. */
  32232. get behaviors(): Behavior<Node>[];
  32233. /**
  32234. * Gets an attached behavior by name
  32235. * @param name defines the name of the behavior to look for
  32236. * @see http://doc.babylonjs.com/features/behaviour
  32237. * @returns null if behavior was not found else the requested behavior
  32238. */
  32239. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32240. /**
  32241. * Returns the latest update of the World matrix
  32242. * @returns a Matrix
  32243. */
  32244. getWorldMatrix(): Matrix;
  32245. /** @hidden */
  32246. _getWorldMatrixDeterminant(): number;
  32247. /**
  32248. * Returns directly the latest state of the mesh World matrix.
  32249. * A Matrix is returned.
  32250. */
  32251. get worldMatrixFromCache(): Matrix;
  32252. /** @hidden */
  32253. _initCache(): void;
  32254. /** @hidden */
  32255. updateCache(force?: boolean): void;
  32256. /** @hidden */
  32257. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32258. /** @hidden */
  32259. _updateCache(ignoreParentClass?: boolean): void;
  32260. /** @hidden */
  32261. _isSynchronized(): boolean;
  32262. /** @hidden */
  32263. _markSyncedWithParent(): void;
  32264. /** @hidden */
  32265. isSynchronizedWithParent(): boolean;
  32266. /** @hidden */
  32267. isSynchronized(): boolean;
  32268. /**
  32269. * Is this node ready to be used/rendered
  32270. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32271. * @return true if the node is ready
  32272. */
  32273. isReady(completeCheck?: boolean): boolean;
  32274. /**
  32275. * Is this node enabled?
  32276. * 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
  32277. * @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
  32278. * @return whether this node (and its parent) is enabled
  32279. */
  32280. isEnabled(checkAncestors?: boolean): boolean;
  32281. /** @hidden */
  32282. protected _syncParentEnabledState(): void;
  32283. /**
  32284. * Set the enabled state of this node
  32285. * @param value defines the new enabled state
  32286. */
  32287. setEnabled(value: boolean): void;
  32288. /**
  32289. * Is this node a descendant of the given node?
  32290. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32291. * @param ancestor defines the parent node to inspect
  32292. * @returns a boolean indicating if this node is a descendant of the given node
  32293. */
  32294. isDescendantOf(ancestor: Node): boolean;
  32295. /** @hidden */
  32296. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32297. /**
  32298. * Will return all nodes that have this node as ascendant
  32299. * @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
  32300. * @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
  32301. * @return all children nodes of all types
  32302. */
  32303. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32304. /**
  32305. * Get all child-meshes of this node
  32306. * @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)
  32307. * @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
  32308. * @returns an array of AbstractMesh
  32309. */
  32310. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32311. /**
  32312. * Get all direct children of this node
  32313. * @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
  32314. * @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)
  32315. * @returns an array of Node
  32316. */
  32317. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32318. /** @hidden */
  32319. _setReady(state: boolean): void;
  32320. /**
  32321. * Get an animation by name
  32322. * @param name defines the name of the animation to look for
  32323. * @returns null if not found else the requested animation
  32324. */
  32325. getAnimationByName(name: string): Nullable<Animation>;
  32326. /**
  32327. * Creates an animation range for this node
  32328. * @param name defines the name of the range
  32329. * @param from defines the starting key
  32330. * @param to defines the end key
  32331. */
  32332. createAnimationRange(name: string, from: number, to: number): void;
  32333. /**
  32334. * Delete a specific animation range
  32335. * @param name defines the name of the range to delete
  32336. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32337. */
  32338. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32339. /**
  32340. * Get an animation range by name
  32341. * @param name defines the name of the animation range to look for
  32342. * @returns null if not found else the requested animation range
  32343. */
  32344. getAnimationRange(name: string): Nullable<AnimationRange>;
  32345. /**
  32346. * Gets the list of all animation ranges defined on this node
  32347. * @returns an array
  32348. */
  32349. getAnimationRanges(): Nullable<AnimationRange>[];
  32350. /**
  32351. * Will start the animation sequence
  32352. * @param name defines the range frames for animation sequence
  32353. * @param loop defines if the animation should loop (false by default)
  32354. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32355. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32356. * @returns the object created for this animation. If range does not exist, it will return null
  32357. */
  32358. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32359. /**
  32360. * Serialize animation ranges into a JSON compatible object
  32361. * @returns serialization object
  32362. */
  32363. serializeAnimationRanges(): any;
  32364. /**
  32365. * Computes the world matrix of the node
  32366. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32367. * @returns the world matrix
  32368. */
  32369. computeWorldMatrix(force?: boolean): Matrix;
  32370. /**
  32371. * Releases resources associated with this node.
  32372. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32373. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32374. */
  32375. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32376. /**
  32377. * Parse animation range data from a serialization object and store them into a given node
  32378. * @param node defines where to store the animation ranges
  32379. * @param parsedNode defines the serialization object to read data from
  32380. * @param scene defines the hosting scene
  32381. */
  32382. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32383. /**
  32384. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32385. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32386. * @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
  32387. * @returns the new bounding vectors
  32388. */
  32389. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32390. min: Vector3;
  32391. max: Vector3;
  32392. };
  32393. }
  32394. }
  32395. declare module BABYLON {
  32396. /**
  32397. * @hidden
  32398. */
  32399. export class _IAnimationState {
  32400. key: number;
  32401. repeatCount: number;
  32402. workValue?: any;
  32403. loopMode?: number;
  32404. offsetValue?: any;
  32405. highLimitValue?: any;
  32406. }
  32407. /**
  32408. * Class used to store any kind of animation
  32409. */
  32410. export class Animation {
  32411. /**Name of the animation */
  32412. name: string;
  32413. /**Property to animate */
  32414. targetProperty: string;
  32415. /**The frames per second of the animation */
  32416. framePerSecond: number;
  32417. /**The data type of the animation */
  32418. dataType: number;
  32419. /**The loop mode of the animation */
  32420. loopMode?: number | undefined;
  32421. /**Specifies if blending should be enabled */
  32422. enableBlending?: boolean | undefined;
  32423. /**
  32424. * Use matrix interpolation instead of using direct key value when animating matrices
  32425. */
  32426. static AllowMatricesInterpolation: boolean;
  32427. /**
  32428. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32429. */
  32430. static AllowMatrixDecomposeForInterpolation: boolean;
  32431. /** Define the Url to load snippets */
  32432. static SnippetUrl: string;
  32433. /** Snippet ID if the animation was created from the snippet server */
  32434. snippetId: string;
  32435. /**
  32436. * Stores the key frames of the animation
  32437. */
  32438. private _keys;
  32439. /**
  32440. * Stores the easing function of the animation
  32441. */
  32442. private _easingFunction;
  32443. /**
  32444. * @hidden Internal use only
  32445. */
  32446. _runtimeAnimations: RuntimeAnimation[];
  32447. /**
  32448. * The set of event that will be linked to this animation
  32449. */
  32450. private _events;
  32451. /**
  32452. * Stores an array of target property paths
  32453. */
  32454. targetPropertyPath: string[];
  32455. /**
  32456. * Stores the blending speed of the animation
  32457. */
  32458. blendingSpeed: number;
  32459. /**
  32460. * Stores the animation ranges for the animation
  32461. */
  32462. private _ranges;
  32463. /**
  32464. * @hidden Internal use
  32465. */
  32466. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32467. /**
  32468. * Sets up an animation
  32469. * @param property The property to animate
  32470. * @param animationType The animation type to apply
  32471. * @param framePerSecond The frames per second of the animation
  32472. * @param easingFunction The easing function used in the animation
  32473. * @returns The created animation
  32474. */
  32475. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32476. /**
  32477. * Create and start an animation on a node
  32478. * @param name defines the name of the global animation that will be run on all nodes
  32479. * @param node defines the root node where the animation will take place
  32480. * @param targetProperty defines property to animate
  32481. * @param framePerSecond defines the number of frame per second yo use
  32482. * @param totalFrame defines the number of frames in total
  32483. * @param from defines the initial value
  32484. * @param to defines the final value
  32485. * @param loopMode defines which loop mode you want to use (off by default)
  32486. * @param easingFunction defines the easing function to use (linear by default)
  32487. * @param onAnimationEnd defines the callback to call when animation end
  32488. * @returns the animatable created for this animation
  32489. */
  32490. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32491. /**
  32492. * Create and start an animation on a node and its descendants
  32493. * @param name defines the name of the global animation that will be run on all nodes
  32494. * @param node defines the root node where the animation will take place
  32495. * @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
  32496. * @param targetProperty defines property to animate
  32497. * @param framePerSecond defines the number of frame per second to use
  32498. * @param totalFrame defines the number of frames in total
  32499. * @param from defines the initial value
  32500. * @param to defines the final value
  32501. * @param loopMode defines which loop mode you want to use (off by default)
  32502. * @param easingFunction defines the easing function to use (linear by default)
  32503. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32504. * @returns the list of animatables created for all nodes
  32505. * @example https://www.babylonjs-playground.com/#MH0VLI
  32506. */
  32507. 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[]>;
  32508. /**
  32509. * Creates a new animation, merges it with the existing animations and starts it
  32510. * @param name Name of the animation
  32511. * @param node Node which contains the scene that begins the animations
  32512. * @param targetProperty Specifies which property to animate
  32513. * @param framePerSecond The frames per second of the animation
  32514. * @param totalFrame The total number of frames
  32515. * @param from The frame at the beginning of the animation
  32516. * @param to The frame at the end of the animation
  32517. * @param loopMode Specifies the loop mode of the animation
  32518. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32519. * @param onAnimationEnd Callback to run once the animation is complete
  32520. * @returns Nullable animation
  32521. */
  32522. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32523. /**
  32524. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32525. * @param sourceAnimation defines the Animation containing keyframes to convert
  32526. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32527. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32528. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32529. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32530. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32531. */
  32532. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32533. /**
  32534. * Transition property of an host to the target Value
  32535. * @param property The property to transition
  32536. * @param targetValue The target Value of the property
  32537. * @param host The object where the property to animate belongs
  32538. * @param scene Scene used to run the animation
  32539. * @param frameRate Framerate (in frame/s) to use
  32540. * @param transition The transition type we want to use
  32541. * @param duration The duration of the animation, in milliseconds
  32542. * @param onAnimationEnd Callback trigger at the end of the animation
  32543. * @returns Nullable animation
  32544. */
  32545. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32546. /**
  32547. * Return the array of runtime animations currently using this animation
  32548. */
  32549. get runtimeAnimations(): RuntimeAnimation[];
  32550. /**
  32551. * Specifies if any of the runtime animations are currently running
  32552. */
  32553. get hasRunningRuntimeAnimations(): boolean;
  32554. /**
  32555. * Initializes the animation
  32556. * @param name Name of the animation
  32557. * @param targetProperty Property to animate
  32558. * @param framePerSecond The frames per second of the animation
  32559. * @param dataType The data type of the animation
  32560. * @param loopMode The loop mode of the animation
  32561. * @param enableBlending Specifies if blending should be enabled
  32562. */
  32563. constructor(
  32564. /**Name of the animation */
  32565. name: string,
  32566. /**Property to animate */
  32567. targetProperty: string,
  32568. /**The frames per second of the animation */
  32569. framePerSecond: number,
  32570. /**The data type of the animation */
  32571. dataType: number,
  32572. /**The loop mode of the animation */
  32573. loopMode?: number | undefined,
  32574. /**Specifies if blending should be enabled */
  32575. enableBlending?: boolean | undefined);
  32576. /**
  32577. * Converts the animation to a string
  32578. * @param fullDetails support for multiple levels of logging within scene loading
  32579. * @returns String form of the animation
  32580. */
  32581. toString(fullDetails?: boolean): string;
  32582. /**
  32583. * Add an event to this animation
  32584. * @param event Event to add
  32585. */
  32586. addEvent(event: AnimationEvent): void;
  32587. /**
  32588. * Remove all events found at the given frame
  32589. * @param frame The frame to remove events from
  32590. */
  32591. removeEvents(frame: number): void;
  32592. /**
  32593. * Retrieves all the events from the animation
  32594. * @returns Events from the animation
  32595. */
  32596. getEvents(): AnimationEvent[];
  32597. /**
  32598. * Creates an animation range
  32599. * @param name Name of the animation range
  32600. * @param from Starting frame of the animation range
  32601. * @param to Ending frame of the animation
  32602. */
  32603. createRange(name: string, from: number, to: number): void;
  32604. /**
  32605. * Deletes an animation range by name
  32606. * @param name Name of the animation range to delete
  32607. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32608. */
  32609. deleteRange(name: string, deleteFrames?: boolean): void;
  32610. /**
  32611. * Gets the animation range by name, or null if not defined
  32612. * @param name Name of the animation range
  32613. * @returns Nullable animation range
  32614. */
  32615. getRange(name: string): Nullable<AnimationRange>;
  32616. /**
  32617. * Gets the key frames from the animation
  32618. * @returns The key frames of the animation
  32619. */
  32620. getKeys(): Array<IAnimationKey>;
  32621. /**
  32622. * Gets the highest frame rate of the animation
  32623. * @returns Highest frame rate of the animation
  32624. */
  32625. getHighestFrame(): number;
  32626. /**
  32627. * Gets the easing function of the animation
  32628. * @returns Easing function of the animation
  32629. */
  32630. getEasingFunction(): IEasingFunction;
  32631. /**
  32632. * Sets the easing function of the animation
  32633. * @param easingFunction A custom mathematical formula for animation
  32634. */
  32635. setEasingFunction(easingFunction: EasingFunction): void;
  32636. /**
  32637. * Interpolates a scalar linearly
  32638. * @param startValue Start value of the animation curve
  32639. * @param endValue End value of the animation curve
  32640. * @param gradient Scalar amount to interpolate
  32641. * @returns Interpolated scalar value
  32642. */
  32643. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32644. /**
  32645. * Interpolates a scalar cubically
  32646. * @param startValue Start value of the animation curve
  32647. * @param outTangent End tangent of the animation
  32648. * @param endValue End value of the animation curve
  32649. * @param inTangent Start tangent of the animation curve
  32650. * @param gradient Scalar amount to interpolate
  32651. * @returns Interpolated scalar value
  32652. */
  32653. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32654. /**
  32655. * Interpolates a quaternion using a spherical linear interpolation
  32656. * @param startValue Start value of the animation curve
  32657. * @param endValue End value of the animation curve
  32658. * @param gradient Scalar amount to interpolate
  32659. * @returns Interpolated quaternion value
  32660. */
  32661. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32662. /**
  32663. * Interpolates a quaternion cubically
  32664. * @param startValue Start value of the animation curve
  32665. * @param outTangent End tangent of the animation curve
  32666. * @param endValue End value of the animation curve
  32667. * @param inTangent Start tangent of the animation curve
  32668. * @param gradient Scalar amount to interpolate
  32669. * @returns Interpolated quaternion value
  32670. */
  32671. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32672. /**
  32673. * Interpolates a Vector3 linearl
  32674. * @param startValue Start value of the animation curve
  32675. * @param endValue End value of the animation curve
  32676. * @param gradient Scalar amount to interpolate
  32677. * @returns Interpolated scalar value
  32678. */
  32679. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32680. /**
  32681. * Interpolates a Vector3 cubically
  32682. * @param startValue Start value of the animation curve
  32683. * @param outTangent End tangent of the animation
  32684. * @param endValue End value of the animation curve
  32685. * @param inTangent Start tangent of the animation curve
  32686. * @param gradient Scalar amount to interpolate
  32687. * @returns InterpolatedVector3 value
  32688. */
  32689. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32690. /**
  32691. * Interpolates a Vector2 linearly
  32692. * @param startValue Start value of the animation curve
  32693. * @param endValue End value of the animation curve
  32694. * @param gradient Scalar amount to interpolate
  32695. * @returns Interpolated Vector2 value
  32696. */
  32697. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32698. /**
  32699. * Interpolates a Vector2 cubically
  32700. * @param startValue Start value of the animation curve
  32701. * @param outTangent End tangent of the animation
  32702. * @param endValue End value of the animation curve
  32703. * @param inTangent Start tangent of the animation curve
  32704. * @param gradient Scalar amount to interpolate
  32705. * @returns Interpolated Vector2 value
  32706. */
  32707. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32708. /**
  32709. * Interpolates a size linearly
  32710. * @param startValue Start value of the animation curve
  32711. * @param endValue End value of the animation curve
  32712. * @param gradient Scalar amount to interpolate
  32713. * @returns Interpolated Size value
  32714. */
  32715. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32716. /**
  32717. * Interpolates a Color3 linearly
  32718. * @param startValue Start value of the animation curve
  32719. * @param endValue End value of the animation curve
  32720. * @param gradient Scalar amount to interpolate
  32721. * @returns Interpolated Color3 value
  32722. */
  32723. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32724. /**
  32725. * Interpolates a Color4 linearly
  32726. * @param startValue Start value of the animation curve
  32727. * @param endValue End value of the animation curve
  32728. * @param gradient Scalar amount to interpolate
  32729. * @returns Interpolated Color3 value
  32730. */
  32731. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32732. /**
  32733. * @hidden Internal use only
  32734. */
  32735. _getKeyValue(value: any): any;
  32736. /**
  32737. * @hidden Internal use only
  32738. */
  32739. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32740. /**
  32741. * Defines the function to use to interpolate matrices
  32742. * @param startValue defines the start matrix
  32743. * @param endValue defines the end matrix
  32744. * @param gradient defines the gradient between both matrices
  32745. * @param result defines an optional target matrix where to store the interpolation
  32746. * @returns the interpolated matrix
  32747. */
  32748. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32749. /**
  32750. * Makes a copy of the animation
  32751. * @returns Cloned animation
  32752. */
  32753. clone(): Animation;
  32754. /**
  32755. * Sets the key frames of the animation
  32756. * @param values The animation key frames to set
  32757. */
  32758. setKeys(values: Array<IAnimationKey>): void;
  32759. /**
  32760. * Serializes the animation to an object
  32761. * @returns Serialized object
  32762. */
  32763. serialize(): any;
  32764. /**
  32765. * Float animation type
  32766. */
  32767. static readonly ANIMATIONTYPE_FLOAT: number;
  32768. /**
  32769. * Vector3 animation type
  32770. */
  32771. static readonly ANIMATIONTYPE_VECTOR3: number;
  32772. /**
  32773. * Quaternion animation type
  32774. */
  32775. static readonly ANIMATIONTYPE_QUATERNION: number;
  32776. /**
  32777. * Matrix animation type
  32778. */
  32779. static readonly ANIMATIONTYPE_MATRIX: number;
  32780. /**
  32781. * Color3 animation type
  32782. */
  32783. static readonly ANIMATIONTYPE_COLOR3: number;
  32784. /**
  32785. * Color3 animation type
  32786. */
  32787. static readonly ANIMATIONTYPE_COLOR4: number;
  32788. /**
  32789. * Vector2 animation type
  32790. */
  32791. static readonly ANIMATIONTYPE_VECTOR2: number;
  32792. /**
  32793. * Size animation type
  32794. */
  32795. static readonly ANIMATIONTYPE_SIZE: number;
  32796. /**
  32797. * Relative Loop Mode
  32798. */
  32799. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32800. /**
  32801. * Cycle Loop Mode
  32802. */
  32803. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32804. /**
  32805. * Constant Loop Mode
  32806. */
  32807. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32808. /** @hidden */
  32809. static _UniversalLerp(left: any, right: any, amount: number): any;
  32810. /**
  32811. * Parses an animation object and creates an animation
  32812. * @param parsedAnimation Parsed animation object
  32813. * @returns Animation object
  32814. */
  32815. static Parse(parsedAnimation: any): Animation;
  32816. /**
  32817. * Appends the serialized animations from the source animations
  32818. * @param source Source containing the animations
  32819. * @param destination Target to store the animations
  32820. */
  32821. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32822. /**
  32823. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32824. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32825. * @param url defines the url to load from
  32826. * @returns a promise that will resolve to the new animation or an array of animations
  32827. */
  32828. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32829. /**
  32830. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32831. * @param snippetId defines the snippet to load
  32832. * @returns a promise that will resolve to the new animation or a new array of animations
  32833. */
  32834. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32835. }
  32836. }
  32837. declare module BABYLON {
  32838. /**
  32839. * Interface containing an array of animations
  32840. */
  32841. export interface IAnimatable {
  32842. /**
  32843. * Array of animations
  32844. */
  32845. animations: Nullable<Array<Animation>>;
  32846. }
  32847. }
  32848. declare module BABYLON {
  32849. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32850. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32851. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32852. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32853. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32854. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32855. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32856. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32857. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32858. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32859. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32860. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32861. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32862. /**
  32863. * Decorator used to define property that can be serialized as reference to a camera
  32864. * @param sourceName defines the name of the property to decorate
  32865. */
  32866. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32867. /**
  32868. * Class used to help serialization objects
  32869. */
  32870. export class SerializationHelper {
  32871. /** @hidden */
  32872. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32873. /** @hidden */
  32874. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32875. /** @hidden */
  32876. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32877. /** @hidden */
  32878. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32879. /**
  32880. * Appends the serialized animations from the source animations
  32881. * @param source Source containing the animations
  32882. * @param destination Target to store the animations
  32883. */
  32884. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32885. /**
  32886. * Static function used to serialized a specific entity
  32887. * @param entity defines the entity to serialize
  32888. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32889. * @returns a JSON compatible object representing the serialization of the entity
  32890. */
  32891. static Serialize<T>(entity: T, serializationObject?: any): any;
  32892. /**
  32893. * Creates a new entity from a serialization data object
  32894. * @param creationFunction defines a function used to instanciated the new entity
  32895. * @param source defines the source serialization data
  32896. * @param scene defines the hosting scene
  32897. * @param rootUrl defines the root url for resources
  32898. * @returns a new entity
  32899. */
  32900. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32901. /**
  32902. * Clones an object
  32903. * @param creationFunction defines the function used to instanciate the new object
  32904. * @param source defines the source object
  32905. * @returns the cloned object
  32906. */
  32907. static Clone<T>(creationFunction: () => T, source: T): T;
  32908. /**
  32909. * Instanciates a new object based on a source one (some data will be shared between both object)
  32910. * @param creationFunction defines the function used to instanciate the new object
  32911. * @param source defines the source object
  32912. * @returns the new object
  32913. */
  32914. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32915. }
  32916. }
  32917. declare module BABYLON {
  32918. /**
  32919. * Base class of all the textures in babylon.
  32920. * It groups all the common properties the materials, post process, lights... might need
  32921. * in order to make a correct use of the texture.
  32922. */
  32923. export class BaseTexture implements IAnimatable {
  32924. /**
  32925. * Default anisotropic filtering level for the application.
  32926. * It is set to 4 as a good tradeoff between perf and quality.
  32927. */
  32928. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32929. /**
  32930. * Gets or sets the unique id of the texture
  32931. */
  32932. uniqueId: number;
  32933. /**
  32934. * Define the name of the texture.
  32935. */
  32936. name: string;
  32937. /**
  32938. * Gets or sets an object used to store user defined information.
  32939. */
  32940. metadata: any;
  32941. /**
  32942. * For internal use only. Please do not use.
  32943. */
  32944. reservedDataStore: any;
  32945. private _hasAlpha;
  32946. /**
  32947. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32948. */
  32949. set hasAlpha(value: boolean);
  32950. get hasAlpha(): boolean;
  32951. /**
  32952. * Defines if the alpha value should be determined via the rgb values.
  32953. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32954. */
  32955. getAlphaFromRGB: boolean;
  32956. /**
  32957. * Intensity or strength of the texture.
  32958. * It is commonly used by materials to fine tune the intensity of the texture
  32959. */
  32960. level: number;
  32961. /**
  32962. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32963. * This is part of the texture as textures usually maps to one uv set.
  32964. */
  32965. coordinatesIndex: number;
  32966. private _coordinatesMode;
  32967. /**
  32968. * How a texture is mapped.
  32969. *
  32970. * | Value | Type | Description |
  32971. * | ----- | ----------------------------------- | ----------- |
  32972. * | 0 | EXPLICIT_MODE | |
  32973. * | 1 | SPHERICAL_MODE | |
  32974. * | 2 | PLANAR_MODE | |
  32975. * | 3 | CUBIC_MODE | |
  32976. * | 4 | PROJECTION_MODE | |
  32977. * | 5 | SKYBOX_MODE | |
  32978. * | 6 | INVCUBIC_MODE | |
  32979. * | 7 | EQUIRECTANGULAR_MODE | |
  32980. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32981. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32982. */
  32983. set coordinatesMode(value: number);
  32984. get coordinatesMode(): number;
  32985. /**
  32986. * | Value | Type | Description |
  32987. * | ----- | ------------------ | ----------- |
  32988. * | 0 | CLAMP_ADDRESSMODE | |
  32989. * | 1 | WRAP_ADDRESSMODE | |
  32990. * | 2 | MIRROR_ADDRESSMODE | |
  32991. */
  32992. wrapU: number;
  32993. /**
  32994. * | Value | Type | Description |
  32995. * | ----- | ------------------ | ----------- |
  32996. * | 0 | CLAMP_ADDRESSMODE | |
  32997. * | 1 | WRAP_ADDRESSMODE | |
  32998. * | 2 | MIRROR_ADDRESSMODE | |
  32999. */
  33000. wrapV: number;
  33001. /**
  33002. * | Value | Type | Description |
  33003. * | ----- | ------------------ | ----------- |
  33004. * | 0 | CLAMP_ADDRESSMODE | |
  33005. * | 1 | WRAP_ADDRESSMODE | |
  33006. * | 2 | MIRROR_ADDRESSMODE | |
  33007. */
  33008. wrapR: number;
  33009. /**
  33010. * With compliant hardware and browser (supporting anisotropic filtering)
  33011. * this defines the level of anisotropic filtering in the texture.
  33012. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33013. */
  33014. anisotropicFilteringLevel: number;
  33015. /**
  33016. * Define if the texture is a cube texture or if false a 2d texture.
  33017. */
  33018. get isCube(): boolean;
  33019. set isCube(value: boolean);
  33020. /**
  33021. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33022. */
  33023. get is3D(): boolean;
  33024. set is3D(value: boolean);
  33025. /**
  33026. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33027. */
  33028. get is2DArray(): boolean;
  33029. set is2DArray(value: boolean);
  33030. /**
  33031. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33032. * HDR texture are usually stored in linear space.
  33033. * This only impacts the PBR and Background materials
  33034. */
  33035. gammaSpace: boolean;
  33036. /**
  33037. * Gets or sets whether or not the texture contains RGBD data.
  33038. */
  33039. get isRGBD(): boolean;
  33040. set isRGBD(value: boolean);
  33041. /**
  33042. * Is Z inverted in the texture (useful in a cube texture).
  33043. */
  33044. invertZ: boolean;
  33045. /**
  33046. * Are mip maps generated for this texture or not.
  33047. */
  33048. get noMipmap(): boolean;
  33049. /**
  33050. * @hidden
  33051. */
  33052. lodLevelInAlpha: boolean;
  33053. /**
  33054. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33055. */
  33056. get lodGenerationOffset(): number;
  33057. set lodGenerationOffset(value: number);
  33058. /**
  33059. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33060. */
  33061. get lodGenerationScale(): number;
  33062. set lodGenerationScale(value: number);
  33063. /**
  33064. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33065. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33066. * average roughness values.
  33067. */
  33068. get linearSpecularLOD(): boolean;
  33069. set linearSpecularLOD(value: boolean);
  33070. /**
  33071. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33072. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33073. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33074. */
  33075. get irradianceTexture(): Nullable<BaseTexture>;
  33076. set irradianceTexture(value: Nullable<BaseTexture>);
  33077. /**
  33078. * Define if the texture is a render target.
  33079. */
  33080. isRenderTarget: boolean;
  33081. /**
  33082. * Define the unique id of the texture in the scene.
  33083. */
  33084. get uid(): string;
  33085. /** @hidden */
  33086. _prefiltered: boolean;
  33087. /**
  33088. * Return a string representation of the texture.
  33089. * @returns the texture as a string
  33090. */
  33091. toString(): string;
  33092. /**
  33093. * Get the class name of the texture.
  33094. * @returns "BaseTexture"
  33095. */
  33096. getClassName(): string;
  33097. /**
  33098. * Define the list of animation attached to the texture.
  33099. */
  33100. animations: Animation[];
  33101. /**
  33102. * An event triggered when the texture is disposed.
  33103. */
  33104. onDisposeObservable: Observable<BaseTexture>;
  33105. private _onDisposeObserver;
  33106. /**
  33107. * Callback triggered when the texture has been disposed.
  33108. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33109. */
  33110. set onDispose(callback: () => void);
  33111. /**
  33112. * Define the current state of the loading sequence when in delayed load mode.
  33113. */
  33114. delayLoadState: number;
  33115. private _scene;
  33116. private _engine;
  33117. /** @hidden */
  33118. _texture: Nullable<InternalTexture>;
  33119. private _uid;
  33120. /**
  33121. * Define if the texture is preventinga material to render or not.
  33122. * If not and the texture is not ready, the engine will use a default black texture instead.
  33123. */
  33124. get isBlocking(): boolean;
  33125. /**
  33126. * Instantiates a new BaseTexture.
  33127. * Base class of all the textures in babylon.
  33128. * It groups all the common properties the materials, post process, lights... might need
  33129. * in order to make a correct use of the texture.
  33130. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33131. */
  33132. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33133. /**
  33134. * Get the scene the texture belongs to.
  33135. * @returns the scene or null if undefined
  33136. */
  33137. getScene(): Nullable<Scene>;
  33138. /** @hidden */
  33139. protected _getEngine(): Nullable<ThinEngine>;
  33140. /**
  33141. * Get the texture transform matrix used to offset tile the texture for istance.
  33142. * @returns the transformation matrix
  33143. */
  33144. getTextureMatrix(): Matrix;
  33145. /**
  33146. * Get the texture reflection matrix used to rotate/transform the reflection.
  33147. * @returns the reflection matrix
  33148. */
  33149. getReflectionTextureMatrix(): Matrix;
  33150. /**
  33151. * Get the underlying lower level texture from Babylon.
  33152. * @returns the insternal texture
  33153. */
  33154. getInternalTexture(): Nullable<InternalTexture>;
  33155. /**
  33156. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33157. * @returns true if ready or not blocking
  33158. */
  33159. isReadyOrNotBlocking(): boolean;
  33160. /**
  33161. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33162. * @returns true if fully ready
  33163. */
  33164. isReady(): boolean;
  33165. private _cachedSize;
  33166. /**
  33167. * Get the size of the texture.
  33168. * @returns the texture size.
  33169. */
  33170. getSize(): ISize;
  33171. /**
  33172. * Get the base size of the texture.
  33173. * It can be different from the size if the texture has been resized for POT for instance
  33174. * @returns the base size
  33175. */
  33176. getBaseSize(): ISize;
  33177. /**
  33178. * Update the sampling mode of the texture.
  33179. * Default is Trilinear mode.
  33180. *
  33181. * | Value | Type | Description |
  33182. * | ----- | ------------------ | ----------- |
  33183. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33184. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33185. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33186. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33187. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33188. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33189. * | 7 | NEAREST_LINEAR | |
  33190. * | 8 | NEAREST_NEAREST | |
  33191. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33192. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33193. * | 11 | LINEAR_LINEAR | |
  33194. * | 12 | LINEAR_NEAREST | |
  33195. *
  33196. * > _mag_: magnification filter (close to the viewer)
  33197. * > _min_: minification filter (far from the viewer)
  33198. * > _mip_: filter used between mip map levels
  33199. *@param samplingMode Define the new sampling mode of the texture
  33200. */
  33201. updateSamplingMode(samplingMode: number): void;
  33202. /**
  33203. * Scales the texture if is `canRescale()`
  33204. * @param ratio the resize factor we want to use to rescale
  33205. */
  33206. scale(ratio: number): void;
  33207. /**
  33208. * Get if the texture can rescale.
  33209. */
  33210. get canRescale(): boolean;
  33211. /** @hidden */
  33212. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33213. /** @hidden */
  33214. _rebuild(): void;
  33215. /**
  33216. * Triggers the load sequence in delayed load mode.
  33217. */
  33218. delayLoad(): void;
  33219. /**
  33220. * Clones the texture.
  33221. * @returns the cloned texture
  33222. */
  33223. clone(): Nullable<BaseTexture>;
  33224. /**
  33225. * Get the texture underlying type (INT, FLOAT...)
  33226. */
  33227. get textureType(): number;
  33228. /**
  33229. * Get the texture underlying format (RGB, RGBA...)
  33230. */
  33231. get textureFormat(): number;
  33232. /**
  33233. * Indicates that textures need to be re-calculated for all materials
  33234. */
  33235. protected _markAllSubMeshesAsTexturesDirty(): void;
  33236. /**
  33237. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33238. * This will returns an RGBA array buffer containing either in values (0-255) or
  33239. * float values (0-1) depending of the underlying buffer type.
  33240. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33241. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33242. * @param buffer defines a user defined buffer to fill with data (can be null)
  33243. * @returns The Array buffer containing the pixels data.
  33244. */
  33245. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33246. /**
  33247. * Release and destroy the underlying lower level texture aka internalTexture.
  33248. */
  33249. releaseInternalTexture(): void;
  33250. /** @hidden */
  33251. get _lodTextureHigh(): Nullable<BaseTexture>;
  33252. /** @hidden */
  33253. get _lodTextureMid(): Nullable<BaseTexture>;
  33254. /** @hidden */
  33255. get _lodTextureLow(): Nullable<BaseTexture>;
  33256. /**
  33257. * Dispose the texture and release its associated resources.
  33258. */
  33259. dispose(): void;
  33260. /**
  33261. * Serialize the texture into a JSON representation that can be parsed later on.
  33262. * @returns the JSON representation of the texture
  33263. */
  33264. serialize(): any;
  33265. /**
  33266. * Helper function to be called back once a list of texture contains only ready textures.
  33267. * @param textures Define the list of textures to wait for
  33268. * @param callback Define the callback triggered once the entire list will be ready
  33269. */
  33270. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33271. private static _isScene;
  33272. }
  33273. }
  33274. declare module BABYLON {
  33275. /**
  33276. * Options to be used when creating an effect.
  33277. */
  33278. export interface IEffectCreationOptions {
  33279. /**
  33280. * Atrributes that will be used in the shader.
  33281. */
  33282. attributes: string[];
  33283. /**
  33284. * Uniform varible names that will be set in the shader.
  33285. */
  33286. uniformsNames: string[];
  33287. /**
  33288. * Uniform buffer variable names that will be set in the shader.
  33289. */
  33290. uniformBuffersNames: string[];
  33291. /**
  33292. * Sampler texture variable names that will be set in the shader.
  33293. */
  33294. samplers: string[];
  33295. /**
  33296. * Define statements that will be set in the shader.
  33297. */
  33298. defines: any;
  33299. /**
  33300. * Possible fallbacks for this effect to improve performance when needed.
  33301. */
  33302. fallbacks: Nullable<IEffectFallbacks>;
  33303. /**
  33304. * Callback that will be called when the shader is compiled.
  33305. */
  33306. onCompiled: Nullable<(effect: Effect) => void>;
  33307. /**
  33308. * Callback that will be called if an error occurs during shader compilation.
  33309. */
  33310. onError: Nullable<(effect: Effect, errors: string) => void>;
  33311. /**
  33312. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33313. */
  33314. indexParameters?: any;
  33315. /**
  33316. * Max number of lights that can be used in the shader.
  33317. */
  33318. maxSimultaneousLights?: number;
  33319. /**
  33320. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33321. */
  33322. transformFeedbackVaryings?: Nullable<string[]>;
  33323. /**
  33324. * 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
  33325. */
  33326. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33327. }
  33328. /**
  33329. * Effect containing vertex and fragment shader that can be executed on an object.
  33330. */
  33331. export class Effect implements IDisposable {
  33332. /**
  33333. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33334. */
  33335. static ShadersRepository: string;
  33336. /**
  33337. * Enable logging of the shader code when a compilation error occurs
  33338. */
  33339. static LogShaderCodeOnCompilationError: boolean;
  33340. /**
  33341. * Name of the effect.
  33342. */
  33343. name: any;
  33344. /**
  33345. * String container all the define statements that should be set on the shader.
  33346. */
  33347. defines: string;
  33348. /**
  33349. * Callback that will be called when the shader is compiled.
  33350. */
  33351. onCompiled: Nullable<(effect: Effect) => void>;
  33352. /**
  33353. * Callback that will be called if an error occurs during shader compilation.
  33354. */
  33355. onError: Nullable<(effect: Effect, errors: string) => void>;
  33356. /**
  33357. * Callback that will be called when effect is bound.
  33358. */
  33359. onBind: Nullable<(effect: Effect) => void>;
  33360. /**
  33361. * Unique ID of the effect.
  33362. */
  33363. uniqueId: number;
  33364. /**
  33365. * Observable that will be called when the shader is compiled.
  33366. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33367. */
  33368. onCompileObservable: Observable<Effect>;
  33369. /**
  33370. * Observable that will be called if an error occurs during shader compilation.
  33371. */
  33372. onErrorObservable: Observable<Effect>;
  33373. /** @hidden */
  33374. _onBindObservable: Nullable<Observable<Effect>>;
  33375. /**
  33376. * @hidden
  33377. * Specifies if the effect was previously ready
  33378. */
  33379. _wasPreviouslyReady: boolean;
  33380. /**
  33381. * Observable that will be called when effect is bound.
  33382. */
  33383. get onBindObservable(): Observable<Effect>;
  33384. /** @hidden */
  33385. _bonesComputationForcedToCPU: boolean;
  33386. private static _uniqueIdSeed;
  33387. private _engine;
  33388. private _uniformBuffersNames;
  33389. private _uniformBuffersNamesList;
  33390. private _uniformsNames;
  33391. private _samplerList;
  33392. private _samplers;
  33393. private _isReady;
  33394. private _compilationError;
  33395. private _allFallbacksProcessed;
  33396. private _attributesNames;
  33397. private _attributes;
  33398. private _attributeLocationByName;
  33399. private _uniforms;
  33400. /**
  33401. * Key for the effect.
  33402. * @hidden
  33403. */
  33404. _key: string;
  33405. private _indexParameters;
  33406. private _fallbacks;
  33407. private _vertexSourceCode;
  33408. private _fragmentSourceCode;
  33409. private _vertexSourceCodeOverride;
  33410. private _fragmentSourceCodeOverride;
  33411. private _transformFeedbackVaryings;
  33412. /**
  33413. * Compiled shader to webGL program.
  33414. * @hidden
  33415. */
  33416. _pipelineContext: Nullable<IPipelineContext>;
  33417. private _valueCache;
  33418. private static _baseCache;
  33419. /**
  33420. * Instantiates an effect.
  33421. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33422. * @param baseName Name of the effect.
  33423. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33424. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33425. * @param samplers List of sampler variables that will be passed to the shader.
  33426. * @param engine Engine to be used to render the effect
  33427. * @param defines Define statements to be added to the shader.
  33428. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33429. * @param onCompiled Callback that will be called when the shader is compiled.
  33430. * @param onError Callback that will be called if an error occurs during shader compilation.
  33431. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33432. */
  33433. 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);
  33434. private _useFinalCode;
  33435. /**
  33436. * Unique key for this effect
  33437. */
  33438. get key(): string;
  33439. /**
  33440. * If the effect has been compiled and prepared.
  33441. * @returns if the effect is compiled and prepared.
  33442. */
  33443. isReady(): boolean;
  33444. private _isReadyInternal;
  33445. /**
  33446. * The engine the effect was initialized with.
  33447. * @returns the engine.
  33448. */
  33449. getEngine(): Engine;
  33450. /**
  33451. * The pipeline context for this effect
  33452. * @returns the associated pipeline context
  33453. */
  33454. getPipelineContext(): Nullable<IPipelineContext>;
  33455. /**
  33456. * The set of names of attribute variables for the shader.
  33457. * @returns An array of attribute names.
  33458. */
  33459. getAttributesNames(): string[];
  33460. /**
  33461. * Returns the attribute at the given index.
  33462. * @param index The index of the attribute.
  33463. * @returns The location of the attribute.
  33464. */
  33465. getAttributeLocation(index: number): number;
  33466. /**
  33467. * Returns the attribute based on the name of the variable.
  33468. * @param name of the attribute to look up.
  33469. * @returns the attribute location.
  33470. */
  33471. getAttributeLocationByName(name: string): number;
  33472. /**
  33473. * The number of attributes.
  33474. * @returns the numnber of attributes.
  33475. */
  33476. getAttributesCount(): number;
  33477. /**
  33478. * Gets the index of a uniform variable.
  33479. * @param uniformName of the uniform to look up.
  33480. * @returns the index.
  33481. */
  33482. getUniformIndex(uniformName: string): number;
  33483. /**
  33484. * Returns the attribute based on the name of the variable.
  33485. * @param uniformName of the uniform to look up.
  33486. * @returns the location of the uniform.
  33487. */
  33488. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33489. /**
  33490. * Returns an array of sampler variable names
  33491. * @returns The array of sampler variable names.
  33492. */
  33493. getSamplers(): string[];
  33494. /**
  33495. * Returns an array of uniform variable names
  33496. * @returns The array of uniform variable names.
  33497. */
  33498. getUniformNames(): string[];
  33499. /**
  33500. * Returns an array of uniform buffer variable names
  33501. * @returns The array of uniform buffer variable names.
  33502. */
  33503. getUniformBuffersNames(): string[];
  33504. /**
  33505. * Returns the index parameters used to create the effect
  33506. * @returns The index parameters object
  33507. */
  33508. getIndexParameters(): any;
  33509. /**
  33510. * The error from the last compilation.
  33511. * @returns the error string.
  33512. */
  33513. getCompilationError(): string;
  33514. /**
  33515. * Gets a boolean indicating that all fallbacks were used during compilation
  33516. * @returns true if all fallbacks were used
  33517. */
  33518. allFallbacksProcessed(): boolean;
  33519. /**
  33520. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33521. * @param func The callback to be used.
  33522. */
  33523. executeWhenCompiled(func: (effect: Effect) => void): void;
  33524. private _checkIsReady;
  33525. private _loadShader;
  33526. /**
  33527. * Gets the vertex shader source code of this effect
  33528. */
  33529. get vertexSourceCode(): string;
  33530. /**
  33531. * Gets the fragment shader source code of this effect
  33532. */
  33533. get fragmentSourceCode(): string;
  33534. /**
  33535. * Recompiles the webGL program
  33536. * @param vertexSourceCode The source code for the vertex shader.
  33537. * @param fragmentSourceCode The source code for the fragment shader.
  33538. * @param onCompiled Callback called when completed.
  33539. * @param onError Callback called on error.
  33540. * @hidden
  33541. */
  33542. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33543. /**
  33544. * Prepares the effect
  33545. * @hidden
  33546. */
  33547. _prepareEffect(): void;
  33548. private _getShaderCodeAndErrorLine;
  33549. private _processCompilationErrors;
  33550. /**
  33551. * Checks if the effect is supported. (Must be called after compilation)
  33552. */
  33553. get isSupported(): boolean;
  33554. /**
  33555. * Binds a texture to the engine to be used as output of the shader.
  33556. * @param channel Name of the output variable.
  33557. * @param texture Texture to bind.
  33558. * @hidden
  33559. */
  33560. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33561. /**
  33562. * Sets a texture on the engine to be used in the shader.
  33563. * @param channel Name of the sampler variable.
  33564. * @param texture Texture to set.
  33565. */
  33566. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33567. /**
  33568. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33569. * @param channel Name of the sampler variable.
  33570. * @param texture Texture to set.
  33571. */
  33572. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33573. /**
  33574. * Sets an array of textures on the engine to be used in the shader.
  33575. * @param channel Name of the variable.
  33576. * @param textures Textures to set.
  33577. */
  33578. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33579. /**
  33580. * 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)
  33581. * @param channel Name of the sampler variable.
  33582. * @param postProcess Post process to get the input texture from.
  33583. */
  33584. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33585. /**
  33586. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33587. * 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)
  33588. * @param channel Name of the sampler variable.
  33589. * @param postProcess Post process to get the output texture from.
  33590. */
  33591. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33592. /** @hidden */
  33593. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33594. /** @hidden */
  33595. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33596. /** @hidden */
  33597. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33598. /** @hidden */
  33599. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33600. /**
  33601. * Binds a buffer to a uniform.
  33602. * @param buffer Buffer to bind.
  33603. * @param name Name of the uniform variable to bind to.
  33604. */
  33605. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33606. /**
  33607. * Binds block to a uniform.
  33608. * @param blockName Name of the block to bind.
  33609. * @param index Index to bind.
  33610. */
  33611. bindUniformBlock(blockName: string, index: number): void;
  33612. /**
  33613. * Sets an interger value on a uniform variable.
  33614. * @param uniformName Name of the variable.
  33615. * @param value Value to be set.
  33616. * @returns this effect.
  33617. */
  33618. setInt(uniformName: string, value: number): Effect;
  33619. /**
  33620. * Sets an int array on a uniform variable.
  33621. * @param uniformName Name of the variable.
  33622. * @param array array to be set.
  33623. * @returns this effect.
  33624. */
  33625. setIntArray(uniformName: string, array: Int32Array): Effect;
  33626. /**
  33627. * 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)
  33628. * @param uniformName Name of the variable.
  33629. * @param array array to be set.
  33630. * @returns this effect.
  33631. */
  33632. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33633. /**
  33634. * 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)
  33635. * @param uniformName Name of the variable.
  33636. * @param array array to be set.
  33637. * @returns this effect.
  33638. */
  33639. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33640. /**
  33641. * 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)
  33642. * @param uniformName Name of the variable.
  33643. * @param array array to be set.
  33644. * @returns this effect.
  33645. */
  33646. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33647. /**
  33648. * Sets an float array on a uniform variable.
  33649. * @param uniformName Name of the variable.
  33650. * @param array array to be set.
  33651. * @returns this effect.
  33652. */
  33653. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33654. /**
  33655. * 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)
  33656. * @param uniformName Name of the variable.
  33657. * @param array array to be set.
  33658. * @returns this effect.
  33659. */
  33660. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33661. /**
  33662. * 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)
  33663. * @param uniformName Name of the variable.
  33664. * @param array array to be set.
  33665. * @returns this effect.
  33666. */
  33667. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33668. /**
  33669. * 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)
  33670. * @param uniformName Name of the variable.
  33671. * @param array array to be set.
  33672. * @returns this effect.
  33673. */
  33674. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33675. /**
  33676. * Sets an array on a uniform variable.
  33677. * @param uniformName Name of the variable.
  33678. * @param array array to be set.
  33679. * @returns this effect.
  33680. */
  33681. setArray(uniformName: string, array: number[]): Effect;
  33682. /**
  33683. * 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)
  33684. * @param uniformName Name of the variable.
  33685. * @param array array to be set.
  33686. * @returns this effect.
  33687. */
  33688. setArray2(uniformName: string, array: number[]): Effect;
  33689. /**
  33690. * 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)
  33691. * @param uniformName Name of the variable.
  33692. * @param array array to be set.
  33693. * @returns this effect.
  33694. */
  33695. setArray3(uniformName: string, array: number[]): Effect;
  33696. /**
  33697. * 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)
  33698. * @param uniformName Name of the variable.
  33699. * @param array array to be set.
  33700. * @returns this effect.
  33701. */
  33702. setArray4(uniformName: string, array: number[]): Effect;
  33703. /**
  33704. * Sets matrices on a uniform variable.
  33705. * @param uniformName Name of the variable.
  33706. * @param matrices matrices to be set.
  33707. * @returns this effect.
  33708. */
  33709. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33710. /**
  33711. * Sets matrix on a uniform variable.
  33712. * @param uniformName Name of the variable.
  33713. * @param matrix matrix to be set.
  33714. * @returns this effect.
  33715. */
  33716. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33717. /**
  33718. * 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)
  33719. * @param uniformName Name of the variable.
  33720. * @param matrix matrix to be set.
  33721. * @returns this effect.
  33722. */
  33723. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33724. /**
  33725. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33726. * @param uniformName Name of the variable.
  33727. * @param matrix matrix to be set.
  33728. * @returns this effect.
  33729. */
  33730. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33731. /**
  33732. * Sets a float on a uniform variable.
  33733. * @param uniformName Name of the variable.
  33734. * @param value value to be set.
  33735. * @returns this effect.
  33736. */
  33737. setFloat(uniformName: string, value: number): Effect;
  33738. /**
  33739. * Sets a boolean on a uniform variable.
  33740. * @param uniformName Name of the variable.
  33741. * @param bool value to be set.
  33742. * @returns this effect.
  33743. */
  33744. setBool(uniformName: string, bool: boolean): Effect;
  33745. /**
  33746. * Sets a Vector2 on a uniform variable.
  33747. * @param uniformName Name of the variable.
  33748. * @param vector2 vector2 to be set.
  33749. * @returns this effect.
  33750. */
  33751. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33752. /**
  33753. * Sets a float2 on a uniform variable.
  33754. * @param uniformName Name of the variable.
  33755. * @param x First float in float2.
  33756. * @param y Second float in float2.
  33757. * @returns this effect.
  33758. */
  33759. setFloat2(uniformName: string, x: number, y: number): Effect;
  33760. /**
  33761. * Sets a Vector3 on a uniform variable.
  33762. * @param uniformName Name of the variable.
  33763. * @param vector3 Value to be set.
  33764. * @returns this effect.
  33765. */
  33766. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33767. /**
  33768. * Sets a float3 on a uniform variable.
  33769. * @param uniformName Name of the variable.
  33770. * @param x First float in float3.
  33771. * @param y Second float in float3.
  33772. * @param z Third float in float3.
  33773. * @returns this effect.
  33774. */
  33775. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33776. /**
  33777. * Sets a Vector4 on a uniform variable.
  33778. * @param uniformName Name of the variable.
  33779. * @param vector4 Value to be set.
  33780. * @returns this effect.
  33781. */
  33782. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33783. /**
  33784. * Sets a float4 on a uniform variable.
  33785. * @param uniformName Name of the variable.
  33786. * @param x First float in float4.
  33787. * @param y Second float in float4.
  33788. * @param z Third float in float4.
  33789. * @param w Fourth float in float4.
  33790. * @returns this effect.
  33791. */
  33792. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33793. /**
  33794. * Sets a Color3 on a uniform variable.
  33795. * @param uniformName Name of the variable.
  33796. * @param color3 Value to be set.
  33797. * @returns this effect.
  33798. */
  33799. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33800. /**
  33801. * Sets a Color4 on a uniform variable.
  33802. * @param uniformName Name of the variable.
  33803. * @param color3 Value to be set.
  33804. * @param alpha Alpha value to be set.
  33805. * @returns this effect.
  33806. */
  33807. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33808. /**
  33809. * Sets a Color4 on a uniform variable
  33810. * @param uniformName defines the name of the variable
  33811. * @param color4 defines the value to be set
  33812. * @returns this effect.
  33813. */
  33814. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33815. /** Release all associated resources */
  33816. dispose(): void;
  33817. /**
  33818. * This function will add a new shader to the shader store
  33819. * @param name the name of the shader
  33820. * @param pixelShader optional pixel shader content
  33821. * @param vertexShader optional vertex shader content
  33822. */
  33823. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33824. /**
  33825. * Store of each shader (The can be looked up using effect.key)
  33826. */
  33827. static ShadersStore: {
  33828. [key: string]: string;
  33829. };
  33830. /**
  33831. * Store of each included file for a shader (The can be looked up using effect.key)
  33832. */
  33833. static IncludesShadersStore: {
  33834. [key: string]: string;
  33835. };
  33836. /**
  33837. * Resets the cache of effects.
  33838. */
  33839. static ResetCache(): void;
  33840. }
  33841. }
  33842. declare module BABYLON {
  33843. /**
  33844. * Interface used to describe the capabilities of the engine relatively to the current browser
  33845. */
  33846. export interface EngineCapabilities {
  33847. /** Maximum textures units per fragment shader */
  33848. maxTexturesImageUnits: number;
  33849. /** Maximum texture units per vertex shader */
  33850. maxVertexTextureImageUnits: number;
  33851. /** Maximum textures units in the entire pipeline */
  33852. maxCombinedTexturesImageUnits: number;
  33853. /** Maximum texture size */
  33854. maxTextureSize: number;
  33855. /** Maximum texture samples */
  33856. maxSamples?: number;
  33857. /** Maximum cube texture size */
  33858. maxCubemapTextureSize: number;
  33859. /** Maximum render texture size */
  33860. maxRenderTextureSize: number;
  33861. /** Maximum number of vertex attributes */
  33862. maxVertexAttribs: number;
  33863. /** Maximum number of varyings */
  33864. maxVaryingVectors: number;
  33865. /** Maximum number of uniforms per vertex shader */
  33866. maxVertexUniformVectors: number;
  33867. /** Maximum number of uniforms per fragment shader */
  33868. maxFragmentUniformVectors: number;
  33869. /** Defines if standard derivates (dx/dy) are supported */
  33870. standardDerivatives: boolean;
  33871. /** Defines if s3tc texture compression is supported */
  33872. s3tc?: WEBGL_compressed_texture_s3tc;
  33873. /** Defines if pvrtc texture compression is supported */
  33874. pvrtc: any;
  33875. /** Defines if etc1 texture compression is supported */
  33876. etc1: any;
  33877. /** Defines if etc2 texture compression is supported */
  33878. etc2: any;
  33879. /** Defines if astc texture compression is supported */
  33880. astc: any;
  33881. /** Defines if float textures are supported */
  33882. textureFloat: boolean;
  33883. /** Defines if vertex array objects are supported */
  33884. vertexArrayObject: boolean;
  33885. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33886. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33887. /** Gets the maximum level of anisotropy supported */
  33888. maxAnisotropy: number;
  33889. /** Defines if instancing is supported */
  33890. instancedArrays: boolean;
  33891. /** Defines if 32 bits indices are supported */
  33892. uintIndices: boolean;
  33893. /** Defines if high precision shaders are supported */
  33894. highPrecisionShaderSupported: boolean;
  33895. /** Defines if depth reading in the fragment shader is supported */
  33896. fragmentDepthSupported: boolean;
  33897. /** Defines if float texture linear filtering is supported*/
  33898. textureFloatLinearFiltering: boolean;
  33899. /** Defines if rendering to float textures is supported */
  33900. textureFloatRender: boolean;
  33901. /** Defines if half float textures are supported*/
  33902. textureHalfFloat: boolean;
  33903. /** Defines if half float texture linear filtering is supported*/
  33904. textureHalfFloatLinearFiltering: boolean;
  33905. /** Defines if rendering to half float textures is supported */
  33906. textureHalfFloatRender: boolean;
  33907. /** Defines if textureLOD shader command is supported */
  33908. textureLOD: boolean;
  33909. /** Defines if draw buffers extension is supported */
  33910. drawBuffersExtension: boolean;
  33911. /** Defines if depth textures are supported */
  33912. depthTextureExtension: boolean;
  33913. /** Defines if float color buffer are supported */
  33914. colorBufferFloat: boolean;
  33915. /** Gets disjoint timer query extension (null if not supported) */
  33916. timerQuery?: EXT_disjoint_timer_query;
  33917. /** Defines if timestamp can be used with timer query */
  33918. canUseTimestampForTimerQuery: boolean;
  33919. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33920. multiview?: any;
  33921. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33922. oculusMultiview?: any;
  33923. /** Function used to let the system compiles shaders in background */
  33924. parallelShaderCompile?: {
  33925. COMPLETION_STATUS_KHR: number;
  33926. };
  33927. /** Max number of texture samples for MSAA */
  33928. maxMSAASamples: number;
  33929. /** Defines if the blend min max extension is supported */
  33930. blendMinMax: boolean;
  33931. }
  33932. }
  33933. declare module BABYLON {
  33934. /**
  33935. * @hidden
  33936. **/
  33937. export class DepthCullingState {
  33938. private _isDepthTestDirty;
  33939. private _isDepthMaskDirty;
  33940. private _isDepthFuncDirty;
  33941. private _isCullFaceDirty;
  33942. private _isCullDirty;
  33943. private _isZOffsetDirty;
  33944. private _isFrontFaceDirty;
  33945. private _depthTest;
  33946. private _depthMask;
  33947. private _depthFunc;
  33948. private _cull;
  33949. private _cullFace;
  33950. private _zOffset;
  33951. private _frontFace;
  33952. /**
  33953. * Initializes the state.
  33954. */
  33955. constructor();
  33956. get isDirty(): boolean;
  33957. get zOffset(): number;
  33958. set zOffset(value: number);
  33959. get cullFace(): Nullable<number>;
  33960. set cullFace(value: Nullable<number>);
  33961. get cull(): Nullable<boolean>;
  33962. set cull(value: Nullable<boolean>);
  33963. get depthFunc(): Nullable<number>;
  33964. set depthFunc(value: Nullable<number>);
  33965. get depthMask(): boolean;
  33966. set depthMask(value: boolean);
  33967. get depthTest(): boolean;
  33968. set depthTest(value: boolean);
  33969. get frontFace(): Nullable<number>;
  33970. set frontFace(value: Nullable<number>);
  33971. reset(): void;
  33972. apply(gl: WebGLRenderingContext): void;
  33973. }
  33974. }
  33975. declare module BABYLON {
  33976. /**
  33977. * @hidden
  33978. **/
  33979. export class StencilState {
  33980. /** 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 */
  33981. static readonly ALWAYS: number;
  33982. /** Passed to stencilOperation to specify that stencil value must be kept */
  33983. static readonly KEEP: number;
  33984. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33985. static readonly REPLACE: number;
  33986. private _isStencilTestDirty;
  33987. private _isStencilMaskDirty;
  33988. private _isStencilFuncDirty;
  33989. private _isStencilOpDirty;
  33990. private _stencilTest;
  33991. private _stencilMask;
  33992. private _stencilFunc;
  33993. private _stencilFuncRef;
  33994. private _stencilFuncMask;
  33995. private _stencilOpStencilFail;
  33996. private _stencilOpDepthFail;
  33997. private _stencilOpStencilDepthPass;
  33998. get isDirty(): boolean;
  33999. get stencilFunc(): number;
  34000. set stencilFunc(value: number);
  34001. get stencilFuncRef(): number;
  34002. set stencilFuncRef(value: number);
  34003. get stencilFuncMask(): number;
  34004. set stencilFuncMask(value: number);
  34005. get stencilOpStencilFail(): number;
  34006. set stencilOpStencilFail(value: number);
  34007. get stencilOpDepthFail(): number;
  34008. set stencilOpDepthFail(value: number);
  34009. get stencilOpStencilDepthPass(): number;
  34010. set stencilOpStencilDepthPass(value: number);
  34011. get stencilMask(): number;
  34012. set stencilMask(value: number);
  34013. get stencilTest(): boolean;
  34014. set stencilTest(value: boolean);
  34015. constructor();
  34016. reset(): void;
  34017. apply(gl: WebGLRenderingContext): void;
  34018. }
  34019. }
  34020. declare module BABYLON {
  34021. /**
  34022. * @hidden
  34023. **/
  34024. export class AlphaState {
  34025. private _isAlphaBlendDirty;
  34026. private _isBlendFunctionParametersDirty;
  34027. private _isBlendEquationParametersDirty;
  34028. private _isBlendConstantsDirty;
  34029. private _alphaBlend;
  34030. private _blendFunctionParameters;
  34031. private _blendEquationParameters;
  34032. private _blendConstants;
  34033. /**
  34034. * Initializes the state.
  34035. */
  34036. constructor();
  34037. get isDirty(): boolean;
  34038. get alphaBlend(): boolean;
  34039. set alphaBlend(value: boolean);
  34040. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34041. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34042. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34043. reset(): void;
  34044. apply(gl: WebGLRenderingContext): void;
  34045. }
  34046. }
  34047. declare module BABYLON {
  34048. /** @hidden */
  34049. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34050. attributeProcessor(attribute: string): string;
  34051. varyingProcessor(varying: string, isFragment: boolean): string;
  34052. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34053. }
  34054. }
  34055. declare module BABYLON {
  34056. /**
  34057. * Interface for attribute information associated with buffer instanciation
  34058. */
  34059. export interface InstancingAttributeInfo {
  34060. /**
  34061. * Name of the GLSL attribute
  34062. * if attribute index is not specified, this is used to retrieve the index from the effect
  34063. */
  34064. attributeName: string;
  34065. /**
  34066. * Index/offset of the attribute in the vertex shader
  34067. * if not specified, this will be computes from the name.
  34068. */
  34069. index?: number;
  34070. /**
  34071. * size of the attribute, 1, 2, 3 or 4
  34072. */
  34073. attributeSize: number;
  34074. /**
  34075. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34076. */
  34077. offset: number;
  34078. /**
  34079. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34080. * default to 1
  34081. */
  34082. divisor?: number;
  34083. /**
  34084. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34085. * default is FLOAT
  34086. */
  34087. attributeType?: number;
  34088. /**
  34089. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34090. */
  34091. normalized?: boolean;
  34092. }
  34093. }
  34094. declare module BABYLON {
  34095. interface ThinEngine {
  34096. /**
  34097. * Update a video texture
  34098. * @param texture defines the texture to update
  34099. * @param video defines the video element to use
  34100. * @param invertY defines if data must be stored with Y axis inverted
  34101. */
  34102. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34103. }
  34104. }
  34105. declare module BABYLON {
  34106. /**
  34107. * Settings for finer control over video usage
  34108. */
  34109. export interface VideoTextureSettings {
  34110. /**
  34111. * Applies `autoplay` to video, if specified
  34112. */
  34113. autoPlay?: boolean;
  34114. /**
  34115. * Applies `loop` to video, if specified
  34116. */
  34117. loop?: boolean;
  34118. /**
  34119. * Automatically updates internal texture from video at every frame in the render loop
  34120. */
  34121. autoUpdateTexture: boolean;
  34122. /**
  34123. * Image src displayed during the video loading or until the user interacts with the video.
  34124. */
  34125. poster?: string;
  34126. }
  34127. /**
  34128. * If you want to display a video in your scene, this is the special texture for that.
  34129. * This special texture works similar to other textures, with the exception of a few parameters.
  34130. * @see https://doc.babylonjs.com/how_to/video_texture
  34131. */
  34132. export class VideoTexture extends Texture {
  34133. /**
  34134. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34135. */
  34136. readonly autoUpdateTexture: boolean;
  34137. /**
  34138. * The video instance used by the texture internally
  34139. */
  34140. readonly video: HTMLVideoElement;
  34141. private _onUserActionRequestedObservable;
  34142. /**
  34143. * Event triggerd when a dom action is required by the user to play the video.
  34144. * This happens due to recent changes in browser policies preventing video to auto start.
  34145. */
  34146. get onUserActionRequestedObservable(): Observable<Texture>;
  34147. private _generateMipMaps;
  34148. private _stillImageCaptured;
  34149. private _displayingPosterTexture;
  34150. private _settings;
  34151. private _createInternalTextureOnEvent;
  34152. private _frameId;
  34153. private _currentSrc;
  34154. /**
  34155. * Creates a video texture.
  34156. * If you want to display a video in your scene, this is the special texture for that.
  34157. * This special texture works similar to other textures, with the exception of a few parameters.
  34158. * @see https://doc.babylonjs.com/how_to/video_texture
  34159. * @param name optional name, will detect from video source, if not defined
  34160. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34161. * @param scene is obviously the current scene.
  34162. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34163. * @param invertY is false by default but can be used to invert video on Y axis
  34164. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34165. * @param settings allows finer control over video usage
  34166. */
  34167. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34168. private _getName;
  34169. private _getVideo;
  34170. private _createInternalTexture;
  34171. private reset;
  34172. /**
  34173. * @hidden Internal method to initiate `update`.
  34174. */
  34175. _rebuild(): void;
  34176. /**
  34177. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34178. */
  34179. update(): void;
  34180. /**
  34181. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34182. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34183. */
  34184. updateTexture(isVisible: boolean): void;
  34185. protected _updateInternalTexture: () => void;
  34186. /**
  34187. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34188. * @param url New url.
  34189. */
  34190. updateURL(url: string): void;
  34191. /**
  34192. * Clones the texture.
  34193. * @returns the cloned texture
  34194. */
  34195. clone(): VideoTexture;
  34196. /**
  34197. * Dispose the texture and release its associated resources.
  34198. */
  34199. dispose(): void;
  34200. /**
  34201. * Creates a video texture straight from a stream.
  34202. * @param scene Define the scene the texture should be created in
  34203. * @param stream Define the stream the texture should be created from
  34204. * @returns The created video texture as a promise
  34205. */
  34206. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34207. /**
  34208. * Creates a video texture straight from your WebCam video feed.
  34209. * @param scene Define the scene the texture should be created in
  34210. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34211. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34212. * @returns The created video texture as a promise
  34213. */
  34214. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34215. minWidth: number;
  34216. maxWidth: number;
  34217. minHeight: number;
  34218. maxHeight: number;
  34219. deviceId: string;
  34220. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34221. /**
  34222. * Creates a video texture straight from your WebCam video feed.
  34223. * @param scene Define the scene the texture should be created in
  34224. * @param onReady Define a callback to triggered once the texture will be ready
  34225. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34226. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34227. */
  34228. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34229. minWidth: number;
  34230. maxWidth: number;
  34231. minHeight: number;
  34232. maxHeight: number;
  34233. deviceId: string;
  34234. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34235. }
  34236. }
  34237. declare module BABYLON {
  34238. /**
  34239. * Defines the interface used by objects working like Scene
  34240. * @hidden
  34241. */
  34242. export interface ISceneLike {
  34243. _addPendingData(data: any): void;
  34244. _removePendingData(data: any): void;
  34245. offlineProvider: IOfflineProvider;
  34246. }
  34247. /** Interface defining initialization parameters for Engine class */
  34248. export interface EngineOptions extends WebGLContextAttributes {
  34249. /**
  34250. * Defines if the engine should no exceed a specified device ratio
  34251. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34252. */
  34253. limitDeviceRatio?: number;
  34254. /**
  34255. * Defines if webvr should be enabled automatically
  34256. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34257. */
  34258. autoEnableWebVR?: boolean;
  34259. /**
  34260. * Defines if webgl2 should be turned off even if supported
  34261. * @see http://doc.babylonjs.com/features/webgl2
  34262. */
  34263. disableWebGL2Support?: boolean;
  34264. /**
  34265. * Defines if webaudio should be initialized as well
  34266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34267. */
  34268. audioEngine?: boolean;
  34269. /**
  34270. * Defines if animations should run using a deterministic lock step
  34271. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34272. */
  34273. deterministicLockstep?: boolean;
  34274. /** Defines the maximum steps to use with deterministic lock step mode */
  34275. lockstepMaxSteps?: number;
  34276. /** Defines the seconds between each deterministic lock step */
  34277. timeStep?: number;
  34278. /**
  34279. * Defines that engine should ignore context lost events
  34280. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34281. */
  34282. doNotHandleContextLost?: boolean;
  34283. /**
  34284. * Defines that engine should ignore modifying touch action attribute and style
  34285. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34286. */
  34287. doNotHandleTouchAction?: boolean;
  34288. /**
  34289. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34290. */
  34291. useHighPrecisionFloats?: boolean;
  34292. /**
  34293. * Make the canvas XR Compatible for XR sessions
  34294. */
  34295. xrCompatible?: boolean;
  34296. }
  34297. /**
  34298. * The base engine class (root of all engines)
  34299. */
  34300. export class ThinEngine {
  34301. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34302. static ExceptionList: ({
  34303. key: string;
  34304. capture: string;
  34305. captureConstraint: number;
  34306. targets: string[];
  34307. } | {
  34308. key: string;
  34309. capture: null;
  34310. captureConstraint: null;
  34311. targets: string[];
  34312. })[];
  34313. /** @hidden */
  34314. static _TextureLoaders: IInternalTextureLoader[];
  34315. /**
  34316. * Returns the current npm package of the sdk
  34317. */
  34318. static get NpmPackage(): string;
  34319. /**
  34320. * Returns the current version of the framework
  34321. */
  34322. static get Version(): string;
  34323. /**
  34324. * Returns a string describing the current engine
  34325. */
  34326. get description(): string;
  34327. /**
  34328. * Gets or sets the epsilon value used by collision engine
  34329. */
  34330. static CollisionsEpsilon: number;
  34331. /**
  34332. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34333. */
  34334. static get ShadersRepository(): string;
  34335. static set ShadersRepository(value: string);
  34336. /** @hidden */
  34337. _shaderProcessor: IShaderProcessor;
  34338. /**
  34339. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34340. */
  34341. forcePOTTextures: boolean;
  34342. /**
  34343. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34344. */
  34345. isFullscreen: boolean;
  34346. /**
  34347. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34348. */
  34349. cullBackFaces: boolean;
  34350. /**
  34351. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34352. */
  34353. renderEvenInBackground: boolean;
  34354. /**
  34355. * Gets or sets a boolean indicating that cache can be kept between frames
  34356. */
  34357. preventCacheWipeBetweenFrames: boolean;
  34358. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34359. validateShaderPrograms: boolean;
  34360. /**
  34361. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34362. * This can provide greater z depth for distant objects.
  34363. */
  34364. useReverseDepthBuffer: boolean;
  34365. /**
  34366. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34367. */
  34368. disableUniformBuffers: boolean;
  34369. /** @hidden */
  34370. _uniformBuffers: UniformBuffer[];
  34371. /**
  34372. * Gets a boolean indicating that the engine supports uniform buffers
  34373. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34374. */
  34375. get supportsUniformBuffers(): boolean;
  34376. /** @hidden */
  34377. _gl: WebGLRenderingContext;
  34378. /** @hidden */
  34379. _webGLVersion: number;
  34380. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34381. protected _windowIsBackground: boolean;
  34382. protected _creationOptions: EngineOptions;
  34383. protected _highPrecisionShadersAllowed: boolean;
  34384. /** @hidden */
  34385. get _shouldUseHighPrecisionShader(): boolean;
  34386. /**
  34387. * Gets a boolean indicating that only power of 2 textures are supported
  34388. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34389. */
  34390. get needPOTTextures(): boolean;
  34391. /** @hidden */
  34392. _badOS: boolean;
  34393. /** @hidden */
  34394. _badDesktopOS: boolean;
  34395. private _hardwareScalingLevel;
  34396. /** @hidden */
  34397. _caps: EngineCapabilities;
  34398. private _isStencilEnable;
  34399. private _glVersion;
  34400. private _glRenderer;
  34401. private _glVendor;
  34402. /** @hidden */
  34403. _videoTextureSupported: boolean;
  34404. protected _renderingQueueLaunched: boolean;
  34405. protected _activeRenderLoops: (() => void)[];
  34406. /**
  34407. * Observable signaled when a context lost event is raised
  34408. */
  34409. onContextLostObservable: Observable<ThinEngine>;
  34410. /**
  34411. * Observable signaled when a context restored event is raised
  34412. */
  34413. onContextRestoredObservable: Observable<ThinEngine>;
  34414. private _onContextLost;
  34415. private _onContextRestored;
  34416. protected _contextWasLost: boolean;
  34417. /** @hidden */
  34418. _doNotHandleContextLost: boolean;
  34419. /**
  34420. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34421. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34422. */
  34423. get doNotHandleContextLost(): boolean;
  34424. set doNotHandleContextLost(value: boolean);
  34425. /**
  34426. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34427. */
  34428. disableVertexArrayObjects: boolean;
  34429. /** @hidden */
  34430. protected _colorWrite: boolean;
  34431. /** @hidden */
  34432. protected _colorWriteChanged: boolean;
  34433. /** @hidden */
  34434. protected _depthCullingState: DepthCullingState;
  34435. /** @hidden */
  34436. protected _stencilState: StencilState;
  34437. /** @hidden */
  34438. _alphaState: AlphaState;
  34439. /** @hidden */
  34440. _alphaMode: number;
  34441. /** @hidden */
  34442. _alphaEquation: number;
  34443. /** @hidden */
  34444. _internalTexturesCache: InternalTexture[];
  34445. /** @hidden */
  34446. protected _activeChannel: number;
  34447. private _currentTextureChannel;
  34448. /** @hidden */
  34449. protected _boundTexturesCache: {
  34450. [key: string]: Nullable<InternalTexture>;
  34451. };
  34452. /** @hidden */
  34453. protected _currentEffect: Nullable<Effect>;
  34454. /** @hidden */
  34455. protected _currentProgram: Nullable<WebGLProgram>;
  34456. private _compiledEffects;
  34457. private _vertexAttribArraysEnabled;
  34458. /** @hidden */
  34459. protected _cachedViewport: Nullable<IViewportLike>;
  34460. private _cachedVertexArrayObject;
  34461. /** @hidden */
  34462. protected _cachedVertexBuffers: any;
  34463. /** @hidden */
  34464. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34465. /** @hidden */
  34466. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34467. /** @hidden */
  34468. _currentRenderTarget: Nullable<InternalTexture>;
  34469. private _uintIndicesCurrentlySet;
  34470. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34471. /** @hidden */
  34472. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34473. /** @hidden */
  34474. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34475. private _currentBufferPointers;
  34476. private _currentInstanceLocations;
  34477. private _currentInstanceBuffers;
  34478. private _textureUnits;
  34479. /** @hidden */
  34480. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34481. /** @hidden */
  34482. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34483. /** @hidden */
  34484. _boundRenderFunction: any;
  34485. private _vaoRecordInProgress;
  34486. private _mustWipeVertexAttributes;
  34487. private _emptyTexture;
  34488. private _emptyCubeTexture;
  34489. private _emptyTexture3D;
  34490. private _emptyTexture2DArray;
  34491. /** @hidden */
  34492. _frameHandler: number;
  34493. private _nextFreeTextureSlots;
  34494. private _maxSimultaneousTextures;
  34495. private _activeRequests;
  34496. /** @hidden */
  34497. _transformTextureUrl: Nullable<(url: string) => string>;
  34498. protected get _supportsHardwareTextureRescaling(): boolean;
  34499. private _framebufferDimensionsObject;
  34500. /**
  34501. * sets the object from which width and height will be taken from when getting render width and height
  34502. * Will fallback to the gl object
  34503. * @param dimensions the framebuffer width and height that will be used.
  34504. */
  34505. set framebufferDimensionsObject(dimensions: Nullable<{
  34506. framebufferWidth: number;
  34507. framebufferHeight: number;
  34508. }>);
  34509. /**
  34510. * Gets the current viewport
  34511. */
  34512. get currentViewport(): Nullable<IViewportLike>;
  34513. /**
  34514. * Gets the default empty texture
  34515. */
  34516. get emptyTexture(): InternalTexture;
  34517. /**
  34518. * Gets the default empty 3D texture
  34519. */
  34520. get emptyTexture3D(): InternalTexture;
  34521. /**
  34522. * Gets the default empty 2D array texture
  34523. */
  34524. get emptyTexture2DArray(): InternalTexture;
  34525. /**
  34526. * Gets the default empty cube texture
  34527. */
  34528. get emptyCubeTexture(): InternalTexture;
  34529. /**
  34530. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34531. */
  34532. readonly premultipliedAlpha: boolean;
  34533. /**
  34534. * Observable event triggered before each texture is initialized
  34535. */
  34536. onBeforeTextureInitObservable: Observable<Texture>;
  34537. /**
  34538. * Creates a new engine
  34539. * @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
  34540. * @param antialias defines enable antialiasing (default: false)
  34541. * @param options defines further options to be sent to the getContext() function
  34542. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34543. */
  34544. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34545. private _rebuildInternalTextures;
  34546. private _rebuildEffects;
  34547. /**
  34548. * Gets a boolean indicating if all created effects are ready
  34549. * @returns true if all effects are ready
  34550. */
  34551. areAllEffectsReady(): boolean;
  34552. protected _rebuildBuffers(): void;
  34553. protected _initGLContext(): void;
  34554. /**
  34555. * Gets version of the current webGL context
  34556. */
  34557. get webGLVersion(): number;
  34558. /**
  34559. * Gets a string idenfifying the name of the class
  34560. * @returns "Engine" string
  34561. */
  34562. getClassName(): string;
  34563. /**
  34564. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34565. */
  34566. get isStencilEnable(): boolean;
  34567. /** @hidden */
  34568. _prepareWorkingCanvas(): void;
  34569. /**
  34570. * Reset the texture cache to empty state
  34571. */
  34572. resetTextureCache(): void;
  34573. /**
  34574. * Gets an object containing information about the current webGL context
  34575. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34576. */
  34577. getGlInfo(): {
  34578. vendor: string;
  34579. renderer: string;
  34580. version: string;
  34581. };
  34582. /**
  34583. * Defines the hardware scaling level.
  34584. * By default the hardware scaling level is computed from the window device ratio.
  34585. * 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.
  34586. * @param level defines the level to use
  34587. */
  34588. setHardwareScalingLevel(level: number): void;
  34589. /**
  34590. * Gets the current hardware scaling level.
  34591. * By default the hardware scaling level is computed from the window device ratio.
  34592. * 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.
  34593. * @returns a number indicating the current hardware scaling level
  34594. */
  34595. getHardwareScalingLevel(): number;
  34596. /**
  34597. * Gets the list of loaded textures
  34598. * @returns an array containing all loaded textures
  34599. */
  34600. getLoadedTexturesCache(): InternalTexture[];
  34601. /**
  34602. * Gets the object containing all engine capabilities
  34603. * @returns the EngineCapabilities object
  34604. */
  34605. getCaps(): EngineCapabilities;
  34606. /**
  34607. * stop executing a render loop function and remove it from the execution array
  34608. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34609. */
  34610. stopRenderLoop(renderFunction?: () => void): void;
  34611. /** @hidden */
  34612. _renderLoop(): void;
  34613. /**
  34614. * Gets the HTML canvas attached with the current webGL context
  34615. * @returns a HTML canvas
  34616. */
  34617. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34618. /**
  34619. * Gets host window
  34620. * @returns the host window object
  34621. */
  34622. getHostWindow(): Nullable<Window>;
  34623. /**
  34624. * Gets the current render width
  34625. * @param useScreen defines if screen size must be used (or the current render target if any)
  34626. * @returns a number defining the current render width
  34627. */
  34628. getRenderWidth(useScreen?: boolean): number;
  34629. /**
  34630. * Gets the current render height
  34631. * @param useScreen defines if screen size must be used (or the current render target if any)
  34632. * @returns a number defining the current render height
  34633. */
  34634. getRenderHeight(useScreen?: boolean): number;
  34635. /**
  34636. * Can be used to override the current requestAnimationFrame requester.
  34637. * @hidden
  34638. */
  34639. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34640. /**
  34641. * Register and execute a render loop. The engine can have more than one render function
  34642. * @param renderFunction defines the function to continuously execute
  34643. */
  34644. runRenderLoop(renderFunction: () => void): void;
  34645. /**
  34646. * Clear the current render buffer or the current render target (if any is set up)
  34647. * @param color defines the color to use
  34648. * @param backBuffer defines if the back buffer must be cleared
  34649. * @param depth defines if the depth buffer must be cleared
  34650. * @param stencil defines if the stencil buffer must be cleared
  34651. */
  34652. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34653. private _viewportCached;
  34654. /** @hidden */
  34655. _viewport(x: number, y: number, width: number, height: number): void;
  34656. /**
  34657. * Set the WebGL's viewport
  34658. * @param viewport defines the viewport element to be used
  34659. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34660. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34661. */
  34662. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34663. /**
  34664. * Begin a new frame
  34665. */
  34666. beginFrame(): void;
  34667. /**
  34668. * Enf the current frame
  34669. */
  34670. endFrame(): void;
  34671. /**
  34672. * Resize the view according to the canvas' size
  34673. */
  34674. resize(): void;
  34675. /**
  34676. * Force a specific size of the canvas
  34677. * @param width defines the new canvas' width
  34678. * @param height defines the new canvas' height
  34679. */
  34680. setSize(width: number, height: number): void;
  34681. /**
  34682. * Binds the frame buffer to the specified texture.
  34683. * @param texture The texture to render to or null for the default canvas
  34684. * @param faceIndex The face of the texture to render to in case of cube texture
  34685. * @param requiredWidth The width of the target to render to
  34686. * @param requiredHeight The height of the target to render to
  34687. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34688. * @param lodLevel defines the lod level to bind to the frame buffer
  34689. * @param layer defines the 2d array index to bind to frame buffer to
  34690. */
  34691. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34692. /** @hidden */
  34693. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34694. /**
  34695. * Unbind the current render target texture from the webGL context
  34696. * @param texture defines the render target texture to unbind
  34697. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34698. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34699. */
  34700. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34701. /**
  34702. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34703. */
  34704. flushFramebuffer(): void;
  34705. /**
  34706. * Unbind the current render target and bind the default framebuffer
  34707. */
  34708. restoreDefaultFramebuffer(): void;
  34709. /** @hidden */
  34710. protected _resetVertexBufferBinding(): void;
  34711. /**
  34712. * Creates a vertex buffer
  34713. * @param data the data for the vertex buffer
  34714. * @returns the new WebGL static buffer
  34715. */
  34716. createVertexBuffer(data: DataArray): DataBuffer;
  34717. private _createVertexBuffer;
  34718. /**
  34719. * Creates a dynamic vertex buffer
  34720. * @param data the data for the dynamic vertex buffer
  34721. * @returns the new WebGL dynamic buffer
  34722. */
  34723. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34724. protected _resetIndexBufferBinding(): void;
  34725. /**
  34726. * Creates a new index buffer
  34727. * @param indices defines the content of the index buffer
  34728. * @param updatable defines if the index buffer must be updatable
  34729. * @returns a new webGL buffer
  34730. */
  34731. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34732. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34733. /**
  34734. * Bind a webGL buffer to the webGL context
  34735. * @param buffer defines the buffer to bind
  34736. */
  34737. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34738. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34739. private bindBuffer;
  34740. /**
  34741. * update the bound buffer with the given data
  34742. * @param data defines the data to update
  34743. */
  34744. updateArrayBuffer(data: Float32Array): void;
  34745. private _vertexAttribPointer;
  34746. /** @hidden */
  34747. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34748. private _bindVertexBuffersAttributes;
  34749. /**
  34750. * Records a vertex array object
  34751. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34752. * @param vertexBuffers defines the list of vertex buffers to store
  34753. * @param indexBuffer defines the index buffer to store
  34754. * @param effect defines the effect to store
  34755. * @returns the new vertex array object
  34756. */
  34757. recordVertexArrayObject(vertexBuffers: {
  34758. [key: string]: VertexBuffer;
  34759. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34760. /**
  34761. * Bind a specific vertex array object
  34762. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34763. * @param vertexArrayObject defines the vertex array object to bind
  34764. * @param indexBuffer defines the index buffer to bind
  34765. */
  34766. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34767. /**
  34768. * Bind webGl buffers directly to the webGL context
  34769. * @param vertexBuffer defines the vertex buffer to bind
  34770. * @param indexBuffer defines the index buffer to bind
  34771. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34772. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34773. * @param effect defines the effect associated with the vertex buffer
  34774. */
  34775. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34776. private _unbindVertexArrayObject;
  34777. /**
  34778. * Bind a list of vertex buffers to the webGL context
  34779. * @param vertexBuffers defines the list of vertex buffers to bind
  34780. * @param indexBuffer defines the index buffer to bind
  34781. * @param effect defines the effect associated with the vertex buffers
  34782. */
  34783. bindBuffers(vertexBuffers: {
  34784. [key: string]: Nullable<VertexBuffer>;
  34785. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34786. /**
  34787. * Unbind all instance attributes
  34788. */
  34789. unbindInstanceAttributes(): void;
  34790. /**
  34791. * Release and free the memory of a vertex array object
  34792. * @param vao defines the vertex array object to delete
  34793. */
  34794. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34795. /** @hidden */
  34796. _releaseBuffer(buffer: DataBuffer): boolean;
  34797. protected _deleteBuffer(buffer: DataBuffer): void;
  34798. /**
  34799. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34800. * @param instancesBuffer defines the webGL buffer to update and bind
  34801. * @param data defines the data to store in the buffer
  34802. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34803. */
  34804. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34805. /**
  34806. * Bind the content of a webGL buffer used with instantiation
  34807. * @param instancesBuffer defines the webGL buffer to bind
  34808. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34809. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34810. */
  34811. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34812. /**
  34813. * Disable the instance attribute corresponding to the name in parameter
  34814. * @param name defines the name of the attribute to disable
  34815. */
  34816. disableInstanceAttributeByName(name: string): void;
  34817. /**
  34818. * Disable the instance attribute corresponding to the location in parameter
  34819. * @param attributeLocation defines the attribute location of the attribute to disable
  34820. */
  34821. disableInstanceAttribute(attributeLocation: number): void;
  34822. /**
  34823. * Disable the attribute corresponding to the location in parameter
  34824. * @param attributeLocation defines the attribute location of the attribute to disable
  34825. */
  34826. disableAttributeByIndex(attributeLocation: number): void;
  34827. /**
  34828. * Send a draw order
  34829. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34830. * @param indexStart defines the starting index
  34831. * @param indexCount defines the number of index to draw
  34832. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34833. */
  34834. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34835. /**
  34836. * Draw a list of points
  34837. * @param verticesStart defines the index of first vertex to draw
  34838. * @param verticesCount defines the count of vertices to draw
  34839. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34840. */
  34841. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34842. /**
  34843. * Draw a list of unindexed primitives
  34844. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34845. * @param verticesStart defines the index of first vertex to draw
  34846. * @param verticesCount defines the count of vertices to draw
  34847. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34848. */
  34849. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34850. /**
  34851. * Draw a list of indexed primitives
  34852. * @param fillMode defines the primitive to use
  34853. * @param indexStart defines the starting index
  34854. * @param indexCount defines the number of index to draw
  34855. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34856. */
  34857. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34858. /**
  34859. * Draw a list of unindexed primitives
  34860. * @param fillMode defines the primitive to use
  34861. * @param verticesStart defines the index of first vertex to draw
  34862. * @param verticesCount defines the count of vertices to draw
  34863. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34864. */
  34865. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34866. private _drawMode;
  34867. /** @hidden */
  34868. protected _reportDrawCall(): void;
  34869. /** @hidden */
  34870. _releaseEffect(effect: Effect): void;
  34871. /** @hidden */
  34872. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34873. /**
  34874. * Create a new effect (used to store vertex/fragment shaders)
  34875. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34876. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34877. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34878. * @param samplers defines an array of string used to represent textures
  34879. * @param defines defines the string containing the defines to use to compile the shaders
  34880. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34881. * @param onCompiled defines a function to call when the effect creation is successful
  34882. * @param onError defines a function to call when the effect creation has failed
  34883. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34884. * @returns the new Effect
  34885. */
  34886. 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;
  34887. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34888. private _compileShader;
  34889. private _compileRawShader;
  34890. /** @hidden */
  34891. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34892. /**
  34893. * Directly creates a webGL program
  34894. * @param pipelineContext defines the pipeline context to attach to
  34895. * @param vertexCode defines the vertex shader code to use
  34896. * @param fragmentCode defines the fragment shader code to use
  34897. * @param context defines the webGL context to use (if not set, the current one will be used)
  34898. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34899. * @returns the new webGL program
  34900. */
  34901. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34902. /**
  34903. * Creates a webGL program
  34904. * @param pipelineContext defines the pipeline context to attach to
  34905. * @param vertexCode defines the vertex shader code to use
  34906. * @param fragmentCode defines the fragment shader code to use
  34907. * @param defines defines the string containing the defines to use to compile the shaders
  34908. * @param context defines the webGL context to use (if not set, the current one will be used)
  34909. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34910. * @returns the new webGL program
  34911. */
  34912. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34913. /**
  34914. * Creates a new pipeline context
  34915. * @returns the new pipeline
  34916. */
  34917. createPipelineContext(): IPipelineContext;
  34918. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34919. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34920. /** @hidden */
  34921. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34922. /** @hidden */
  34923. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34924. /** @hidden */
  34925. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34926. /**
  34927. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34928. * @param pipelineContext defines the pipeline context to use
  34929. * @param uniformsNames defines the list of uniform names
  34930. * @returns an array of webGL uniform locations
  34931. */
  34932. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34933. /**
  34934. * Gets the lsit of active attributes for a given webGL program
  34935. * @param pipelineContext defines the pipeline context to use
  34936. * @param attributesNames defines the list of attribute names to get
  34937. * @returns an array of indices indicating the offset of each attribute
  34938. */
  34939. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34940. /**
  34941. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34942. * @param effect defines the effect to activate
  34943. */
  34944. enableEffect(effect: Nullable<Effect>): void;
  34945. /**
  34946. * Set the value of an uniform to a number (int)
  34947. * @param uniform defines the webGL uniform location where to store the value
  34948. * @param value defines the int number to store
  34949. */
  34950. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34951. /**
  34952. * Set the value of an uniform to an array of int32
  34953. * @param uniform defines the webGL uniform location where to store the value
  34954. * @param array defines the array of int32 to store
  34955. */
  34956. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34957. /**
  34958. * Set the value of an uniform to an array of int32 (stored as vec2)
  34959. * @param uniform defines the webGL uniform location where to store the value
  34960. * @param array defines the array of int32 to store
  34961. */
  34962. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34963. /**
  34964. * Set the value of an uniform to an array of int32 (stored as vec3)
  34965. * @param uniform defines the webGL uniform location where to store the value
  34966. * @param array defines the array of int32 to store
  34967. */
  34968. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34969. /**
  34970. * Set the value of an uniform to an array of int32 (stored as vec4)
  34971. * @param uniform defines the webGL uniform location where to store the value
  34972. * @param array defines the array of int32 to store
  34973. */
  34974. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34975. /**
  34976. * Set the value of an uniform to an array of number
  34977. * @param uniform defines the webGL uniform location where to store the value
  34978. * @param array defines the array of number to store
  34979. */
  34980. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34981. /**
  34982. * Set the value of an uniform to an array of number (stored as vec2)
  34983. * @param uniform defines the webGL uniform location where to store the value
  34984. * @param array defines the array of number to store
  34985. */
  34986. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34987. /**
  34988. * Set the value of an uniform to an array of number (stored as vec3)
  34989. * @param uniform defines the webGL uniform location where to store the value
  34990. * @param array defines the array of number to store
  34991. */
  34992. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34993. /**
  34994. * Set the value of an uniform to an array of number (stored as vec4)
  34995. * @param uniform defines the webGL uniform location where to store the value
  34996. * @param array defines the array of number to store
  34997. */
  34998. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34999. /**
  35000. * Set the value of an uniform to an array of float32 (stored as matrices)
  35001. * @param uniform defines the webGL uniform location where to store the value
  35002. * @param matrices defines the array of float32 to store
  35003. */
  35004. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35005. /**
  35006. * Set the value of an uniform to a matrix (3x3)
  35007. * @param uniform defines the webGL uniform location where to store the value
  35008. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35009. */
  35010. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35011. /**
  35012. * Set the value of an uniform to a matrix (2x2)
  35013. * @param uniform defines the webGL uniform location where to store the value
  35014. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35015. */
  35016. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35017. /**
  35018. * Set the value of an uniform to a number (float)
  35019. * @param uniform defines the webGL uniform location where to store the value
  35020. * @param value defines the float number to store
  35021. */
  35022. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35023. /**
  35024. * Set the value of an uniform to a vec2
  35025. * @param uniform defines the webGL uniform location where to store the value
  35026. * @param x defines the 1st component of the value
  35027. * @param y defines the 2nd component of the value
  35028. */
  35029. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35030. /**
  35031. * Set the value of an uniform to a vec3
  35032. * @param uniform defines the webGL uniform location where to store the value
  35033. * @param x defines the 1st component of the value
  35034. * @param y defines the 2nd component of the value
  35035. * @param z defines the 3rd component of the value
  35036. */
  35037. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35038. /**
  35039. * Set the value of an uniform to a vec4
  35040. * @param uniform defines the webGL uniform location where to store the value
  35041. * @param x defines the 1st component of the value
  35042. * @param y defines the 2nd component of the value
  35043. * @param z defines the 3rd component of the value
  35044. * @param w defines the 4th component of the value
  35045. */
  35046. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35047. /**
  35048. * Apply all cached states (depth, culling, stencil and alpha)
  35049. */
  35050. applyStates(): void;
  35051. /**
  35052. * Enable or disable color writing
  35053. * @param enable defines the state to set
  35054. */
  35055. setColorWrite(enable: boolean): void;
  35056. /**
  35057. * Gets a boolean indicating if color writing is enabled
  35058. * @returns the current color writing state
  35059. */
  35060. getColorWrite(): boolean;
  35061. /**
  35062. * Gets the depth culling state manager
  35063. */
  35064. get depthCullingState(): DepthCullingState;
  35065. /**
  35066. * Gets the alpha state manager
  35067. */
  35068. get alphaState(): AlphaState;
  35069. /**
  35070. * Gets the stencil state manager
  35071. */
  35072. get stencilState(): StencilState;
  35073. /**
  35074. * Clears the list of texture accessible through engine.
  35075. * This can help preventing texture load conflict due to name collision.
  35076. */
  35077. clearInternalTexturesCache(): void;
  35078. /**
  35079. * Force the entire cache to be cleared
  35080. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35081. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35082. */
  35083. wipeCaches(bruteForce?: boolean): void;
  35084. /** @hidden */
  35085. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35086. min: number;
  35087. mag: number;
  35088. };
  35089. /** @hidden */
  35090. _createTexture(): WebGLTexture;
  35091. /**
  35092. * Usually called from Texture.ts.
  35093. * Passed information to create a WebGLTexture
  35094. * @param url defines a value which contains one of the following:
  35095. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35096. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35097. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35098. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35099. * @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)
  35100. * @param scene needed for loading to the correct scene
  35101. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35102. * @param onLoad optional callback to be called upon successful completion
  35103. * @param onError optional callback to be called upon failure
  35104. * @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
  35105. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35106. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35107. * @param forcedExtension defines the extension to use to pick the right loader
  35108. * @param mimeType defines an optional mime type
  35109. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35110. */
  35111. 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;
  35112. /**
  35113. * Loads an image as an HTMLImageElement.
  35114. * @param input url string, ArrayBuffer, or Blob to load
  35115. * @param onLoad callback called when the image successfully loads
  35116. * @param onError callback called when the image fails to load
  35117. * @param offlineProvider offline provider for caching
  35118. * @param mimeType optional mime type
  35119. * @returns the HTMLImageElement of the loaded image
  35120. * @hidden
  35121. */
  35122. 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>;
  35123. /**
  35124. * @hidden
  35125. */
  35126. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35127. private _unpackFlipYCached;
  35128. /**
  35129. * In case you are sharing the context with other applications, it might
  35130. * be interested to not cache the unpack flip y state to ensure a consistent
  35131. * value would be set.
  35132. */
  35133. enableUnpackFlipYCached: boolean;
  35134. /** @hidden */
  35135. _unpackFlipY(value: boolean): void;
  35136. /** @hidden */
  35137. _getUnpackAlignement(): number;
  35138. private _getTextureTarget;
  35139. /**
  35140. * Update the sampling mode of a given texture
  35141. * @param samplingMode defines the required sampling mode
  35142. * @param texture defines the texture to update
  35143. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35144. */
  35145. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35146. /**
  35147. * Update the sampling mode of a given texture
  35148. * @param texture defines the texture to update
  35149. * @param wrapU defines the texture wrap mode of the u coordinates
  35150. * @param wrapV defines the texture wrap mode of the v coordinates
  35151. * @param wrapR defines the texture wrap mode of the r coordinates
  35152. */
  35153. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35154. /** @hidden */
  35155. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35156. width: number;
  35157. height: number;
  35158. layers?: number;
  35159. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35160. /** @hidden */
  35161. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35162. /** @hidden */
  35163. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35164. /**
  35165. * Update a portion of an internal texture
  35166. * @param texture defines the texture to update
  35167. * @param imageData defines the data to store into the texture
  35168. * @param xOffset defines the x coordinates of the update rectangle
  35169. * @param yOffset defines the y coordinates of the update rectangle
  35170. * @param width defines the width of the update rectangle
  35171. * @param height defines the height of the update rectangle
  35172. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35173. * @param lod defines the lod level to update (0 by default)
  35174. */
  35175. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35176. /** @hidden */
  35177. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35178. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35179. private _prepareWebGLTexture;
  35180. /** @hidden */
  35181. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35182. private _getDepthStencilBuffer;
  35183. /** @hidden */
  35184. _releaseFramebufferObjects(texture: InternalTexture): void;
  35185. /** @hidden */
  35186. _releaseTexture(texture: InternalTexture): void;
  35187. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35188. protected _setProgram(program: WebGLProgram): void;
  35189. protected _boundUniforms: {
  35190. [key: number]: WebGLUniformLocation;
  35191. };
  35192. /**
  35193. * Binds an effect to the webGL context
  35194. * @param effect defines the effect to bind
  35195. */
  35196. bindSamplers(effect: Effect): void;
  35197. private _activateCurrentTexture;
  35198. /** @hidden */
  35199. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35200. /** @hidden */
  35201. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35202. /**
  35203. * Unbind all textures from the webGL context
  35204. */
  35205. unbindAllTextures(): void;
  35206. /**
  35207. * Sets a texture to the according uniform.
  35208. * @param channel The texture channel
  35209. * @param uniform The uniform to set
  35210. * @param texture The texture to apply
  35211. */
  35212. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35213. private _bindSamplerUniformToChannel;
  35214. private _getTextureWrapMode;
  35215. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35216. /**
  35217. * Sets an array of texture to the webGL context
  35218. * @param channel defines the channel where the texture array must be set
  35219. * @param uniform defines the associated uniform location
  35220. * @param textures defines the array of textures to bind
  35221. */
  35222. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35223. /** @hidden */
  35224. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35225. private _setTextureParameterFloat;
  35226. private _setTextureParameterInteger;
  35227. /**
  35228. * Unbind all vertex attributes from the webGL context
  35229. */
  35230. unbindAllAttributes(): void;
  35231. /**
  35232. * 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
  35233. */
  35234. releaseEffects(): void;
  35235. /**
  35236. * Dispose and release all associated resources
  35237. */
  35238. dispose(): void;
  35239. /**
  35240. * Attach a new callback raised when context lost event is fired
  35241. * @param callback defines the callback to call
  35242. */
  35243. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35244. /**
  35245. * Attach a new callback raised when context restored event is fired
  35246. * @param callback defines the callback to call
  35247. */
  35248. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35249. /**
  35250. * Get the current error code of the webGL context
  35251. * @returns the error code
  35252. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35253. */
  35254. getError(): number;
  35255. private _canRenderToFloatFramebuffer;
  35256. private _canRenderToHalfFloatFramebuffer;
  35257. private _canRenderToFramebuffer;
  35258. /** @hidden */
  35259. _getWebGLTextureType(type: number): number;
  35260. /** @hidden */
  35261. _getInternalFormat(format: number): number;
  35262. /** @hidden */
  35263. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35264. /** @hidden */
  35265. _getRGBAMultiSampleBufferFormat(type: number): number;
  35266. /** @hidden */
  35267. _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;
  35268. /**
  35269. * Loads a file from a url
  35270. * @param url url to load
  35271. * @param onSuccess callback called when the file successfully loads
  35272. * @param onProgress callback called while file is loading (if the server supports this mode)
  35273. * @param offlineProvider defines the offline provider for caching
  35274. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35275. * @param onError callback called when the file fails to load
  35276. * @returns a file request object
  35277. * @hidden
  35278. */
  35279. 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;
  35280. /**
  35281. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35282. * @param x defines the x coordinate of the rectangle where pixels must be read
  35283. * @param y defines the y coordinate of the rectangle where pixels must be read
  35284. * @param width defines the width of the rectangle where pixels must be read
  35285. * @param height defines the height of the rectangle where pixels must be read
  35286. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35287. * @returns a Uint8Array containing RGBA colors
  35288. */
  35289. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35290. private static _isSupported;
  35291. /**
  35292. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35293. * @returns true if the engine can be created
  35294. * @ignorenaming
  35295. */
  35296. static isSupported(): boolean;
  35297. /**
  35298. * Find the next highest power of two.
  35299. * @param x Number to start search from.
  35300. * @return Next highest power of two.
  35301. */
  35302. static CeilingPOT(x: number): number;
  35303. /**
  35304. * Find the next lowest power of two.
  35305. * @param x Number to start search from.
  35306. * @return Next lowest power of two.
  35307. */
  35308. static FloorPOT(x: number): number;
  35309. /**
  35310. * Find the nearest power of two.
  35311. * @param x Number to start search from.
  35312. * @return Next nearest power of two.
  35313. */
  35314. static NearestPOT(x: number): number;
  35315. /**
  35316. * Get the closest exponent of two
  35317. * @param value defines the value to approximate
  35318. * @param max defines the maximum value to return
  35319. * @param mode defines how to define the closest value
  35320. * @returns closest exponent of two of the given value
  35321. */
  35322. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35323. /**
  35324. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35325. * @param func - the function to be called
  35326. * @param requester - the object that will request the next frame. Falls back to window.
  35327. * @returns frame number
  35328. */
  35329. static QueueNewFrame(func: () => void, requester?: any): number;
  35330. /**
  35331. * Gets host document
  35332. * @returns the host document object
  35333. */
  35334. getHostDocument(): Nullable<Document>;
  35335. }
  35336. }
  35337. declare module BABYLON {
  35338. /**
  35339. * Class representing spherical harmonics coefficients to the 3rd degree
  35340. */
  35341. export class SphericalHarmonics {
  35342. /**
  35343. * Defines whether or not the harmonics have been prescaled for rendering.
  35344. */
  35345. preScaled: boolean;
  35346. /**
  35347. * The l0,0 coefficients of the spherical harmonics
  35348. */
  35349. l00: Vector3;
  35350. /**
  35351. * The l1,-1 coefficients of the spherical harmonics
  35352. */
  35353. l1_1: Vector3;
  35354. /**
  35355. * The l1,0 coefficients of the spherical harmonics
  35356. */
  35357. l10: Vector3;
  35358. /**
  35359. * The l1,1 coefficients of the spherical harmonics
  35360. */
  35361. l11: Vector3;
  35362. /**
  35363. * The l2,-2 coefficients of the spherical harmonics
  35364. */
  35365. l2_2: Vector3;
  35366. /**
  35367. * The l2,-1 coefficients of the spherical harmonics
  35368. */
  35369. l2_1: Vector3;
  35370. /**
  35371. * The l2,0 coefficients of the spherical harmonics
  35372. */
  35373. l20: Vector3;
  35374. /**
  35375. * The l2,1 coefficients of the spherical harmonics
  35376. */
  35377. l21: Vector3;
  35378. /**
  35379. * The l2,2 coefficients of the spherical harmonics
  35380. */
  35381. l22: Vector3;
  35382. /**
  35383. * Adds a light to the spherical harmonics
  35384. * @param direction the direction of the light
  35385. * @param color the color of the light
  35386. * @param deltaSolidAngle the delta solid angle of the light
  35387. */
  35388. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35389. /**
  35390. * Scales the spherical harmonics by the given amount
  35391. * @param scale the amount to scale
  35392. */
  35393. scaleInPlace(scale: number): void;
  35394. /**
  35395. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35396. *
  35397. * ```
  35398. * E_lm = A_l * L_lm
  35399. * ```
  35400. *
  35401. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35402. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35403. * the scaling factors are given in equation 9.
  35404. */
  35405. convertIncidentRadianceToIrradiance(): void;
  35406. /**
  35407. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35408. *
  35409. * ```
  35410. * L = (1/pi) * E * rho
  35411. * ```
  35412. *
  35413. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35414. */
  35415. convertIrradianceToLambertianRadiance(): void;
  35416. /**
  35417. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35418. * required operations at run time.
  35419. *
  35420. * This is simply done by scaling back the SH with Ylm constants parameter.
  35421. * The trigonometric part being applied by the shader at run time.
  35422. */
  35423. preScaleForRendering(): void;
  35424. /**
  35425. * Constructs a spherical harmonics from an array.
  35426. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35427. * @returns the spherical harmonics
  35428. */
  35429. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35430. /**
  35431. * Gets the spherical harmonics from polynomial
  35432. * @param polynomial the spherical polynomial
  35433. * @returns the spherical harmonics
  35434. */
  35435. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35436. }
  35437. /**
  35438. * Class representing spherical polynomial coefficients to the 3rd degree
  35439. */
  35440. export class SphericalPolynomial {
  35441. private _harmonics;
  35442. /**
  35443. * The spherical harmonics used to create the polynomials.
  35444. */
  35445. get preScaledHarmonics(): SphericalHarmonics;
  35446. /**
  35447. * The x coefficients of the spherical polynomial
  35448. */
  35449. x: Vector3;
  35450. /**
  35451. * The y coefficients of the spherical polynomial
  35452. */
  35453. y: Vector3;
  35454. /**
  35455. * The z coefficients of the spherical polynomial
  35456. */
  35457. z: Vector3;
  35458. /**
  35459. * The xx coefficients of the spherical polynomial
  35460. */
  35461. xx: Vector3;
  35462. /**
  35463. * The yy coefficients of the spherical polynomial
  35464. */
  35465. yy: Vector3;
  35466. /**
  35467. * The zz coefficients of the spherical polynomial
  35468. */
  35469. zz: Vector3;
  35470. /**
  35471. * The xy coefficients of the spherical polynomial
  35472. */
  35473. xy: Vector3;
  35474. /**
  35475. * The yz coefficients of the spherical polynomial
  35476. */
  35477. yz: Vector3;
  35478. /**
  35479. * The zx coefficients of the spherical polynomial
  35480. */
  35481. zx: Vector3;
  35482. /**
  35483. * Adds an ambient color to the spherical polynomial
  35484. * @param color the color to add
  35485. */
  35486. addAmbient(color: Color3): void;
  35487. /**
  35488. * Scales the spherical polynomial by the given amount
  35489. * @param scale the amount to scale
  35490. */
  35491. scaleInPlace(scale: number): void;
  35492. /**
  35493. * Gets the spherical polynomial from harmonics
  35494. * @param harmonics the spherical harmonics
  35495. * @returns the spherical polynomial
  35496. */
  35497. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35498. /**
  35499. * Constructs a spherical polynomial from an array.
  35500. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35501. * @returns the spherical polynomial
  35502. */
  35503. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35504. }
  35505. }
  35506. declare module BABYLON {
  35507. /**
  35508. * Defines the source of the internal texture
  35509. */
  35510. export enum InternalTextureSource {
  35511. /**
  35512. * The source of the texture data is unknown
  35513. */
  35514. Unknown = 0,
  35515. /**
  35516. * Texture data comes from an URL
  35517. */
  35518. Url = 1,
  35519. /**
  35520. * Texture data is only used for temporary storage
  35521. */
  35522. Temp = 2,
  35523. /**
  35524. * Texture data comes from raw data (ArrayBuffer)
  35525. */
  35526. Raw = 3,
  35527. /**
  35528. * Texture content is dynamic (video or dynamic texture)
  35529. */
  35530. Dynamic = 4,
  35531. /**
  35532. * Texture content is generated by rendering to it
  35533. */
  35534. RenderTarget = 5,
  35535. /**
  35536. * Texture content is part of a multi render target process
  35537. */
  35538. MultiRenderTarget = 6,
  35539. /**
  35540. * Texture data comes from a cube data file
  35541. */
  35542. Cube = 7,
  35543. /**
  35544. * Texture data comes from a raw cube data
  35545. */
  35546. CubeRaw = 8,
  35547. /**
  35548. * Texture data come from a prefiltered cube data file
  35549. */
  35550. CubePrefiltered = 9,
  35551. /**
  35552. * Texture content is raw 3D data
  35553. */
  35554. Raw3D = 10,
  35555. /**
  35556. * Texture content is raw 2D array data
  35557. */
  35558. Raw2DArray = 11,
  35559. /**
  35560. * Texture content is a depth texture
  35561. */
  35562. Depth = 12,
  35563. /**
  35564. * Texture data comes from a raw cube data encoded with RGBD
  35565. */
  35566. CubeRawRGBD = 13
  35567. }
  35568. /**
  35569. * Class used to store data associated with WebGL texture data for the engine
  35570. * This class should not be used directly
  35571. */
  35572. export class InternalTexture {
  35573. /** @hidden */
  35574. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35575. /**
  35576. * Defines if the texture is ready
  35577. */
  35578. isReady: boolean;
  35579. /**
  35580. * Defines if the texture is a cube texture
  35581. */
  35582. isCube: boolean;
  35583. /**
  35584. * Defines if the texture contains 3D data
  35585. */
  35586. is3D: boolean;
  35587. /**
  35588. * Defines if the texture contains 2D array data
  35589. */
  35590. is2DArray: boolean;
  35591. /**
  35592. * Defines if the texture contains multiview data
  35593. */
  35594. isMultiview: boolean;
  35595. /**
  35596. * Gets the URL used to load this texture
  35597. */
  35598. url: string;
  35599. /**
  35600. * Gets the sampling mode of the texture
  35601. */
  35602. samplingMode: number;
  35603. /**
  35604. * Gets a boolean indicating if the texture needs mipmaps generation
  35605. */
  35606. generateMipMaps: boolean;
  35607. /**
  35608. * Gets the number of samples used by the texture (WebGL2+ only)
  35609. */
  35610. samples: number;
  35611. /**
  35612. * Gets the type of the texture (int, float...)
  35613. */
  35614. type: number;
  35615. /**
  35616. * Gets the format of the texture (RGB, RGBA...)
  35617. */
  35618. format: number;
  35619. /**
  35620. * Observable called when the texture is loaded
  35621. */
  35622. onLoadedObservable: Observable<InternalTexture>;
  35623. /**
  35624. * Gets the width of the texture
  35625. */
  35626. width: number;
  35627. /**
  35628. * Gets the height of the texture
  35629. */
  35630. height: number;
  35631. /**
  35632. * Gets the depth of the texture
  35633. */
  35634. depth: number;
  35635. /**
  35636. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35637. */
  35638. baseWidth: number;
  35639. /**
  35640. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35641. */
  35642. baseHeight: number;
  35643. /**
  35644. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35645. */
  35646. baseDepth: number;
  35647. /**
  35648. * Gets a boolean indicating if the texture is inverted on Y axis
  35649. */
  35650. invertY: boolean;
  35651. /** @hidden */
  35652. _invertVScale: boolean;
  35653. /** @hidden */
  35654. _associatedChannel: number;
  35655. /** @hidden */
  35656. _source: InternalTextureSource;
  35657. /** @hidden */
  35658. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35659. /** @hidden */
  35660. _bufferView: Nullable<ArrayBufferView>;
  35661. /** @hidden */
  35662. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35663. /** @hidden */
  35664. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35665. /** @hidden */
  35666. _size: number;
  35667. /** @hidden */
  35668. _extension: string;
  35669. /** @hidden */
  35670. _files: Nullable<string[]>;
  35671. /** @hidden */
  35672. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35673. /** @hidden */
  35674. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35675. /** @hidden */
  35676. _framebuffer: Nullable<WebGLFramebuffer>;
  35677. /** @hidden */
  35678. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35679. /** @hidden */
  35680. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35681. /** @hidden */
  35682. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35683. /** @hidden */
  35684. _attachments: Nullable<number[]>;
  35685. /** @hidden */
  35686. _cachedCoordinatesMode: Nullable<number>;
  35687. /** @hidden */
  35688. _cachedWrapU: Nullable<number>;
  35689. /** @hidden */
  35690. _cachedWrapV: Nullable<number>;
  35691. /** @hidden */
  35692. _cachedWrapR: Nullable<number>;
  35693. /** @hidden */
  35694. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35695. /** @hidden */
  35696. _isDisabled: boolean;
  35697. /** @hidden */
  35698. _compression: Nullable<string>;
  35699. /** @hidden */
  35700. _generateStencilBuffer: boolean;
  35701. /** @hidden */
  35702. _generateDepthBuffer: boolean;
  35703. /** @hidden */
  35704. _comparisonFunction: number;
  35705. /** @hidden */
  35706. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35707. /** @hidden */
  35708. _lodGenerationScale: number;
  35709. /** @hidden */
  35710. _lodGenerationOffset: number;
  35711. /** @hidden */
  35712. _depthStencilTexture: Nullable<InternalTexture>;
  35713. /** @hidden */
  35714. _colorTextureArray: Nullable<WebGLTexture>;
  35715. /** @hidden */
  35716. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35717. /** @hidden */
  35718. _lodTextureHigh: Nullable<BaseTexture>;
  35719. /** @hidden */
  35720. _lodTextureMid: Nullable<BaseTexture>;
  35721. /** @hidden */
  35722. _lodTextureLow: Nullable<BaseTexture>;
  35723. /** @hidden */
  35724. _isRGBD: boolean;
  35725. /** @hidden */
  35726. _linearSpecularLOD: boolean;
  35727. /** @hidden */
  35728. _irradianceTexture: Nullable<BaseTexture>;
  35729. /** @hidden */
  35730. _webGLTexture: Nullable<WebGLTexture>;
  35731. /** @hidden */
  35732. _references: number;
  35733. private _engine;
  35734. /**
  35735. * Gets the Engine the texture belongs to.
  35736. * @returns The babylon engine
  35737. */
  35738. getEngine(): ThinEngine;
  35739. /**
  35740. * Gets the data source type of the texture
  35741. */
  35742. get source(): InternalTextureSource;
  35743. /**
  35744. * Creates a new InternalTexture
  35745. * @param engine defines the engine to use
  35746. * @param source defines the type of data that will be used
  35747. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35748. */
  35749. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35750. /**
  35751. * Increments the number of references (ie. the number of Texture that point to it)
  35752. */
  35753. incrementReferences(): void;
  35754. /**
  35755. * Change the size of the texture (not the size of the content)
  35756. * @param width defines the new width
  35757. * @param height defines the new height
  35758. * @param depth defines the new depth (1 by default)
  35759. */
  35760. updateSize(width: int, height: int, depth?: int): void;
  35761. /** @hidden */
  35762. _rebuild(): void;
  35763. /** @hidden */
  35764. _swapAndDie(target: InternalTexture): void;
  35765. /**
  35766. * Dispose the current allocated resources
  35767. */
  35768. dispose(): void;
  35769. }
  35770. }
  35771. declare module BABYLON {
  35772. /**
  35773. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35775. */
  35776. export class Analyser {
  35777. /**
  35778. * Gets or sets the smoothing
  35779. * @ignorenaming
  35780. */
  35781. SMOOTHING: number;
  35782. /**
  35783. * Gets or sets the FFT table size
  35784. * @ignorenaming
  35785. */
  35786. FFT_SIZE: number;
  35787. /**
  35788. * Gets or sets the bar graph amplitude
  35789. * @ignorenaming
  35790. */
  35791. BARGRAPHAMPLITUDE: number;
  35792. /**
  35793. * Gets or sets the position of the debug canvas
  35794. * @ignorenaming
  35795. */
  35796. DEBUGCANVASPOS: {
  35797. x: number;
  35798. y: number;
  35799. };
  35800. /**
  35801. * Gets or sets the debug canvas size
  35802. * @ignorenaming
  35803. */
  35804. DEBUGCANVASSIZE: {
  35805. width: number;
  35806. height: number;
  35807. };
  35808. private _byteFreqs;
  35809. private _byteTime;
  35810. private _floatFreqs;
  35811. private _webAudioAnalyser;
  35812. private _debugCanvas;
  35813. private _debugCanvasContext;
  35814. private _scene;
  35815. private _registerFunc;
  35816. private _audioEngine;
  35817. /**
  35818. * Creates a new analyser
  35819. * @param scene defines hosting scene
  35820. */
  35821. constructor(scene: Scene);
  35822. /**
  35823. * Get the number of data values you will have to play with for the visualization
  35824. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35825. * @returns a number
  35826. */
  35827. getFrequencyBinCount(): number;
  35828. /**
  35829. * Gets the current frequency data as a byte array
  35830. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35831. * @returns a Uint8Array
  35832. */
  35833. getByteFrequencyData(): Uint8Array;
  35834. /**
  35835. * Gets the current waveform as a byte array
  35836. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35837. * @returns a Uint8Array
  35838. */
  35839. getByteTimeDomainData(): Uint8Array;
  35840. /**
  35841. * Gets the current frequency data as a float array
  35842. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35843. * @returns a Float32Array
  35844. */
  35845. getFloatFrequencyData(): Float32Array;
  35846. /**
  35847. * Renders the debug canvas
  35848. */
  35849. drawDebugCanvas(): void;
  35850. /**
  35851. * Stops rendering the debug canvas and removes it
  35852. */
  35853. stopDebugCanvas(): void;
  35854. /**
  35855. * Connects two audio nodes
  35856. * @param inputAudioNode defines first node to connect
  35857. * @param outputAudioNode defines second node to connect
  35858. */
  35859. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35860. /**
  35861. * Releases all associated resources
  35862. */
  35863. dispose(): void;
  35864. }
  35865. }
  35866. declare module BABYLON {
  35867. /**
  35868. * This represents an audio engine and it is responsible
  35869. * to play, synchronize and analyse sounds throughout the application.
  35870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35871. */
  35872. export interface IAudioEngine extends IDisposable {
  35873. /**
  35874. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35875. */
  35876. readonly canUseWebAudio: boolean;
  35877. /**
  35878. * Gets the current AudioContext if available.
  35879. */
  35880. readonly audioContext: Nullable<AudioContext>;
  35881. /**
  35882. * The master gain node defines the global audio volume of your audio engine.
  35883. */
  35884. readonly masterGain: GainNode;
  35885. /**
  35886. * Gets whether or not mp3 are supported by your browser.
  35887. */
  35888. readonly isMP3supported: boolean;
  35889. /**
  35890. * Gets whether or not ogg are supported by your browser.
  35891. */
  35892. readonly isOGGsupported: boolean;
  35893. /**
  35894. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35895. * @ignoreNaming
  35896. */
  35897. WarnedWebAudioUnsupported: boolean;
  35898. /**
  35899. * Defines if the audio engine relies on a custom unlocked button.
  35900. * In this case, the embedded button will not be displayed.
  35901. */
  35902. useCustomUnlockedButton: boolean;
  35903. /**
  35904. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35905. */
  35906. readonly unlocked: boolean;
  35907. /**
  35908. * Event raised when audio has been unlocked on the browser.
  35909. */
  35910. onAudioUnlockedObservable: Observable<AudioEngine>;
  35911. /**
  35912. * Event raised when audio has been locked on the browser.
  35913. */
  35914. onAudioLockedObservable: Observable<AudioEngine>;
  35915. /**
  35916. * Flags the audio engine in Locked state.
  35917. * This happens due to new browser policies preventing audio to autoplay.
  35918. */
  35919. lock(): void;
  35920. /**
  35921. * Unlocks the audio engine once a user action has been done on the dom.
  35922. * This is helpful to resume play once browser policies have been satisfied.
  35923. */
  35924. unlock(): void;
  35925. /**
  35926. * Gets the global volume sets on the master gain.
  35927. * @returns the global volume if set or -1 otherwise
  35928. */
  35929. getGlobalVolume(): number;
  35930. /**
  35931. * Sets the global volume of your experience (sets on the master gain).
  35932. * @param newVolume Defines the new global volume of the application
  35933. */
  35934. setGlobalVolume(newVolume: number): void;
  35935. /**
  35936. * Connect the audio engine to an audio analyser allowing some amazing
  35937. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35939. * @param analyser The analyser to connect to the engine
  35940. */
  35941. connectToAnalyser(analyser: Analyser): void;
  35942. }
  35943. /**
  35944. * This represents the default audio engine used in babylon.
  35945. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35947. */
  35948. export class AudioEngine implements IAudioEngine {
  35949. private _audioContext;
  35950. private _audioContextInitialized;
  35951. private _muteButton;
  35952. private _hostElement;
  35953. /**
  35954. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35955. */
  35956. canUseWebAudio: boolean;
  35957. /**
  35958. * The master gain node defines the global audio volume of your audio engine.
  35959. */
  35960. masterGain: GainNode;
  35961. /**
  35962. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35963. * @ignoreNaming
  35964. */
  35965. WarnedWebAudioUnsupported: boolean;
  35966. /**
  35967. * Gets whether or not mp3 are supported by your browser.
  35968. */
  35969. isMP3supported: boolean;
  35970. /**
  35971. * Gets whether or not ogg are supported by your browser.
  35972. */
  35973. isOGGsupported: boolean;
  35974. /**
  35975. * Gets whether audio has been unlocked on the device.
  35976. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35977. * a user interaction has happened.
  35978. */
  35979. unlocked: boolean;
  35980. /**
  35981. * Defines if the audio engine relies on a custom unlocked button.
  35982. * In this case, the embedded button will not be displayed.
  35983. */
  35984. useCustomUnlockedButton: boolean;
  35985. /**
  35986. * Event raised when audio has been unlocked on the browser.
  35987. */
  35988. onAudioUnlockedObservable: Observable<AudioEngine>;
  35989. /**
  35990. * Event raised when audio has been locked on the browser.
  35991. */
  35992. onAudioLockedObservable: Observable<AudioEngine>;
  35993. /**
  35994. * Gets the current AudioContext if available.
  35995. */
  35996. get audioContext(): Nullable<AudioContext>;
  35997. private _connectedAnalyser;
  35998. /**
  35999. * Instantiates a new audio engine.
  36000. *
  36001. * There should be only one per page as some browsers restrict the number
  36002. * of audio contexts you can create.
  36003. * @param hostElement defines the host element where to display the mute icon if necessary
  36004. */
  36005. constructor(hostElement?: Nullable<HTMLElement>);
  36006. /**
  36007. * Flags the audio engine in Locked state.
  36008. * This happens due to new browser policies preventing audio to autoplay.
  36009. */
  36010. lock(): void;
  36011. /**
  36012. * Unlocks the audio engine once a user action has been done on the dom.
  36013. * This is helpful to resume play once browser policies have been satisfied.
  36014. */
  36015. unlock(): void;
  36016. private _resumeAudioContext;
  36017. private _initializeAudioContext;
  36018. private _tryToRun;
  36019. private _triggerRunningState;
  36020. private _triggerSuspendedState;
  36021. private _displayMuteButton;
  36022. private _moveButtonToTopLeft;
  36023. private _onResize;
  36024. private _hideMuteButton;
  36025. /**
  36026. * Destroy and release the resources associated with the audio ccontext.
  36027. */
  36028. dispose(): void;
  36029. /**
  36030. * Gets the global volume sets on the master gain.
  36031. * @returns the global volume if set or -1 otherwise
  36032. */
  36033. getGlobalVolume(): number;
  36034. /**
  36035. * Sets the global volume of your experience (sets on the master gain).
  36036. * @param newVolume Defines the new global volume of the application
  36037. */
  36038. setGlobalVolume(newVolume: number): void;
  36039. /**
  36040. * Connect the audio engine to an audio analyser allowing some amazing
  36041. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36043. * @param analyser The analyser to connect to the engine
  36044. */
  36045. connectToAnalyser(analyser: Analyser): void;
  36046. }
  36047. }
  36048. declare module BABYLON {
  36049. /**
  36050. * Interface used to present a loading screen while loading a scene
  36051. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36052. */
  36053. export interface ILoadingScreen {
  36054. /**
  36055. * Function called to display the loading screen
  36056. */
  36057. displayLoadingUI: () => void;
  36058. /**
  36059. * Function called to hide the loading screen
  36060. */
  36061. hideLoadingUI: () => void;
  36062. /**
  36063. * Gets or sets the color to use for the background
  36064. */
  36065. loadingUIBackgroundColor: string;
  36066. /**
  36067. * Gets or sets the text to display while loading
  36068. */
  36069. loadingUIText: string;
  36070. }
  36071. /**
  36072. * Class used for the default loading screen
  36073. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36074. */
  36075. export class DefaultLoadingScreen implements ILoadingScreen {
  36076. private _renderingCanvas;
  36077. private _loadingText;
  36078. private _loadingDivBackgroundColor;
  36079. private _loadingDiv;
  36080. private _loadingTextDiv;
  36081. /** Gets or sets the logo url to use for the default loading screen */
  36082. static DefaultLogoUrl: string;
  36083. /** Gets or sets the spinner url to use for the default loading screen */
  36084. static DefaultSpinnerUrl: string;
  36085. /**
  36086. * Creates a new default loading screen
  36087. * @param _renderingCanvas defines the canvas used to render the scene
  36088. * @param _loadingText defines the default text to display
  36089. * @param _loadingDivBackgroundColor defines the default background color
  36090. */
  36091. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36092. /**
  36093. * Function called to display the loading screen
  36094. */
  36095. displayLoadingUI(): void;
  36096. /**
  36097. * Function called to hide the loading screen
  36098. */
  36099. hideLoadingUI(): void;
  36100. /**
  36101. * Gets or sets the text to display while loading
  36102. */
  36103. set loadingUIText(text: string);
  36104. get loadingUIText(): string;
  36105. /**
  36106. * Gets or sets the color to use for the background
  36107. */
  36108. get loadingUIBackgroundColor(): string;
  36109. set loadingUIBackgroundColor(color: string);
  36110. private _resizeLoadingUI;
  36111. }
  36112. }
  36113. declare module BABYLON {
  36114. /**
  36115. * Interface for any object that can request an animation frame
  36116. */
  36117. export interface ICustomAnimationFrameRequester {
  36118. /**
  36119. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36120. */
  36121. renderFunction?: Function;
  36122. /**
  36123. * Called to request the next frame to render to
  36124. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36125. */
  36126. requestAnimationFrame: Function;
  36127. /**
  36128. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36129. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36130. */
  36131. requestID?: number;
  36132. }
  36133. }
  36134. declare module BABYLON {
  36135. /**
  36136. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36137. */
  36138. export class PerformanceMonitor {
  36139. private _enabled;
  36140. private _rollingFrameTime;
  36141. private _lastFrameTimeMs;
  36142. /**
  36143. * constructor
  36144. * @param frameSampleSize The number of samples required to saturate the sliding window
  36145. */
  36146. constructor(frameSampleSize?: number);
  36147. /**
  36148. * Samples current frame
  36149. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36150. */
  36151. sampleFrame(timeMs?: number): void;
  36152. /**
  36153. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36154. */
  36155. get averageFrameTime(): number;
  36156. /**
  36157. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36158. */
  36159. get averageFrameTimeVariance(): number;
  36160. /**
  36161. * Returns the frame time of the most recent frame
  36162. */
  36163. get instantaneousFrameTime(): number;
  36164. /**
  36165. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36166. */
  36167. get averageFPS(): number;
  36168. /**
  36169. * Returns the average framerate in frames per second using the most recent frame time
  36170. */
  36171. get instantaneousFPS(): number;
  36172. /**
  36173. * Returns true if enough samples have been taken to completely fill the sliding window
  36174. */
  36175. get isSaturated(): boolean;
  36176. /**
  36177. * Enables contributions to the sliding window sample set
  36178. */
  36179. enable(): void;
  36180. /**
  36181. * Disables contributions to the sliding window sample set
  36182. * Samples will not be interpolated over the disabled period
  36183. */
  36184. disable(): void;
  36185. /**
  36186. * Returns true if sampling is enabled
  36187. */
  36188. get isEnabled(): boolean;
  36189. /**
  36190. * Resets performance monitor
  36191. */
  36192. reset(): void;
  36193. }
  36194. /**
  36195. * RollingAverage
  36196. *
  36197. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36198. */
  36199. export class RollingAverage {
  36200. /**
  36201. * Current average
  36202. */
  36203. average: number;
  36204. /**
  36205. * Current variance
  36206. */
  36207. variance: number;
  36208. protected _samples: Array<number>;
  36209. protected _sampleCount: number;
  36210. protected _pos: number;
  36211. protected _m2: number;
  36212. /**
  36213. * constructor
  36214. * @param length The number of samples required to saturate the sliding window
  36215. */
  36216. constructor(length: number);
  36217. /**
  36218. * Adds a sample to the sample set
  36219. * @param v The sample value
  36220. */
  36221. add(v: number): void;
  36222. /**
  36223. * Returns previously added values or null if outside of history or outside the sliding window domain
  36224. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36225. * @return Value previously recorded with add() or null if outside of range
  36226. */
  36227. history(i: number): number;
  36228. /**
  36229. * Returns true if enough samples have been taken to completely fill the sliding window
  36230. * @return true if sample-set saturated
  36231. */
  36232. isSaturated(): boolean;
  36233. /**
  36234. * Resets the rolling average (equivalent to 0 samples taken so far)
  36235. */
  36236. reset(): void;
  36237. /**
  36238. * Wraps a value around the sample range boundaries
  36239. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36240. * @return Wrapped position in sample range
  36241. */
  36242. protected _wrapPosition(i: number): number;
  36243. }
  36244. }
  36245. declare module BABYLON {
  36246. /**
  36247. * This class is used to track a performance counter which is number based.
  36248. * The user has access to many properties which give statistics of different nature.
  36249. *
  36250. * The implementer can track two kinds of Performance Counter: time and count.
  36251. * 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.
  36252. * 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.
  36253. */
  36254. export class PerfCounter {
  36255. /**
  36256. * Gets or sets a global boolean to turn on and off all the counters
  36257. */
  36258. static Enabled: boolean;
  36259. /**
  36260. * Returns the smallest value ever
  36261. */
  36262. get min(): number;
  36263. /**
  36264. * Returns the biggest value ever
  36265. */
  36266. get max(): number;
  36267. /**
  36268. * Returns the average value since the performance counter is running
  36269. */
  36270. get average(): number;
  36271. /**
  36272. * Returns the average value of the last second the counter was monitored
  36273. */
  36274. get lastSecAverage(): number;
  36275. /**
  36276. * Returns the current value
  36277. */
  36278. get current(): number;
  36279. /**
  36280. * Gets the accumulated total
  36281. */
  36282. get total(): number;
  36283. /**
  36284. * Gets the total value count
  36285. */
  36286. get count(): number;
  36287. /**
  36288. * Creates a new counter
  36289. */
  36290. constructor();
  36291. /**
  36292. * Call this method to start monitoring a new frame.
  36293. * 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.
  36294. */
  36295. fetchNewFrame(): void;
  36296. /**
  36297. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36298. * @param newCount the count value to add to the monitored count
  36299. * @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.
  36300. */
  36301. addCount(newCount: number, fetchResult: boolean): void;
  36302. /**
  36303. * Start monitoring this performance counter
  36304. */
  36305. beginMonitoring(): void;
  36306. /**
  36307. * Compute the time lapsed since the previous beginMonitoring() call.
  36308. * @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
  36309. */
  36310. endMonitoring(newFrame?: boolean): void;
  36311. private _fetchResult;
  36312. private _startMonitoringTime;
  36313. private _min;
  36314. private _max;
  36315. private _average;
  36316. private _current;
  36317. private _totalValueCount;
  36318. private _totalAccumulated;
  36319. private _lastSecAverage;
  36320. private _lastSecAccumulated;
  36321. private _lastSecTime;
  36322. private _lastSecValueCount;
  36323. }
  36324. }
  36325. declare module BABYLON {
  36326. interface ThinEngine {
  36327. /**
  36328. * Sets alpha constants used by some alpha blending modes
  36329. * @param r defines the red component
  36330. * @param g defines the green component
  36331. * @param b defines the blue component
  36332. * @param a defines the alpha component
  36333. */
  36334. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36335. /**
  36336. * Sets the current alpha mode
  36337. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36338. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36339. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36340. */
  36341. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36342. /**
  36343. * Gets the current alpha mode
  36344. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36345. * @returns the current alpha mode
  36346. */
  36347. getAlphaMode(): number;
  36348. /**
  36349. * Sets the current alpha equation
  36350. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36351. */
  36352. setAlphaEquation(equation: number): void;
  36353. /**
  36354. * Gets the current alpha equation.
  36355. * @returns the current alpha equation
  36356. */
  36357. getAlphaEquation(): number;
  36358. }
  36359. }
  36360. declare module BABYLON {
  36361. interface ThinEngine {
  36362. /** @hidden */
  36363. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36364. }
  36365. }
  36366. declare module BABYLON {
  36367. /**
  36368. * Defines the interface used by display changed events
  36369. */
  36370. export interface IDisplayChangedEventArgs {
  36371. /** Gets the vrDisplay object (if any) */
  36372. vrDisplay: Nullable<any>;
  36373. /** Gets a boolean indicating if webVR is supported */
  36374. vrSupported: boolean;
  36375. }
  36376. /**
  36377. * Defines the interface used by objects containing a viewport (like a camera)
  36378. */
  36379. interface IViewportOwnerLike {
  36380. /**
  36381. * Gets or sets the viewport
  36382. */
  36383. viewport: IViewportLike;
  36384. }
  36385. /**
  36386. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36387. */
  36388. export class Engine extends ThinEngine {
  36389. /** Defines that alpha blending is disabled */
  36390. static readonly ALPHA_DISABLE: number;
  36391. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36392. static readonly ALPHA_ADD: number;
  36393. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36394. static readonly ALPHA_COMBINE: number;
  36395. /** Defines that alpha blending to DEST - SRC * DEST */
  36396. static readonly ALPHA_SUBTRACT: number;
  36397. /** Defines that alpha blending to SRC * DEST */
  36398. static readonly ALPHA_MULTIPLY: number;
  36399. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36400. static readonly ALPHA_MAXIMIZED: number;
  36401. /** Defines that alpha blending to SRC + DEST */
  36402. static readonly ALPHA_ONEONE: number;
  36403. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36404. static readonly ALPHA_PREMULTIPLIED: number;
  36405. /**
  36406. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36407. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36408. */
  36409. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36410. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36411. static readonly ALPHA_INTERPOLATE: number;
  36412. /**
  36413. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36414. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36415. */
  36416. static readonly ALPHA_SCREENMODE: number;
  36417. /** Defines that the ressource is not delayed*/
  36418. static readonly DELAYLOADSTATE_NONE: number;
  36419. /** Defines that the ressource was successfully delay loaded */
  36420. static readonly DELAYLOADSTATE_LOADED: number;
  36421. /** Defines that the ressource is currently delay loading */
  36422. static readonly DELAYLOADSTATE_LOADING: number;
  36423. /** Defines that the ressource is delayed and has not started loading */
  36424. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36425. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36426. static readonly NEVER: number;
  36427. /** 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 */
  36428. static readonly ALWAYS: number;
  36429. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36430. static readonly LESS: number;
  36431. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36432. static readonly EQUAL: number;
  36433. /** 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 */
  36434. static readonly LEQUAL: number;
  36435. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36436. static readonly GREATER: number;
  36437. /** 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 */
  36438. static readonly GEQUAL: number;
  36439. /** 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 */
  36440. static readonly NOTEQUAL: number;
  36441. /** Passed to stencilOperation to specify that stencil value must be kept */
  36442. static readonly KEEP: number;
  36443. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36444. static readonly REPLACE: number;
  36445. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36446. static readonly INCR: number;
  36447. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36448. static readonly DECR: number;
  36449. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36450. static readonly INVERT: number;
  36451. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36452. static readonly INCR_WRAP: number;
  36453. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36454. static readonly DECR_WRAP: number;
  36455. /** Texture is not repeating outside of 0..1 UVs */
  36456. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36457. /** Texture is repeating outside of 0..1 UVs */
  36458. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36459. /** Texture is repeating and mirrored */
  36460. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36461. /** ALPHA */
  36462. static readonly TEXTUREFORMAT_ALPHA: number;
  36463. /** LUMINANCE */
  36464. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36465. /** LUMINANCE_ALPHA */
  36466. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36467. /** RGB */
  36468. static readonly TEXTUREFORMAT_RGB: number;
  36469. /** RGBA */
  36470. static readonly TEXTUREFORMAT_RGBA: number;
  36471. /** RED */
  36472. static readonly TEXTUREFORMAT_RED: number;
  36473. /** RED (2nd reference) */
  36474. static readonly TEXTUREFORMAT_R: number;
  36475. /** RG */
  36476. static readonly TEXTUREFORMAT_RG: number;
  36477. /** RED_INTEGER */
  36478. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36479. /** RED_INTEGER (2nd reference) */
  36480. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36481. /** RG_INTEGER */
  36482. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36483. /** RGB_INTEGER */
  36484. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36485. /** RGBA_INTEGER */
  36486. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36487. /** UNSIGNED_BYTE */
  36488. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36489. /** UNSIGNED_BYTE (2nd reference) */
  36490. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36491. /** FLOAT */
  36492. static readonly TEXTURETYPE_FLOAT: number;
  36493. /** HALF_FLOAT */
  36494. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36495. /** BYTE */
  36496. static readonly TEXTURETYPE_BYTE: number;
  36497. /** SHORT */
  36498. static readonly TEXTURETYPE_SHORT: number;
  36499. /** UNSIGNED_SHORT */
  36500. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36501. /** INT */
  36502. static readonly TEXTURETYPE_INT: number;
  36503. /** UNSIGNED_INT */
  36504. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36505. /** UNSIGNED_SHORT_4_4_4_4 */
  36506. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36507. /** UNSIGNED_SHORT_5_5_5_1 */
  36508. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36509. /** UNSIGNED_SHORT_5_6_5 */
  36510. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36511. /** UNSIGNED_INT_2_10_10_10_REV */
  36512. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36513. /** UNSIGNED_INT_24_8 */
  36514. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36515. /** UNSIGNED_INT_10F_11F_11F_REV */
  36516. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36517. /** UNSIGNED_INT_5_9_9_9_REV */
  36518. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36519. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36520. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36521. /** nearest is mag = nearest and min = nearest and mip = linear */
  36522. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36524. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36525. /** Trilinear is mag = linear and min = linear and mip = linear */
  36526. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36527. /** nearest is mag = nearest and min = nearest and mip = linear */
  36528. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36529. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36530. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36531. /** Trilinear is mag = linear and min = linear and mip = linear */
  36532. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36533. /** mag = nearest and min = nearest and mip = nearest */
  36534. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36535. /** mag = nearest and min = linear and mip = nearest */
  36536. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36537. /** mag = nearest and min = linear and mip = linear */
  36538. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36539. /** mag = nearest and min = linear and mip = none */
  36540. static readonly TEXTURE_NEAREST_LINEAR: number;
  36541. /** mag = nearest and min = nearest and mip = none */
  36542. static readonly TEXTURE_NEAREST_NEAREST: number;
  36543. /** mag = linear and min = nearest and mip = nearest */
  36544. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36545. /** mag = linear and min = nearest and mip = linear */
  36546. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36547. /** mag = linear and min = linear and mip = none */
  36548. static readonly TEXTURE_LINEAR_LINEAR: number;
  36549. /** mag = linear and min = nearest and mip = none */
  36550. static readonly TEXTURE_LINEAR_NEAREST: number;
  36551. /** Explicit coordinates mode */
  36552. static readonly TEXTURE_EXPLICIT_MODE: number;
  36553. /** Spherical coordinates mode */
  36554. static readonly TEXTURE_SPHERICAL_MODE: number;
  36555. /** Planar coordinates mode */
  36556. static readonly TEXTURE_PLANAR_MODE: number;
  36557. /** Cubic coordinates mode */
  36558. static readonly TEXTURE_CUBIC_MODE: number;
  36559. /** Projection coordinates mode */
  36560. static readonly TEXTURE_PROJECTION_MODE: number;
  36561. /** Skybox coordinates mode */
  36562. static readonly TEXTURE_SKYBOX_MODE: number;
  36563. /** Inverse Cubic coordinates mode */
  36564. static readonly TEXTURE_INVCUBIC_MODE: number;
  36565. /** Equirectangular coordinates mode */
  36566. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36567. /** Equirectangular Fixed coordinates mode */
  36568. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36569. /** Equirectangular Fixed Mirrored coordinates mode */
  36570. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36571. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36572. static readonly SCALEMODE_FLOOR: number;
  36573. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36574. static readonly SCALEMODE_NEAREST: number;
  36575. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36576. static readonly SCALEMODE_CEILING: number;
  36577. /**
  36578. * Returns the current npm package of the sdk
  36579. */
  36580. static get NpmPackage(): string;
  36581. /**
  36582. * Returns the current version of the framework
  36583. */
  36584. static get Version(): string;
  36585. /** Gets the list of created engines */
  36586. static get Instances(): Engine[];
  36587. /**
  36588. * Gets the latest created engine
  36589. */
  36590. static get LastCreatedEngine(): Nullable<Engine>;
  36591. /**
  36592. * Gets the latest created scene
  36593. */
  36594. static get LastCreatedScene(): Nullable<Scene>;
  36595. /**
  36596. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36597. * @param flag defines which part of the materials must be marked as dirty
  36598. * @param predicate defines a predicate used to filter which materials should be affected
  36599. */
  36600. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36601. /**
  36602. * Method called to create the default loading screen.
  36603. * This can be overriden in your own app.
  36604. * @param canvas The rendering canvas element
  36605. * @returns The loading screen
  36606. */
  36607. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36608. /**
  36609. * Method called to create the default rescale post process on each engine.
  36610. */
  36611. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36612. /**
  36613. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36614. **/
  36615. enableOfflineSupport: boolean;
  36616. /**
  36617. * 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)
  36618. **/
  36619. disableManifestCheck: boolean;
  36620. /**
  36621. * Gets the list of created scenes
  36622. */
  36623. scenes: Scene[];
  36624. /**
  36625. * Event raised when a new scene is created
  36626. */
  36627. onNewSceneAddedObservable: Observable<Scene>;
  36628. /**
  36629. * Gets the list of created postprocesses
  36630. */
  36631. postProcesses: PostProcess[];
  36632. /**
  36633. * Gets a boolean indicating if the pointer is currently locked
  36634. */
  36635. isPointerLock: boolean;
  36636. /**
  36637. * Observable event triggered each time the rendering canvas is resized
  36638. */
  36639. onResizeObservable: Observable<Engine>;
  36640. /**
  36641. * Observable event triggered each time the canvas loses focus
  36642. */
  36643. onCanvasBlurObservable: Observable<Engine>;
  36644. /**
  36645. * Observable event triggered each time the canvas gains focus
  36646. */
  36647. onCanvasFocusObservable: Observable<Engine>;
  36648. /**
  36649. * Observable event triggered each time the canvas receives pointerout event
  36650. */
  36651. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36652. /**
  36653. * Observable raised when the engine begins a new frame
  36654. */
  36655. onBeginFrameObservable: Observable<Engine>;
  36656. /**
  36657. * If set, will be used to request the next animation frame for the render loop
  36658. */
  36659. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36660. /**
  36661. * Observable raised when the engine ends the current frame
  36662. */
  36663. onEndFrameObservable: Observable<Engine>;
  36664. /**
  36665. * Observable raised when the engine is about to compile a shader
  36666. */
  36667. onBeforeShaderCompilationObservable: Observable<Engine>;
  36668. /**
  36669. * Observable raised when the engine has jsut compiled a shader
  36670. */
  36671. onAfterShaderCompilationObservable: Observable<Engine>;
  36672. /**
  36673. * Gets the audio engine
  36674. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36675. * @ignorenaming
  36676. */
  36677. static audioEngine: IAudioEngine;
  36678. /**
  36679. * Default AudioEngine factory responsible of creating the Audio Engine.
  36680. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36681. */
  36682. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36683. /**
  36684. * Default offline support factory responsible of creating a tool used to store data locally.
  36685. * By default, this will create a Database object if the workload has been embedded.
  36686. */
  36687. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36688. private _loadingScreen;
  36689. private _pointerLockRequested;
  36690. private _rescalePostProcess;
  36691. private _deterministicLockstep;
  36692. private _lockstepMaxSteps;
  36693. private _timeStep;
  36694. protected get _supportsHardwareTextureRescaling(): boolean;
  36695. private _fps;
  36696. private _deltaTime;
  36697. /** @hidden */
  36698. _drawCalls: PerfCounter;
  36699. /** 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 */
  36700. canvasTabIndex: number;
  36701. /**
  36702. * Turn this value on if you want to pause FPS computation when in background
  36703. */
  36704. disablePerformanceMonitorInBackground: boolean;
  36705. private _performanceMonitor;
  36706. /**
  36707. * Gets the performance monitor attached to this engine
  36708. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36709. */
  36710. get performanceMonitor(): PerformanceMonitor;
  36711. private _onFocus;
  36712. private _onBlur;
  36713. private _onCanvasPointerOut;
  36714. private _onCanvasBlur;
  36715. private _onCanvasFocus;
  36716. private _onFullscreenChange;
  36717. private _onPointerLockChange;
  36718. /**
  36719. * Gets the HTML element used to attach event listeners
  36720. * @returns a HTML element
  36721. */
  36722. getInputElement(): Nullable<HTMLElement>;
  36723. /**
  36724. * Creates a new engine
  36725. * @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
  36726. * @param antialias defines enable antialiasing (default: false)
  36727. * @param options defines further options to be sent to the getContext() function
  36728. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36729. */
  36730. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36731. /**
  36732. * Gets current aspect ratio
  36733. * @param viewportOwner defines the camera to use to get the aspect ratio
  36734. * @param useScreen defines if screen size must be used (or the current render target if any)
  36735. * @returns a number defining the aspect ratio
  36736. */
  36737. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36738. /**
  36739. * Gets current screen aspect ratio
  36740. * @returns a number defining the aspect ratio
  36741. */
  36742. getScreenAspectRatio(): number;
  36743. /**
  36744. * Gets the client rect of the HTML canvas attached with the current webGL context
  36745. * @returns a client rectanglee
  36746. */
  36747. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36748. /**
  36749. * Gets the client rect of the HTML element used for events
  36750. * @returns a client rectanglee
  36751. */
  36752. getInputElementClientRect(): Nullable<ClientRect>;
  36753. /**
  36754. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36755. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36756. * @returns true if engine is in deterministic lock step mode
  36757. */
  36758. isDeterministicLockStep(): boolean;
  36759. /**
  36760. * Gets the max steps when engine is running in deterministic lock step
  36761. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36762. * @returns the max steps
  36763. */
  36764. getLockstepMaxSteps(): number;
  36765. /**
  36766. * Returns the time in ms between steps when using deterministic lock step.
  36767. * @returns time step in (ms)
  36768. */
  36769. getTimeStep(): number;
  36770. /**
  36771. * Force the mipmap generation for the given render target texture
  36772. * @param texture defines the render target texture to use
  36773. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36774. */
  36775. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36776. /** States */
  36777. /**
  36778. * Set various states to the webGL context
  36779. * @param culling defines backface culling state
  36780. * @param zOffset defines the value to apply to zOffset (0 by default)
  36781. * @param force defines if states must be applied even if cache is up to date
  36782. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36783. */
  36784. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36785. /**
  36786. * Set the z offset to apply to current rendering
  36787. * @param value defines the offset to apply
  36788. */
  36789. setZOffset(value: number): void;
  36790. /**
  36791. * Gets the current value of the zOffset
  36792. * @returns the current zOffset state
  36793. */
  36794. getZOffset(): number;
  36795. /**
  36796. * Enable or disable depth buffering
  36797. * @param enable defines the state to set
  36798. */
  36799. setDepthBuffer(enable: boolean): void;
  36800. /**
  36801. * Gets a boolean indicating if depth writing is enabled
  36802. * @returns the current depth writing state
  36803. */
  36804. getDepthWrite(): boolean;
  36805. /**
  36806. * Enable or disable depth writing
  36807. * @param enable defines the state to set
  36808. */
  36809. setDepthWrite(enable: boolean): void;
  36810. /**
  36811. * Gets a boolean indicating if stencil buffer is enabled
  36812. * @returns the current stencil buffer state
  36813. */
  36814. getStencilBuffer(): boolean;
  36815. /**
  36816. * Enable or disable the stencil buffer
  36817. * @param enable defines if the stencil buffer must be enabled or disabled
  36818. */
  36819. setStencilBuffer(enable: boolean): void;
  36820. /**
  36821. * Gets the current stencil mask
  36822. * @returns a number defining the new stencil mask to use
  36823. */
  36824. getStencilMask(): number;
  36825. /**
  36826. * Sets the current stencil mask
  36827. * @param mask defines the new stencil mask to use
  36828. */
  36829. setStencilMask(mask: number): void;
  36830. /**
  36831. * Gets the current stencil function
  36832. * @returns a number defining the stencil function to use
  36833. */
  36834. getStencilFunction(): number;
  36835. /**
  36836. * Gets the current stencil reference value
  36837. * @returns a number defining the stencil reference value to use
  36838. */
  36839. getStencilFunctionReference(): number;
  36840. /**
  36841. * Gets the current stencil mask
  36842. * @returns a number defining the stencil mask to use
  36843. */
  36844. getStencilFunctionMask(): number;
  36845. /**
  36846. * Sets the current stencil function
  36847. * @param stencilFunc defines the new stencil function to use
  36848. */
  36849. setStencilFunction(stencilFunc: number): void;
  36850. /**
  36851. * Sets the current stencil reference
  36852. * @param reference defines the new stencil reference to use
  36853. */
  36854. setStencilFunctionReference(reference: number): void;
  36855. /**
  36856. * Sets the current stencil mask
  36857. * @param mask defines the new stencil mask to use
  36858. */
  36859. setStencilFunctionMask(mask: number): void;
  36860. /**
  36861. * Gets the current stencil operation when stencil fails
  36862. * @returns a number defining stencil operation to use when stencil fails
  36863. */
  36864. getStencilOperationFail(): number;
  36865. /**
  36866. * Gets the current stencil operation when depth fails
  36867. * @returns a number defining stencil operation to use when depth fails
  36868. */
  36869. getStencilOperationDepthFail(): number;
  36870. /**
  36871. * Gets the current stencil operation when stencil passes
  36872. * @returns a number defining stencil operation to use when stencil passes
  36873. */
  36874. getStencilOperationPass(): number;
  36875. /**
  36876. * Sets the stencil operation to use when stencil fails
  36877. * @param operation defines the stencil operation to use when stencil fails
  36878. */
  36879. setStencilOperationFail(operation: number): void;
  36880. /**
  36881. * Sets the stencil operation to use when depth fails
  36882. * @param operation defines the stencil operation to use when depth fails
  36883. */
  36884. setStencilOperationDepthFail(operation: number): void;
  36885. /**
  36886. * Sets the stencil operation to use when stencil passes
  36887. * @param operation defines the stencil operation to use when stencil passes
  36888. */
  36889. setStencilOperationPass(operation: number): void;
  36890. /**
  36891. * Sets a boolean indicating if the dithering state is enabled or disabled
  36892. * @param value defines the dithering state
  36893. */
  36894. setDitheringState(value: boolean): void;
  36895. /**
  36896. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36897. * @param value defines the rasterizer state
  36898. */
  36899. setRasterizerState(value: boolean): void;
  36900. /**
  36901. * Gets the current depth function
  36902. * @returns a number defining the depth function
  36903. */
  36904. getDepthFunction(): Nullable<number>;
  36905. /**
  36906. * Sets the current depth function
  36907. * @param depthFunc defines the function to use
  36908. */
  36909. setDepthFunction(depthFunc: number): void;
  36910. /**
  36911. * Sets the current depth function to GREATER
  36912. */
  36913. setDepthFunctionToGreater(): void;
  36914. /**
  36915. * Sets the current depth function to GEQUAL
  36916. */
  36917. setDepthFunctionToGreaterOrEqual(): void;
  36918. /**
  36919. * Sets the current depth function to LESS
  36920. */
  36921. setDepthFunctionToLess(): void;
  36922. /**
  36923. * Sets the current depth function to LEQUAL
  36924. */
  36925. setDepthFunctionToLessOrEqual(): void;
  36926. private _cachedStencilBuffer;
  36927. private _cachedStencilFunction;
  36928. private _cachedStencilMask;
  36929. private _cachedStencilOperationPass;
  36930. private _cachedStencilOperationFail;
  36931. private _cachedStencilOperationDepthFail;
  36932. private _cachedStencilReference;
  36933. /**
  36934. * Caches the the state of the stencil buffer
  36935. */
  36936. cacheStencilState(): void;
  36937. /**
  36938. * Restores the state of the stencil buffer
  36939. */
  36940. restoreStencilState(): void;
  36941. /**
  36942. * Directly set the WebGL Viewport
  36943. * @param x defines the x coordinate of the viewport (in screen space)
  36944. * @param y defines the y coordinate of the viewport (in screen space)
  36945. * @param width defines the width of the viewport (in screen space)
  36946. * @param height defines the height of the viewport (in screen space)
  36947. * @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
  36948. */
  36949. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36950. /**
  36951. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36952. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36953. * @param y defines the y-coordinate of the corner of the clear rectangle
  36954. * @param width defines the width of the clear rectangle
  36955. * @param height defines the height of the clear rectangle
  36956. * @param clearColor defines the clear color
  36957. */
  36958. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36959. /**
  36960. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36961. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36962. * @param y defines the y-coordinate of the corner of the clear rectangle
  36963. * @param width defines the width of the clear rectangle
  36964. * @param height defines the height of the clear rectangle
  36965. */
  36966. enableScissor(x: number, y: number, width: number, height: number): void;
  36967. /**
  36968. * Disable previously set scissor test rectangle
  36969. */
  36970. disableScissor(): void;
  36971. protected _reportDrawCall(): void;
  36972. /**
  36973. * Initializes a webVR display and starts listening to display change events
  36974. * The onVRDisplayChangedObservable will be notified upon these changes
  36975. * @returns The onVRDisplayChangedObservable
  36976. */
  36977. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36978. /** @hidden */
  36979. _prepareVRComponent(): void;
  36980. /** @hidden */
  36981. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36982. /** @hidden */
  36983. _submitVRFrame(): void;
  36984. /**
  36985. * Call this function to leave webVR mode
  36986. * Will do nothing if webVR is not supported or if there is no webVR device
  36987. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36988. */
  36989. disableVR(): void;
  36990. /**
  36991. * Gets a boolean indicating that the system is in VR mode and is presenting
  36992. * @returns true if VR mode is engaged
  36993. */
  36994. isVRPresenting(): boolean;
  36995. /** @hidden */
  36996. _requestVRFrame(): void;
  36997. /** @hidden */
  36998. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36999. /**
  37000. * Gets the source code of the vertex shader associated with a specific webGL program
  37001. * @param program defines the program to use
  37002. * @returns a string containing the source code of the vertex shader associated with the program
  37003. */
  37004. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37005. /**
  37006. * Gets the source code of the fragment shader associated with a specific webGL program
  37007. * @param program defines the program to use
  37008. * @returns a string containing the source code of the fragment shader associated with the program
  37009. */
  37010. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37011. /**
  37012. * Sets a depth stencil texture from a render target to the according uniform.
  37013. * @param channel The texture channel
  37014. * @param uniform The uniform to set
  37015. * @param texture The render target texture containing the depth stencil texture to apply
  37016. */
  37017. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37018. /**
  37019. * Sets a texture to the webGL context from a postprocess
  37020. * @param channel defines the channel to use
  37021. * @param postProcess defines the source postprocess
  37022. */
  37023. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37024. /**
  37025. * Binds the output of the passed in post process to the texture channel specified
  37026. * @param channel The channel the texture should be bound to
  37027. * @param postProcess The post process which's output should be bound
  37028. */
  37029. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37030. protected _rebuildBuffers(): void;
  37031. /** @hidden */
  37032. _renderFrame(): void;
  37033. _renderLoop(): void;
  37034. /** @hidden */
  37035. _renderViews(): boolean;
  37036. /**
  37037. * Toggle full screen mode
  37038. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37039. */
  37040. switchFullscreen(requestPointerLock: boolean): void;
  37041. /**
  37042. * Enters full screen mode
  37043. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37044. */
  37045. enterFullscreen(requestPointerLock: boolean): void;
  37046. /**
  37047. * Exits full screen mode
  37048. */
  37049. exitFullscreen(): void;
  37050. /**
  37051. * Enters Pointerlock mode
  37052. */
  37053. enterPointerlock(): void;
  37054. /**
  37055. * Exits Pointerlock mode
  37056. */
  37057. exitPointerlock(): void;
  37058. /**
  37059. * Begin a new frame
  37060. */
  37061. beginFrame(): void;
  37062. /**
  37063. * Enf the current frame
  37064. */
  37065. endFrame(): void;
  37066. resize(): void;
  37067. /**
  37068. * Force a specific size of the canvas
  37069. * @param width defines the new canvas' width
  37070. * @param height defines the new canvas' height
  37071. */
  37072. setSize(width: number, height: number): void;
  37073. /**
  37074. * Updates a dynamic vertex buffer.
  37075. * @param vertexBuffer the vertex buffer to update
  37076. * @param data the data used to update the vertex buffer
  37077. * @param byteOffset the byte offset of the data
  37078. * @param byteLength the byte length of the data
  37079. */
  37080. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37081. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37082. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37083. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37084. _releaseTexture(texture: InternalTexture): void;
  37085. /**
  37086. * @hidden
  37087. * Rescales a texture
  37088. * @param source input texutre
  37089. * @param destination destination texture
  37090. * @param scene scene to use to render the resize
  37091. * @param internalFormat format to use when resizing
  37092. * @param onComplete callback to be called when resize has completed
  37093. */
  37094. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37095. /**
  37096. * Gets the current framerate
  37097. * @returns a number representing the framerate
  37098. */
  37099. getFps(): number;
  37100. /**
  37101. * Gets the time spent between current and previous frame
  37102. * @returns a number representing the delta time in ms
  37103. */
  37104. getDeltaTime(): number;
  37105. private _measureFps;
  37106. /** @hidden */
  37107. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37108. /**
  37109. * Update a dynamic index buffer
  37110. * @param indexBuffer defines the target index buffer
  37111. * @param indices defines the data to update
  37112. * @param offset defines the offset in the target index buffer where update should start
  37113. */
  37114. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37115. /**
  37116. * Updates the sample count of a render target texture
  37117. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37118. * @param texture defines the texture to update
  37119. * @param samples defines the sample count to set
  37120. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37121. */
  37122. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37123. /**
  37124. * Updates a depth texture Comparison Mode and Function.
  37125. * If the comparison Function is equal to 0, the mode will be set to none.
  37126. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37127. * @param texture The texture to set the comparison function for
  37128. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37129. */
  37130. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37131. /**
  37132. * Creates a webGL buffer to use with instanciation
  37133. * @param capacity defines the size of the buffer
  37134. * @returns the webGL buffer
  37135. */
  37136. createInstancesBuffer(capacity: number): DataBuffer;
  37137. /**
  37138. * Delete a webGL buffer used with instanciation
  37139. * @param buffer defines the webGL buffer to delete
  37140. */
  37141. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37142. private _clientWaitAsync;
  37143. /** @hidden */
  37144. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37145. dispose(): void;
  37146. private _disableTouchAction;
  37147. /**
  37148. * Display the loading screen
  37149. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37150. */
  37151. displayLoadingUI(): void;
  37152. /**
  37153. * Hide the loading screen
  37154. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37155. */
  37156. hideLoadingUI(): void;
  37157. /**
  37158. * Gets the current loading screen object
  37159. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37160. */
  37161. get loadingScreen(): ILoadingScreen;
  37162. /**
  37163. * Sets the current loading screen object
  37164. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37165. */
  37166. set loadingScreen(loadingScreen: ILoadingScreen);
  37167. /**
  37168. * Sets the current loading screen text
  37169. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37170. */
  37171. set loadingUIText(text: string);
  37172. /**
  37173. * Sets the current loading screen background color
  37174. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37175. */
  37176. set loadingUIBackgroundColor(color: string);
  37177. /** Pointerlock and fullscreen */
  37178. /**
  37179. * Ask the browser to promote the current element to pointerlock mode
  37180. * @param element defines the DOM element to promote
  37181. */
  37182. static _RequestPointerlock(element: HTMLElement): void;
  37183. /**
  37184. * Asks the browser to exit pointerlock mode
  37185. */
  37186. static _ExitPointerlock(): void;
  37187. /**
  37188. * Ask the browser to promote the current element to fullscreen rendering mode
  37189. * @param element defines the DOM element to promote
  37190. */
  37191. static _RequestFullscreen(element: HTMLElement): void;
  37192. /**
  37193. * Asks the browser to exit fullscreen mode
  37194. */
  37195. static _ExitFullscreen(): void;
  37196. }
  37197. }
  37198. declare module BABYLON {
  37199. /**
  37200. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37201. * during the life time of the application.
  37202. */
  37203. export class EngineStore {
  37204. /** Gets the list of created engines */
  37205. static Instances: Engine[];
  37206. /** @hidden */
  37207. static _LastCreatedScene: Nullable<Scene>;
  37208. /**
  37209. * Gets the latest created engine
  37210. */
  37211. static get LastCreatedEngine(): Nullable<Engine>;
  37212. /**
  37213. * Gets the latest created scene
  37214. */
  37215. static get LastCreatedScene(): Nullable<Scene>;
  37216. /**
  37217. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37218. * @ignorenaming
  37219. */
  37220. static UseFallbackTexture: boolean;
  37221. /**
  37222. * Texture content used if a texture cannot loaded
  37223. * @ignorenaming
  37224. */
  37225. static FallbackTexture: string;
  37226. }
  37227. }
  37228. declare module BABYLON {
  37229. /**
  37230. * Helper class that provides a small promise polyfill
  37231. */
  37232. export class PromisePolyfill {
  37233. /**
  37234. * Static function used to check if the polyfill is required
  37235. * If this is the case then the function will inject the polyfill to window.Promise
  37236. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37237. */
  37238. static Apply(force?: boolean): void;
  37239. }
  37240. }
  37241. declare module BABYLON {
  37242. /**
  37243. * Interface for screenshot methods with describe argument called `size` as object with options
  37244. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37245. */
  37246. export interface IScreenshotSize {
  37247. /**
  37248. * number in pixels for canvas height
  37249. */
  37250. height?: number;
  37251. /**
  37252. * multiplier allowing render at a higher or lower resolution
  37253. * If value is defined then height and width will be ignored and taken from camera
  37254. */
  37255. precision?: number;
  37256. /**
  37257. * number in pixels for canvas width
  37258. */
  37259. width?: number;
  37260. }
  37261. }
  37262. declare module BABYLON {
  37263. interface IColor4Like {
  37264. r: float;
  37265. g: float;
  37266. b: float;
  37267. a: float;
  37268. }
  37269. /**
  37270. * Class containing a set of static utilities functions
  37271. */
  37272. export class Tools {
  37273. /**
  37274. * Gets or sets the base URL to use to load assets
  37275. */
  37276. static get BaseUrl(): string;
  37277. static set BaseUrl(value: string);
  37278. /**
  37279. * Enable/Disable Custom HTTP Request Headers globally.
  37280. * default = false
  37281. * @see CustomRequestHeaders
  37282. */
  37283. static UseCustomRequestHeaders: boolean;
  37284. /**
  37285. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37286. * i.e. when loading files, where the server/service expects an Authorization header
  37287. */
  37288. static CustomRequestHeaders: {
  37289. [key: string]: string;
  37290. };
  37291. /**
  37292. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37293. */
  37294. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37295. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37296. /**
  37297. * Default behaviour for cors in the application.
  37298. * It can be a string if the expected behavior is identical in the entire app.
  37299. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37300. */
  37301. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37302. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37303. /**
  37304. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37305. * @ignorenaming
  37306. */
  37307. static get UseFallbackTexture(): boolean;
  37308. static set UseFallbackTexture(value: boolean);
  37309. /**
  37310. * Use this object to register external classes like custom textures or material
  37311. * to allow the laoders to instantiate them
  37312. */
  37313. static get RegisteredExternalClasses(): {
  37314. [key: string]: Object;
  37315. };
  37316. static set RegisteredExternalClasses(classes: {
  37317. [key: string]: Object;
  37318. });
  37319. /**
  37320. * Texture content used if a texture cannot loaded
  37321. * @ignorenaming
  37322. */
  37323. static get fallbackTexture(): string;
  37324. static set fallbackTexture(value: string);
  37325. /**
  37326. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37327. * @param u defines the coordinate on X axis
  37328. * @param v defines the coordinate on Y axis
  37329. * @param width defines the width of the source data
  37330. * @param height defines the height of the source data
  37331. * @param pixels defines the source byte array
  37332. * @param color defines the output color
  37333. */
  37334. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37335. /**
  37336. * Interpolates between a and b via alpha
  37337. * @param a The lower value (returned when alpha = 0)
  37338. * @param b The upper value (returned when alpha = 1)
  37339. * @param alpha The interpolation-factor
  37340. * @return The mixed value
  37341. */
  37342. static Mix(a: number, b: number, alpha: number): number;
  37343. /**
  37344. * Tries to instantiate a new object from a given class name
  37345. * @param className defines the class name to instantiate
  37346. * @returns the new object or null if the system was not able to do the instantiation
  37347. */
  37348. static Instantiate(className: string): any;
  37349. /**
  37350. * Provides a slice function that will work even on IE
  37351. * @param data defines the array to slice
  37352. * @param start defines the start of the data (optional)
  37353. * @param end defines the end of the data (optional)
  37354. * @returns the new sliced array
  37355. */
  37356. static Slice<T>(data: T, start?: number, end?: number): T;
  37357. /**
  37358. * Polyfill for setImmediate
  37359. * @param action defines the action to execute after the current execution block
  37360. */
  37361. static SetImmediate(action: () => void): void;
  37362. /**
  37363. * Function indicating if a number is an exponent of 2
  37364. * @param value defines the value to test
  37365. * @returns true if the value is an exponent of 2
  37366. */
  37367. static IsExponentOfTwo(value: number): boolean;
  37368. private static _tmpFloatArray;
  37369. /**
  37370. * Returns the nearest 32-bit single precision float representation of a Number
  37371. * @param value A Number. If the parameter is of a different type, it will get converted
  37372. * to a number or to NaN if it cannot be converted
  37373. * @returns number
  37374. */
  37375. static FloatRound(value: number): number;
  37376. /**
  37377. * Extracts the filename from a path
  37378. * @param path defines the path to use
  37379. * @returns the filename
  37380. */
  37381. static GetFilename(path: string): string;
  37382. /**
  37383. * Extracts the "folder" part of a path (everything before the filename).
  37384. * @param uri The URI to extract the info from
  37385. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37386. * @returns The "folder" part of the path
  37387. */
  37388. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37389. /**
  37390. * Extracts text content from a DOM element hierarchy
  37391. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37392. */
  37393. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37394. /**
  37395. * Convert an angle in radians to degrees
  37396. * @param angle defines the angle to convert
  37397. * @returns the angle in degrees
  37398. */
  37399. static ToDegrees(angle: number): number;
  37400. /**
  37401. * Convert an angle in degrees to radians
  37402. * @param angle defines the angle to convert
  37403. * @returns the angle in radians
  37404. */
  37405. static ToRadians(angle: number): number;
  37406. /**
  37407. * Returns an array if obj is not an array
  37408. * @param obj defines the object to evaluate as an array
  37409. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37410. * @returns either obj directly if obj is an array or a new array containing obj
  37411. */
  37412. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37413. /**
  37414. * Gets the pointer prefix to use
  37415. * @param engine defines the engine we are finding the prefix for
  37416. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37417. */
  37418. static GetPointerPrefix(engine: Engine): string;
  37419. /**
  37420. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37421. * @param url define the url we are trying
  37422. * @param element define the dom element where to configure the cors policy
  37423. */
  37424. static SetCorsBehavior(url: string | string[], element: {
  37425. crossOrigin: string | null;
  37426. }): void;
  37427. /**
  37428. * Removes unwanted characters from an url
  37429. * @param url defines the url to clean
  37430. * @returns the cleaned url
  37431. */
  37432. static CleanUrl(url: string): string;
  37433. /**
  37434. * Gets or sets a function used to pre-process url before using them to load assets
  37435. */
  37436. static get PreprocessUrl(): (url: string) => string;
  37437. static set PreprocessUrl(processor: (url: string) => string);
  37438. /**
  37439. * Loads an image as an HTMLImageElement.
  37440. * @param input url string, ArrayBuffer, or Blob to load
  37441. * @param onLoad callback called when the image successfully loads
  37442. * @param onError callback called when the image fails to load
  37443. * @param offlineProvider offline provider for caching
  37444. * @param mimeType optional mime type
  37445. * @returns the HTMLImageElement of the loaded image
  37446. */
  37447. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37448. /**
  37449. * Loads a file from a url
  37450. * @param url url string, ArrayBuffer, or Blob to load
  37451. * @param onSuccess callback called when the file successfully loads
  37452. * @param onProgress callback called while file is loading (if the server supports this mode)
  37453. * @param offlineProvider defines the offline provider for caching
  37454. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37455. * @param onError callback called when the file fails to load
  37456. * @returns a file request object
  37457. */
  37458. 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;
  37459. /**
  37460. * Loads a file from a url
  37461. * @param url the file url to load
  37462. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37463. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37464. */
  37465. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37466. /**
  37467. * Load a script (identified by an url). When the url returns, the
  37468. * content of this file is added into a new script element, attached to the DOM (body element)
  37469. * @param scriptUrl defines the url of the script to laod
  37470. * @param onSuccess defines the callback called when the script is loaded
  37471. * @param onError defines the callback to call if an error occurs
  37472. * @param scriptId defines the id of the script element
  37473. */
  37474. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37475. /**
  37476. * Load an asynchronous script (identified by an url). When the url returns, the
  37477. * content of this file is added into a new script element, attached to the DOM (body element)
  37478. * @param scriptUrl defines the url of the script to laod
  37479. * @param scriptId defines the id of the script element
  37480. * @returns a promise request object
  37481. */
  37482. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37483. /**
  37484. * Loads a file from a blob
  37485. * @param fileToLoad defines the blob to use
  37486. * @param callback defines the callback to call when data is loaded
  37487. * @param progressCallback defines the callback to call during loading process
  37488. * @returns a file request object
  37489. */
  37490. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37491. /**
  37492. * Reads a file from a File object
  37493. * @param file defines the file to load
  37494. * @param onSuccess defines the callback to call when data is loaded
  37495. * @param onProgress defines the callback to call during loading process
  37496. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37497. * @param onError defines the callback to call when an error occurs
  37498. * @returns a file request object
  37499. */
  37500. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37501. /**
  37502. * Creates a data url from a given string content
  37503. * @param content defines the content to convert
  37504. * @returns the new data url link
  37505. */
  37506. static FileAsURL(content: string): string;
  37507. /**
  37508. * Format the given number to a specific decimal format
  37509. * @param value defines the number to format
  37510. * @param decimals defines the number of decimals to use
  37511. * @returns the formatted string
  37512. */
  37513. static Format(value: number, decimals?: number): string;
  37514. /**
  37515. * Tries to copy an object by duplicating every property
  37516. * @param source defines the source object
  37517. * @param destination defines the target object
  37518. * @param doNotCopyList defines a list of properties to avoid
  37519. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37520. */
  37521. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37522. /**
  37523. * Gets a boolean indicating if the given object has no own property
  37524. * @param obj defines the object to test
  37525. * @returns true if object has no own property
  37526. */
  37527. static IsEmpty(obj: any): boolean;
  37528. /**
  37529. * Function used to register events at window level
  37530. * @param windowElement defines the Window object to use
  37531. * @param events defines the events to register
  37532. */
  37533. static RegisterTopRootEvents(windowElement: Window, events: {
  37534. name: string;
  37535. handler: Nullable<(e: FocusEvent) => any>;
  37536. }[]): void;
  37537. /**
  37538. * Function used to unregister events from window level
  37539. * @param windowElement defines the Window object to use
  37540. * @param events defines the events to unregister
  37541. */
  37542. static UnregisterTopRootEvents(windowElement: Window, events: {
  37543. name: string;
  37544. handler: Nullable<(e: FocusEvent) => any>;
  37545. }[]): void;
  37546. /**
  37547. * @ignore
  37548. */
  37549. static _ScreenshotCanvas: HTMLCanvasElement;
  37550. /**
  37551. * Dumps the current bound framebuffer
  37552. * @param width defines the rendering width
  37553. * @param height defines the rendering height
  37554. * @param engine defines the hosting engine
  37555. * @param successCallback defines the callback triggered once the data are available
  37556. * @param mimeType defines the mime type of the result
  37557. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37558. */
  37559. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37560. /**
  37561. * Converts the canvas data to blob.
  37562. * This acts as a polyfill for browsers not supporting the to blob function.
  37563. * @param canvas Defines the canvas to extract the data from
  37564. * @param successCallback Defines the callback triggered once the data are available
  37565. * @param mimeType Defines the mime type of the result
  37566. */
  37567. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37568. /**
  37569. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37570. * @param successCallback defines the callback triggered once the data are available
  37571. * @param mimeType defines the mime type of the result
  37572. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37573. */
  37574. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37575. /**
  37576. * Downloads a blob in the browser
  37577. * @param blob defines the blob to download
  37578. * @param fileName defines the name of the downloaded file
  37579. */
  37580. static Download(blob: Blob, fileName: string): void;
  37581. /**
  37582. * Captures a screenshot of the current rendering
  37583. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37584. * @param engine defines the rendering engine
  37585. * @param camera defines the source camera
  37586. * @param size This parameter can be set to a single number or to an object with the
  37587. * following (optional) properties: precision, width, height. If a single number is passed,
  37588. * it will be used for both width and height. If an object is passed, the screenshot size
  37589. * will be derived from the parameters. The precision property is a multiplier allowing
  37590. * rendering at a higher or lower resolution
  37591. * @param successCallback defines the callback receives a single parameter which contains the
  37592. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37593. * src parameter of an <img> to display it
  37594. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37595. * Check your browser for supported MIME types
  37596. */
  37597. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37598. /**
  37599. * Captures a screenshot of the current rendering
  37600. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37601. * @param engine defines the rendering engine
  37602. * @param camera defines the source camera
  37603. * @param size This parameter can be set to a single number or to an object with the
  37604. * following (optional) properties: precision, width, height. If a single number is passed,
  37605. * it will be used for both width and height. If an object is passed, the screenshot size
  37606. * will be derived from the parameters. The precision property is a multiplier allowing
  37607. * rendering at a higher or lower resolution
  37608. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37609. * Check your browser for supported MIME types
  37610. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37611. * to the src parameter of an <img> to display it
  37612. */
  37613. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37614. /**
  37615. * Generates an image screenshot from the specified camera.
  37616. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37617. * @param engine The engine to use for rendering
  37618. * @param camera The camera to use for rendering
  37619. * @param size This parameter can be set to a single number or to an object with the
  37620. * following (optional) properties: precision, width, height. If a single number is passed,
  37621. * it will be used for both width and height. If an object is passed, the screenshot size
  37622. * will be derived from the parameters. The precision property is a multiplier allowing
  37623. * rendering at a higher or lower resolution
  37624. * @param successCallback The callback receives a single parameter which contains the
  37625. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37626. * src parameter of an <img> to display it
  37627. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37628. * Check your browser for supported MIME types
  37629. * @param samples Texture samples (default: 1)
  37630. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37631. * @param fileName A name for for the downloaded file.
  37632. */
  37633. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37634. /**
  37635. * Generates an image screenshot from the specified camera.
  37636. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37637. * @param engine The engine to use for rendering
  37638. * @param camera The camera to use for rendering
  37639. * @param size This parameter can be set to a single number or to an object with the
  37640. * following (optional) properties: precision, width, height. If a single number is passed,
  37641. * it will be used for both width and height. If an object is passed, the screenshot size
  37642. * will be derived from the parameters. The precision property is a multiplier allowing
  37643. * rendering at a higher or lower resolution
  37644. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37645. * Check your browser for supported MIME types
  37646. * @param samples Texture samples (default: 1)
  37647. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37648. * @param fileName A name for for the downloaded file.
  37649. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37650. * to the src parameter of an <img> to display it
  37651. */
  37652. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37653. /**
  37654. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37655. * Be aware Math.random() could cause collisions, but:
  37656. * "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"
  37657. * @returns a pseudo random id
  37658. */
  37659. static RandomId(): string;
  37660. /**
  37661. * Test if the given uri is a base64 string
  37662. * @param uri The uri to test
  37663. * @return True if the uri is a base64 string or false otherwise
  37664. */
  37665. static IsBase64(uri: string): boolean;
  37666. /**
  37667. * Decode the given base64 uri.
  37668. * @param uri The uri to decode
  37669. * @return The decoded base64 data.
  37670. */
  37671. static DecodeBase64(uri: string): ArrayBuffer;
  37672. /**
  37673. * Gets the absolute url.
  37674. * @param url the input url
  37675. * @return the absolute url
  37676. */
  37677. static GetAbsoluteUrl(url: string): string;
  37678. /**
  37679. * No log
  37680. */
  37681. static readonly NoneLogLevel: number;
  37682. /**
  37683. * Only message logs
  37684. */
  37685. static readonly MessageLogLevel: number;
  37686. /**
  37687. * Only warning logs
  37688. */
  37689. static readonly WarningLogLevel: number;
  37690. /**
  37691. * Only error logs
  37692. */
  37693. static readonly ErrorLogLevel: number;
  37694. /**
  37695. * All logs
  37696. */
  37697. static readonly AllLogLevel: number;
  37698. /**
  37699. * Gets a value indicating the number of loading errors
  37700. * @ignorenaming
  37701. */
  37702. static get errorsCount(): number;
  37703. /**
  37704. * Callback called when a new log is added
  37705. */
  37706. static OnNewCacheEntry: (entry: string) => void;
  37707. /**
  37708. * Log a message to the console
  37709. * @param message defines the message to log
  37710. */
  37711. static Log(message: string): void;
  37712. /**
  37713. * Write a warning message to the console
  37714. * @param message defines the message to log
  37715. */
  37716. static Warn(message: string): void;
  37717. /**
  37718. * Write an error message to the console
  37719. * @param message defines the message to log
  37720. */
  37721. static Error(message: string): void;
  37722. /**
  37723. * Gets current log cache (list of logs)
  37724. */
  37725. static get LogCache(): string;
  37726. /**
  37727. * Clears the log cache
  37728. */
  37729. static ClearLogCache(): void;
  37730. /**
  37731. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37732. */
  37733. static set LogLevels(level: number);
  37734. /**
  37735. * Checks if the window object exists
  37736. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37737. */
  37738. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37739. /**
  37740. * No performance log
  37741. */
  37742. static readonly PerformanceNoneLogLevel: number;
  37743. /**
  37744. * Use user marks to log performance
  37745. */
  37746. static readonly PerformanceUserMarkLogLevel: number;
  37747. /**
  37748. * Log performance to the console
  37749. */
  37750. static readonly PerformanceConsoleLogLevel: number;
  37751. private static _performance;
  37752. /**
  37753. * Sets the current performance log level
  37754. */
  37755. static set PerformanceLogLevel(level: number);
  37756. private static _StartPerformanceCounterDisabled;
  37757. private static _EndPerformanceCounterDisabled;
  37758. private static _StartUserMark;
  37759. private static _EndUserMark;
  37760. private static _StartPerformanceConsole;
  37761. private static _EndPerformanceConsole;
  37762. /**
  37763. * Starts a performance counter
  37764. */
  37765. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37766. /**
  37767. * Ends a specific performance coutner
  37768. */
  37769. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37770. /**
  37771. * Gets either window.performance.now() if supported or Date.now() else
  37772. */
  37773. static get Now(): number;
  37774. /**
  37775. * This method will return the name of the class used to create the instance of the given object.
  37776. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37777. * @param object the object to get the class name from
  37778. * @param isType defines if the object is actually a type
  37779. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37780. */
  37781. static GetClassName(object: any, isType?: boolean): string;
  37782. /**
  37783. * Gets the first element of an array satisfying a given predicate
  37784. * @param array defines the array to browse
  37785. * @param predicate defines the predicate to use
  37786. * @returns null if not found or the element
  37787. */
  37788. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37789. /**
  37790. * This method will return the name of the full name of the class, including its owning module (if any).
  37791. * 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).
  37792. * @param object the object to get the class name from
  37793. * @param isType defines if the object is actually a type
  37794. * @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.
  37795. * @ignorenaming
  37796. */
  37797. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37798. /**
  37799. * Returns a promise that resolves after the given amount of time.
  37800. * @param delay Number of milliseconds to delay
  37801. * @returns Promise that resolves after the given amount of time
  37802. */
  37803. static DelayAsync(delay: number): Promise<void>;
  37804. /**
  37805. * Utility function to detect if the current user agent is Safari
  37806. * @returns whether or not the current user agent is safari
  37807. */
  37808. static IsSafari(): boolean;
  37809. }
  37810. /**
  37811. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37812. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37813. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37814. * @param name The name of the class, case should be preserved
  37815. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37816. */
  37817. export function className(name: string, module?: string): (target: Object) => void;
  37818. /**
  37819. * An implementation of a loop for asynchronous functions.
  37820. */
  37821. export class AsyncLoop {
  37822. /**
  37823. * Defines the number of iterations for the loop
  37824. */
  37825. iterations: number;
  37826. /**
  37827. * Defines the current index of the loop.
  37828. */
  37829. index: number;
  37830. private _done;
  37831. private _fn;
  37832. private _successCallback;
  37833. /**
  37834. * Constructor.
  37835. * @param iterations the number of iterations.
  37836. * @param func the function to run each iteration
  37837. * @param successCallback the callback that will be called upon succesful execution
  37838. * @param offset starting offset.
  37839. */
  37840. constructor(
  37841. /**
  37842. * Defines the number of iterations for the loop
  37843. */
  37844. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37845. /**
  37846. * Execute the next iteration. Must be called after the last iteration was finished.
  37847. */
  37848. executeNext(): void;
  37849. /**
  37850. * Break the loop and run the success callback.
  37851. */
  37852. breakLoop(): void;
  37853. /**
  37854. * Create and run an async loop.
  37855. * @param iterations the number of iterations.
  37856. * @param fn the function to run each iteration
  37857. * @param successCallback the callback that will be called upon succesful execution
  37858. * @param offset starting offset.
  37859. * @returns the created async loop object
  37860. */
  37861. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37862. /**
  37863. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37864. * @param iterations total number of iterations
  37865. * @param syncedIterations number of synchronous iterations in each async iteration.
  37866. * @param fn the function to call each iteration.
  37867. * @param callback a success call back that will be called when iterating stops.
  37868. * @param breakFunction a break condition (optional)
  37869. * @param timeout timeout settings for the setTimeout function. default - 0.
  37870. * @returns the created async loop object
  37871. */
  37872. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37873. }
  37874. }
  37875. declare module BABYLON {
  37876. /**
  37877. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37878. * The underlying implementation relies on an associative array to ensure the best performances.
  37879. * The value can be anything including 'null' but except 'undefined'
  37880. */
  37881. export class StringDictionary<T> {
  37882. /**
  37883. * This will clear this dictionary and copy the content from the 'source' one.
  37884. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37885. * @param source the dictionary to take the content from and copy to this dictionary
  37886. */
  37887. copyFrom(source: StringDictionary<T>): void;
  37888. /**
  37889. * Get a value based from its key
  37890. * @param key the given key to get the matching value from
  37891. * @return the value if found, otherwise undefined is returned
  37892. */
  37893. get(key: string): T | undefined;
  37894. /**
  37895. * Get a value from its key or add it if it doesn't exist.
  37896. * This method will ensure you that a given key/data will be present in the dictionary.
  37897. * @param key the given key to get the matching value from
  37898. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37899. * The factory will only be invoked if there's no data for the given key.
  37900. * @return the value corresponding to the key.
  37901. */
  37902. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37903. /**
  37904. * Get a value from its key if present in the dictionary otherwise add it
  37905. * @param key the key to get the value from
  37906. * @param val if there's no such key/value pair in the dictionary add it with this value
  37907. * @return the value corresponding to the key
  37908. */
  37909. getOrAdd(key: string, val: T): T;
  37910. /**
  37911. * Check if there's a given key in the dictionary
  37912. * @param key the key to check for
  37913. * @return true if the key is present, false otherwise
  37914. */
  37915. contains(key: string): boolean;
  37916. /**
  37917. * Add a new key and its corresponding value
  37918. * @param key the key to add
  37919. * @param value the value corresponding to the key
  37920. * @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
  37921. */
  37922. add(key: string, value: T): boolean;
  37923. /**
  37924. * Update a specific value associated to a key
  37925. * @param key defines the key to use
  37926. * @param value defines the value to store
  37927. * @returns true if the value was updated (or false if the key was not found)
  37928. */
  37929. set(key: string, value: T): boolean;
  37930. /**
  37931. * Get the element of the given key and remove it from the dictionary
  37932. * @param key defines the key to search
  37933. * @returns the value associated with the key or null if not found
  37934. */
  37935. getAndRemove(key: string): Nullable<T>;
  37936. /**
  37937. * Remove a key/value from the dictionary.
  37938. * @param key the key to remove
  37939. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37940. */
  37941. remove(key: string): boolean;
  37942. /**
  37943. * Clear the whole content of the dictionary
  37944. */
  37945. clear(): void;
  37946. /**
  37947. * Gets the current count
  37948. */
  37949. get count(): number;
  37950. /**
  37951. * Execute a callback on each key/val of the dictionary.
  37952. * Note that you can remove any element in this dictionary in the callback implementation
  37953. * @param callback the callback to execute on a given key/value pair
  37954. */
  37955. forEach(callback: (key: string, val: T) => void): void;
  37956. /**
  37957. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37958. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37959. * Note that you can remove any element in this dictionary in the callback implementation
  37960. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37961. * @returns the first item
  37962. */
  37963. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37964. private _count;
  37965. private _data;
  37966. }
  37967. }
  37968. declare module BABYLON {
  37969. /** @hidden */
  37970. export interface ICollisionCoordinator {
  37971. createCollider(): Collider;
  37972. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37973. init(scene: Scene): void;
  37974. }
  37975. /** @hidden */
  37976. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37977. private _scene;
  37978. private _scaledPosition;
  37979. private _scaledVelocity;
  37980. private _finalPosition;
  37981. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37982. createCollider(): Collider;
  37983. init(scene: Scene): void;
  37984. private _collideWithWorld;
  37985. }
  37986. }
  37987. declare module BABYLON {
  37988. /**
  37989. * Class used to manage all inputs for the scene.
  37990. */
  37991. export class InputManager {
  37992. /** The distance in pixel that you have to move to prevent some events */
  37993. static DragMovementThreshold: number;
  37994. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  37995. static LongPressDelay: number;
  37996. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  37997. static DoubleClickDelay: number;
  37998. /** If you need to check double click without raising a single click at first click, enable this flag */
  37999. static ExclusiveDoubleClickMode: boolean;
  38000. private _wheelEventName;
  38001. private _onPointerMove;
  38002. private _onPointerDown;
  38003. private _onPointerUp;
  38004. private _initClickEvent;
  38005. private _initActionManager;
  38006. private _delayedSimpleClick;
  38007. private _delayedSimpleClickTimeout;
  38008. private _previousDelayedSimpleClickTimeout;
  38009. private _meshPickProceed;
  38010. private _previousButtonPressed;
  38011. private _currentPickResult;
  38012. private _previousPickResult;
  38013. private _totalPointersPressed;
  38014. private _doubleClickOccured;
  38015. private _pointerOverMesh;
  38016. private _pickedDownMesh;
  38017. private _pickedUpMesh;
  38018. private _pointerX;
  38019. private _pointerY;
  38020. private _unTranslatedPointerX;
  38021. private _unTranslatedPointerY;
  38022. private _startingPointerPosition;
  38023. private _previousStartingPointerPosition;
  38024. private _startingPointerTime;
  38025. private _previousStartingPointerTime;
  38026. private _pointerCaptures;
  38027. private _onKeyDown;
  38028. private _onKeyUp;
  38029. private _onCanvasFocusObserver;
  38030. private _onCanvasBlurObserver;
  38031. private _scene;
  38032. /**
  38033. * Creates a new InputManager
  38034. * @param scene defines the hosting scene
  38035. */
  38036. constructor(scene: Scene);
  38037. /**
  38038. * Gets the mesh that is currently under the pointer
  38039. */
  38040. get meshUnderPointer(): Nullable<AbstractMesh>;
  38041. /**
  38042. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38043. */
  38044. get unTranslatedPointer(): Vector2;
  38045. /**
  38046. * Gets or sets the current on-screen X position of the pointer
  38047. */
  38048. get pointerX(): number;
  38049. set pointerX(value: number);
  38050. /**
  38051. * Gets or sets the current on-screen Y position of the pointer
  38052. */
  38053. get pointerY(): number;
  38054. set pointerY(value: number);
  38055. private _updatePointerPosition;
  38056. private _processPointerMove;
  38057. private _setRayOnPointerInfo;
  38058. private _checkPrePointerObservable;
  38059. /**
  38060. * Use this method to simulate a pointer move on a mesh
  38061. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38062. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38063. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38064. */
  38065. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38066. /**
  38067. * Use this method to simulate a pointer down on a mesh
  38068. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38069. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38070. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38071. */
  38072. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38073. private _processPointerDown;
  38074. /** @hidden */
  38075. _isPointerSwiping(): boolean;
  38076. /**
  38077. * Use this method to simulate a pointer up on a mesh
  38078. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38079. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38080. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38081. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38082. */
  38083. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38084. private _processPointerUp;
  38085. /**
  38086. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38087. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38088. * @returns true if the pointer was captured
  38089. */
  38090. isPointerCaptured(pointerId?: number): boolean;
  38091. /**
  38092. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38093. * @param attachUp defines if you want to attach events to pointerup
  38094. * @param attachDown defines if you want to attach events to pointerdown
  38095. * @param attachMove defines if you want to attach events to pointermove
  38096. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38097. */
  38098. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38099. /**
  38100. * Detaches all event handlers
  38101. */
  38102. detachControl(): void;
  38103. /**
  38104. * Force the value of meshUnderPointer
  38105. * @param mesh defines the mesh to use
  38106. */
  38107. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38108. /**
  38109. * Gets the mesh under the pointer
  38110. * @returns a Mesh or null if no mesh is under the pointer
  38111. */
  38112. getPointerOverMesh(): Nullable<AbstractMesh>;
  38113. }
  38114. }
  38115. declare module BABYLON {
  38116. /**
  38117. * This class defines the direct association between an animation and a target
  38118. */
  38119. export class TargetedAnimation {
  38120. /**
  38121. * Animation to perform
  38122. */
  38123. animation: Animation;
  38124. /**
  38125. * Target to animate
  38126. */
  38127. target: any;
  38128. /**
  38129. * Returns the string "TargetedAnimation"
  38130. * @returns "TargetedAnimation"
  38131. */
  38132. getClassName(): string;
  38133. /**
  38134. * Serialize the object
  38135. * @returns the JSON object representing the current entity
  38136. */
  38137. serialize(): any;
  38138. }
  38139. /**
  38140. * Use this class to create coordinated animations on multiple targets
  38141. */
  38142. export class AnimationGroup implements IDisposable {
  38143. /** The name of the animation group */
  38144. name: string;
  38145. private _scene;
  38146. private _targetedAnimations;
  38147. private _animatables;
  38148. private _from;
  38149. private _to;
  38150. private _isStarted;
  38151. private _isPaused;
  38152. private _speedRatio;
  38153. private _loopAnimation;
  38154. private _isAdditive;
  38155. /**
  38156. * Gets or sets the unique id of the node
  38157. */
  38158. uniqueId: number;
  38159. /**
  38160. * This observable will notify when one animation have ended
  38161. */
  38162. onAnimationEndObservable: Observable<TargetedAnimation>;
  38163. /**
  38164. * Observer raised when one animation loops
  38165. */
  38166. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38167. /**
  38168. * Observer raised when all animations have looped
  38169. */
  38170. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38171. /**
  38172. * This observable will notify when all animations have ended.
  38173. */
  38174. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38175. /**
  38176. * This observable will notify when all animations have paused.
  38177. */
  38178. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38179. /**
  38180. * This observable will notify when all animations are playing.
  38181. */
  38182. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38183. /**
  38184. * Gets the first frame
  38185. */
  38186. get from(): number;
  38187. /**
  38188. * Gets the last frame
  38189. */
  38190. get to(): number;
  38191. /**
  38192. * Define if the animations are started
  38193. */
  38194. get isStarted(): boolean;
  38195. /**
  38196. * Gets a value indicating that the current group is playing
  38197. */
  38198. get isPlaying(): boolean;
  38199. /**
  38200. * Gets or sets the speed ratio to use for all animations
  38201. */
  38202. get speedRatio(): number;
  38203. /**
  38204. * Gets or sets the speed ratio to use for all animations
  38205. */
  38206. set speedRatio(value: number);
  38207. /**
  38208. * Gets or sets if all animations should loop or not
  38209. */
  38210. get loopAnimation(): boolean;
  38211. set loopAnimation(value: boolean);
  38212. /**
  38213. * Gets or sets if all animations should be evaluated additively
  38214. */
  38215. get isAdditive(): boolean;
  38216. set isAdditive(value: boolean);
  38217. /**
  38218. * Gets the targeted animations for this animation group
  38219. */
  38220. get targetedAnimations(): Array<TargetedAnimation>;
  38221. /**
  38222. * returning the list of animatables controlled by this animation group.
  38223. */
  38224. get animatables(): Array<Animatable>;
  38225. /**
  38226. * Gets the list of target animations
  38227. */
  38228. get children(): TargetedAnimation[];
  38229. /**
  38230. * Instantiates a new Animation Group.
  38231. * This helps managing several animations at once.
  38232. * @see http://doc.babylonjs.com/how_to/group
  38233. * @param name Defines the name of the group
  38234. * @param scene Defines the scene the group belongs to
  38235. */
  38236. constructor(
  38237. /** The name of the animation group */
  38238. name: string, scene?: Nullable<Scene>);
  38239. /**
  38240. * Add an animation (with its target) in the group
  38241. * @param animation defines the animation we want to add
  38242. * @param target defines the target of the animation
  38243. * @returns the TargetedAnimation object
  38244. */
  38245. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38246. /**
  38247. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38248. * It can add constant keys at begin or end
  38249. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38250. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38251. * @returns the animation group
  38252. */
  38253. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38254. private _animationLoopCount;
  38255. private _animationLoopFlags;
  38256. private _processLoop;
  38257. /**
  38258. * Start all animations on given targets
  38259. * @param loop defines if animations must loop
  38260. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38261. * @param from defines the from key (optional)
  38262. * @param to defines the to key (optional)
  38263. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38264. * @returns the current animation group
  38265. */
  38266. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38267. /**
  38268. * Pause all animations
  38269. * @returns the animation group
  38270. */
  38271. pause(): AnimationGroup;
  38272. /**
  38273. * Play all animations to initial state
  38274. * This function will start() the animations if they were not started or will restart() them if they were paused
  38275. * @param loop defines if animations must loop
  38276. * @returns the animation group
  38277. */
  38278. play(loop?: boolean): AnimationGroup;
  38279. /**
  38280. * Reset all animations to initial state
  38281. * @returns the animation group
  38282. */
  38283. reset(): AnimationGroup;
  38284. /**
  38285. * Restart animations from key 0
  38286. * @returns the animation group
  38287. */
  38288. restart(): AnimationGroup;
  38289. /**
  38290. * Stop all animations
  38291. * @returns the animation group
  38292. */
  38293. stop(): AnimationGroup;
  38294. /**
  38295. * Set animation weight for all animatables
  38296. * @param weight defines the weight to use
  38297. * @return the animationGroup
  38298. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38299. */
  38300. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38301. /**
  38302. * Synchronize and normalize all animatables with a source animatable
  38303. * @param root defines the root animatable to synchronize with
  38304. * @return the animationGroup
  38305. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38306. */
  38307. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38308. /**
  38309. * Goes to a specific frame in this animation group
  38310. * @param frame the frame number to go to
  38311. * @return the animationGroup
  38312. */
  38313. goToFrame(frame: number): AnimationGroup;
  38314. /**
  38315. * Dispose all associated resources
  38316. */
  38317. dispose(): void;
  38318. private _checkAnimationGroupEnded;
  38319. /**
  38320. * Clone the current animation group and returns a copy
  38321. * @param newName defines the name of the new group
  38322. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38323. * @returns the new aniamtion group
  38324. */
  38325. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38326. /**
  38327. * Serializes the animationGroup to an object
  38328. * @returns Serialized object
  38329. */
  38330. serialize(): any;
  38331. /**
  38332. * Returns a new AnimationGroup object parsed from the source provided.
  38333. * @param parsedAnimationGroup defines the source
  38334. * @param scene defines the scene that will receive the animationGroup
  38335. * @returns a new AnimationGroup
  38336. */
  38337. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38338. /**
  38339. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38340. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38341. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38342. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38343. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38344. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38345. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38346. */
  38347. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38348. /**
  38349. * Returns the string "AnimationGroup"
  38350. * @returns "AnimationGroup"
  38351. */
  38352. getClassName(): string;
  38353. /**
  38354. * Creates a detailled string about the object
  38355. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38356. * @returns a string representing the object
  38357. */
  38358. toString(fullDetails?: boolean): string;
  38359. }
  38360. }
  38361. declare module BABYLON {
  38362. /**
  38363. * Define an interface for all classes that will hold resources
  38364. */
  38365. export interface IDisposable {
  38366. /**
  38367. * Releases all held resources
  38368. */
  38369. dispose(): void;
  38370. }
  38371. /** Interface defining initialization parameters for Scene class */
  38372. export interface SceneOptions {
  38373. /**
  38374. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38375. * It will improve performance when the number of geometries becomes important.
  38376. */
  38377. useGeometryUniqueIdsMap?: boolean;
  38378. /**
  38379. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38380. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38381. */
  38382. useMaterialMeshMap?: boolean;
  38383. /**
  38384. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38385. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38386. */
  38387. useClonedMeshMap?: boolean;
  38388. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38389. virtual?: boolean;
  38390. }
  38391. /**
  38392. * Represents a scene to be rendered by the engine.
  38393. * @see http://doc.babylonjs.com/features/scene
  38394. */
  38395. export class Scene extends AbstractScene implements IAnimatable {
  38396. /** The fog is deactivated */
  38397. static readonly FOGMODE_NONE: number;
  38398. /** The fog density is following an exponential function */
  38399. static readonly FOGMODE_EXP: number;
  38400. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38401. static readonly FOGMODE_EXP2: number;
  38402. /** The fog density is following a linear function. */
  38403. static readonly FOGMODE_LINEAR: number;
  38404. /**
  38405. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38406. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38407. */
  38408. static MinDeltaTime: number;
  38409. /**
  38410. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38411. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38412. */
  38413. static MaxDeltaTime: number;
  38414. /**
  38415. * Factory used to create the default material.
  38416. * @param name The name of the material to create
  38417. * @param scene The scene to create the material for
  38418. * @returns The default material
  38419. */
  38420. static DefaultMaterialFactory(scene: Scene): Material;
  38421. /**
  38422. * Factory used to create the a collision coordinator.
  38423. * @returns The collision coordinator
  38424. */
  38425. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38426. /** @hidden */
  38427. _inputManager: InputManager;
  38428. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38429. cameraToUseForPointers: Nullable<Camera>;
  38430. /** @hidden */
  38431. readonly _isScene: boolean;
  38432. /** @hidden */
  38433. _blockEntityCollection: boolean;
  38434. /**
  38435. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38436. */
  38437. autoClear: boolean;
  38438. /**
  38439. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38440. */
  38441. autoClearDepthAndStencil: boolean;
  38442. /**
  38443. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38444. */
  38445. clearColor: Color4;
  38446. /**
  38447. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38448. */
  38449. ambientColor: Color3;
  38450. /**
  38451. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38452. * It should only be one of the following (if not the default embedded one):
  38453. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38454. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38455. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38456. * The material properties need to be setup according to the type of texture in use.
  38457. */
  38458. environmentBRDFTexture: BaseTexture;
  38459. /** @hidden */
  38460. protected _environmentTexture: Nullable<BaseTexture>;
  38461. /**
  38462. * Texture used in all pbr material as the reflection texture.
  38463. * As in the majority of the scene they are the same (exception for multi room and so on),
  38464. * this is easier to reference from here than from all the materials.
  38465. */
  38466. get environmentTexture(): Nullable<BaseTexture>;
  38467. /**
  38468. * Texture used in all pbr material as the reflection texture.
  38469. * As in the majority of the scene they are the same (exception for multi room and so on),
  38470. * this is easier to set here than in all the materials.
  38471. */
  38472. set environmentTexture(value: Nullable<BaseTexture>);
  38473. /** @hidden */
  38474. protected _environmentIntensity: number;
  38475. /**
  38476. * Intensity of the environment in all pbr material.
  38477. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38478. * As in the majority of the scene they are the same (exception for multi room and so on),
  38479. * this is easier to reference from here than from all the materials.
  38480. */
  38481. get environmentIntensity(): number;
  38482. /**
  38483. * Intensity of the environment in all pbr material.
  38484. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38485. * As in the majority of the scene they are the same (exception for multi room and so on),
  38486. * this is easier to set here than in all the materials.
  38487. */
  38488. set environmentIntensity(value: number);
  38489. /** @hidden */
  38490. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38491. /**
  38492. * Default image processing configuration used either in the rendering
  38493. * Forward main pass or through the imageProcessingPostProcess if present.
  38494. * As in the majority of the scene they are the same (exception for multi camera),
  38495. * this is easier to reference from here than from all the materials and post process.
  38496. *
  38497. * No setter as we it is a shared configuration, you can set the values instead.
  38498. */
  38499. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38500. private _forceWireframe;
  38501. /**
  38502. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38503. */
  38504. set forceWireframe(value: boolean);
  38505. get forceWireframe(): boolean;
  38506. private _skipFrustumClipping;
  38507. /**
  38508. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38509. */
  38510. set skipFrustumClipping(value: boolean);
  38511. get skipFrustumClipping(): boolean;
  38512. private _forcePointsCloud;
  38513. /**
  38514. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38515. */
  38516. set forcePointsCloud(value: boolean);
  38517. get forcePointsCloud(): boolean;
  38518. /**
  38519. * Gets or sets the active clipplane 1
  38520. */
  38521. clipPlane: Nullable<Plane>;
  38522. /**
  38523. * Gets or sets the active clipplane 2
  38524. */
  38525. clipPlane2: Nullable<Plane>;
  38526. /**
  38527. * Gets or sets the active clipplane 3
  38528. */
  38529. clipPlane3: Nullable<Plane>;
  38530. /**
  38531. * Gets or sets the active clipplane 4
  38532. */
  38533. clipPlane4: Nullable<Plane>;
  38534. /**
  38535. * Gets or sets the active clipplane 5
  38536. */
  38537. clipPlane5: Nullable<Plane>;
  38538. /**
  38539. * Gets or sets the active clipplane 6
  38540. */
  38541. clipPlane6: Nullable<Plane>;
  38542. /**
  38543. * Gets or sets a boolean indicating if animations are enabled
  38544. */
  38545. animationsEnabled: boolean;
  38546. private _animationPropertiesOverride;
  38547. /**
  38548. * Gets or sets the animation properties override
  38549. */
  38550. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38551. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38552. /**
  38553. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38554. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38555. */
  38556. useConstantAnimationDeltaTime: boolean;
  38557. /**
  38558. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38559. * Please note that it requires to run a ray cast through the scene on every frame
  38560. */
  38561. constantlyUpdateMeshUnderPointer: boolean;
  38562. /**
  38563. * Defines the HTML cursor to use when hovering over interactive elements
  38564. */
  38565. hoverCursor: string;
  38566. /**
  38567. * Defines the HTML default cursor to use (empty by default)
  38568. */
  38569. defaultCursor: string;
  38570. /**
  38571. * Defines whether cursors are handled by the scene.
  38572. */
  38573. doNotHandleCursors: boolean;
  38574. /**
  38575. * This is used to call preventDefault() on pointer down
  38576. * in order to block unwanted artifacts like system double clicks
  38577. */
  38578. preventDefaultOnPointerDown: boolean;
  38579. /**
  38580. * This is used to call preventDefault() on pointer up
  38581. * in order to block unwanted artifacts like system double clicks
  38582. */
  38583. preventDefaultOnPointerUp: boolean;
  38584. /**
  38585. * Gets or sets user defined metadata
  38586. */
  38587. metadata: any;
  38588. /**
  38589. * For internal use only. Please do not use.
  38590. */
  38591. reservedDataStore: any;
  38592. /**
  38593. * Gets the name of the plugin used to load this scene (null by default)
  38594. */
  38595. loadingPluginName: string;
  38596. /**
  38597. * Use this array to add regular expressions used to disable offline support for specific urls
  38598. */
  38599. disableOfflineSupportExceptionRules: RegExp[];
  38600. /**
  38601. * An event triggered when the scene is disposed.
  38602. */
  38603. onDisposeObservable: Observable<Scene>;
  38604. private _onDisposeObserver;
  38605. /** Sets a function to be executed when this scene is disposed. */
  38606. set onDispose(callback: () => void);
  38607. /**
  38608. * An event triggered before rendering the scene (right after animations and physics)
  38609. */
  38610. onBeforeRenderObservable: Observable<Scene>;
  38611. private _onBeforeRenderObserver;
  38612. /** Sets a function to be executed before rendering this scene */
  38613. set beforeRender(callback: Nullable<() => void>);
  38614. /**
  38615. * An event triggered after rendering the scene
  38616. */
  38617. onAfterRenderObservable: Observable<Scene>;
  38618. /**
  38619. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38620. */
  38621. onAfterRenderCameraObservable: Observable<Camera>;
  38622. private _onAfterRenderObserver;
  38623. /** Sets a function to be executed after rendering this scene */
  38624. set afterRender(callback: Nullable<() => void>);
  38625. /**
  38626. * An event triggered before animating the scene
  38627. */
  38628. onBeforeAnimationsObservable: Observable<Scene>;
  38629. /**
  38630. * An event triggered after animations processing
  38631. */
  38632. onAfterAnimationsObservable: Observable<Scene>;
  38633. /**
  38634. * An event triggered before draw calls are ready to be sent
  38635. */
  38636. onBeforeDrawPhaseObservable: Observable<Scene>;
  38637. /**
  38638. * An event triggered after draw calls have been sent
  38639. */
  38640. onAfterDrawPhaseObservable: Observable<Scene>;
  38641. /**
  38642. * An event triggered when the scene is ready
  38643. */
  38644. onReadyObservable: Observable<Scene>;
  38645. /**
  38646. * An event triggered before rendering a camera
  38647. */
  38648. onBeforeCameraRenderObservable: Observable<Camera>;
  38649. private _onBeforeCameraRenderObserver;
  38650. /** Sets a function to be executed before rendering a camera*/
  38651. set beforeCameraRender(callback: () => void);
  38652. /**
  38653. * An event triggered after rendering a camera
  38654. */
  38655. onAfterCameraRenderObservable: Observable<Camera>;
  38656. private _onAfterCameraRenderObserver;
  38657. /** Sets a function to be executed after rendering a camera*/
  38658. set afterCameraRender(callback: () => void);
  38659. /**
  38660. * An event triggered when active meshes evaluation is about to start
  38661. */
  38662. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38663. /**
  38664. * An event triggered when active meshes evaluation is done
  38665. */
  38666. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38667. /**
  38668. * An event triggered when particles rendering is about to start
  38669. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38670. */
  38671. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38672. /**
  38673. * An event triggered when particles rendering is done
  38674. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38675. */
  38676. onAfterParticlesRenderingObservable: Observable<Scene>;
  38677. /**
  38678. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38679. */
  38680. onDataLoadedObservable: Observable<Scene>;
  38681. /**
  38682. * An event triggered when a camera is created
  38683. */
  38684. onNewCameraAddedObservable: Observable<Camera>;
  38685. /**
  38686. * An event triggered when a camera is removed
  38687. */
  38688. onCameraRemovedObservable: Observable<Camera>;
  38689. /**
  38690. * An event triggered when a light is created
  38691. */
  38692. onNewLightAddedObservable: Observable<Light>;
  38693. /**
  38694. * An event triggered when a light is removed
  38695. */
  38696. onLightRemovedObservable: Observable<Light>;
  38697. /**
  38698. * An event triggered when a geometry is created
  38699. */
  38700. onNewGeometryAddedObservable: Observable<Geometry>;
  38701. /**
  38702. * An event triggered when a geometry is removed
  38703. */
  38704. onGeometryRemovedObservable: Observable<Geometry>;
  38705. /**
  38706. * An event triggered when a transform node is created
  38707. */
  38708. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38709. /**
  38710. * An event triggered when a transform node is removed
  38711. */
  38712. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38713. /**
  38714. * An event triggered when a mesh is created
  38715. */
  38716. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38717. /**
  38718. * An event triggered when a mesh is removed
  38719. */
  38720. onMeshRemovedObservable: Observable<AbstractMesh>;
  38721. /**
  38722. * An event triggered when a skeleton is created
  38723. */
  38724. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38725. /**
  38726. * An event triggered when a skeleton is removed
  38727. */
  38728. onSkeletonRemovedObservable: Observable<Skeleton>;
  38729. /**
  38730. * An event triggered when a material is created
  38731. */
  38732. onNewMaterialAddedObservable: Observable<Material>;
  38733. /**
  38734. * An event triggered when a material is removed
  38735. */
  38736. onMaterialRemovedObservable: Observable<Material>;
  38737. /**
  38738. * An event triggered when a texture is created
  38739. */
  38740. onNewTextureAddedObservable: Observable<BaseTexture>;
  38741. /**
  38742. * An event triggered when a texture is removed
  38743. */
  38744. onTextureRemovedObservable: Observable<BaseTexture>;
  38745. /**
  38746. * An event triggered when render targets are about to be rendered
  38747. * Can happen multiple times per frame.
  38748. */
  38749. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38750. /**
  38751. * An event triggered when render targets were rendered.
  38752. * Can happen multiple times per frame.
  38753. */
  38754. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38755. /**
  38756. * An event triggered before calculating deterministic simulation step
  38757. */
  38758. onBeforeStepObservable: Observable<Scene>;
  38759. /**
  38760. * An event triggered after calculating deterministic simulation step
  38761. */
  38762. onAfterStepObservable: Observable<Scene>;
  38763. /**
  38764. * An event triggered when the activeCamera property is updated
  38765. */
  38766. onActiveCameraChanged: Observable<Scene>;
  38767. /**
  38768. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38769. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38770. * 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)
  38771. */
  38772. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38773. /**
  38774. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38775. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38776. * 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)
  38777. */
  38778. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38779. /**
  38780. * This Observable will when a mesh has been imported into the scene.
  38781. */
  38782. onMeshImportedObservable: Observable<AbstractMesh>;
  38783. /**
  38784. * This Observable will when an animation file has been imported into the scene.
  38785. */
  38786. onAnimationFileImportedObservable: Observable<Scene>;
  38787. /**
  38788. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38789. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38790. */
  38791. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38792. /** @hidden */
  38793. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38794. /**
  38795. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38796. */
  38797. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38798. /**
  38799. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38800. */
  38801. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38802. /**
  38803. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38804. */
  38805. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38806. /** Callback called when a pointer move is detected */
  38807. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38808. /** Callback called when a pointer down is detected */
  38809. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38810. /** Callback called when a pointer up is detected */
  38811. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38812. /** Callback called when a pointer pick is detected */
  38813. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38814. /**
  38815. * 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).
  38816. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38817. */
  38818. onPrePointerObservable: Observable<PointerInfoPre>;
  38819. /**
  38820. * Observable event triggered each time an input event is received from the rendering canvas
  38821. */
  38822. onPointerObservable: Observable<PointerInfo>;
  38823. /**
  38824. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38825. */
  38826. get unTranslatedPointer(): Vector2;
  38827. /**
  38828. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38829. */
  38830. static get DragMovementThreshold(): number;
  38831. static set DragMovementThreshold(value: number);
  38832. /**
  38833. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38834. */
  38835. static get LongPressDelay(): number;
  38836. static set LongPressDelay(value: number);
  38837. /**
  38838. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38839. */
  38840. static get DoubleClickDelay(): number;
  38841. static set DoubleClickDelay(value: number);
  38842. /** If you need to check double click without raising a single click at first click, enable this flag */
  38843. static get ExclusiveDoubleClickMode(): boolean;
  38844. static set ExclusiveDoubleClickMode(value: boolean);
  38845. /** @hidden */
  38846. _mirroredCameraPosition: Nullable<Vector3>;
  38847. /**
  38848. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38849. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38850. */
  38851. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38852. /**
  38853. * Observable event triggered each time an keyboard event is received from the hosting window
  38854. */
  38855. onKeyboardObservable: Observable<KeyboardInfo>;
  38856. private _useRightHandedSystem;
  38857. /**
  38858. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38859. */
  38860. set useRightHandedSystem(value: boolean);
  38861. get useRightHandedSystem(): boolean;
  38862. private _timeAccumulator;
  38863. private _currentStepId;
  38864. private _currentInternalStep;
  38865. /**
  38866. * Sets the step Id used by deterministic lock step
  38867. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38868. * @param newStepId defines the step Id
  38869. */
  38870. setStepId(newStepId: number): void;
  38871. /**
  38872. * Gets the step Id used by deterministic lock step
  38873. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38874. * @returns the step Id
  38875. */
  38876. getStepId(): number;
  38877. /**
  38878. * Gets the internal step used by deterministic lock step
  38879. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38880. * @returns the internal step
  38881. */
  38882. getInternalStep(): number;
  38883. private _fogEnabled;
  38884. /**
  38885. * Gets or sets a boolean indicating if fog is enabled on this scene
  38886. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38887. * (Default is true)
  38888. */
  38889. set fogEnabled(value: boolean);
  38890. get fogEnabled(): boolean;
  38891. private _fogMode;
  38892. /**
  38893. * Gets or sets the fog mode to use
  38894. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38895. * | mode | value |
  38896. * | --- | --- |
  38897. * | FOGMODE_NONE | 0 |
  38898. * | FOGMODE_EXP | 1 |
  38899. * | FOGMODE_EXP2 | 2 |
  38900. * | FOGMODE_LINEAR | 3 |
  38901. */
  38902. set fogMode(value: number);
  38903. get fogMode(): number;
  38904. /**
  38905. * Gets or sets the fog color to use
  38906. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38907. * (Default is Color3(0.2, 0.2, 0.3))
  38908. */
  38909. fogColor: Color3;
  38910. /**
  38911. * Gets or sets the fog density to use
  38912. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38913. * (Default is 0.1)
  38914. */
  38915. fogDensity: number;
  38916. /**
  38917. * Gets or sets the fog start distance to use
  38918. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38919. * (Default is 0)
  38920. */
  38921. fogStart: number;
  38922. /**
  38923. * Gets or sets the fog end distance to use
  38924. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38925. * (Default is 1000)
  38926. */
  38927. fogEnd: number;
  38928. private _shadowsEnabled;
  38929. /**
  38930. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38931. */
  38932. set shadowsEnabled(value: boolean);
  38933. get shadowsEnabled(): boolean;
  38934. private _lightsEnabled;
  38935. /**
  38936. * Gets or sets a boolean indicating if lights are enabled on this scene
  38937. */
  38938. set lightsEnabled(value: boolean);
  38939. get lightsEnabled(): boolean;
  38940. /** All of the active cameras added to this scene. */
  38941. activeCameras: Camera[];
  38942. /** @hidden */
  38943. _activeCamera: Nullable<Camera>;
  38944. /** Gets or sets the current active camera */
  38945. get activeCamera(): Nullable<Camera>;
  38946. set activeCamera(value: Nullable<Camera>);
  38947. private _defaultMaterial;
  38948. /** The default material used on meshes when no material is affected */
  38949. get defaultMaterial(): Material;
  38950. /** The default material used on meshes when no material is affected */
  38951. set defaultMaterial(value: Material);
  38952. private _texturesEnabled;
  38953. /**
  38954. * Gets or sets a boolean indicating if textures are enabled on this scene
  38955. */
  38956. set texturesEnabled(value: boolean);
  38957. get texturesEnabled(): boolean;
  38958. /**
  38959. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38960. */
  38961. physicsEnabled: boolean;
  38962. /**
  38963. * Gets or sets a boolean indicating if particles are enabled on this scene
  38964. */
  38965. particlesEnabled: boolean;
  38966. /**
  38967. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38968. */
  38969. spritesEnabled: boolean;
  38970. private _skeletonsEnabled;
  38971. /**
  38972. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38973. */
  38974. set skeletonsEnabled(value: boolean);
  38975. get skeletonsEnabled(): boolean;
  38976. /**
  38977. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38978. */
  38979. lensFlaresEnabled: boolean;
  38980. /**
  38981. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38982. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38983. */
  38984. collisionsEnabled: boolean;
  38985. private _collisionCoordinator;
  38986. /** @hidden */
  38987. get collisionCoordinator(): ICollisionCoordinator;
  38988. /**
  38989. * Defines the gravity applied to this scene (used only for collisions)
  38990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38991. */
  38992. gravity: Vector3;
  38993. /**
  38994. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  38995. */
  38996. postProcessesEnabled: boolean;
  38997. /**
  38998. * The list of postprocesses added to the scene
  38999. */
  39000. postProcesses: PostProcess[];
  39001. /**
  39002. * Gets the current postprocess manager
  39003. */
  39004. postProcessManager: PostProcessManager;
  39005. /**
  39006. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39007. */
  39008. renderTargetsEnabled: boolean;
  39009. /**
  39010. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39011. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39012. */
  39013. dumpNextRenderTargets: boolean;
  39014. /**
  39015. * The list of user defined render targets added to the scene
  39016. */
  39017. customRenderTargets: RenderTargetTexture[];
  39018. /**
  39019. * Defines if texture loading must be delayed
  39020. * If true, textures will only be loaded when they need to be rendered
  39021. */
  39022. useDelayedTextureLoading: boolean;
  39023. /**
  39024. * Gets the list of meshes imported to the scene through SceneLoader
  39025. */
  39026. importedMeshesFiles: String[];
  39027. /**
  39028. * Gets or sets a boolean indicating if probes are enabled on this scene
  39029. */
  39030. probesEnabled: boolean;
  39031. /**
  39032. * Gets or sets the current offline provider to use to store scene data
  39033. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39034. */
  39035. offlineProvider: IOfflineProvider;
  39036. /**
  39037. * Gets or sets the action manager associated with the scene
  39038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39039. */
  39040. actionManager: AbstractActionManager;
  39041. private _meshesForIntersections;
  39042. /**
  39043. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39044. */
  39045. proceduralTexturesEnabled: boolean;
  39046. private _engine;
  39047. private _totalVertices;
  39048. /** @hidden */
  39049. _activeIndices: PerfCounter;
  39050. /** @hidden */
  39051. _activeParticles: PerfCounter;
  39052. /** @hidden */
  39053. _activeBones: PerfCounter;
  39054. private _animationRatio;
  39055. /** @hidden */
  39056. _animationTimeLast: number;
  39057. /** @hidden */
  39058. _animationTime: number;
  39059. /**
  39060. * Gets or sets a general scale for animation speed
  39061. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39062. */
  39063. animationTimeScale: number;
  39064. /** @hidden */
  39065. _cachedMaterial: Nullable<Material>;
  39066. /** @hidden */
  39067. _cachedEffect: Nullable<Effect>;
  39068. /** @hidden */
  39069. _cachedVisibility: Nullable<number>;
  39070. private _renderId;
  39071. private _frameId;
  39072. private _executeWhenReadyTimeoutId;
  39073. private _intermediateRendering;
  39074. private _viewUpdateFlag;
  39075. private _projectionUpdateFlag;
  39076. /** @hidden */
  39077. _toBeDisposed: Nullable<IDisposable>[];
  39078. private _activeRequests;
  39079. /** @hidden */
  39080. _pendingData: any[];
  39081. private _isDisposed;
  39082. /**
  39083. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39084. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39085. */
  39086. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39087. private _activeMeshes;
  39088. private _processedMaterials;
  39089. private _renderTargets;
  39090. /** @hidden */
  39091. _activeParticleSystems: SmartArray<IParticleSystem>;
  39092. private _activeSkeletons;
  39093. private _softwareSkinnedMeshes;
  39094. private _renderingManager;
  39095. /** @hidden */
  39096. _activeAnimatables: Animatable[];
  39097. private _transformMatrix;
  39098. private _sceneUbo;
  39099. /** @hidden */
  39100. _viewMatrix: Matrix;
  39101. private _projectionMatrix;
  39102. /** @hidden */
  39103. _forcedViewPosition: Nullable<Vector3>;
  39104. /** @hidden */
  39105. _frustumPlanes: Plane[];
  39106. /**
  39107. * Gets the list of frustum planes (built from the active camera)
  39108. */
  39109. get frustumPlanes(): Plane[];
  39110. /**
  39111. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39112. * This is useful if there are more lights that the maximum simulteanous authorized
  39113. */
  39114. requireLightSorting: boolean;
  39115. /** @hidden */
  39116. readonly useMaterialMeshMap: boolean;
  39117. /** @hidden */
  39118. readonly useClonedMeshMap: boolean;
  39119. private _externalData;
  39120. private _uid;
  39121. /**
  39122. * @hidden
  39123. * Backing store of defined scene components.
  39124. */
  39125. _components: ISceneComponent[];
  39126. /**
  39127. * @hidden
  39128. * Backing store of defined scene components.
  39129. */
  39130. _serializableComponents: ISceneSerializableComponent[];
  39131. /**
  39132. * List of components to register on the next registration step.
  39133. */
  39134. private _transientComponents;
  39135. /**
  39136. * Registers the transient components if needed.
  39137. */
  39138. private _registerTransientComponents;
  39139. /**
  39140. * @hidden
  39141. * Add a component to the scene.
  39142. * Note that the ccomponent could be registered on th next frame if this is called after
  39143. * the register component stage.
  39144. * @param component Defines the component to add to the scene
  39145. */
  39146. _addComponent(component: ISceneComponent): void;
  39147. /**
  39148. * @hidden
  39149. * Gets a component from the scene.
  39150. * @param name defines the name of the component to retrieve
  39151. * @returns the component or null if not present
  39152. */
  39153. _getComponent(name: string): Nullable<ISceneComponent>;
  39154. /**
  39155. * @hidden
  39156. * Defines the actions happening before camera updates.
  39157. */
  39158. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39159. /**
  39160. * @hidden
  39161. * Defines the actions happening before clear the canvas.
  39162. */
  39163. _beforeClearStage: Stage<SimpleStageAction>;
  39164. /**
  39165. * @hidden
  39166. * Defines the actions when collecting render targets for the frame.
  39167. */
  39168. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39169. /**
  39170. * @hidden
  39171. * Defines the actions happening for one camera in the frame.
  39172. */
  39173. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39174. /**
  39175. * @hidden
  39176. * Defines the actions happening during the per mesh ready checks.
  39177. */
  39178. _isReadyForMeshStage: Stage<MeshStageAction>;
  39179. /**
  39180. * @hidden
  39181. * Defines the actions happening before evaluate active mesh checks.
  39182. */
  39183. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39184. /**
  39185. * @hidden
  39186. * Defines the actions happening during the evaluate sub mesh checks.
  39187. */
  39188. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39189. /**
  39190. * @hidden
  39191. * Defines the actions happening during the active mesh stage.
  39192. */
  39193. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39194. /**
  39195. * @hidden
  39196. * Defines the actions happening during the per camera render target step.
  39197. */
  39198. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39199. /**
  39200. * @hidden
  39201. * Defines the actions happening just before the active camera is drawing.
  39202. */
  39203. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39204. /**
  39205. * @hidden
  39206. * Defines the actions happening just before a render target is drawing.
  39207. */
  39208. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39209. /**
  39210. * @hidden
  39211. * Defines the actions happening just before a rendering group is drawing.
  39212. */
  39213. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39214. /**
  39215. * @hidden
  39216. * Defines the actions happening just before a mesh is drawing.
  39217. */
  39218. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39219. /**
  39220. * @hidden
  39221. * Defines the actions happening just after a mesh has been drawn.
  39222. */
  39223. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39224. /**
  39225. * @hidden
  39226. * Defines the actions happening just after a rendering group has been drawn.
  39227. */
  39228. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39229. /**
  39230. * @hidden
  39231. * Defines the actions happening just after the active camera has been drawn.
  39232. */
  39233. _afterCameraDrawStage: Stage<CameraStageAction>;
  39234. /**
  39235. * @hidden
  39236. * Defines the actions happening just after a render target has been drawn.
  39237. */
  39238. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39239. /**
  39240. * @hidden
  39241. * Defines the actions happening just after rendering all cameras and computing intersections.
  39242. */
  39243. _afterRenderStage: Stage<SimpleStageAction>;
  39244. /**
  39245. * @hidden
  39246. * Defines the actions happening when a pointer move event happens.
  39247. */
  39248. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39249. /**
  39250. * @hidden
  39251. * Defines the actions happening when a pointer down event happens.
  39252. */
  39253. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39254. /**
  39255. * @hidden
  39256. * Defines the actions happening when a pointer up event happens.
  39257. */
  39258. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39259. /**
  39260. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39261. */
  39262. private geometriesByUniqueId;
  39263. /**
  39264. * Creates a new Scene
  39265. * @param engine defines the engine to use to render this scene
  39266. * @param options defines the scene options
  39267. */
  39268. constructor(engine: Engine, options?: SceneOptions);
  39269. /**
  39270. * Gets a string idenfifying the name of the class
  39271. * @returns "Scene" string
  39272. */
  39273. getClassName(): string;
  39274. private _defaultMeshCandidates;
  39275. /**
  39276. * @hidden
  39277. */
  39278. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39279. private _defaultSubMeshCandidates;
  39280. /**
  39281. * @hidden
  39282. */
  39283. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39284. /**
  39285. * Sets the default candidate providers for the scene.
  39286. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39287. * and getCollidingSubMeshCandidates to their default function
  39288. */
  39289. setDefaultCandidateProviders(): void;
  39290. /**
  39291. * Gets the mesh that is currently under the pointer
  39292. */
  39293. get meshUnderPointer(): Nullable<AbstractMesh>;
  39294. /**
  39295. * Gets or sets the current on-screen X position of the pointer
  39296. */
  39297. get pointerX(): number;
  39298. set pointerX(value: number);
  39299. /**
  39300. * Gets or sets the current on-screen Y position of the pointer
  39301. */
  39302. get pointerY(): number;
  39303. set pointerY(value: number);
  39304. /**
  39305. * Gets the cached material (ie. the latest rendered one)
  39306. * @returns the cached material
  39307. */
  39308. getCachedMaterial(): Nullable<Material>;
  39309. /**
  39310. * Gets the cached effect (ie. the latest rendered one)
  39311. * @returns the cached effect
  39312. */
  39313. getCachedEffect(): Nullable<Effect>;
  39314. /**
  39315. * Gets the cached visibility state (ie. the latest rendered one)
  39316. * @returns the cached visibility state
  39317. */
  39318. getCachedVisibility(): Nullable<number>;
  39319. /**
  39320. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39321. * @param material defines the current material
  39322. * @param effect defines the current effect
  39323. * @param visibility defines the current visibility state
  39324. * @returns true if one parameter is not cached
  39325. */
  39326. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39327. /**
  39328. * Gets the engine associated with the scene
  39329. * @returns an Engine
  39330. */
  39331. getEngine(): Engine;
  39332. /**
  39333. * Gets the total number of vertices rendered per frame
  39334. * @returns the total number of vertices rendered per frame
  39335. */
  39336. getTotalVertices(): number;
  39337. /**
  39338. * Gets the performance counter for total vertices
  39339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39340. */
  39341. get totalVerticesPerfCounter(): PerfCounter;
  39342. /**
  39343. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39344. * @returns the total number of active indices rendered per frame
  39345. */
  39346. getActiveIndices(): number;
  39347. /**
  39348. * Gets the performance counter for active indices
  39349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39350. */
  39351. get totalActiveIndicesPerfCounter(): PerfCounter;
  39352. /**
  39353. * Gets the total number of active particles rendered per frame
  39354. * @returns the total number of active particles rendered per frame
  39355. */
  39356. getActiveParticles(): number;
  39357. /**
  39358. * Gets the performance counter for active particles
  39359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39360. */
  39361. get activeParticlesPerfCounter(): PerfCounter;
  39362. /**
  39363. * Gets the total number of active bones rendered per frame
  39364. * @returns the total number of active bones rendered per frame
  39365. */
  39366. getActiveBones(): number;
  39367. /**
  39368. * Gets the performance counter for active bones
  39369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39370. */
  39371. get activeBonesPerfCounter(): PerfCounter;
  39372. /**
  39373. * Gets the array of active meshes
  39374. * @returns an array of AbstractMesh
  39375. */
  39376. getActiveMeshes(): SmartArray<AbstractMesh>;
  39377. /**
  39378. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39379. * @returns a number
  39380. */
  39381. getAnimationRatio(): number;
  39382. /**
  39383. * Gets an unique Id for the current render phase
  39384. * @returns a number
  39385. */
  39386. getRenderId(): number;
  39387. /**
  39388. * Gets an unique Id for the current frame
  39389. * @returns a number
  39390. */
  39391. getFrameId(): number;
  39392. /** Call this function if you want to manually increment the render Id*/
  39393. incrementRenderId(): void;
  39394. private _createUbo;
  39395. /**
  39396. * Use this method to simulate a pointer move on a mesh
  39397. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39398. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39399. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39400. * @returns the current scene
  39401. */
  39402. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39403. /**
  39404. * Use this method to simulate a pointer down on a mesh
  39405. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39406. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39407. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39408. * @returns the current scene
  39409. */
  39410. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39411. /**
  39412. * Use this method to simulate a pointer up on a mesh
  39413. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39414. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39415. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39416. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39417. * @returns the current scene
  39418. */
  39419. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39420. /**
  39421. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39422. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39423. * @returns true if the pointer was captured
  39424. */
  39425. isPointerCaptured(pointerId?: number): boolean;
  39426. /**
  39427. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39428. * @param attachUp defines if you want to attach events to pointerup
  39429. * @param attachDown defines if you want to attach events to pointerdown
  39430. * @param attachMove defines if you want to attach events to pointermove
  39431. */
  39432. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39433. /** Detaches all event handlers*/
  39434. detachControl(): void;
  39435. /**
  39436. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39437. * Delay loaded resources are not taking in account
  39438. * @return true if all required resources are ready
  39439. */
  39440. isReady(): boolean;
  39441. /** Resets all cached information relative to material (including effect and visibility) */
  39442. resetCachedMaterial(): void;
  39443. /**
  39444. * Registers a function to be called before every frame render
  39445. * @param func defines the function to register
  39446. */
  39447. registerBeforeRender(func: () => void): void;
  39448. /**
  39449. * Unregisters a function called before every frame render
  39450. * @param func defines the function to unregister
  39451. */
  39452. unregisterBeforeRender(func: () => void): void;
  39453. /**
  39454. * Registers a function to be called after every frame render
  39455. * @param func defines the function to register
  39456. */
  39457. registerAfterRender(func: () => void): void;
  39458. /**
  39459. * Unregisters a function called after every frame render
  39460. * @param func defines the function to unregister
  39461. */
  39462. unregisterAfterRender(func: () => void): void;
  39463. private _executeOnceBeforeRender;
  39464. /**
  39465. * The provided function will run before render once and will be disposed afterwards.
  39466. * A timeout delay can be provided so that the function will be executed in N ms.
  39467. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39468. * @param func The function to be executed.
  39469. * @param timeout optional delay in ms
  39470. */
  39471. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39472. /** @hidden */
  39473. _addPendingData(data: any): void;
  39474. /** @hidden */
  39475. _removePendingData(data: any): void;
  39476. /**
  39477. * Returns the number of items waiting to be loaded
  39478. * @returns the number of items waiting to be loaded
  39479. */
  39480. getWaitingItemsCount(): number;
  39481. /**
  39482. * Returns a boolean indicating if the scene is still loading data
  39483. */
  39484. get isLoading(): boolean;
  39485. /**
  39486. * Registers a function to be executed when the scene is ready
  39487. * @param {Function} func - the function to be executed
  39488. */
  39489. executeWhenReady(func: () => void): void;
  39490. /**
  39491. * Returns a promise that resolves when the scene is ready
  39492. * @returns A promise that resolves when the scene is ready
  39493. */
  39494. whenReadyAsync(): Promise<void>;
  39495. /** @hidden */
  39496. _checkIsReady(): void;
  39497. /**
  39498. * Gets all animatable attached to the scene
  39499. */
  39500. get animatables(): Animatable[];
  39501. /**
  39502. * Resets the last animation time frame.
  39503. * Useful to override when animations start running when loading a scene for the first time.
  39504. */
  39505. resetLastAnimationTimeFrame(): void;
  39506. /**
  39507. * Gets the current view matrix
  39508. * @returns a Matrix
  39509. */
  39510. getViewMatrix(): Matrix;
  39511. /**
  39512. * Gets the current projection matrix
  39513. * @returns a Matrix
  39514. */
  39515. getProjectionMatrix(): Matrix;
  39516. /**
  39517. * Gets the current transform matrix
  39518. * @returns a Matrix made of View * Projection
  39519. */
  39520. getTransformMatrix(): Matrix;
  39521. /**
  39522. * Sets the current transform matrix
  39523. * @param viewL defines the View matrix to use
  39524. * @param projectionL defines the Projection matrix to use
  39525. * @param viewR defines the right View matrix to use (if provided)
  39526. * @param projectionR defines the right Projection matrix to use (if provided)
  39527. */
  39528. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39529. /**
  39530. * Gets the uniform buffer used to store scene data
  39531. * @returns a UniformBuffer
  39532. */
  39533. getSceneUniformBuffer(): UniformBuffer;
  39534. /**
  39535. * Gets an unique (relatively to the current scene) Id
  39536. * @returns an unique number for the scene
  39537. */
  39538. getUniqueId(): number;
  39539. /**
  39540. * Add a mesh to the list of scene's meshes
  39541. * @param newMesh defines the mesh to add
  39542. * @param recursive if all child meshes should also be added to the scene
  39543. */
  39544. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39545. /**
  39546. * Remove a mesh for the list of scene's meshes
  39547. * @param toRemove defines the mesh to remove
  39548. * @param recursive if all child meshes should also be removed from the scene
  39549. * @returns the index where the mesh was in the mesh list
  39550. */
  39551. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39552. /**
  39553. * Add a transform node to the list of scene's transform nodes
  39554. * @param newTransformNode defines the transform node to add
  39555. */
  39556. addTransformNode(newTransformNode: TransformNode): void;
  39557. /**
  39558. * Remove a transform node for the list of scene's transform nodes
  39559. * @param toRemove defines the transform node to remove
  39560. * @returns the index where the transform node was in the transform node list
  39561. */
  39562. removeTransformNode(toRemove: TransformNode): number;
  39563. /**
  39564. * Remove a skeleton for the list of scene's skeletons
  39565. * @param toRemove defines the skeleton to remove
  39566. * @returns the index where the skeleton was in the skeleton list
  39567. */
  39568. removeSkeleton(toRemove: Skeleton): number;
  39569. /**
  39570. * Remove a morph target for the list of scene's morph targets
  39571. * @param toRemove defines the morph target to remove
  39572. * @returns the index where the morph target was in the morph target list
  39573. */
  39574. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39575. /**
  39576. * Remove a light for the list of scene's lights
  39577. * @param toRemove defines the light to remove
  39578. * @returns the index where the light was in the light list
  39579. */
  39580. removeLight(toRemove: Light): number;
  39581. /**
  39582. * Remove a camera for the list of scene's cameras
  39583. * @param toRemove defines the camera to remove
  39584. * @returns the index where the camera was in the camera list
  39585. */
  39586. removeCamera(toRemove: Camera): number;
  39587. /**
  39588. * Remove a particle system for the list of scene's particle systems
  39589. * @param toRemove defines the particle system to remove
  39590. * @returns the index where the particle system was in the particle system list
  39591. */
  39592. removeParticleSystem(toRemove: IParticleSystem): number;
  39593. /**
  39594. * Remove a animation for the list of scene's animations
  39595. * @param toRemove defines the animation to remove
  39596. * @returns the index where the animation was in the animation list
  39597. */
  39598. removeAnimation(toRemove: Animation): number;
  39599. /**
  39600. * Will stop the animation of the given target
  39601. * @param target - the target
  39602. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39603. * @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)
  39604. */
  39605. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39606. /**
  39607. * Removes the given animation group from this scene.
  39608. * @param toRemove The animation group to remove
  39609. * @returns The index of the removed animation group
  39610. */
  39611. removeAnimationGroup(toRemove: AnimationGroup): number;
  39612. /**
  39613. * Removes the given multi-material from this scene.
  39614. * @param toRemove The multi-material to remove
  39615. * @returns The index of the removed multi-material
  39616. */
  39617. removeMultiMaterial(toRemove: MultiMaterial): number;
  39618. /**
  39619. * Removes the given material from this scene.
  39620. * @param toRemove The material to remove
  39621. * @returns The index of the removed material
  39622. */
  39623. removeMaterial(toRemove: Material): number;
  39624. /**
  39625. * Removes the given action manager from this scene.
  39626. * @param toRemove The action manager to remove
  39627. * @returns The index of the removed action manager
  39628. */
  39629. removeActionManager(toRemove: AbstractActionManager): number;
  39630. /**
  39631. * Removes the given texture from this scene.
  39632. * @param toRemove The texture to remove
  39633. * @returns The index of the removed texture
  39634. */
  39635. removeTexture(toRemove: BaseTexture): number;
  39636. /**
  39637. * Adds the given light to this scene
  39638. * @param newLight The light to add
  39639. */
  39640. addLight(newLight: Light): void;
  39641. /**
  39642. * Sorts the list list based on light priorities
  39643. */
  39644. sortLightsByPriority(): void;
  39645. /**
  39646. * Adds the given camera to this scene
  39647. * @param newCamera The camera to add
  39648. */
  39649. addCamera(newCamera: Camera): void;
  39650. /**
  39651. * Adds the given skeleton to this scene
  39652. * @param newSkeleton The skeleton to add
  39653. */
  39654. addSkeleton(newSkeleton: Skeleton): void;
  39655. /**
  39656. * Adds the given particle system to this scene
  39657. * @param newParticleSystem The particle system to add
  39658. */
  39659. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39660. /**
  39661. * Adds the given animation to this scene
  39662. * @param newAnimation The animation to add
  39663. */
  39664. addAnimation(newAnimation: Animation): void;
  39665. /**
  39666. * Adds the given animation group to this scene.
  39667. * @param newAnimationGroup The animation group to add
  39668. */
  39669. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39670. /**
  39671. * Adds the given multi-material to this scene
  39672. * @param newMultiMaterial The multi-material to add
  39673. */
  39674. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39675. /**
  39676. * Adds the given material to this scene
  39677. * @param newMaterial The material to add
  39678. */
  39679. addMaterial(newMaterial: Material): void;
  39680. /**
  39681. * Adds the given morph target to this scene
  39682. * @param newMorphTargetManager The morph target to add
  39683. */
  39684. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39685. /**
  39686. * Adds the given geometry to this scene
  39687. * @param newGeometry The geometry to add
  39688. */
  39689. addGeometry(newGeometry: Geometry): void;
  39690. /**
  39691. * Adds the given action manager to this scene
  39692. * @param newActionManager The action manager to add
  39693. */
  39694. addActionManager(newActionManager: AbstractActionManager): void;
  39695. /**
  39696. * Adds the given texture to this scene.
  39697. * @param newTexture The texture to add
  39698. */
  39699. addTexture(newTexture: BaseTexture): void;
  39700. /**
  39701. * Switch active camera
  39702. * @param newCamera defines the new active camera
  39703. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39704. */
  39705. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39706. /**
  39707. * sets the active camera of the scene using its ID
  39708. * @param id defines the camera's ID
  39709. * @return the new active camera or null if none found.
  39710. */
  39711. setActiveCameraByID(id: string): Nullable<Camera>;
  39712. /**
  39713. * sets the active camera of the scene using its name
  39714. * @param name defines the camera's name
  39715. * @returns the new active camera or null if none found.
  39716. */
  39717. setActiveCameraByName(name: string): Nullable<Camera>;
  39718. /**
  39719. * get an animation group using its name
  39720. * @param name defines the material's name
  39721. * @return the animation group or null if none found.
  39722. */
  39723. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39724. /**
  39725. * Get a material using its unique id
  39726. * @param uniqueId defines the material's unique id
  39727. * @return the material or null if none found.
  39728. */
  39729. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39730. /**
  39731. * get a material using its id
  39732. * @param id defines the material's ID
  39733. * @return the material or null if none found.
  39734. */
  39735. getMaterialByID(id: string): Nullable<Material>;
  39736. /**
  39737. * Gets a the last added material using a given id
  39738. * @param id defines the material's ID
  39739. * @return the last material with the given id or null if none found.
  39740. */
  39741. getLastMaterialByID(id: string): Nullable<Material>;
  39742. /**
  39743. * Gets a material using its name
  39744. * @param name defines the material's name
  39745. * @return the material or null if none found.
  39746. */
  39747. getMaterialByName(name: string): Nullable<Material>;
  39748. /**
  39749. * Get a texture using its unique id
  39750. * @param uniqueId defines the texture's unique id
  39751. * @return the texture or null if none found.
  39752. */
  39753. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39754. /**
  39755. * Gets a camera using its id
  39756. * @param id defines the id to look for
  39757. * @returns the camera or null if not found
  39758. */
  39759. getCameraByID(id: string): Nullable<Camera>;
  39760. /**
  39761. * Gets a camera using its unique id
  39762. * @param uniqueId defines the unique id to look for
  39763. * @returns the camera or null if not found
  39764. */
  39765. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39766. /**
  39767. * Gets a camera using its name
  39768. * @param name defines the camera's name
  39769. * @return the camera or null if none found.
  39770. */
  39771. getCameraByName(name: string): Nullable<Camera>;
  39772. /**
  39773. * Gets a bone using its id
  39774. * @param id defines the bone's id
  39775. * @return the bone or null if not found
  39776. */
  39777. getBoneByID(id: string): Nullable<Bone>;
  39778. /**
  39779. * Gets a bone using its id
  39780. * @param name defines the bone's name
  39781. * @return the bone or null if not found
  39782. */
  39783. getBoneByName(name: string): Nullable<Bone>;
  39784. /**
  39785. * Gets a light node using its name
  39786. * @param name defines the the light's name
  39787. * @return the light or null if none found.
  39788. */
  39789. getLightByName(name: string): Nullable<Light>;
  39790. /**
  39791. * Gets a light node using its id
  39792. * @param id defines the light's id
  39793. * @return the light or null if none found.
  39794. */
  39795. getLightByID(id: string): Nullable<Light>;
  39796. /**
  39797. * Gets a light node using its scene-generated unique ID
  39798. * @param uniqueId defines the light's unique id
  39799. * @return the light or null if none found.
  39800. */
  39801. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39802. /**
  39803. * Gets a particle system by id
  39804. * @param id defines the particle system id
  39805. * @return the corresponding system or null if none found
  39806. */
  39807. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39808. /**
  39809. * Gets a geometry using its ID
  39810. * @param id defines the geometry's id
  39811. * @return the geometry or null if none found.
  39812. */
  39813. getGeometryByID(id: string): Nullable<Geometry>;
  39814. private _getGeometryByUniqueID;
  39815. /**
  39816. * Add a new geometry to this scene
  39817. * @param geometry defines the geometry to be added to the scene.
  39818. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39819. * @return a boolean defining if the geometry was added or not
  39820. */
  39821. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39822. /**
  39823. * Removes an existing geometry
  39824. * @param geometry defines the geometry to be removed from the scene
  39825. * @return a boolean defining if the geometry was removed or not
  39826. */
  39827. removeGeometry(geometry: Geometry): boolean;
  39828. /**
  39829. * Gets the list of geometries attached to the scene
  39830. * @returns an array of Geometry
  39831. */
  39832. getGeometries(): Geometry[];
  39833. /**
  39834. * Gets the first added mesh found of a given ID
  39835. * @param id defines the id to search for
  39836. * @return the mesh found or null if not found at all
  39837. */
  39838. getMeshByID(id: string): Nullable<AbstractMesh>;
  39839. /**
  39840. * Gets a list of meshes using their id
  39841. * @param id defines the id to search for
  39842. * @returns a list of meshes
  39843. */
  39844. getMeshesByID(id: string): Array<AbstractMesh>;
  39845. /**
  39846. * Gets the first added transform node found of a given ID
  39847. * @param id defines the id to search for
  39848. * @return the found transform node or null if not found at all.
  39849. */
  39850. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39851. /**
  39852. * Gets a transform node with its auto-generated unique id
  39853. * @param uniqueId efines the unique id to search for
  39854. * @return the found transform node or null if not found at all.
  39855. */
  39856. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39857. /**
  39858. * Gets a list of transform nodes using their id
  39859. * @param id defines the id to search for
  39860. * @returns a list of transform nodes
  39861. */
  39862. getTransformNodesByID(id: string): Array<TransformNode>;
  39863. /**
  39864. * Gets a mesh with its auto-generated unique id
  39865. * @param uniqueId defines the unique id to search for
  39866. * @return the found mesh or null if not found at all.
  39867. */
  39868. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39869. /**
  39870. * Gets a the last added mesh using a given id
  39871. * @param id defines the id to search for
  39872. * @return the found mesh or null if not found at all.
  39873. */
  39874. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39875. /**
  39876. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39877. * @param id defines the id to search for
  39878. * @return the found node or null if not found at all
  39879. */
  39880. getLastEntryByID(id: string): Nullable<Node>;
  39881. /**
  39882. * Gets a node (Mesh, Camera, Light) using a given id
  39883. * @param id defines the id to search for
  39884. * @return the found node or null if not found at all
  39885. */
  39886. getNodeByID(id: string): Nullable<Node>;
  39887. /**
  39888. * Gets a node (Mesh, Camera, Light) using a given name
  39889. * @param name defines the name to search for
  39890. * @return the found node or null if not found at all.
  39891. */
  39892. getNodeByName(name: string): Nullable<Node>;
  39893. /**
  39894. * Gets a mesh using a given name
  39895. * @param name defines the name to search for
  39896. * @return the found mesh or null if not found at all.
  39897. */
  39898. getMeshByName(name: string): Nullable<AbstractMesh>;
  39899. /**
  39900. * Gets a transform node using a given name
  39901. * @param name defines the name to search for
  39902. * @return the found transform node or null if not found at all.
  39903. */
  39904. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39905. /**
  39906. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39907. * @param id defines the id to search for
  39908. * @return the found skeleton or null if not found at all.
  39909. */
  39910. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39911. /**
  39912. * Gets a skeleton using a given auto generated unique id
  39913. * @param uniqueId defines the unique id to search for
  39914. * @return the found skeleton or null if not found at all.
  39915. */
  39916. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39917. /**
  39918. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39919. * @param id defines the id to search for
  39920. * @return the found skeleton or null if not found at all.
  39921. */
  39922. getSkeletonById(id: string): Nullable<Skeleton>;
  39923. /**
  39924. * Gets a skeleton using a given name
  39925. * @param name defines the name to search for
  39926. * @return the found skeleton or null if not found at all.
  39927. */
  39928. getSkeletonByName(name: string): Nullable<Skeleton>;
  39929. /**
  39930. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39931. * @param id defines the id to search for
  39932. * @return the found morph target manager or null if not found at all.
  39933. */
  39934. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39935. /**
  39936. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39937. * @param id defines the id to search for
  39938. * @return the found morph target or null if not found at all.
  39939. */
  39940. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39941. /**
  39942. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39943. * @param name defines the name to search for
  39944. * @return the found morph target or null if not found at all.
  39945. */
  39946. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39947. /**
  39948. * Gets a boolean indicating if the given mesh is active
  39949. * @param mesh defines the mesh to look for
  39950. * @returns true if the mesh is in the active list
  39951. */
  39952. isActiveMesh(mesh: AbstractMesh): boolean;
  39953. /**
  39954. * Return a unique id as a string which can serve as an identifier for the scene
  39955. */
  39956. get uid(): string;
  39957. /**
  39958. * Add an externaly attached data from its key.
  39959. * This method call will fail and return false, if such key already exists.
  39960. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39961. * @param key the unique key that identifies the data
  39962. * @param data the data object to associate to the key for this Engine instance
  39963. * @return true if no such key were already present and the data was added successfully, false otherwise
  39964. */
  39965. addExternalData<T>(key: string, data: T): boolean;
  39966. /**
  39967. * Get an externaly attached data from its key
  39968. * @param key the unique key that identifies the data
  39969. * @return the associated data, if present (can be null), or undefined if not present
  39970. */
  39971. getExternalData<T>(key: string): Nullable<T>;
  39972. /**
  39973. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39974. * @param key the unique key that identifies the data
  39975. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39976. * @return the associated data, can be null if the factory returned null.
  39977. */
  39978. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39979. /**
  39980. * Remove an externaly attached data from the Engine instance
  39981. * @param key the unique key that identifies the data
  39982. * @return true if the data was successfully removed, false if it doesn't exist
  39983. */
  39984. removeExternalData(key: string): boolean;
  39985. private _evaluateSubMesh;
  39986. /**
  39987. * Clear the processed materials smart array preventing retention point in material dispose.
  39988. */
  39989. freeProcessedMaterials(): void;
  39990. private _preventFreeActiveMeshesAndRenderingGroups;
  39991. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39992. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39993. * when disposing several meshes in a row or a hierarchy of meshes.
  39994. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  39995. */
  39996. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  39997. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  39998. /**
  39999. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40000. */
  40001. freeActiveMeshes(): void;
  40002. /**
  40003. * Clear the info related to rendering groups preventing retention points during dispose.
  40004. */
  40005. freeRenderingGroups(): void;
  40006. /** @hidden */
  40007. _isInIntermediateRendering(): boolean;
  40008. /**
  40009. * Lambda returning the list of potentially active meshes.
  40010. */
  40011. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40012. /**
  40013. * Lambda returning the list of potentially active sub meshes.
  40014. */
  40015. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40016. /**
  40017. * Lambda returning the list of potentially intersecting sub meshes.
  40018. */
  40019. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40020. /**
  40021. * Lambda returning the list of potentially colliding sub meshes.
  40022. */
  40023. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40024. private _activeMeshesFrozen;
  40025. private _skipEvaluateActiveMeshesCompletely;
  40026. /**
  40027. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40028. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40029. * @returns the current scene
  40030. */
  40031. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40032. /**
  40033. * Use this function to restart evaluating active meshes on every frame
  40034. * @returns the current scene
  40035. */
  40036. unfreezeActiveMeshes(): Scene;
  40037. private _evaluateActiveMeshes;
  40038. private _activeMesh;
  40039. /**
  40040. * Update the transform matrix to update from the current active camera
  40041. * @param force defines a boolean used to force the update even if cache is up to date
  40042. */
  40043. updateTransformMatrix(force?: boolean): void;
  40044. private _bindFrameBuffer;
  40045. /** @hidden */
  40046. _allowPostProcessClearColor: boolean;
  40047. /** @hidden */
  40048. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40049. private _processSubCameras;
  40050. private _checkIntersections;
  40051. /** @hidden */
  40052. _advancePhysicsEngineStep(step: number): void;
  40053. /**
  40054. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40055. */
  40056. getDeterministicFrameTime: () => number;
  40057. /** @hidden */
  40058. _animate(): void;
  40059. /** Execute all animations (for a frame) */
  40060. animate(): void;
  40061. /**
  40062. * Render the scene
  40063. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40064. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40065. */
  40066. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40067. /**
  40068. * Freeze all materials
  40069. * A frozen material will not be updatable but should be faster to render
  40070. */
  40071. freezeMaterials(): void;
  40072. /**
  40073. * Unfreeze all materials
  40074. * A frozen material will not be updatable but should be faster to render
  40075. */
  40076. unfreezeMaterials(): void;
  40077. /**
  40078. * Releases all held ressources
  40079. */
  40080. dispose(): void;
  40081. /**
  40082. * Gets if the scene is already disposed
  40083. */
  40084. get isDisposed(): boolean;
  40085. /**
  40086. * Call this function to reduce memory footprint of the scene.
  40087. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40088. */
  40089. clearCachedVertexData(): void;
  40090. /**
  40091. * This function will remove the local cached buffer data from texture.
  40092. * It will save memory but will prevent the texture from being rebuilt
  40093. */
  40094. cleanCachedTextureBuffer(): void;
  40095. /**
  40096. * Get the world extend vectors with an optional filter
  40097. *
  40098. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40099. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40100. */
  40101. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40102. min: Vector3;
  40103. max: Vector3;
  40104. };
  40105. /**
  40106. * Creates a ray that can be used to pick in the scene
  40107. * @param x defines the x coordinate of the origin (on-screen)
  40108. * @param y defines the y coordinate of the origin (on-screen)
  40109. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40110. * @param camera defines the camera to use for the picking
  40111. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40112. * @returns a Ray
  40113. */
  40114. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40115. /**
  40116. * Creates a ray that can be used to pick in the scene
  40117. * @param x defines the x coordinate of the origin (on-screen)
  40118. * @param y defines the y coordinate of the origin (on-screen)
  40119. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40120. * @param result defines the ray where to store the picking ray
  40121. * @param camera defines the camera to use for the picking
  40122. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40123. * @returns the current scene
  40124. */
  40125. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40126. /**
  40127. * Creates a ray that can be used to pick in the scene
  40128. * @param x defines the x coordinate of the origin (on-screen)
  40129. * @param y defines the y coordinate of the origin (on-screen)
  40130. * @param camera defines the camera to use for the picking
  40131. * @returns a Ray
  40132. */
  40133. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40134. /**
  40135. * Creates a ray that can be used to pick in the scene
  40136. * @param x defines the x coordinate of the origin (on-screen)
  40137. * @param y defines the y coordinate of the origin (on-screen)
  40138. * @param result defines the ray where to store the picking ray
  40139. * @param camera defines the camera to use for the picking
  40140. * @returns the current scene
  40141. */
  40142. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40143. /** Launch a ray to try to pick a mesh in the scene
  40144. * @param x position on screen
  40145. * @param y position on screen
  40146. * @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
  40147. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40148. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40149. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40150. * @returns a PickingInfo
  40151. */
  40152. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40153. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40154. * @param x position on screen
  40155. * @param y position on screen
  40156. * @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
  40157. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40158. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40159. * @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)
  40160. */
  40161. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40162. /** Use the given ray to pick a mesh in the scene
  40163. * @param ray The ray to use to pick meshes
  40164. * @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
  40165. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40166. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40167. * @returns a PickingInfo
  40168. */
  40169. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40170. /**
  40171. * Launch a ray to try to pick a mesh in the scene
  40172. * @param x X position on screen
  40173. * @param y Y position on screen
  40174. * @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
  40175. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40176. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40177. * @returns an array of PickingInfo
  40178. */
  40179. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40180. /**
  40181. * Launch a ray to try to pick a mesh in the scene
  40182. * @param ray Ray to use
  40183. * @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
  40184. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40185. * @returns an array of PickingInfo
  40186. */
  40187. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40188. /**
  40189. * Force the value of meshUnderPointer
  40190. * @param mesh defines the mesh to use
  40191. */
  40192. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40193. /**
  40194. * Gets the mesh under the pointer
  40195. * @returns a Mesh or null if no mesh is under the pointer
  40196. */
  40197. getPointerOverMesh(): Nullable<AbstractMesh>;
  40198. /** @hidden */
  40199. _rebuildGeometries(): void;
  40200. /** @hidden */
  40201. _rebuildTextures(): void;
  40202. private _getByTags;
  40203. /**
  40204. * Get a list of meshes by tags
  40205. * @param tagsQuery defines the tags query to use
  40206. * @param forEach defines a predicate used to filter results
  40207. * @returns an array of Mesh
  40208. */
  40209. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40210. /**
  40211. * Get a list of cameras by tags
  40212. * @param tagsQuery defines the tags query to use
  40213. * @param forEach defines a predicate used to filter results
  40214. * @returns an array of Camera
  40215. */
  40216. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40217. /**
  40218. * Get a list of lights by tags
  40219. * @param tagsQuery defines the tags query to use
  40220. * @param forEach defines a predicate used to filter results
  40221. * @returns an array of Light
  40222. */
  40223. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40224. /**
  40225. * Get a list of materials by tags
  40226. * @param tagsQuery defines the tags query to use
  40227. * @param forEach defines a predicate used to filter results
  40228. * @returns an array of Material
  40229. */
  40230. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40231. /**
  40232. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40233. * This allowed control for front to back rendering or reversly depending of the special needs.
  40234. *
  40235. * @param renderingGroupId The rendering group id corresponding to its index
  40236. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40237. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40238. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40239. */
  40240. 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;
  40241. /**
  40242. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40243. *
  40244. * @param renderingGroupId The rendering group id corresponding to its index
  40245. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40246. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40247. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40248. */
  40249. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40250. /**
  40251. * Gets the current auto clear configuration for one rendering group of the rendering
  40252. * manager.
  40253. * @param index the rendering group index to get the information for
  40254. * @returns The auto clear setup for the requested rendering group
  40255. */
  40256. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40257. private _blockMaterialDirtyMechanism;
  40258. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40259. get blockMaterialDirtyMechanism(): boolean;
  40260. set blockMaterialDirtyMechanism(value: boolean);
  40261. /**
  40262. * Will flag all materials as dirty to trigger new shader compilation
  40263. * @param flag defines the flag used to specify which material part must be marked as dirty
  40264. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40265. */
  40266. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40267. /** @hidden */
  40268. _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;
  40269. /** @hidden */
  40270. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40271. /** @hidden */
  40272. _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;
  40273. /** @hidden */
  40274. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40275. /** @hidden */
  40276. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40277. /** @hidden */
  40278. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40279. }
  40280. }
  40281. declare module BABYLON {
  40282. /**
  40283. * Set of assets to keep when moving a scene into an asset container.
  40284. */
  40285. export class KeepAssets extends AbstractScene {
  40286. }
  40287. /**
  40288. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40289. */
  40290. export class InstantiatedEntries {
  40291. /**
  40292. * List of new root nodes (eg. nodes with no parent)
  40293. */
  40294. rootNodes: TransformNode[];
  40295. /**
  40296. * List of new skeletons
  40297. */
  40298. skeletons: Skeleton[];
  40299. /**
  40300. * List of new animation groups
  40301. */
  40302. animationGroups: AnimationGroup[];
  40303. }
  40304. /**
  40305. * Container with a set of assets that can be added or removed from a scene.
  40306. */
  40307. export class AssetContainer extends AbstractScene {
  40308. private _wasAddedToScene;
  40309. /**
  40310. * The scene the AssetContainer belongs to.
  40311. */
  40312. scene: Scene;
  40313. /**
  40314. * Instantiates an AssetContainer.
  40315. * @param scene The scene the AssetContainer belongs to.
  40316. */
  40317. constructor(scene: Scene);
  40318. /**
  40319. * Instantiate or clone all meshes and add the new ones to the scene.
  40320. * Skeletons and animation groups will all be cloned
  40321. * @param nameFunction defines an optional function used to get new names for clones
  40322. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40323. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40324. */
  40325. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40326. /**
  40327. * Adds all the assets from the container to the scene.
  40328. */
  40329. addAllToScene(): void;
  40330. /**
  40331. * Removes all the assets in the container from the scene
  40332. */
  40333. removeAllFromScene(): void;
  40334. /**
  40335. * Disposes all the assets in the container
  40336. */
  40337. dispose(): void;
  40338. private _moveAssets;
  40339. /**
  40340. * Removes all the assets contained in the scene and adds them to the container.
  40341. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40342. */
  40343. moveAllFromScene(keepAssets?: KeepAssets): void;
  40344. /**
  40345. * 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.
  40346. * @returns the root mesh
  40347. */
  40348. createRootMesh(): Mesh;
  40349. /**
  40350. * Merge animations (direct and animation groups) from this asset container into a scene
  40351. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40352. * @param animatables set of animatables to retarget to a node from the scene
  40353. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40354. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40355. */
  40356. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40357. }
  40358. }
  40359. declare module BABYLON {
  40360. /**
  40361. * Defines how the parser contract is defined.
  40362. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40363. */
  40364. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40365. /**
  40366. * Defines how the individual parser contract is defined.
  40367. * These parser can parse an individual asset
  40368. */
  40369. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40370. /**
  40371. * Base class of the scene acting as a container for the different elements composing a scene.
  40372. * This class is dynamically extended by the different components of the scene increasing
  40373. * flexibility and reducing coupling
  40374. */
  40375. export abstract class AbstractScene {
  40376. /**
  40377. * Stores the list of available parsers in the application.
  40378. */
  40379. private static _BabylonFileParsers;
  40380. /**
  40381. * Stores the list of available individual parsers in the application.
  40382. */
  40383. private static _IndividualBabylonFileParsers;
  40384. /**
  40385. * Adds a parser in the list of available ones
  40386. * @param name Defines the name of the parser
  40387. * @param parser Defines the parser to add
  40388. */
  40389. static AddParser(name: string, parser: BabylonFileParser): void;
  40390. /**
  40391. * Gets a general parser from the list of avaialble ones
  40392. * @param name Defines the name of the parser
  40393. * @returns the requested parser or null
  40394. */
  40395. static GetParser(name: string): Nullable<BabylonFileParser>;
  40396. /**
  40397. * Adds n individual parser in the list of available ones
  40398. * @param name Defines the name of the parser
  40399. * @param parser Defines the parser to add
  40400. */
  40401. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40402. /**
  40403. * Gets an individual parser from the list of avaialble ones
  40404. * @param name Defines the name of the parser
  40405. * @returns the requested parser or null
  40406. */
  40407. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40408. /**
  40409. * Parser json data and populate both a scene and its associated container object
  40410. * @param jsonData Defines the data to parse
  40411. * @param scene Defines the scene to parse the data for
  40412. * @param container Defines the container attached to the parsing sequence
  40413. * @param rootUrl Defines the root url of the data
  40414. */
  40415. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40416. /**
  40417. * Gets the list of root nodes (ie. nodes with no parent)
  40418. */
  40419. rootNodes: Node[];
  40420. /** All of the cameras added to this scene
  40421. * @see http://doc.babylonjs.com/babylon101/cameras
  40422. */
  40423. cameras: Camera[];
  40424. /**
  40425. * All of the lights added to this scene
  40426. * @see http://doc.babylonjs.com/babylon101/lights
  40427. */
  40428. lights: Light[];
  40429. /**
  40430. * All of the (abstract) meshes added to this scene
  40431. */
  40432. meshes: AbstractMesh[];
  40433. /**
  40434. * The list of skeletons added to the scene
  40435. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40436. */
  40437. skeletons: Skeleton[];
  40438. /**
  40439. * All of the particle systems added to this scene
  40440. * @see http://doc.babylonjs.com/babylon101/particles
  40441. */
  40442. particleSystems: IParticleSystem[];
  40443. /**
  40444. * Gets a list of Animations associated with the scene
  40445. */
  40446. animations: Animation[];
  40447. /**
  40448. * All of the animation groups added to this scene
  40449. * @see http://doc.babylonjs.com/how_to/group
  40450. */
  40451. animationGroups: AnimationGroup[];
  40452. /**
  40453. * All of the multi-materials added to this scene
  40454. * @see http://doc.babylonjs.com/how_to/multi_materials
  40455. */
  40456. multiMaterials: MultiMaterial[];
  40457. /**
  40458. * All of the materials added to this scene
  40459. * In the context of a Scene, it is not supposed to be modified manually.
  40460. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40461. * Note also that the order of the Material within the array is not significant and might change.
  40462. * @see http://doc.babylonjs.com/babylon101/materials
  40463. */
  40464. materials: Material[];
  40465. /**
  40466. * The list of morph target managers added to the scene
  40467. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40468. */
  40469. morphTargetManagers: MorphTargetManager[];
  40470. /**
  40471. * The list of geometries used in the scene.
  40472. */
  40473. geometries: Geometry[];
  40474. /**
  40475. * All of the tranform nodes added to this scene
  40476. * In the context of a Scene, it is not supposed to be modified manually.
  40477. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40478. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40479. * @see http://doc.babylonjs.com/how_to/transformnode
  40480. */
  40481. transformNodes: TransformNode[];
  40482. /**
  40483. * ActionManagers available on the scene.
  40484. */
  40485. actionManagers: AbstractActionManager[];
  40486. /**
  40487. * Textures to keep.
  40488. */
  40489. textures: BaseTexture[];
  40490. /**
  40491. * Environment texture for the scene
  40492. */
  40493. environmentTexture: Nullable<BaseTexture>;
  40494. /**
  40495. * @returns all meshes, lights, cameras, transformNodes and bones
  40496. */
  40497. getNodes(): Array<Node>;
  40498. }
  40499. }
  40500. declare module BABYLON {
  40501. /**
  40502. * Interface used to define options for Sound class
  40503. */
  40504. export interface ISoundOptions {
  40505. /**
  40506. * Does the sound autoplay once loaded.
  40507. */
  40508. autoplay?: boolean;
  40509. /**
  40510. * Does the sound loop after it finishes playing once.
  40511. */
  40512. loop?: boolean;
  40513. /**
  40514. * Sound's volume
  40515. */
  40516. volume?: number;
  40517. /**
  40518. * Is it a spatial sound?
  40519. */
  40520. spatialSound?: boolean;
  40521. /**
  40522. * Maximum distance to hear that sound
  40523. */
  40524. maxDistance?: number;
  40525. /**
  40526. * Uses user defined attenuation function
  40527. */
  40528. useCustomAttenuation?: boolean;
  40529. /**
  40530. * Define the roll off factor of spatial sounds.
  40531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40532. */
  40533. rolloffFactor?: number;
  40534. /**
  40535. * Define the reference distance the sound should be heard perfectly.
  40536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40537. */
  40538. refDistance?: number;
  40539. /**
  40540. * Define the distance attenuation model the sound will follow.
  40541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40542. */
  40543. distanceModel?: string;
  40544. /**
  40545. * Defines the playback speed (1 by default)
  40546. */
  40547. playbackRate?: number;
  40548. /**
  40549. * Defines if the sound is from a streaming source
  40550. */
  40551. streaming?: boolean;
  40552. /**
  40553. * Defines an optional length (in seconds) inside the sound file
  40554. */
  40555. length?: number;
  40556. /**
  40557. * Defines an optional offset (in seconds) inside the sound file
  40558. */
  40559. offset?: number;
  40560. /**
  40561. * If true, URLs will not be required to state the audio file codec to use.
  40562. */
  40563. skipCodecCheck?: boolean;
  40564. }
  40565. /**
  40566. * Defines a sound that can be played in the application.
  40567. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40569. */
  40570. export class Sound {
  40571. /**
  40572. * The name of the sound in the scene.
  40573. */
  40574. name: string;
  40575. /**
  40576. * Does the sound autoplay once loaded.
  40577. */
  40578. autoplay: boolean;
  40579. /**
  40580. * Does the sound loop after it finishes playing once.
  40581. */
  40582. loop: boolean;
  40583. /**
  40584. * Does the sound use a custom attenuation curve to simulate the falloff
  40585. * happening when the source gets further away from the camera.
  40586. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40587. */
  40588. useCustomAttenuation: boolean;
  40589. /**
  40590. * The sound track id this sound belongs to.
  40591. */
  40592. soundTrackId: number;
  40593. /**
  40594. * Is this sound currently played.
  40595. */
  40596. isPlaying: boolean;
  40597. /**
  40598. * Is this sound currently paused.
  40599. */
  40600. isPaused: boolean;
  40601. /**
  40602. * Does this sound enables spatial sound.
  40603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40604. */
  40605. spatialSound: boolean;
  40606. /**
  40607. * Define the reference distance the sound should be heard perfectly.
  40608. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40609. */
  40610. refDistance: number;
  40611. /**
  40612. * Define the roll off factor of spatial sounds.
  40613. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40614. */
  40615. rolloffFactor: number;
  40616. /**
  40617. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40619. */
  40620. maxDistance: number;
  40621. /**
  40622. * Define the distance attenuation model the sound will follow.
  40623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40624. */
  40625. distanceModel: string;
  40626. /**
  40627. * @hidden
  40628. * Back Compat
  40629. **/
  40630. onended: () => any;
  40631. /**
  40632. * Gets or sets an object used to store user defined information for the sound.
  40633. */
  40634. metadata: any;
  40635. /**
  40636. * Observable event when the current playing sound finishes.
  40637. */
  40638. onEndedObservable: Observable<Sound>;
  40639. private _panningModel;
  40640. private _playbackRate;
  40641. private _streaming;
  40642. private _startTime;
  40643. private _startOffset;
  40644. private _position;
  40645. /** @hidden */
  40646. _positionInEmitterSpace: boolean;
  40647. private _localDirection;
  40648. private _volume;
  40649. private _isReadyToPlay;
  40650. private _isDirectional;
  40651. private _readyToPlayCallback;
  40652. private _audioBuffer;
  40653. private _soundSource;
  40654. private _streamingSource;
  40655. private _soundPanner;
  40656. private _soundGain;
  40657. private _inputAudioNode;
  40658. private _outputAudioNode;
  40659. private _coneInnerAngle;
  40660. private _coneOuterAngle;
  40661. private _coneOuterGain;
  40662. private _scene;
  40663. private _connectedTransformNode;
  40664. private _customAttenuationFunction;
  40665. private _registerFunc;
  40666. private _isOutputConnected;
  40667. private _htmlAudioElement;
  40668. private _urlType;
  40669. private _length?;
  40670. private _offset?;
  40671. /** @hidden */
  40672. static _SceneComponentInitialization: (scene: Scene) => void;
  40673. /**
  40674. * Create a sound and attach it to a scene
  40675. * @param name Name of your sound
  40676. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40677. * @param scene defines the scene the sound belongs to
  40678. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40679. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40680. */
  40681. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40682. /**
  40683. * Release the sound and its associated resources
  40684. */
  40685. dispose(): void;
  40686. /**
  40687. * Gets if the sounds is ready to be played or not.
  40688. * @returns true if ready, otherwise false
  40689. */
  40690. isReady(): boolean;
  40691. private _soundLoaded;
  40692. /**
  40693. * Sets the data of the sound from an audiobuffer
  40694. * @param audioBuffer The audioBuffer containing the data
  40695. */
  40696. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40697. /**
  40698. * Updates the current sounds options such as maxdistance, loop...
  40699. * @param options A JSON object containing values named as the object properties
  40700. */
  40701. updateOptions(options: ISoundOptions): void;
  40702. private _createSpatialParameters;
  40703. private _updateSpatialParameters;
  40704. /**
  40705. * Switch the panning model to HRTF:
  40706. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40707. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40708. */
  40709. switchPanningModelToHRTF(): void;
  40710. /**
  40711. * Switch the panning model to Equal Power:
  40712. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40714. */
  40715. switchPanningModelToEqualPower(): void;
  40716. private _switchPanningModel;
  40717. /**
  40718. * Connect this sound to a sound track audio node like gain...
  40719. * @param soundTrackAudioNode the sound track audio node to connect to
  40720. */
  40721. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40722. /**
  40723. * Transform this sound into a directional source
  40724. * @param coneInnerAngle Size of the inner cone in degree
  40725. * @param coneOuterAngle Size of the outer cone in degree
  40726. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40727. */
  40728. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40729. /**
  40730. * Gets or sets the inner angle for the directional cone.
  40731. */
  40732. get directionalConeInnerAngle(): number;
  40733. /**
  40734. * Gets or sets the inner angle for the directional cone.
  40735. */
  40736. set directionalConeInnerAngle(value: number);
  40737. /**
  40738. * Gets or sets the outer angle for the directional cone.
  40739. */
  40740. get directionalConeOuterAngle(): number;
  40741. /**
  40742. * Gets or sets the outer angle for the directional cone.
  40743. */
  40744. set directionalConeOuterAngle(value: number);
  40745. /**
  40746. * Sets the position of the emitter if spatial sound is enabled
  40747. * @param newPosition Defines the new posisiton
  40748. */
  40749. setPosition(newPosition: Vector3): void;
  40750. /**
  40751. * Sets the local direction of the emitter if spatial sound is enabled
  40752. * @param newLocalDirection Defines the new local direction
  40753. */
  40754. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40755. private _updateDirection;
  40756. /** @hidden */
  40757. updateDistanceFromListener(): void;
  40758. /**
  40759. * Sets a new custom attenuation function for the sound.
  40760. * @param callback Defines the function used for the attenuation
  40761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40762. */
  40763. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40764. /**
  40765. * Play the sound
  40766. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40767. * @param offset (optional) Start the sound at a specific time in seconds
  40768. * @param length (optional) Sound duration (in seconds)
  40769. */
  40770. play(time?: number, offset?: number, length?: number): void;
  40771. private _onended;
  40772. /**
  40773. * Stop the sound
  40774. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40775. */
  40776. stop(time?: number): void;
  40777. /**
  40778. * Put the sound in pause
  40779. */
  40780. pause(): void;
  40781. /**
  40782. * Sets a dedicated volume for this sounds
  40783. * @param newVolume Define the new volume of the sound
  40784. * @param time Define time for gradual change to new volume
  40785. */
  40786. setVolume(newVolume: number, time?: number): void;
  40787. /**
  40788. * Set the sound play back rate
  40789. * @param newPlaybackRate Define the playback rate the sound should be played at
  40790. */
  40791. setPlaybackRate(newPlaybackRate: number): void;
  40792. /**
  40793. * Gets the volume of the sound.
  40794. * @returns the volume of the sound
  40795. */
  40796. getVolume(): number;
  40797. /**
  40798. * Attach the sound to a dedicated mesh
  40799. * @param transformNode The transform node to connect the sound with
  40800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40801. */
  40802. attachToMesh(transformNode: TransformNode): void;
  40803. /**
  40804. * Detach the sound from the previously attached mesh
  40805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40806. */
  40807. detachFromMesh(): void;
  40808. private _onRegisterAfterWorldMatrixUpdate;
  40809. /**
  40810. * Clone the current sound in the scene.
  40811. * @returns the new sound clone
  40812. */
  40813. clone(): Nullable<Sound>;
  40814. /**
  40815. * Gets the current underlying audio buffer containing the data
  40816. * @returns the audio buffer
  40817. */
  40818. getAudioBuffer(): Nullable<AudioBuffer>;
  40819. /**
  40820. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40821. * @returns the source node
  40822. */
  40823. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40824. /**
  40825. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40826. * @returns the gain node
  40827. */
  40828. getSoundGain(): Nullable<GainNode>;
  40829. /**
  40830. * Serializes the Sound in a JSON representation
  40831. * @returns the JSON representation of the sound
  40832. */
  40833. serialize(): any;
  40834. /**
  40835. * Parse a JSON representation of a sound to innstantiate in a given scene
  40836. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40837. * @param scene Define the scene the new parsed sound should be created in
  40838. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40839. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40840. * @returns the newly parsed sound
  40841. */
  40842. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40843. }
  40844. }
  40845. declare module BABYLON {
  40846. /**
  40847. * This defines an action helpful to play a defined sound on a triggered action.
  40848. */
  40849. export class PlaySoundAction extends Action {
  40850. private _sound;
  40851. /**
  40852. * Instantiate the action
  40853. * @param triggerOptions defines the trigger options
  40854. * @param sound defines the sound to play
  40855. * @param condition defines the trigger related conditions
  40856. */
  40857. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40858. /** @hidden */
  40859. _prepare(): void;
  40860. /**
  40861. * Execute the action and play the sound.
  40862. */
  40863. execute(): void;
  40864. /**
  40865. * Serializes the actions and its related information.
  40866. * @param parent defines the object to serialize in
  40867. * @returns the serialized object
  40868. */
  40869. serialize(parent: any): any;
  40870. }
  40871. /**
  40872. * This defines an action helpful to stop a defined sound on a triggered action.
  40873. */
  40874. export class StopSoundAction extends Action {
  40875. private _sound;
  40876. /**
  40877. * Instantiate the action
  40878. * @param triggerOptions defines the trigger options
  40879. * @param sound defines the sound to stop
  40880. * @param condition defines the trigger related conditions
  40881. */
  40882. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40883. /** @hidden */
  40884. _prepare(): void;
  40885. /**
  40886. * Execute the action and stop the sound.
  40887. */
  40888. execute(): void;
  40889. /**
  40890. * Serializes the actions and its related information.
  40891. * @param parent defines the object to serialize in
  40892. * @returns the serialized object
  40893. */
  40894. serialize(parent: any): any;
  40895. }
  40896. }
  40897. declare module BABYLON {
  40898. /**
  40899. * This defines an action responsible to change the value of a property
  40900. * by interpolating between its current value and the newly set one once triggered.
  40901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40902. */
  40903. export class InterpolateValueAction extends Action {
  40904. /**
  40905. * Defines the path of the property where the value should be interpolated
  40906. */
  40907. propertyPath: string;
  40908. /**
  40909. * Defines the target value at the end of the interpolation.
  40910. */
  40911. value: any;
  40912. /**
  40913. * Defines the time it will take for the property to interpolate to the value.
  40914. */
  40915. duration: number;
  40916. /**
  40917. * Defines if the other scene animations should be stopped when the action has been triggered
  40918. */
  40919. stopOtherAnimations?: boolean;
  40920. /**
  40921. * Defines a callback raised once the interpolation animation has been done.
  40922. */
  40923. onInterpolationDone?: () => void;
  40924. /**
  40925. * Observable triggered once the interpolation animation has been done.
  40926. */
  40927. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40928. private _target;
  40929. private _effectiveTarget;
  40930. private _property;
  40931. /**
  40932. * Instantiate the action
  40933. * @param triggerOptions defines the trigger options
  40934. * @param target defines the object containing the value to interpolate
  40935. * @param propertyPath defines the path to the property in the target object
  40936. * @param value defines the target value at the end of the interpolation
  40937. * @param duration deines the time it will take for the property to interpolate to the value.
  40938. * @param condition defines the trigger related conditions
  40939. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40940. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40941. */
  40942. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40943. /** @hidden */
  40944. _prepare(): void;
  40945. /**
  40946. * Execute the action starts the value interpolation.
  40947. */
  40948. execute(): void;
  40949. /**
  40950. * Serializes the actions and its related information.
  40951. * @param parent defines the object to serialize in
  40952. * @returns the serialized object
  40953. */
  40954. serialize(parent: any): any;
  40955. }
  40956. }
  40957. declare module BABYLON {
  40958. /**
  40959. * Options allowed during the creation of a sound track.
  40960. */
  40961. export interface ISoundTrackOptions {
  40962. /**
  40963. * The volume the sound track should take during creation
  40964. */
  40965. volume?: number;
  40966. /**
  40967. * Define if the sound track is the main sound track of the scene
  40968. */
  40969. mainTrack?: boolean;
  40970. }
  40971. /**
  40972. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40973. * It will be also used in a future release to apply effects on a specific track.
  40974. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40975. */
  40976. export class SoundTrack {
  40977. /**
  40978. * The unique identifier of the sound track in the scene.
  40979. */
  40980. id: number;
  40981. /**
  40982. * The list of sounds included in the sound track.
  40983. */
  40984. soundCollection: Array<Sound>;
  40985. private _outputAudioNode;
  40986. private _scene;
  40987. private _connectedAnalyser;
  40988. private _options;
  40989. private _isInitialized;
  40990. /**
  40991. * Creates a new sound track.
  40992. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40993. * @param scene Define the scene the sound track belongs to
  40994. * @param options
  40995. */
  40996. constructor(scene: Scene, options?: ISoundTrackOptions);
  40997. private _initializeSoundTrackAudioGraph;
  40998. /**
  40999. * Release the sound track and its associated resources
  41000. */
  41001. dispose(): void;
  41002. /**
  41003. * Adds a sound to this sound track
  41004. * @param sound define the cound to add
  41005. * @ignoreNaming
  41006. */
  41007. AddSound(sound: Sound): void;
  41008. /**
  41009. * Removes a sound to this sound track
  41010. * @param sound define the cound to remove
  41011. * @ignoreNaming
  41012. */
  41013. RemoveSound(sound: Sound): void;
  41014. /**
  41015. * Set a global volume for the full sound track.
  41016. * @param newVolume Define the new volume of the sound track
  41017. */
  41018. setVolume(newVolume: number): void;
  41019. /**
  41020. * Switch the panning model to HRTF:
  41021. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41023. */
  41024. switchPanningModelToHRTF(): void;
  41025. /**
  41026. * Switch the panning model to Equal Power:
  41027. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41029. */
  41030. switchPanningModelToEqualPower(): void;
  41031. /**
  41032. * Connect the sound track to an audio analyser allowing some amazing
  41033. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41035. * @param analyser The analyser to connect to the engine
  41036. */
  41037. connectToAnalyser(analyser: Analyser): void;
  41038. }
  41039. }
  41040. declare module BABYLON {
  41041. interface AbstractScene {
  41042. /**
  41043. * The list of sounds used in the scene.
  41044. */
  41045. sounds: Nullable<Array<Sound>>;
  41046. }
  41047. interface Scene {
  41048. /**
  41049. * @hidden
  41050. * Backing field
  41051. */
  41052. _mainSoundTrack: SoundTrack;
  41053. /**
  41054. * The main sound track played by the scene.
  41055. * It cotains your primary collection of sounds.
  41056. */
  41057. mainSoundTrack: SoundTrack;
  41058. /**
  41059. * The list of sound tracks added to the scene
  41060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41061. */
  41062. soundTracks: Nullable<Array<SoundTrack>>;
  41063. /**
  41064. * Gets a sound using a given name
  41065. * @param name defines the name to search for
  41066. * @return the found sound or null if not found at all.
  41067. */
  41068. getSoundByName(name: string): Nullable<Sound>;
  41069. /**
  41070. * Gets or sets if audio support is enabled
  41071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41072. */
  41073. audioEnabled: boolean;
  41074. /**
  41075. * Gets or sets if audio will be output to headphones
  41076. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41077. */
  41078. headphone: boolean;
  41079. /**
  41080. * Gets or sets custom audio listener position provider
  41081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41082. */
  41083. audioListenerPositionProvider: Nullable<() => Vector3>;
  41084. /**
  41085. * Gets or sets a refresh rate when using 3D audio positioning
  41086. */
  41087. audioPositioningRefreshRate: number;
  41088. }
  41089. /**
  41090. * Defines the sound scene component responsible to manage any sounds
  41091. * in a given scene.
  41092. */
  41093. export class AudioSceneComponent implements ISceneSerializableComponent {
  41094. /**
  41095. * The component name helpfull to identify the component in the list of scene components.
  41096. */
  41097. readonly name: string;
  41098. /**
  41099. * The scene the component belongs to.
  41100. */
  41101. scene: Scene;
  41102. private _audioEnabled;
  41103. /**
  41104. * Gets whether audio is enabled or not.
  41105. * Please use related enable/disable method to switch state.
  41106. */
  41107. get audioEnabled(): boolean;
  41108. private _headphone;
  41109. /**
  41110. * Gets whether audio is outputing to headphone or not.
  41111. * Please use the according Switch methods to change output.
  41112. */
  41113. get headphone(): boolean;
  41114. /**
  41115. * Gets or sets a refresh rate when using 3D audio positioning
  41116. */
  41117. audioPositioningRefreshRate: number;
  41118. private _audioListenerPositionProvider;
  41119. /**
  41120. * Gets the current audio listener position provider
  41121. */
  41122. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41123. /**
  41124. * Sets a custom listener position for all sounds in the scene
  41125. * By default, this is the position of the first active camera
  41126. */
  41127. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41128. /**
  41129. * Creates a new instance of the component for the given scene
  41130. * @param scene Defines the scene to register the component in
  41131. */
  41132. constructor(scene: Scene);
  41133. /**
  41134. * Registers the component in a given scene
  41135. */
  41136. register(): void;
  41137. /**
  41138. * Rebuilds the elements related to this component in case of
  41139. * context lost for instance.
  41140. */
  41141. rebuild(): void;
  41142. /**
  41143. * Serializes the component data to the specified json object
  41144. * @param serializationObject The object to serialize to
  41145. */
  41146. serialize(serializationObject: any): void;
  41147. /**
  41148. * Adds all the elements from the container to the scene
  41149. * @param container the container holding the elements
  41150. */
  41151. addFromContainer(container: AbstractScene): void;
  41152. /**
  41153. * Removes all the elements in the container from the scene
  41154. * @param container contains the elements to remove
  41155. * @param dispose if the removed element should be disposed (default: false)
  41156. */
  41157. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41158. /**
  41159. * Disposes the component and the associated ressources.
  41160. */
  41161. dispose(): void;
  41162. /**
  41163. * Disables audio in the associated scene.
  41164. */
  41165. disableAudio(): void;
  41166. /**
  41167. * Enables audio in the associated scene.
  41168. */
  41169. enableAudio(): void;
  41170. /**
  41171. * Switch audio to headphone output.
  41172. */
  41173. switchAudioModeForHeadphones(): void;
  41174. /**
  41175. * Switch audio to normal speakers.
  41176. */
  41177. switchAudioModeForNormalSpeakers(): void;
  41178. private _cachedCameraDirection;
  41179. private _cachedCameraPosition;
  41180. private _lastCheck;
  41181. private _afterRender;
  41182. }
  41183. }
  41184. declare module BABYLON {
  41185. /**
  41186. * Wraps one or more Sound objects and selects one with random weight for playback.
  41187. */
  41188. export class WeightedSound {
  41189. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41190. loop: boolean;
  41191. private _coneInnerAngle;
  41192. private _coneOuterAngle;
  41193. private _volume;
  41194. /** A Sound is currently playing. */
  41195. isPlaying: boolean;
  41196. /** A Sound is currently paused. */
  41197. isPaused: boolean;
  41198. private _sounds;
  41199. private _weights;
  41200. private _currentIndex?;
  41201. /**
  41202. * Creates a new WeightedSound from the list of sounds given.
  41203. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41204. * @param sounds Array of Sounds that will be selected from.
  41205. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41206. */
  41207. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41208. /**
  41209. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41210. */
  41211. get directionalConeInnerAngle(): number;
  41212. /**
  41213. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41214. */
  41215. set directionalConeInnerAngle(value: number);
  41216. /**
  41217. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41218. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41219. */
  41220. get directionalConeOuterAngle(): number;
  41221. /**
  41222. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41223. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41224. */
  41225. set directionalConeOuterAngle(value: number);
  41226. /**
  41227. * Playback volume.
  41228. */
  41229. get volume(): number;
  41230. /**
  41231. * Playback volume.
  41232. */
  41233. set volume(value: number);
  41234. private _onended;
  41235. /**
  41236. * Suspend playback
  41237. */
  41238. pause(): void;
  41239. /**
  41240. * Stop playback
  41241. */
  41242. stop(): void;
  41243. /**
  41244. * Start playback.
  41245. * @param startOffset Position the clip head at a specific time in seconds.
  41246. */
  41247. play(startOffset?: number): void;
  41248. }
  41249. }
  41250. declare module BABYLON {
  41251. /**
  41252. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41253. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41254. */
  41255. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41256. /**
  41257. * Gets the name of the behavior.
  41258. */
  41259. get name(): string;
  41260. /**
  41261. * The easing function used by animations
  41262. */
  41263. static EasingFunction: BackEase;
  41264. /**
  41265. * The easing mode used by animations
  41266. */
  41267. static EasingMode: number;
  41268. /**
  41269. * The duration of the animation, in milliseconds
  41270. */
  41271. transitionDuration: number;
  41272. /**
  41273. * Length of the distance animated by the transition when lower radius is reached
  41274. */
  41275. lowerRadiusTransitionRange: number;
  41276. /**
  41277. * Length of the distance animated by the transition when upper radius is reached
  41278. */
  41279. upperRadiusTransitionRange: number;
  41280. private _autoTransitionRange;
  41281. /**
  41282. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41283. */
  41284. get autoTransitionRange(): boolean;
  41285. /**
  41286. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41287. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41288. */
  41289. set autoTransitionRange(value: boolean);
  41290. private _attachedCamera;
  41291. private _onAfterCheckInputsObserver;
  41292. private _onMeshTargetChangedObserver;
  41293. /**
  41294. * Initializes the behavior.
  41295. */
  41296. init(): void;
  41297. /**
  41298. * Attaches the behavior to its arc rotate camera.
  41299. * @param camera Defines the camera to attach the behavior to
  41300. */
  41301. attach(camera: ArcRotateCamera): void;
  41302. /**
  41303. * Detaches the behavior from its current arc rotate camera.
  41304. */
  41305. detach(): void;
  41306. private _radiusIsAnimating;
  41307. private _radiusBounceTransition;
  41308. private _animatables;
  41309. private _cachedWheelPrecision;
  41310. /**
  41311. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41312. * @param radiusLimit The limit to check against.
  41313. * @return Bool to indicate if at limit.
  41314. */
  41315. private _isRadiusAtLimit;
  41316. /**
  41317. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41318. * @param radiusDelta The delta by which to animate to. Can be negative.
  41319. */
  41320. private _applyBoundRadiusAnimation;
  41321. /**
  41322. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41323. */
  41324. protected _clearAnimationLocks(): void;
  41325. /**
  41326. * Stops and removes all animations that have been applied to the camera
  41327. */
  41328. stopAllAnimations(): void;
  41329. }
  41330. }
  41331. declare module BABYLON {
  41332. /**
  41333. * 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.
  41334. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41335. */
  41336. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41337. /**
  41338. * Gets the name of the behavior.
  41339. */
  41340. get name(): string;
  41341. private _mode;
  41342. private _radiusScale;
  41343. private _positionScale;
  41344. private _defaultElevation;
  41345. private _elevationReturnTime;
  41346. private _elevationReturnWaitTime;
  41347. private _zoomStopsAnimation;
  41348. private _framingTime;
  41349. /**
  41350. * The easing function used by animations
  41351. */
  41352. static EasingFunction: ExponentialEase;
  41353. /**
  41354. * The easing mode used by animations
  41355. */
  41356. static EasingMode: number;
  41357. /**
  41358. * Sets the current mode used by the behavior
  41359. */
  41360. set mode(mode: number);
  41361. /**
  41362. * Gets current mode used by the behavior.
  41363. */
  41364. get mode(): number;
  41365. /**
  41366. * Sets the scale applied to the radius (1 by default)
  41367. */
  41368. set radiusScale(radius: number);
  41369. /**
  41370. * Gets the scale applied to the radius
  41371. */
  41372. get radiusScale(): number;
  41373. /**
  41374. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41375. */
  41376. set positionScale(scale: number);
  41377. /**
  41378. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41379. */
  41380. get positionScale(): number;
  41381. /**
  41382. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41383. * behaviour is triggered, in radians.
  41384. */
  41385. set defaultElevation(elevation: number);
  41386. /**
  41387. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41388. * behaviour is triggered, in radians.
  41389. */
  41390. get defaultElevation(): number;
  41391. /**
  41392. * Sets the time (in milliseconds) taken to return to the default beta position.
  41393. * Negative value indicates camera should not return to default.
  41394. */
  41395. set elevationReturnTime(speed: number);
  41396. /**
  41397. * Gets the time (in milliseconds) taken to return to the default beta position.
  41398. * Negative value indicates camera should not return to default.
  41399. */
  41400. get elevationReturnTime(): number;
  41401. /**
  41402. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41403. */
  41404. set elevationReturnWaitTime(time: number);
  41405. /**
  41406. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41407. */
  41408. get elevationReturnWaitTime(): number;
  41409. /**
  41410. * Sets the flag that indicates if user zooming should stop animation.
  41411. */
  41412. set zoomStopsAnimation(flag: boolean);
  41413. /**
  41414. * Gets the flag that indicates if user zooming should stop animation.
  41415. */
  41416. get zoomStopsAnimation(): boolean;
  41417. /**
  41418. * Sets the transition time when framing the mesh, in milliseconds
  41419. */
  41420. set framingTime(time: number);
  41421. /**
  41422. * Gets the transition time when framing the mesh, in milliseconds
  41423. */
  41424. get framingTime(): number;
  41425. /**
  41426. * Define if the behavior should automatically change the configured
  41427. * camera limits and sensibilities.
  41428. */
  41429. autoCorrectCameraLimitsAndSensibility: boolean;
  41430. private _onPrePointerObservableObserver;
  41431. private _onAfterCheckInputsObserver;
  41432. private _onMeshTargetChangedObserver;
  41433. private _attachedCamera;
  41434. private _isPointerDown;
  41435. private _lastInteractionTime;
  41436. /**
  41437. * Initializes the behavior.
  41438. */
  41439. init(): void;
  41440. /**
  41441. * Attaches the behavior to its arc rotate camera.
  41442. * @param camera Defines the camera to attach the behavior to
  41443. */
  41444. attach(camera: ArcRotateCamera): void;
  41445. /**
  41446. * Detaches the behavior from its current arc rotate camera.
  41447. */
  41448. detach(): void;
  41449. private _animatables;
  41450. private _betaIsAnimating;
  41451. private _betaTransition;
  41452. private _radiusTransition;
  41453. private _vectorTransition;
  41454. /**
  41455. * Targets the given mesh and updates zoom level accordingly.
  41456. * @param mesh The mesh to target.
  41457. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41458. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41459. */
  41460. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41461. /**
  41462. * Targets the given mesh with its children and updates zoom level accordingly.
  41463. * @param mesh The mesh to target.
  41464. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41465. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41466. */
  41467. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41468. /**
  41469. * Targets the given meshes with their children and updates zoom level accordingly.
  41470. * @param meshes The mesh to target.
  41471. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41472. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41473. */
  41474. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41475. /**
  41476. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41477. * @param minimumWorld Determines the smaller position of the bounding box extend
  41478. * @param maximumWorld Determines the bigger position of the bounding box extend
  41479. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41480. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41481. */
  41482. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41483. /**
  41484. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41485. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41486. * frustum width.
  41487. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41488. * to fully enclose the mesh in the viewing frustum.
  41489. */
  41490. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41491. /**
  41492. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41493. * is automatically returned to its default position (expected to be above ground plane).
  41494. */
  41495. private _maintainCameraAboveGround;
  41496. /**
  41497. * Returns the frustum slope based on the canvas ratio and camera FOV
  41498. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41499. */
  41500. private _getFrustumSlope;
  41501. /**
  41502. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41503. */
  41504. private _clearAnimationLocks;
  41505. /**
  41506. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41507. */
  41508. private _applyUserInteraction;
  41509. /**
  41510. * Stops and removes all animations that have been applied to the camera
  41511. */
  41512. stopAllAnimations(): void;
  41513. /**
  41514. * Gets a value indicating if the user is moving the camera
  41515. */
  41516. get isUserIsMoving(): boolean;
  41517. /**
  41518. * The camera can move all the way towards the mesh.
  41519. */
  41520. static IgnoreBoundsSizeMode: number;
  41521. /**
  41522. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41523. */
  41524. static FitFrustumSidesMode: number;
  41525. }
  41526. }
  41527. declare module BABYLON {
  41528. /**
  41529. * Base class for Camera Pointer Inputs.
  41530. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41531. * for example usage.
  41532. */
  41533. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41534. /**
  41535. * Defines the camera the input is attached to.
  41536. */
  41537. abstract camera: Camera;
  41538. /**
  41539. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41540. */
  41541. protected _altKey: boolean;
  41542. protected _ctrlKey: boolean;
  41543. protected _metaKey: boolean;
  41544. protected _shiftKey: boolean;
  41545. /**
  41546. * Which mouse buttons were pressed at time of last mouse event.
  41547. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41548. */
  41549. protected _buttonsPressed: number;
  41550. /**
  41551. * Defines the buttons associated with the input to handle camera move.
  41552. */
  41553. buttons: number[];
  41554. /**
  41555. * Attach the input controls to a specific dom element to get the input from.
  41556. * @param element Defines the element the controls should be listened from
  41557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41558. */
  41559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41560. /**
  41561. * Detach the current controls from the specified dom element.
  41562. * @param element Defines the element to stop listening the inputs from
  41563. */
  41564. detachControl(element: Nullable<HTMLElement>): void;
  41565. /**
  41566. * Gets the class name of the current input.
  41567. * @returns the class name
  41568. */
  41569. getClassName(): string;
  41570. /**
  41571. * Get the friendly name associated with the input class.
  41572. * @returns the input friendly name
  41573. */
  41574. getSimpleName(): string;
  41575. /**
  41576. * Called on pointer POINTERDOUBLETAP event.
  41577. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41578. */
  41579. protected onDoubleTap(type: string): void;
  41580. /**
  41581. * Called on pointer POINTERMOVE event if only a single touch is active.
  41582. * Override this method to provide functionality.
  41583. */
  41584. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41585. /**
  41586. * Called on pointer POINTERMOVE event if multiple touches are active.
  41587. * Override this method to provide functionality.
  41588. */
  41589. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41590. /**
  41591. * Called on JS contextmenu event.
  41592. * Override this method to provide functionality.
  41593. */
  41594. protected onContextMenu(evt: PointerEvent): void;
  41595. /**
  41596. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41597. * press.
  41598. * Override this method to provide functionality.
  41599. */
  41600. protected onButtonDown(evt: PointerEvent): void;
  41601. /**
  41602. * Called each time a new POINTERUP event occurs. Ie, for each button
  41603. * release.
  41604. * Override this method to provide functionality.
  41605. */
  41606. protected onButtonUp(evt: PointerEvent): void;
  41607. /**
  41608. * Called when window becomes inactive.
  41609. * Override this method to provide functionality.
  41610. */
  41611. protected onLostFocus(): void;
  41612. private _pointerInput;
  41613. private _observer;
  41614. private _onLostFocus;
  41615. private pointA;
  41616. private pointB;
  41617. }
  41618. }
  41619. declare module BABYLON {
  41620. /**
  41621. * Manage the pointers inputs to control an arc rotate camera.
  41622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41623. */
  41624. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41625. /**
  41626. * Defines the camera the input is attached to.
  41627. */
  41628. camera: ArcRotateCamera;
  41629. /**
  41630. * Gets the class name of the current input.
  41631. * @returns the class name
  41632. */
  41633. getClassName(): string;
  41634. /**
  41635. * Defines the buttons associated with the input to handle camera move.
  41636. */
  41637. buttons: number[];
  41638. /**
  41639. * Defines the pointer angular sensibility along the X axis or how fast is
  41640. * the camera rotating.
  41641. */
  41642. angularSensibilityX: number;
  41643. /**
  41644. * Defines the pointer angular sensibility along the Y axis or how fast is
  41645. * the camera rotating.
  41646. */
  41647. angularSensibilityY: number;
  41648. /**
  41649. * Defines the pointer pinch precision or how fast is the camera zooming.
  41650. */
  41651. pinchPrecision: number;
  41652. /**
  41653. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41654. * from 0.
  41655. * It defines the percentage of current camera.radius to use as delta when
  41656. * pinch zoom is used.
  41657. */
  41658. pinchDeltaPercentage: number;
  41659. /**
  41660. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41661. * that any object in the plane at the camera's target point will scale
  41662. * perfectly with finger motion.
  41663. * Overrides pinchDeltaPercentage and pinchPrecision.
  41664. */
  41665. useNaturalPinchZoom: boolean;
  41666. /**
  41667. * Defines the pointer panning sensibility or how fast is the camera moving.
  41668. */
  41669. panningSensibility: number;
  41670. /**
  41671. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41672. */
  41673. multiTouchPanning: boolean;
  41674. /**
  41675. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41676. * zoom (pinch) through multitouch.
  41677. */
  41678. multiTouchPanAndZoom: boolean;
  41679. /**
  41680. * Revers pinch action direction.
  41681. */
  41682. pinchInwards: boolean;
  41683. private _isPanClick;
  41684. private _twoFingerActivityCount;
  41685. private _isPinching;
  41686. /**
  41687. * Called on pointer POINTERMOVE event if only a single touch is active.
  41688. */
  41689. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41690. /**
  41691. * Called on pointer POINTERDOUBLETAP event.
  41692. */
  41693. protected onDoubleTap(type: string): void;
  41694. /**
  41695. * Called on pointer POINTERMOVE event if multiple touches are active.
  41696. */
  41697. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41698. /**
  41699. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41700. * press.
  41701. */
  41702. protected onButtonDown(evt: PointerEvent): void;
  41703. /**
  41704. * Called each time a new POINTERUP event occurs. Ie, for each button
  41705. * release.
  41706. */
  41707. protected onButtonUp(evt: PointerEvent): void;
  41708. /**
  41709. * Called when window becomes inactive.
  41710. */
  41711. protected onLostFocus(): void;
  41712. }
  41713. }
  41714. declare module BABYLON {
  41715. /**
  41716. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41717. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41718. */
  41719. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41720. /**
  41721. * Defines the camera the input is attached to.
  41722. */
  41723. camera: ArcRotateCamera;
  41724. /**
  41725. * Defines the list of key codes associated with the up action (increase alpha)
  41726. */
  41727. keysUp: number[];
  41728. /**
  41729. * Defines the list of key codes associated with the down action (decrease alpha)
  41730. */
  41731. keysDown: number[];
  41732. /**
  41733. * Defines the list of key codes associated with the left action (increase beta)
  41734. */
  41735. keysLeft: number[];
  41736. /**
  41737. * Defines the list of key codes associated with the right action (decrease beta)
  41738. */
  41739. keysRight: number[];
  41740. /**
  41741. * Defines the list of key codes associated with the reset action.
  41742. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41743. */
  41744. keysReset: number[];
  41745. /**
  41746. * Defines the panning sensibility of the inputs.
  41747. * (How fast is the camera panning)
  41748. */
  41749. panningSensibility: number;
  41750. /**
  41751. * Defines the zooming sensibility of the inputs.
  41752. * (How fast is the camera zooming)
  41753. */
  41754. zoomingSensibility: number;
  41755. /**
  41756. * Defines whether maintaining the alt key down switch the movement mode from
  41757. * orientation to zoom.
  41758. */
  41759. useAltToZoom: boolean;
  41760. /**
  41761. * Rotation speed of the camera
  41762. */
  41763. angularSpeed: number;
  41764. private _keys;
  41765. private _ctrlPressed;
  41766. private _altPressed;
  41767. private _onCanvasBlurObserver;
  41768. private _onKeyboardObserver;
  41769. private _engine;
  41770. private _scene;
  41771. /**
  41772. * Attach the input controls to a specific dom element to get the input from.
  41773. * @param element Defines the element the controls should be listened from
  41774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41775. */
  41776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41777. /**
  41778. * Detach the current controls from the specified dom element.
  41779. * @param element Defines the element to stop listening the inputs from
  41780. */
  41781. detachControl(element: Nullable<HTMLElement>): void;
  41782. /**
  41783. * Update the current camera state depending on the inputs that have been used this frame.
  41784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41785. */
  41786. checkInputs(): void;
  41787. /**
  41788. * Gets the class name of the current intput.
  41789. * @returns the class name
  41790. */
  41791. getClassName(): string;
  41792. /**
  41793. * Get the friendly name associated with the input class.
  41794. * @returns the input friendly name
  41795. */
  41796. getSimpleName(): string;
  41797. }
  41798. }
  41799. declare module BABYLON {
  41800. /**
  41801. * Manage the mouse wheel inputs to control an arc rotate camera.
  41802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41803. */
  41804. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41805. /**
  41806. * Defines the camera the input is attached to.
  41807. */
  41808. camera: ArcRotateCamera;
  41809. /**
  41810. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41811. */
  41812. wheelPrecision: number;
  41813. /**
  41814. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41815. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41816. */
  41817. wheelDeltaPercentage: number;
  41818. private _wheel;
  41819. private _observer;
  41820. private computeDeltaFromMouseWheelLegacyEvent;
  41821. /**
  41822. * Attach the input controls to a specific dom element to get the input from.
  41823. * @param element Defines the element the controls should be listened from
  41824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41825. */
  41826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41827. /**
  41828. * Detach the current controls from the specified dom element.
  41829. * @param element Defines the element to stop listening the inputs from
  41830. */
  41831. detachControl(element: Nullable<HTMLElement>): void;
  41832. /**
  41833. * Gets the class name of the current intput.
  41834. * @returns the class name
  41835. */
  41836. getClassName(): string;
  41837. /**
  41838. * Get the friendly name associated with the input class.
  41839. * @returns the input friendly name
  41840. */
  41841. getSimpleName(): string;
  41842. }
  41843. }
  41844. declare module BABYLON {
  41845. /**
  41846. * Default Inputs manager for the ArcRotateCamera.
  41847. * It groups all the default supported inputs for ease of use.
  41848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41849. */
  41850. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41851. /**
  41852. * Instantiates a new ArcRotateCameraInputsManager.
  41853. * @param camera Defines the camera the inputs belong to
  41854. */
  41855. constructor(camera: ArcRotateCamera);
  41856. /**
  41857. * Add mouse wheel input support to the input manager.
  41858. * @returns the current input manager
  41859. */
  41860. addMouseWheel(): ArcRotateCameraInputsManager;
  41861. /**
  41862. * Add pointers input support to the input manager.
  41863. * @returns the current input manager
  41864. */
  41865. addPointers(): ArcRotateCameraInputsManager;
  41866. /**
  41867. * Add keyboard input support to the input manager.
  41868. * @returns the current input manager
  41869. */
  41870. addKeyboard(): ArcRotateCameraInputsManager;
  41871. }
  41872. }
  41873. declare module BABYLON {
  41874. /**
  41875. * This represents an orbital type of camera.
  41876. *
  41877. * 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.
  41878. * 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.
  41879. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41880. */
  41881. export class ArcRotateCamera extends TargetCamera {
  41882. /**
  41883. * Defines the rotation angle of the camera along the longitudinal axis.
  41884. */
  41885. alpha: number;
  41886. /**
  41887. * Defines the rotation angle of the camera along the latitudinal axis.
  41888. */
  41889. beta: number;
  41890. /**
  41891. * Defines the radius of the camera from it s target point.
  41892. */
  41893. radius: number;
  41894. protected _target: Vector3;
  41895. protected _targetHost: Nullable<AbstractMesh>;
  41896. /**
  41897. * Defines the target point of the camera.
  41898. * The camera looks towards it form the radius distance.
  41899. */
  41900. get target(): Vector3;
  41901. set target(value: Vector3);
  41902. /**
  41903. * Define the current local position of the camera in the scene
  41904. */
  41905. get position(): Vector3;
  41906. set position(newPosition: Vector3);
  41907. protected _upVector: Vector3;
  41908. protected _upToYMatrix: Matrix;
  41909. protected _YToUpMatrix: Matrix;
  41910. /**
  41911. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41912. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41913. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41914. */
  41915. set upVector(vec: Vector3);
  41916. get upVector(): Vector3;
  41917. /**
  41918. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41919. */
  41920. setMatUp(): void;
  41921. /**
  41922. * Current inertia value on the longitudinal axis.
  41923. * The bigger this number the longer it will take for the camera to stop.
  41924. */
  41925. inertialAlphaOffset: number;
  41926. /**
  41927. * Current inertia value on the latitudinal axis.
  41928. * The bigger this number the longer it will take for the camera to stop.
  41929. */
  41930. inertialBetaOffset: number;
  41931. /**
  41932. * Current inertia value on the radius axis.
  41933. * The bigger this number the longer it will take for the camera to stop.
  41934. */
  41935. inertialRadiusOffset: number;
  41936. /**
  41937. * Minimum allowed angle on the longitudinal axis.
  41938. * This can help limiting how the Camera is able to move in the scene.
  41939. */
  41940. lowerAlphaLimit: Nullable<number>;
  41941. /**
  41942. * Maximum allowed angle on the longitudinal axis.
  41943. * This can help limiting how the Camera is able to move in the scene.
  41944. */
  41945. upperAlphaLimit: Nullable<number>;
  41946. /**
  41947. * Minimum allowed angle on the latitudinal axis.
  41948. * This can help limiting how the Camera is able to move in the scene.
  41949. */
  41950. lowerBetaLimit: number;
  41951. /**
  41952. * Maximum allowed angle on the latitudinal axis.
  41953. * This can help limiting how the Camera is able to move in the scene.
  41954. */
  41955. upperBetaLimit: number;
  41956. /**
  41957. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41958. * This can help limiting how the Camera is able to move in the scene.
  41959. */
  41960. lowerRadiusLimit: Nullable<number>;
  41961. /**
  41962. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41963. * This can help limiting how the Camera is able to move in the scene.
  41964. */
  41965. upperRadiusLimit: Nullable<number>;
  41966. /**
  41967. * Defines the current inertia value used during panning of the camera along the X axis.
  41968. */
  41969. inertialPanningX: number;
  41970. /**
  41971. * Defines the current inertia value used during panning of the camera along the Y axis.
  41972. */
  41973. inertialPanningY: number;
  41974. /**
  41975. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41976. * Basically if your fingers moves away from more than this distance you will be considered
  41977. * in pinch mode.
  41978. */
  41979. pinchToPanMaxDistance: number;
  41980. /**
  41981. * Defines the maximum distance the camera can pan.
  41982. * This could help keeping the cammera always in your scene.
  41983. */
  41984. panningDistanceLimit: Nullable<number>;
  41985. /**
  41986. * Defines the target of the camera before paning.
  41987. */
  41988. panningOriginTarget: Vector3;
  41989. /**
  41990. * Defines the value of the inertia used during panning.
  41991. * 0 would mean stop inertia and one would mean no decelleration at all.
  41992. */
  41993. panningInertia: number;
  41994. /**
  41995. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41996. */
  41997. get angularSensibilityX(): number;
  41998. set angularSensibilityX(value: number);
  41999. /**
  42000. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42001. */
  42002. get angularSensibilityY(): number;
  42003. set angularSensibilityY(value: number);
  42004. /**
  42005. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42006. */
  42007. get pinchPrecision(): number;
  42008. set pinchPrecision(value: number);
  42009. /**
  42010. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42011. * It will be used instead of pinchDeltaPrecision if different from 0.
  42012. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42013. */
  42014. get pinchDeltaPercentage(): number;
  42015. set pinchDeltaPercentage(value: number);
  42016. /**
  42017. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42018. * and pinch delta percentage.
  42019. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42020. * that any object in the plane at the camera's target point will scale
  42021. * perfectly with finger motion.
  42022. */
  42023. get useNaturalPinchZoom(): boolean;
  42024. set useNaturalPinchZoom(value: boolean);
  42025. /**
  42026. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42027. */
  42028. get panningSensibility(): number;
  42029. set panningSensibility(value: number);
  42030. /**
  42031. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42032. */
  42033. get keysUp(): number[];
  42034. set keysUp(value: number[]);
  42035. /**
  42036. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42037. */
  42038. get keysDown(): number[];
  42039. set keysDown(value: number[]);
  42040. /**
  42041. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42042. */
  42043. get keysLeft(): number[];
  42044. set keysLeft(value: number[]);
  42045. /**
  42046. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42047. */
  42048. get keysRight(): number[];
  42049. set keysRight(value: number[]);
  42050. /**
  42051. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42052. */
  42053. get wheelPrecision(): number;
  42054. set wheelPrecision(value: number);
  42055. /**
  42056. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42057. * It will be used instead of pinchDeltaPrecision if different from 0.
  42058. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42059. */
  42060. get wheelDeltaPercentage(): number;
  42061. set wheelDeltaPercentage(value: number);
  42062. /**
  42063. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42064. */
  42065. zoomOnFactor: number;
  42066. /**
  42067. * Defines a screen offset for the camera position.
  42068. */
  42069. targetScreenOffset: Vector2;
  42070. /**
  42071. * Allows the camera to be completely reversed.
  42072. * If false the camera can not arrive upside down.
  42073. */
  42074. allowUpsideDown: boolean;
  42075. /**
  42076. * Define if double tap/click is used to restore the previously saved state of the camera.
  42077. */
  42078. useInputToRestoreState: boolean;
  42079. /** @hidden */
  42080. _viewMatrix: Matrix;
  42081. /** @hidden */
  42082. _useCtrlForPanning: boolean;
  42083. /** @hidden */
  42084. _panningMouseButton: number;
  42085. /**
  42086. * Defines the input associated to the camera.
  42087. */
  42088. inputs: ArcRotateCameraInputsManager;
  42089. /** @hidden */
  42090. _reset: () => void;
  42091. /**
  42092. * Defines the allowed panning axis.
  42093. */
  42094. panningAxis: Vector3;
  42095. protected _localDirection: Vector3;
  42096. protected _transformedDirection: Vector3;
  42097. private _bouncingBehavior;
  42098. /**
  42099. * Gets the bouncing behavior of the camera if it has been enabled.
  42100. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42101. */
  42102. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42103. /**
  42104. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42106. */
  42107. get useBouncingBehavior(): boolean;
  42108. set useBouncingBehavior(value: boolean);
  42109. private _framingBehavior;
  42110. /**
  42111. * Gets the framing behavior of the camera if it has been enabled.
  42112. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42113. */
  42114. get framingBehavior(): Nullable<FramingBehavior>;
  42115. /**
  42116. * Defines if the framing behavior of the camera is enabled on the camera.
  42117. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42118. */
  42119. get useFramingBehavior(): boolean;
  42120. set useFramingBehavior(value: boolean);
  42121. private _autoRotationBehavior;
  42122. /**
  42123. * Gets the auto rotation behavior of the camera if it has been enabled.
  42124. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42125. */
  42126. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42127. /**
  42128. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42129. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42130. */
  42131. get useAutoRotationBehavior(): boolean;
  42132. set useAutoRotationBehavior(value: boolean);
  42133. /**
  42134. * Observable triggered when the mesh target has been changed on the camera.
  42135. */
  42136. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42137. /**
  42138. * Event raised when the camera is colliding with a mesh.
  42139. */
  42140. onCollide: (collidedMesh: AbstractMesh) => void;
  42141. /**
  42142. * Defines whether the camera should check collision with the objects oh the scene.
  42143. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42144. */
  42145. checkCollisions: boolean;
  42146. /**
  42147. * Defines the collision radius of the camera.
  42148. * This simulates a sphere around the camera.
  42149. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42150. */
  42151. collisionRadius: Vector3;
  42152. protected _collider: Collider;
  42153. protected _previousPosition: Vector3;
  42154. protected _collisionVelocity: Vector3;
  42155. protected _newPosition: Vector3;
  42156. protected _previousAlpha: number;
  42157. protected _previousBeta: number;
  42158. protected _previousRadius: number;
  42159. protected _collisionTriggered: boolean;
  42160. protected _targetBoundingCenter: Nullable<Vector3>;
  42161. private _computationVector;
  42162. /**
  42163. * Instantiates a new ArcRotateCamera in a given scene
  42164. * @param name Defines the name of the camera
  42165. * @param alpha Defines the camera rotation along the logitudinal axis
  42166. * @param beta Defines the camera rotation along the latitudinal axis
  42167. * @param radius Defines the camera distance from its target
  42168. * @param target Defines the camera target
  42169. * @param scene Defines the scene the camera belongs to
  42170. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42171. */
  42172. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42173. /** @hidden */
  42174. _initCache(): void;
  42175. /** @hidden */
  42176. _updateCache(ignoreParentClass?: boolean): void;
  42177. protected _getTargetPosition(): Vector3;
  42178. private _storedAlpha;
  42179. private _storedBeta;
  42180. private _storedRadius;
  42181. private _storedTarget;
  42182. private _storedTargetScreenOffset;
  42183. /**
  42184. * Stores the current state of the camera (alpha, beta, radius and target)
  42185. * @returns the camera itself
  42186. */
  42187. storeState(): Camera;
  42188. /**
  42189. * @hidden
  42190. * Restored camera state. You must call storeState() first
  42191. */
  42192. _restoreStateValues(): boolean;
  42193. /** @hidden */
  42194. _isSynchronizedViewMatrix(): boolean;
  42195. /**
  42196. * Attached controls to the current camera.
  42197. * @param element Defines the element the controls should be listened from
  42198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42199. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42200. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42201. */
  42202. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42203. /**
  42204. * Detach the current controls from the camera.
  42205. * The camera will stop reacting to inputs.
  42206. * @param element Defines the element to stop listening the inputs from
  42207. */
  42208. detachControl(element: HTMLElement): void;
  42209. /** @hidden */
  42210. _checkInputs(): void;
  42211. protected _checkLimits(): void;
  42212. /**
  42213. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42214. */
  42215. rebuildAnglesAndRadius(): void;
  42216. /**
  42217. * Use a position to define the current camera related information like alpha, beta and radius
  42218. * @param position Defines the position to set the camera at
  42219. */
  42220. setPosition(position: Vector3): void;
  42221. /**
  42222. * Defines the target the camera should look at.
  42223. * This will automatically adapt alpha beta and radius to fit within the new target.
  42224. * @param target Defines the new target as a Vector or a mesh
  42225. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42226. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42227. */
  42228. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42229. /** @hidden */
  42230. _getViewMatrix(): Matrix;
  42231. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42232. /**
  42233. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42234. * @param meshes Defines the mesh to zoom on
  42235. * @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)
  42236. */
  42237. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42238. /**
  42239. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42240. * The target will be changed but the radius
  42241. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42242. * @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)
  42243. */
  42244. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42245. min: Vector3;
  42246. max: Vector3;
  42247. distance: number;
  42248. }, doNotUpdateMaxZ?: boolean): void;
  42249. /**
  42250. * @override
  42251. * Override Camera.createRigCamera
  42252. */
  42253. createRigCamera(name: string, cameraIndex: number): Camera;
  42254. /**
  42255. * @hidden
  42256. * @override
  42257. * Override Camera._updateRigCameras
  42258. */
  42259. _updateRigCameras(): void;
  42260. /**
  42261. * Destroy the camera and release the current resources hold by it.
  42262. */
  42263. dispose(): void;
  42264. /**
  42265. * Gets the current object class name.
  42266. * @return the class name
  42267. */
  42268. getClassName(): string;
  42269. }
  42270. }
  42271. declare module BABYLON {
  42272. /**
  42273. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42274. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42275. */
  42276. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42277. /**
  42278. * Gets the name of the behavior.
  42279. */
  42280. get name(): string;
  42281. private _zoomStopsAnimation;
  42282. private _idleRotationSpeed;
  42283. private _idleRotationWaitTime;
  42284. private _idleRotationSpinupTime;
  42285. /**
  42286. * Sets the flag that indicates if user zooming should stop animation.
  42287. */
  42288. set zoomStopsAnimation(flag: boolean);
  42289. /**
  42290. * Gets the flag that indicates if user zooming should stop animation.
  42291. */
  42292. get zoomStopsAnimation(): boolean;
  42293. /**
  42294. * Sets the default speed at which the camera rotates around the model.
  42295. */
  42296. set idleRotationSpeed(speed: number);
  42297. /**
  42298. * Gets the default speed at which the camera rotates around the model.
  42299. */
  42300. get idleRotationSpeed(): number;
  42301. /**
  42302. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42303. */
  42304. set idleRotationWaitTime(time: number);
  42305. /**
  42306. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42307. */
  42308. get idleRotationWaitTime(): number;
  42309. /**
  42310. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42311. */
  42312. set idleRotationSpinupTime(time: number);
  42313. /**
  42314. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42315. */
  42316. get idleRotationSpinupTime(): number;
  42317. /**
  42318. * Gets a value indicating if the camera is currently rotating because of this behavior
  42319. */
  42320. get rotationInProgress(): boolean;
  42321. private _onPrePointerObservableObserver;
  42322. private _onAfterCheckInputsObserver;
  42323. private _attachedCamera;
  42324. private _isPointerDown;
  42325. private _lastFrameTime;
  42326. private _lastInteractionTime;
  42327. private _cameraRotationSpeed;
  42328. /**
  42329. * Initializes the behavior.
  42330. */
  42331. init(): void;
  42332. /**
  42333. * Attaches the behavior to its arc rotate camera.
  42334. * @param camera Defines the camera to attach the behavior to
  42335. */
  42336. attach(camera: ArcRotateCamera): void;
  42337. /**
  42338. * Detaches the behavior from its current arc rotate camera.
  42339. */
  42340. detach(): void;
  42341. /**
  42342. * Returns true if user is scrolling.
  42343. * @return true if user is scrolling.
  42344. */
  42345. private _userIsZooming;
  42346. private _lastFrameRadius;
  42347. private _shouldAnimationStopForInteraction;
  42348. /**
  42349. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42350. */
  42351. private _applyUserInteraction;
  42352. private _userIsMoving;
  42353. }
  42354. }
  42355. declare module BABYLON {
  42356. /**
  42357. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42358. */
  42359. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42360. private ui;
  42361. /**
  42362. * The name of the behavior
  42363. */
  42364. name: string;
  42365. /**
  42366. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42367. */
  42368. distanceAwayFromFace: number;
  42369. /**
  42370. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42371. */
  42372. distanceAwayFromBottomOfFace: number;
  42373. private _faceVectors;
  42374. private _target;
  42375. private _scene;
  42376. private _onRenderObserver;
  42377. private _tmpMatrix;
  42378. private _tmpVector;
  42379. /**
  42380. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42381. * @param ui The transform node that should be attched to the mesh
  42382. */
  42383. constructor(ui: TransformNode);
  42384. /**
  42385. * Initializes the behavior
  42386. */
  42387. init(): void;
  42388. private _closestFace;
  42389. private _zeroVector;
  42390. private _lookAtTmpMatrix;
  42391. private _lookAtToRef;
  42392. /**
  42393. * Attaches the AttachToBoxBehavior to the passed in mesh
  42394. * @param target The mesh that the specified node will be attached to
  42395. */
  42396. attach(target: Mesh): void;
  42397. /**
  42398. * Detaches the behavior from the mesh
  42399. */
  42400. detach(): void;
  42401. }
  42402. }
  42403. declare module BABYLON {
  42404. /**
  42405. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42406. */
  42407. export class FadeInOutBehavior implements Behavior<Mesh> {
  42408. /**
  42409. * Time in milliseconds to delay before fading in (Default: 0)
  42410. */
  42411. delay: number;
  42412. /**
  42413. * Time in milliseconds for the mesh to fade in (Default: 300)
  42414. */
  42415. fadeInTime: number;
  42416. private _millisecondsPerFrame;
  42417. private _hovered;
  42418. private _hoverValue;
  42419. private _ownerNode;
  42420. /**
  42421. * Instatiates the FadeInOutBehavior
  42422. */
  42423. constructor();
  42424. /**
  42425. * The name of the behavior
  42426. */
  42427. get name(): string;
  42428. /**
  42429. * Initializes the behavior
  42430. */
  42431. init(): void;
  42432. /**
  42433. * Attaches the fade behavior on the passed in mesh
  42434. * @param ownerNode The mesh that will be faded in/out once attached
  42435. */
  42436. attach(ownerNode: Mesh): void;
  42437. /**
  42438. * Detaches the behavior from the mesh
  42439. */
  42440. detach(): void;
  42441. /**
  42442. * Triggers the mesh to begin fading in or out
  42443. * @param value if the object should fade in or out (true to fade in)
  42444. */
  42445. fadeIn(value: boolean): void;
  42446. private _update;
  42447. private _setAllVisibility;
  42448. }
  42449. }
  42450. declare module BABYLON {
  42451. /**
  42452. * Class containing a set of static utilities functions for managing Pivots
  42453. * @hidden
  42454. */
  42455. export class PivotTools {
  42456. private static _PivotCached;
  42457. private static _OldPivotPoint;
  42458. private static _PivotTranslation;
  42459. private static _PivotTmpVector;
  42460. /** @hidden */
  42461. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42462. /** @hidden */
  42463. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42464. }
  42465. }
  42466. declare module BABYLON {
  42467. /**
  42468. * Class containing static functions to help procedurally build meshes
  42469. */
  42470. export class PlaneBuilder {
  42471. /**
  42472. * Creates a plane mesh
  42473. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42474. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42475. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42477. * * 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
  42478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42479. * @param name defines the name of the mesh
  42480. * @param options defines the options used to create the mesh
  42481. * @param scene defines the hosting scene
  42482. * @returns the plane mesh
  42483. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42484. */
  42485. static CreatePlane(name: string, options: {
  42486. size?: number;
  42487. width?: number;
  42488. height?: number;
  42489. sideOrientation?: number;
  42490. frontUVs?: Vector4;
  42491. backUVs?: Vector4;
  42492. updatable?: boolean;
  42493. sourcePlane?: Plane;
  42494. }, scene?: Nullable<Scene>): Mesh;
  42495. }
  42496. }
  42497. declare module BABYLON {
  42498. /**
  42499. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42500. */
  42501. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42502. private static _AnyMouseID;
  42503. /**
  42504. * Abstract mesh the behavior is set on
  42505. */
  42506. attachedNode: AbstractMesh;
  42507. private _dragPlane;
  42508. private _scene;
  42509. private _pointerObserver;
  42510. private _beforeRenderObserver;
  42511. private static _planeScene;
  42512. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42513. /**
  42514. * 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)
  42515. */
  42516. maxDragAngle: number;
  42517. /**
  42518. * @hidden
  42519. */
  42520. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42521. /**
  42522. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42523. */
  42524. currentDraggingPointerID: number;
  42525. /**
  42526. * The last position where the pointer hit the drag plane in world space
  42527. */
  42528. lastDragPosition: Vector3;
  42529. /**
  42530. * If the behavior is currently in a dragging state
  42531. */
  42532. dragging: boolean;
  42533. /**
  42534. * 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)
  42535. */
  42536. dragDeltaRatio: number;
  42537. /**
  42538. * If the drag plane orientation should be updated during the dragging (Default: true)
  42539. */
  42540. updateDragPlane: boolean;
  42541. private _debugMode;
  42542. private _moving;
  42543. /**
  42544. * Fires each time the attached mesh is dragged with the pointer
  42545. * * delta between last drag position and current drag position in world space
  42546. * * dragDistance along the drag axis
  42547. * * dragPlaneNormal normal of the current drag plane used during the drag
  42548. * * dragPlanePoint in world space where the drag intersects the drag plane
  42549. */
  42550. onDragObservable: Observable<{
  42551. delta: Vector3;
  42552. dragPlanePoint: Vector3;
  42553. dragPlaneNormal: Vector3;
  42554. dragDistance: number;
  42555. pointerId: number;
  42556. }>;
  42557. /**
  42558. * Fires each time a drag begins (eg. mouse down on mesh)
  42559. */
  42560. onDragStartObservable: Observable<{
  42561. dragPlanePoint: Vector3;
  42562. pointerId: number;
  42563. }>;
  42564. /**
  42565. * Fires each time a drag ends (eg. mouse release after drag)
  42566. */
  42567. onDragEndObservable: Observable<{
  42568. dragPlanePoint: Vector3;
  42569. pointerId: number;
  42570. }>;
  42571. /**
  42572. * If the attached mesh should be moved when dragged
  42573. */
  42574. moveAttached: boolean;
  42575. /**
  42576. * If the drag behavior will react to drag events (Default: true)
  42577. */
  42578. enabled: boolean;
  42579. /**
  42580. * If pointer events should start and release the drag (Default: true)
  42581. */
  42582. startAndReleaseDragOnPointerEvents: boolean;
  42583. /**
  42584. * If camera controls should be detached during the drag
  42585. */
  42586. detachCameraControls: boolean;
  42587. /**
  42588. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42589. */
  42590. useObjectOrientationForDragging: boolean;
  42591. private _options;
  42592. /**
  42593. * Gets the options used by the behavior
  42594. */
  42595. get options(): {
  42596. dragAxis?: Vector3;
  42597. dragPlaneNormal?: Vector3;
  42598. };
  42599. /**
  42600. * Sets the options used by the behavior
  42601. */
  42602. set options(options: {
  42603. dragAxis?: Vector3;
  42604. dragPlaneNormal?: Vector3;
  42605. });
  42606. /**
  42607. * Creates a pointer drag behavior that can be attached to a mesh
  42608. * @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)
  42609. */
  42610. constructor(options?: {
  42611. dragAxis?: Vector3;
  42612. dragPlaneNormal?: Vector3;
  42613. });
  42614. /**
  42615. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42616. */
  42617. validateDrag: (targetPosition: Vector3) => boolean;
  42618. /**
  42619. * The name of the behavior
  42620. */
  42621. get name(): string;
  42622. /**
  42623. * Initializes the behavior
  42624. */
  42625. init(): void;
  42626. private _tmpVector;
  42627. private _alternatePickedPoint;
  42628. private _worldDragAxis;
  42629. private _targetPosition;
  42630. private _attachedElement;
  42631. /**
  42632. * Attaches the drag behavior the passed in mesh
  42633. * @param ownerNode The mesh that will be dragged around once attached
  42634. * @param predicate Predicate to use for pick filtering
  42635. */
  42636. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42637. /**
  42638. * Force relase the drag action by code.
  42639. */
  42640. releaseDrag(): void;
  42641. private _startDragRay;
  42642. private _lastPointerRay;
  42643. /**
  42644. * Simulates the start of a pointer drag event on the behavior
  42645. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42646. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42647. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42648. */
  42649. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42650. private _startDrag;
  42651. private _dragDelta;
  42652. private _moveDrag;
  42653. private _pickWithRayOnDragPlane;
  42654. private _pointA;
  42655. private _pointB;
  42656. private _pointC;
  42657. private _lineA;
  42658. private _lineB;
  42659. private _localAxis;
  42660. private _lookAt;
  42661. private _updateDragPlanePosition;
  42662. /**
  42663. * Detaches the behavior from the mesh
  42664. */
  42665. detach(): void;
  42666. }
  42667. }
  42668. declare module BABYLON {
  42669. /**
  42670. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42671. */
  42672. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42673. private _dragBehaviorA;
  42674. private _dragBehaviorB;
  42675. private _startDistance;
  42676. private _initialScale;
  42677. private _targetScale;
  42678. private _ownerNode;
  42679. private _sceneRenderObserver;
  42680. /**
  42681. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42682. */
  42683. constructor();
  42684. /**
  42685. * The name of the behavior
  42686. */
  42687. get name(): string;
  42688. /**
  42689. * Initializes the behavior
  42690. */
  42691. init(): void;
  42692. private _getCurrentDistance;
  42693. /**
  42694. * Attaches the scale behavior the passed in mesh
  42695. * @param ownerNode The mesh that will be scaled around once attached
  42696. */
  42697. attach(ownerNode: Mesh): void;
  42698. /**
  42699. * Detaches the behavior from the mesh
  42700. */
  42701. detach(): void;
  42702. }
  42703. }
  42704. declare module BABYLON {
  42705. /**
  42706. * 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
  42707. */
  42708. export class SixDofDragBehavior implements Behavior<Mesh> {
  42709. private static _virtualScene;
  42710. private _ownerNode;
  42711. private _sceneRenderObserver;
  42712. private _scene;
  42713. private _targetPosition;
  42714. private _virtualOriginMesh;
  42715. private _virtualDragMesh;
  42716. private _pointerObserver;
  42717. private _moving;
  42718. private _startingOrientation;
  42719. private _attachedElement;
  42720. /**
  42721. * 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)
  42722. */
  42723. private zDragFactor;
  42724. /**
  42725. * If the object should rotate to face the drag origin
  42726. */
  42727. rotateDraggedObject: boolean;
  42728. /**
  42729. * If the behavior is currently in a dragging state
  42730. */
  42731. dragging: boolean;
  42732. /**
  42733. * 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)
  42734. */
  42735. dragDeltaRatio: number;
  42736. /**
  42737. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42738. */
  42739. currentDraggingPointerID: number;
  42740. /**
  42741. * If camera controls should be detached during the drag
  42742. */
  42743. detachCameraControls: boolean;
  42744. /**
  42745. * Fires each time a drag starts
  42746. */
  42747. onDragStartObservable: Observable<{}>;
  42748. /**
  42749. * Fires each time a drag ends (eg. mouse release after drag)
  42750. */
  42751. onDragEndObservable: Observable<{}>;
  42752. /**
  42753. * 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
  42754. */
  42755. constructor();
  42756. /**
  42757. * The name of the behavior
  42758. */
  42759. get name(): string;
  42760. /**
  42761. * Initializes the behavior
  42762. */
  42763. init(): void;
  42764. /**
  42765. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42766. */
  42767. private get _pointerCamera();
  42768. /**
  42769. * Attaches the scale behavior the passed in mesh
  42770. * @param ownerNode The mesh that will be scaled around once attached
  42771. */
  42772. attach(ownerNode: Mesh): void;
  42773. /**
  42774. * Detaches the behavior from the mesh
  42775. */
  42776. detach(): void;
  42777. }
  42778. }
  42779. declare module BABYLON {
  42780. /**
  42781. * Class used to apply inverse kinematics to bones
  42782. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42783. */
  42784. export class BoneIKController {
  42785. private static _tmpVecs;
  42786. private static _tmpQuat;
  42787. private static _tmpMats;
  42788. /**
  42789. * Gets or sets the target mesh
  42790. */
  42791. targetMesh: AbstractMesh;
  42792. /** Gets or sets the mesh used as pole */
  42793. poleTargetMesh: AbstractMesh;
  42794. /**
  42795. * Gets or sets the bone used as pole
  42796. */
  42797. poleTargetBone: Nullable<Bone>;
  42798. /**
  42799. * Gets or sets the target position
  42800. */
  42801. targetPosition: Vector3;
  42802. /**
  42803. * Gets or sets the pole target position
  42804. */
  42805. poleTargetPosition: Vector3;
  42806. /**
  42807. * Gets or sets the pole target local offset
  42808. */
  42809. poleTargetLocalOffset: Vector3;
  42810. /**
  42811. * Gets or sets the pole angle
  42812. */
  42813. poleAngle: number;
  42814. /**
  42815. * Gets or sets the mesh associated with the controller
  42816. */
  42817. mesh: AbstractMesh;
  42818. /**
  42819. * 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)
  42820. */
  42821. slerpAmount: number;
  42822. private _bone1Quat;
  42823. private _bone1Mat;
  42824. private _bone2Ang;
  42825. private _bone1;
  42826. private _bone2;
  42827. private _bone1Length;
  42828. private _bone2Length;
  42829. private _maxAngle;
  42830. private _maxReach;
  42831. private _rightHandedSystem;
  42832. private _bendAxis;
  42833. private _slerping;
  42834. private _adjustRoll;
  42835. /**
  42836. * Gets or sets maximum allowed angle
  42837. */
  42838. get maxAngle(): number;
  42839. set maxAngle(value: number);
  42840. /**
  42841. * Creates a new BoneIKController
  42842. * @param mesh defines the mesh to control
  42843. * @param bone defines the bone to control
  42844. * @param options defines options to set up the controller
  42845. */
  42846. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42847. targetMesh?: AbstractMesh;
  42848. poleTargetMesh?: AbstractMesh;
  42849. poleTargetBone?: Bone;
  42850. poleTargetLocalOffset?: Vector3;
  42851. poleAngle?: number;
  42852. bendAxis?: Vector3;
  42853. maxAngle?: number;
  42854. slerpAmount?: number;
  42855. });
  42856. private _setMaxAngle;
  42857. /**
  42858. * Force the controller to update the bones
  42859. */
  42860. update(): void;
  42861. }
  42862. }
  42863. declare module BABYLON {
  42864. /**
  42865. * Class used to make a bone look toward a point in space
  42866. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42867. */
  42868. export class BoneLookController {
  42869. private static _tmpVecs;
  42870. private static _tmpQuat;
  42871. private static _tmpMats;
  42872. /**
  42873. * The target Vector3 that the bone will look at
  42874. */
  42875. target: Vector3;
  42876. /**
  42877. * The mesh that the bone is attached to
  42878. */
  42879. mesh: AbstractMesh;
  42880. /**
  42881. * The bone that will be looking to the target
  42882. */
  42883. bone: Bone;
  42884. /**
  42885. * The up axis of the coordinate system that is used when the bone is rotated
  42886. */
  42887. upAxis: Vector3;
  42888. /**
  42889. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42890. */
  42891. upAxisSpace: Space;
  42892. /**
  42893. * Used to make an adjustment to the yaw of the bone
  42894. */
  42895. adjustYaw: number;
  42896. /**
  42897. * Used to make an adjustment to the pitch of the bone
  42898. */
  42899. adjustPitch: number;
  42900. /**
  42901. * Used to make an adjustment to the roll of the bone
  42902. */
  42903. adjustRoll: number;
  42904. /**
  42905. * 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)
  42906. */
  42907. slerpAmount: number;
  42908. private _minYaw;
  42909. private _maxYaw;
  42910. private _minPitch;
  42911. private _maxPitch;
  42912. private _minYawSin;
  42913. private _minYawCos;
  42914. private _maxYawSin;
  42915. private _maxYawCos;
  42916. private _midYawConstraint;
  42917. private _minPitchTan;
  42918. private _maxPitchTan;
  42919. private _boneQuat;
  42920. private _slerping;
  42921. private _transformYawPitch;
  42922. private _transformYawPitchInv;
  42923. private _firstFrameSkipped;
  42924. private _yawRange;
  42925. private _fowardAxis;
  42926. /**
  42927. * Gets or sets the minimum yaw angle that the bone can look to
  42928. */
  42929. get minYaw(): number;
  42930. set minYaw(value: number);
  42931. /**
  42932. * Gets or sets the maximum yaw angle that the bone can look to
  42933. */
  42934. get maxYaw(): number;
  42935. set maxYaw(value: number);
  42936. /**
  42937. * Gets or sets the minimum pitch angle that the bone can look to
  42938. */
  42939. get minPitch(): number;
  42940. set minPitch(value: number);
  42941. /**
  42942. * Gets or sets the maximum pitch angle that the bone can look to
  42943. */
  42944. get maxPitch(): number;
  42945. set maxPitch(value: number);
  42946. /**
  42947. * Create a BoneLookController
  42948. * @param mesh the mesh that the bone belongs to
  42949. * @param bone the bone that will be looking to the target
  42950. * @param target the target Vector3 to look at
  42951. * @param options optional settings:
  42952. * * maxYaw: the maximum angle the bone will yaw to
  42953. * * minYaw: the minimum angle the bone will yaw to
  42954. * * maxPitch: the maximum angle the bone will pitch to
  42955. * * minPitch: the minimum angle the bone will yaw to
  42956. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42957. * * upAxis: the up axis of the coordinate system
  42958. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42959. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42960. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42961. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42962. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42963. * * adjustRoll: used to make an adjustment to the roll of the bone
  42964. **/
  42965. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42966. maxYaw?: number;
  42967. minYaw?: number;
  42968. maxPitch?: number;
  42969. minPitch?: number;
  42970. slerpAmount?: number;
  42971. upAxis?: Vector3;
  42972. upAxisSpace?: Space;
  42973. yawAxis?: Vector3;
  42974. pitchAxis?: Vector3;
  42975. adjustYaw?: number;
  42976. adjustPitch?: number;
  42977. adjustRoll?: number;
  42978. });
  42979. /**
  42980. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42981. */
  42982. update(): void;
  42983. private _getAngleDiff;
  42984. private _getAngleBetween;
  42985. private _isAngleBetween;
  42986. }
  42987. }
  42988. declare module BABYLON {
  42989. /**
  42990. * Manage the gamepad inputs to control an arc rotate camera.
  42991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42992. */
  42993. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  42994. /**
  42995. * Defines the camera the input is attached to.
  42996. */
  42997. camera: ArcRotateCamera;
  42998. /**
  42999. * Defines the gamepad the input is gathering event from.
  43000. */
  43001. gamepad: Nullable<Gamepad>;
  43002. /**
  43003. * Defines the gamepad rotation sensiblity.
  43004. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43005. */
  43006. gamepadRotationSensibility: number;
  43007. /**
  43008. * Defines the gamepad move sensiblity.
  43009. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43010. */
  43011. gamepadMoveSensibility: number;
  43012. private _yAxisScale;
  43013. /**
  43014. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43015. */
  43016. get invertYAxis(): boolean;
  43017. set invertYAxis(value: boolean);
  43018. private _onGamepadConnectedObserver;
  43019. private _onGamepadDisconnectedObserver;
  43020. /**
  43021. * Attach the input controls to a specific dom element to get the input from.
  43022. * @param element Defines the element the controls should be listened from
  43023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43024. */
  43025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43026. /**
  43027. * Detach the current controls from the specified dom element.
  43028. * @param element Defines the element to stop listening the inputs from
  43029. */
  43030. detachControl(element: Nullable<HTMLElement>): void;
  43031. /**
  43032. * Update the current camera state depending on the inputs that have been used this frame.
  43033. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43034. */
  43035. checkInputs(): void;
  43036. /**
  43037. * Gets the class name of the current intput.
  43038. * @returns the class name
  43039. */
  43040. getClassName(): string;
  43041. /**
  43042. * Get the friendly name associated with the input class.
  43043. * @returns the input friendly name
  43044. */
  43045. getSimpleName(): string;
  43046. }
  43047. }
  43048. declare module BABYLON {
  43049. interface ArcRotateCameraInputsManager {
  43050. /**
  43051. * Add orientation input support to the input manager.
  43052. * @returns the current input manager
  43053. */
  43054. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43055. }
  43056. /**
  43057. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43058. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43059. */
  43060. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43061. /**
  43062. * Defines the camera the input is attached to.
  43063. */
  43064. camera: ArcRotateCamera;
  43065. /**
  43066. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43067. */
  43068. alphaCorrection: number;
  43069. /**
  43070. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43071. */
  43072. gammaCorrection: number;
  43073. private _alpha;
  43074. private _gamma;
  43075. private _dirty;
  43076. private _deviceOrientationHandler;
  43077. /**
  43078. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43079. */
  43080. constructor();
  43081. /**
  43082. * Attach the input controls to a specific dom element to get the input from.
  43083. * @param element Defines the element the controls should be listened from
  43084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43085. */
  43086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43087. /** @hidden */
  43088. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43089. /**
  43090. * Update the current camera state depending on the inputs that have been used this frame.
  43091. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43092. */
  43093. checkInputs(): void;
  43094. /**
  43095. * Detach the current controls from the specified dom element.
  43096. * @param element Defines the element to stop listening the inputs from
  43097. */
  43098. detachControl(element: Nullable<HTMLElement>): void;
  43099. /**
  43100. * Gets the class name of the current intput.
  43101. * @returns the class name
  43102. */
  43103. getClassName(): string;
  43104. /**
  43105. * Get the friendly name associated with the input class.
  43106. * @returns the input friendly name
  43107. */
  43108. getSimpleName(): string;
  43109. }
  43110. }
  43111. declare module BABYLON {
  43112. /**
  43113. * Listen to mouse events to control the camera.
  43114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43115. */
  43116. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43117. /**
  43118. * Defines the camera the input is attached to.
  43119. */
  43120. camera: FlyCamera;
  43121. /**
  43122. * Defines if touch is enabled. (Default is true.)
  43123. */
  43124. touchEnabled: boolean;
  43125. /**
  43126. * Defines the buttons associated with the input to handle camera rotation.
  43127. */
  43128. buttons: number[];
  43129. /**
  43130. * Assign buttons for Yaw control.
  43131. */
  43132. buttonsYaw: number[];
  43133. /**
  43134. * Assign buttons for Pitch control.
  43135. */
  43136. buttonsPitch: number[];
  43137. /**
  43138. * Assign buttons for Roll control.
  43139. */
  43140. buttonsRoll: number[];
  43141. /**
  43142. * Detect if any button is being pressed while mouse is moved.
  43143. * -1 = Mouse locked.
  43144. * 0 = Left button.
  43145. * 1 = Middle Button.
  43146. * 2 = Right Button.
  43147. */
  43148. activeButton: number;
  43149. /**
  43150. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43151. * Higher values reduce its sensitivity.
  43152. */
  43153. angularSensibility: number;
  43154. private _mousemoveCallback;
  43155. private _observer;
  43156. private _rollObserver;
  43157. private previousPosition;
  43158. private noPreventDefault;
  43159. private element;
  43160. /**
  43161. * Listen to mouse events to control the camera.
  43162. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43164. */
  43165. constructor(touchEnabled?: boolean);
  43166. /**
  43167. * Attach the mouse control to the HTML DOM element.
  43168. * @param element Defines the element that listens to the input events.
  43169. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43170. */
  43171. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43172. /**
  43173. * Detach the current controls from the specified dom element.
  43174. * @param element Defines the element to stop listening the inputs from
  43175. */
  43176. detachControl(element: Nullable<HTMLElement>): void;
  43177. /**
  43178. * Gets the class name of the current input.
  43179. * @returns the class name.
  43180. */
  43181. getClassName(): string;
  43182. /**
  43183. * Get the friendly name associated with the input class.
  43184. * @returns the input's friendly name.
  43185. */
  43186. getSimpleName(): string;
  43187. private _pointerInput;
  43188. private _onMouseMove;
  43189. /**
  43190. * Rotate camera by mouse offset.
  43191. */
  43192. private rotateCamera;
  43193. }
  43194. }
  43195. declare module BABYLON {
  43196. /**
  43197. * Default Inputs manager for the FlyCamera.
  43198. * It groups all the default supported inputs for ease of use.
  43199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43200. */
  43201. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43202. /**
  43203. * Instantiates a new FlyCameraInputsManager.
  43204. * @param camera Defines the camera the inputs belong to.
  43205. */
  43206. constructor(camera: FlyCamera);
  43207. /**
  43208. * Add keyboard input support to the input manager.
  43209. * @returns the new FlyCameraKeyboardMoveInput().
  43210. */
  43211. addKeyboard(): FlyCameraInputsManager;
  43212. /**
  43213. * Add mouse input support to the input manager.
  43214. * @param touchEnabled Enable touch screen support.
  43215. * @returns the new FlyCameraMouseInput().
  43216. */
  43217. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43218. }
  43219. }
  43220. declare module BABYLON {
  43221. /**
  43222. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43223. * such as in a 3D Space Shooter or a Flight Simulator.
  43224. */
  43225. export class FlyCamera extends TargetCamera {
  43226. /**
  43227. * Define the collision ellipsoid of the camera.
  43228. * This is helpful for simulating a camera body, like a player's body.
  43229. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43230. */
  43231. ellipsoid: Vector3;
  43232. /**
  43233. * Define an offset for the position of the ellipsoid around the camera.
  43234. * This can be helpful if the camera is attached away from the player's body center,
  43235. * such as at its head.
  43236. */
  43237. ellipsoidOffset: Vector3;
  43238. /**
  43239. * Enable or disable collisions of the camera with the rest of the scene objects.
  43240. */
  43241. checkCollisions: boolean;
  43242. /**
  43243. * Enable or disable gravity on the camera.
  43244. */
  43245. applyGravity: boolean;
  43246. /**
  43247. * Define the current direction the camera is moving to.
  43248. */
  43249. cameraDirection: Vector3;
  43250. /**
  43251. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43252. * This overrides and empties cameraRotation.
  43253. */
  43254. rotationQuaternion: Quaternion;
  43255. /**
  43256. * Track Roll to maintain the wanted Rolling when looking around.
  43257. */
  43258. _trackRoll: number;
  43259. /**
  43260. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43261. */
  43262. rollCorrect: number;
  43263. /**
  43264. * Mimic a banked turn, Rolling the camera when Yawing.
  43265. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43266. */
  43267. bankedTurn: boolean;
  43268. /**
  43269. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43270. */
  43271. bankedTurnLimit: number;
  43272. /**
  43273. * Value of 0 disables the banked Roll.
  43274. * Value of 1 is equal to the Yaw angle in radians.
  43275. */
  43276. bankedTurnMultiplier: number;
  43277. /**
  43278. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43279. */
  43280. inputs: FlyCameraInputsManager;
  43281. /**
  43282. * Gets the input sensibility for mouse input.
  43283. * Higher values reduce sensitivity.
  43284. */
  43285. get angularSensibility(): number;
  43286. /**
  43287. * Sets the input sensibility for a mouse input.
  43288. * Higher values reduce sensitivity.
  43289. */
  43290. set angularSensibility(value: number);
  43291. /**
  43292. * Get the keys for camera movement forward.
  43293. */
  43294. get keysForward(): number[];
  43295. /**
  43296. * Set the keys for camera movement forward.
  43297. */
  43298. set keysForward(value: number[]);
  43299. /**
  43300. * Get the keys for camera movement backward.
  43301. */
  43302. get keysBackward(): number[];
  43303. set keysBackward(value: number[]);
  43304. /**
  43305. * Get the keys for camera movement up.
  43306. */
  43307. get keysUp(): number[];
  43308. /**
  43309. * Set the keys for camera movement up.
  43310. */
  43311. set keysUp(value: number[]);
  43312. /**
  43313. * Get the keys for camera movement down.
  43314. */
  43315. get keysDown(): number[];
  43316. /**
  43317. * Set the keys for camera movement down.
  43318. */
  43319. set keysDown(value: number[]);
  43320. /**
  43321. * Get the keys for camera movement left.
  43322. */
  43323. get keysLeft(): number[];
  43324. /**
  43325. * Set the keys for camera movement left.
  43326. */
  43327. set keysLeft(value: number[]);
  43328. /**
  43329. * Set the keys for camera movement right.
  43330. */
  43331. get keysRight(): number[];
  43332. /**
  43333. * Set the keys for camera movement right.
  43334. */
  43335. set keysRight(value: number[]);
  43336. /**
  43337. * Event raised when the camera collides with a mesh in the scene.
  43338. */
  43339. onCollide: (collidedMesh: AbstractMesh) => void;
  43340. private _collider;
  43341. private _needMoveForGravity;
  43342. private _oldPosition;
  43343. private _diffPosition;
  43344. private _newPosition;
  43345. /** @hidden */
  43346. _localDirection: Vector3;
  43347. /** @hidden */
  43348. _transformedDirection: Vector3;
  43349. /**
  43350. * Instantiates a FlyCamera.
  43351. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43352. * such as in a 3D Space Shooter or a Flight Simulator.
  43353. * @param name Define the name of the camera in the scene.
  43354. * @param position Define the starting position of the camera in the scene.
  43355. * @param scene Define the scene the camera belongs to.
  43356. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43357. */
  43358. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43359. /**
  43360. * Attach a control to the HTML DOM element.
  43361. * @param element Defines the element that listens to the input events.
  43362. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43363. */
  43364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43365. /**
  43366. * Detach a control from the HTML DOM element.
  43367. * The camera will stop reacting to that input.
  43368. * @param element Defines the element that listens to the input events.
  43369. */
  43370. detachControl(element: HTMLElement): void;
  43371. private _collisionMask;
  43372. /**
  43373. * Get the mask that the camera ignores in collision events.
  43374. */
  43375. get collisionMask(): number;
  43376. /**
  43377. * Set the mask that the camera ignores in collision events.
  43378. */
  43379. set collisionMask(mask: number);
  43380. /** @hidden */
  43381. _collideWithWorld(displacement: Vector3): void;
  43382. /** @hidden */
  43383. private _onCollisionPositionChange;
  43384. /** @hidden */
  43385. _checkInputs(): void;
  43386. /** @hidden */
  43387. _decideIfNeedsToMove(): boolean;
  43388. /** @hidden */
  43389. _updatePosition(): void;
  43390. /**
  43391. * Restore the Roll to its target value at the rate specified.
  43392. * @param rate - Higher means slower restoring.
  43393. * @hidden
  43394. */
  43395. restoreRoll(rate: number): void;
  43396. /**
  43397. * Destroy the camera and release the current resources held by it.
  43398. */
  43399. dispose(): void;
  43400. /**
  43401. * Get the current object class name.
  43402. * @returns the class name.
  43403. */
  43404. getClassName(): string;
  43405. }
  43406. }
  43407. declare module BABYLON {
  43408. /**
  43409. * Listen to keyboard events to control the camera.
  43410. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43411. */
  43412. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43413. /**
  43414. * Defines the camera the input is attached to.
  43415. */
  43416. camera: FlyCamera;
  43417. /**
  43418. * The list of keyboard keys used to control the forward move of the camera.
  43419. */
  43420. keysForward: number[];
  43421. /**
  43422. * The list of keyboard keys used to control the backward move of the camera.
  43423. */
  43424. keysBackward: number[];
  43425. /**
  43426. * The list of keyboard keys used to control the forward move of the camera.
  43427. */
  43428. keysUp: number[];
  43429. /**
  43430. * The list of keyboard keys used to control the backward move of the camera.
  43431. */
  43432. keysDown: number[];
  43433. /**
  43434. * The list of keyboard keys used to control the right strafe move of the camera.
  43435. */
  43436. keysRight: number[];
  43437. /**
  43438. * The list of keyboard keys used to control the left strafe move of the camera.
  43439. */
  43440. keysLeft: number[];
  43441. private _keys;
  43442. private _onCanvasBlurObserver;
  43443. private _onKeyboardObserver;
  43444. private _engine;
  43445. private _scene;
  43446. /**
  43447. * Attach the input controls to a specific dom element to get the input from.
  43448. * @param element Defines the element the controls should be listened from
  43449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43450. */
  43451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43452. /**
  43453. * Detach the current controls from the specified dom element.
  43454. * @param element Defines the element to stop listening the inputs from
  43455. */
  43456. detachControl(element: Nullable<HTMLElement>): void;
  43457. /**
  43458. * Gets the class name of the current intput.
  43459. * @returns the class name
  43460. */
  43461. getClassName(): string;
  43462. /** @hidden */
  43463. _onLostFocus(e: FocusEvent): void;
  43464. /**
  43465. * Get the friendly name associated with the input class.
  43466. * @returns the input friendly name
  43467. */
  43468. getSimpleName(): string;
  43469. /**
  43470. * Update the current camera state depending on the inputs that have been used this frame.
  43471. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43472. */
  43473. checkInputs(): void;
  43474. }
  43475. }
  43476. declare module BABYLON {
  43477. /**
  43478. * Manage the mouse wheel inputs to control a follow camera.
  43479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43480. */
  43481. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43482. /**
  43483. * Defines the camera the input is attached to.
  43484. */
  43485. camera: FollowCamera;
  43486. /**
  43487. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43488. */
  43489. axisControlRadius: boolean;
  43490. /**
  43491. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43492. */
  43493. axisControlHeight: boolean;
  43494. /**
  43495. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43496. */
  43497. axisControlRotation: boolean;
  43498. /**
  43499. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43500. * relation to mouseWheel events.
  43501. */
  43502. wheelPrecision: number;
  43503. /**
  43504. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43505. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43506. */
  43507. wheelDeltaPercentage: number;
  43508. private _wheel;
  43509. private _observer;
  43510. /**
  43511. * Attach the input controls to a specific dom element to get the input from.
  43512. * @param element Defines the element the controls should be listened from
  43513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43514. */
  43515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43516. /**
  43517. * Detach the current controls from the specified dom element.
  43518. * @param element Defines the element to stop listening the inputs from
  43519. */
  43520. detachControl(element: Nullable<HTMLElement>): void;
  43521. /**
  43522. * Gets the class name of the current intput.
  43523. * @returns the class name
  43524. */
  43525. getClassName(): string;
  43526. /**
  43527. * Get the friendly name associated with the input class.
  43528. * @returns the input friendly name
  43529. */
  43530. getSimpleName(): string;
  43531. }
  43532. }
  43533. declare module BABYLON {
  43534. /**
  43535. * Manage the pointers inputs to control an follow camera.
  43536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43537. */
  43538. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43539. /**
  43540. * Defines the camera the input is attached to.
  43541. */
  43542. camera: FollowCamera;
  43543. /**
  43544. * Gets the class name of the current input.
  43545. * @returns the class name
  43546. */
  43547. getClassName(): string;
  43548. /**
  43549. * Defines the pointer angular sensibility along the X axis or how fast is
  43550. * the camera rotating.
  43551. * A negative number will reverse the axis direction.
  43552. */
  43553. angularSensibilityX: number;
  43554. /**
  43555. * Defines the pointer angular sensibility along the Y axis or how fast is
  43556. * the camera rotating.
  43557. * A negative number will reverse the axis direction.
  43558. */
  43559. angularSensibilityY: number;
  43560. /**
  43561. * Defines the pointer pinch precision or how fast is the camera zooming.
  43562. * A negative number will reverse the axis direction.
  43563. */
  43564. pinchPrecision: number;
  43565. /**
  43566. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43567. * from 0.
  43568. * It defines the percentage of current camera.radius to use as delta when
  43569. * pinch zoom is used.
  43570. */
  43571. pinchDeltaPercentage: number;
  43572. /**
  43573. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43574. */
  43575. axisXControlRadius: boolean;
  43576. /**
  43577. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43578. */
  43579. axisXControlHeight: boolean;
  43580. /**
  43581. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43582. */
  43583. axisXControlRotation: boolean;
  43584. /**
  43585. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43586. */
  43587. axisYControlRadius: boolean;
  43588. /**
  43589. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43590. */
  43591. axisYControlHeight: boolean;
  43592. /**
  43593. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43594. */
  43595. axisYControlRotation: boolean;
  43596. /**
  43597. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43598. */
  43599. axisPinchControlRadius: boolean;
  43600. /**
  43601. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43602. */
  43603. axisPinchControlHeight: boolean;
  43604. /**
  43605. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43606. */
  43607. axisPinchControlRotation: boolean;
  43608. /**
  43609. * Log error messages if basic misconfiguration has occurred.
  43610. */
  43611. warningEnable: boolean;
  43612. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43613. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43614. private _warningCounter;
  43615. private _warning;
  43616. }
  43617. }
  43618. declare module BABYLON {
  43619. /**
  43620. * Default Inputs manager for the FollowCamera.
  43621. * It groups all the default supported inputs for ease of use.
  43622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43623. */
  43624. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43625. /**
  43626. * Instantiates a new FollowCameraInputsManager.
  43627. * @param camera Defines the camera the inputs belong to
  43628. */
  43629. constructor(camera: FollowCamera);
  43630. /**
  43631. * Add keyboard input support to the input manager.
  43632. * @returns the current input manager
  43633. */
  43634. addKeyboard(): FollowCameraInputsManager;
  43635. /**
  43636. * Add mouse wheel input support to the input manager.
  43637. * @returns the current input manager
  43638. */
  43639. addMouseWheel(): FollowCameraInputsManager;
  43640. /**
  43641. * Add pointers input support to the input manager.
  43642. * @returns the current input manager
  43643. */
  43644. addPointers(): FollowCameraInputsManager;
  43645. /**
  43646. * Add orientation input support to the input manager.
  43647. * @returns the current input manager
  43648. */
  43649. addVRDeviceOrientation(): FollowCameraInputsManager;
  43650. }
  43651. }
  43652. declare module BABYLON {
  43653. /**
  43654. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43655. * an arc rotate version arcFollowCamera are available.
  43656. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43657. */
  43658. export class FollowCamera extends TargetCamera {
  43659. /**
  43660. * Distance the follow camera should follow an object at
  43661. */
  43662. radius: number;
  43663. /**
  43664. * Minimum allowed distance of the camera to the axis of rotation
  43665. * (The camera can not get closer).
  43666. * This can help limiting how the Camera is able to move in the scene.
  43667. */
  43668. lowerRadiusLimit: Nullable<number>;
  43669. /**
  43670. * Maximum allowed distance of the camera to the axis of rotation
  43671. * (The camera can not get further).
  43672. * This can help limiting how the Camera is able to move in the scene.
  43673. */
  43674. upperRadiusLimit: Nullable<number>;
  43675. /**
  43676. * Define a rotation offset between the camera and the object it follows
  43677. */
  43678. rotationOffset: number;
  43679. /**
  43680. * Minimum allowed angle to camera position relative to target object.
  43681. * This can help limiting how the Camera is able to move in the scene.
  43682. */
  43683. lowerRotationOffsetLimit: Nullable<number>;
  43684. /**
  43685. * Maximum allowed angle to camera position relative to target object.
  43686. * This can help limiting how the Camera is able to move in the scene.
  43687. */
  43688. upperRotationOffsetLimit: Nullable<number>;
  43689. /**
  43690. * Define a height offset between the camera and the object it follows.
  43691. * It can help following an object from the top (like a car chaing a plane)
  43692. */
  43693. heightOffset: number;
  43694. /**
  43695. * Minimum allowed height of camera position relative to target object.
  43696. * This can help limiting how the Camera is able to move in the scene.
  43697. */
  43698. lowerHeightOffsetLimit: Nullable<number>;
  43699. /**
  43700. * Maximum allowed height of camera position relative to target object.
  43701. * This can help limiting how the Camera is able to move in the scene.
  43702. */
  43703. upperHeightOffsetLimit: Nullable<number>;
  43704. /**
  43705. * Define how fast the camera can accelerate to follow it s target.
  43706. */
  43707. cameraAcceleration: number;
  43708. /**
  43709. * Define the speed limit of the camera following an object.
  43710. */
  43711. maxCameraSpeed: number;
  43712. /**
  43713. * Define the target of the camera.
  43714. */
  43715. lockedTarget: Nullable<AbstractMesh>;
  43716. /**
  43717. * Defines the input associated with the camera.
  43718. */
  43719. inputs: FollowCameraInputsManager;
  43720. /**
  43721. * Instantiates the follow camera.
  43722. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43723. * @param name Define the name of the camera in the scene
  43724. * @param position Define the position of the camera
  43725. * @param scene Define the scene the camera belong to
  43726. * @param lockedTarget Define the target of the camera
  43727. */
  43728. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43729. private _follow;
  43730. /**
  43731. * Attached controls to the current camera.
  43732. * @param element Defines the element the controls should be listened from
  43733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43734. */
  43735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43736. /**
  43737. * Detach the current controls from the camera.
  43738. * The camera will stop reacting to inputs.
  43739. * @param element Defines the element to stop listening the inputs from
  43740. */
  43741. detachControl(element: HTMLElement): void;
  43742. /** @hidden */
  43743. _checkInputs(): void;
  43744. private _checkLimits;
  43745. /**
  43746. * Gets the camera class name.
  43747. * @returns the class name
  43748. */
  43749. getClassName(): string;
  43750. }
  43751. /**
  43752. * Arc Rotate version of the follow camera.
  43753. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43754. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43755. */
  43756. export class ArcFollowCamera extends TargetCamera {
  43757. /** The longitudinal angle of the camera */
  43758. alpha: number;
  43759. /** The latitudinal angle of the camera */
  43760. beta: number;
  43761. /** The radius of the camera from its target */
  43762. radius: number;
  43763. /** Define the camera target (the mesh it should follow) */
  43764. target: Nullable<AbstractMesh>;
  43765. private _cartesianCoordinates;
  43766. /**
  43767. * Instantiates a new ArcFollowCamera
  43768. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43769. * @param name Define the name of the camera
  43770. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43771. * @param beta Define the rotation angle of the camera around the elevation axis
  43772. * @param radius Define the radius of the camera from its target point
  43773. * @param target Define the target of the camera
  43774. * @param scene Define the scene the camera belongs to
  43775. */
  43776. constructor(name: string,
  43777. /** The longitudinal angle of the camera */
  43778. alpha: number,
  43779. /** The latitudinal angle of the camera */
  43780. beta: number,
  43781. /** The radius of the camera from its target */
  43782. radius: number,
  43783. /** Define the camera target (the mesh it should follow) */
  43784. target: Nullable<AbstractMesh>, scene: Scene);
  43785. private _follow;
  43786. /** @hidden */
  43787. _checkInputs(): void;
  43788. /**
  43789. * Returns the class name of the object.
  43790. * It is mostly used internally for serialization purposes.
  43791. */
  43792. getClassName(): string;
  43793. }
  43794. }
  43795. declare module BABYLON {
  43796. /**
  43797. * Manage the keyboard inputs to control the movement of a follow camera.
  43798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43799. */
  43800. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43801. /**
  43802. * Defines the camera the input is attached to.
  43803. */
  43804. camera: FollowCamera;
  43805. /**
  43806. * Defines the list of key codes associated with the up action (increase heightOffset)
  43807. */
  43808. keysHeightOffsetIncr: number[];
  43809. /**
  43810. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43811. */
  43812. keysHeightOffsetDecr: number[];
  43813. /**
  43814. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43815. */
  43816. keysHeightOffsetModifierAlt: boolean;
  43817. /**
  43818. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43819. */
  43820. keysHeightOffsetModifierCtrl: boolean;
  43821. /**
  43822. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43823. */
  43824. keysHeightOffsetModifierShift: boolean;
  43825. /**
  43826. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43827. */
  43828. keysRotationOffsetIncr: number[];
  43829. /**
  43830. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43831. */
  43832. keysRotationOffsetDecr: number[];
  43833. /**
  43834. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43835. */
  43836. keysRotationOffsetModifierAlt: boolean;
  43837. /**
  43838. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43839. */
  43840. keysRotationOffsetModifierCtrl: boolean;
  43841. /**
  43842. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43843. */
  43844. keysRotationOffsetModifierShift: boolean;
  43845. /**
  43846. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43847. */
  43848. keysRadiusIncr: number[];
  43849. /**
  43850. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43851. */
  43852. keysRadiusDecr: number[];
  43853. /**
  43854. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43855. */
  43856. keysRadiusModifierAlt: boolean;
  43857. /**
  43858. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43859. */
  43860. keysRadiusModifierCtrl: boolean;
  43861. /**
  43862. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43863. */
  43864. keysRadiusModifierShift: boolean;
  43865. /**
  43866. * Defines the rate of change of heightOffset.
  43867. */
  43868. heightSensibility: number;
  43869. /**
  43870. * Defines the rate of change of rotationOffset.
  43871. */
  43872. rotationSensibility: number;
  43873. /**
  43874. * Defines the rate of change of radius.
  43875. */
  43876. radiusSensibility: number;
  43877. private _keys;
  43878. private _ctrlPressed;
  43879. private _altPressed;
  43880. private _shiftPressed;
  43881. private _onCanvasBlurObserver;
  43882. private _onKeyboardObserver;
  43883. private _engine;
  43884. private _scene;
  43885. /**
  43886. * Attach the input controls to a specific dom element to get the input from.
  43887. * @param element Defines the element the controls should be listened from
  43888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43889. */
  43890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43891. /**
  43892. * Detach the current controls from the specified dom element.
  43893. * @param element Defines the element to stop listening the inputs from
  43894. */
  43895. detachControl(element: Nullable<HTMLElement>): void;
  43896. /**
  43897. * Update the current camera state depending on the inputs that have been used this frame.
  43898. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43899. */
  43900. checkInputs(): void;
  43901. /**
  43902. * Gets the class name of the current input.
  43903. * @returns the class name
  43904. */
  43905. getClassName(): string;
  43906. /**
  43907. * Get the friendly name associated with the input class.
  43908. * @returns the input friendly name
  43909. */
  43910. getSimpleName(): string;
  43911. /**
  43912. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43913. * allow modification of the heightOffset value.
  43914. */
  43915. private _modifierHeightOffset;
  43916. /**
  43917. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43918. * allow modification of the rotationOffset value.
  43919. */
  43920. private _modifierRotationOffset;
  43921. /**
  43922. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43923. * allow modification of the radius value.
  43924. */
  43925. private _modifierRadius;
  43926. }
  43927. }
  43928. declare module BABYLON {
  43929. interface FreeCameraInputsManager {
  43930. /**
  43931. * @hidden
  43932. */
  43933. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43934. /**
  43935. * Add orientation input support to the input manager.
  43936. * @returns the current input manager
  43937. */
  43938. addDeviceOrientation(): FreeCameraInputsManager;
  43939. }
  43940. /**
  43941. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43942. * Screen rotation is taken into account.
  43943. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43944. */
  43945. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43946. private _camera;
  43947. private _screenOrientationAngle;
  43948. private _constantTranform;
  43949. private _screenQuaternion;
  43950. private _alpha;
  43951. private _beta;
  43952. private _gamma;
  43953. /**
  43954. * Can be used to detect if a device orientation sensor is available on a device
  43955. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43956. * @returns a promise that will resolve on orientation change
  43957. */
  43958. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43959. /**
  43960. * @hidden
  43961. */
  43962. _onDeviceOrientationChangedObservable: Observable<void>;
  43963. /**
  43964. * Instantiates a new input
  43965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43966. */
  43967. constructor();
  43968. /**
  43969. * Define the camera controlled by the input.
  43970. */
  43971. get camera(): FreeCamera;
  43972. set camera(camera: FreeCamera);
  43973. /**
  43974. * Attach the input controls to a specific dom element to get the input from.
  43975. * @param element Defines the element the controls should be listened from
  43976. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43977. */
  43978. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43979. private _orientationChanged;
  43980. private _deviceOrientation;
  43981. /**
  43982. * Detach the current controls from the specified dom element.
  43983. * @param element Defines the element to stop listening the inputs from
  43984. */
  43985. detachControl(element: Nullable<HTMLElement>): void;
  43986. /**
  43987. * Update the current camera state depending on the inputs that have been used this frame.
  43988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43989. */
  43990. checkInputs(): void;
  43991. /**
  43992. * Gets the class name of the current intput.
  43993. * @returns the class name
  43994. */
  43995. getClassName(): string;
  43996. /**
  43997. * Get the friendly name associated with the input class.
  43998. * @returns the input friendly name
  43999. */
  44000. getSimpleName(): string;
  44001. }
  44002. }
  44003. declare module BABYLON {
  44004. /**
  44005. * Manage the gamepad inputs to control a free camera.
  44006. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44007. */
  44008. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44009. /**
  44010. * Define the camera the input is attached to.
  44011. */
  44012. camera: FreeCamera;
  44013. /**
  44014. * Define the Gamepad controlling the input
  44015. */
  44016. gamepad: Nullable<Gamepad>;
  44017. /**
  44018. * Defines the gamepad rotation sensiblity.
  44019. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44020. */
  44021. gamepadAngularSensibility: number;
  44022. /**
  44023. * Defines the gamepad move sensiblity.
  44024. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44025. */
  44026. gamepadMoveSensibility: number;
  44027. private _yAxisScale;
  44028. /**
  44029. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44030. */
  44031. get invertYAxis(): boolean;
  44032. set invertYAxis(value: boolean);
  44033. private _onGamepadConnectedObserver;
  44034. private _onGamepadDisconnectedObserver;
  44035. private _cameraTransform;
  44036. private _deltaTransform;
  44037. private _vector3;
  44038. private _vector2;
  44039. /**
  44040. * Attach the input controls to a specific dom element to get the input from.
  44041. * @param element Defines the element the controls should be listened from
  44042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44043. */
  44044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44045. /**
  44046. * Detach the current controls from the specified dom element.
  44047. * @param element Defines the element to stop listening the inputs from
  44048. */
  44049. detachControl(element: Nullable<HTMLElement>): void;
  44050. /**
  44051. * Update the current camera state depending on the inputs that have been used this frame.
  44052. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44053. */
  44054. checkInputs(): void;
  44055. /**
  44056. * Gets the class name of the current intput.
  44057. * @returns the class name
  44058. */
  44059. getClassName(): string;
  44060. /**
  44061. * Get the friendly name associated with the input class.
  44062. * @returns the input friendly name
  44063. */
  44064. getSimpleName(): string;
  44065. }
  44066. }
  44067. declare module BABYLON {
  44068. /**
  44069. * Defines the potential axis of a Joystick
  44070. */
  44071. export enum JoystickAxis {
  44072. /** X axis */
  44073. X = 0,
  44074. /** Y axis */
  44075. Y = 1,
  44076. /** Z axis */
  44077. Z = 2
  44078. }
  44079. /**
  44080. * Class used to define virtual joystick (used in touch mode)
  44081. */
  44082. export class VirtualJoystick {
  44083. /**
  44084. * Gets or sets a boolean indicating that left and right values must be inverted
  44085. */
  44086. reverseLeftRight: boolean;
  44087. /**
  44088. * Gets or sets a boolean indicating that up and down values must be inverted
  44089. */
  44090. reverseUpDown: boolean;
  44091. /**
  44092. * Gets the offset value for the position (ie. the change of the position value)
  44093. */
  44094. deltaPosition: Vector3;
  44095. /**
  44096. * Gets a boolean indicating if the virtual joystick was pressed
  44097. */
  44098. pressed: boolean;
  44099. /**
  44100. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44101. */
  44102. static Canvas: Nullable<HTMLCanvasElement>;
  44103. private static _globalJoystickIndex;
  44104. private static vjCanvasContext;
  44105. private static vjCanvasWidth;
  44106. private static vjCanvasHeight;
  44107. private static halfWidth;
  44108. private _action;
  44109. private _axisTargetedByLeftAndRight;
  44110. private _axisTargetedByUpAndDown;
  44111. private _joystickSensibility;
  44112. private _inversedSensibility;
  44113. private _joystickPointerID;
  44114. private _joystickColor;
  44115. private _joystickPointerPos;
  44116. private _joystickPreviousPointerPos;
  44117. private _joystickPointerStartPos;
  44118. private _deltaJoystickVector;
  44119. private _leftJoystick;
  44120. private _touches;
  44121. private _onPointerDownHandlerRef;
  44122. private _onPointerMoveHandlerRef;
  44123. private _onPointerUpHandlerRef;
  44124. private _onResize;
  44125. /**
  44126. * Creates a new virtual joystick
  44127. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44128. */
  44129. constructor(leftJoystick?: boolean);
  44130. /**
  44131. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44132. * @param newJoystickSensibility defines the new sensibility
  44133. */
  44134. setJoystickSensibility(newJoystickSensibility: number): void;
  44135. private _onPointerDown;
  44136. private _onPointerMove;
  44137. private _onPointerUp;
  44138. /**
  44139. * Change the color of the virtual joystick
  44140. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44141. */
  44142. setJoystickColor(newColor: string): void;
  44143. /**
  44144. * Defines a callback to call when the joystick is touched
  44145. * @param action defines the callback
  44146. */
  44147. setActionOnTouch(action: () => any): void;
  44148. /**
  44149. * Defines which axis you'd like to control for left & right
  44150. * @param axis defines the axis to use
  44151. */
  44152. setAxisForLeftRight(axis: JoystickAxis): void;
  44153. /**
  44154. * Defines which axis you'd like to control for up & down
  44155. * @param axis defines the axis to use
  44156. */
  44157. setAxisForUpDown(axis: JoystickAxis): void;
  44158. private _drawVirtualJoystick;
  44159. /**
  44160. * Release internal HTML canvas
  44161. */
  44162. releaseCanvas(): void;
  44163. }
  44164. }
  44165. declare module BABYLON {
  44166. interface FreeCameraInputsManager {
  44167. /**
  44168. * Add virtual joystick input support to the input manager.
  44169. * @returns the current input manager
  44170. */
  44171. addVirtualJoystick(): FreeCameraInputsManager;
  44172. }
  44173. /**
  44174. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44176. */
  44177. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44178. /**
  44179. * Defines the camera the input is attached to.
  44180. */
  44181. camera: FreeCamera;
  44182. private _leftjoystick;
  44183. private _rightjoystick;
  44184. /**
  44185. * Gets the left stick of the virtual joystick.
  44186. * @returns The virtual Joystick
  44187. */
  44188. getLeftJoystick(): VirtualJoystick;
  44189. /**
  44190. * Gets the right stick of the virtual joystick.
  44191. * @returns The virtual Joystick
  44192. */
  44193. getRightJoystick(): VirtualJoystick;
  44194. /**
  44195. * Update the current camera state depending on the inputs that have been used this frame.
  44196. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44197. */
  44198. checkInputs(): void;
  44199. /**
  44200. * Attach the input controls to a specific dom element to get the input from.
  44201. * @param element Defines the element the controls should be listened from
  44202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44203. */
  44204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44205. /**
  44206. * Detach the current controls from the specified dom element.
  44207. * @param element Defines the element to stop listening the inputs from
  44208. */
  44209. detachControl(element: Nullable<HTMLElement>): void;
  44210. /**
  44211. * Gets the class name of the current intput.
  44212. * @returns the class name
  44213. */
  44214. getClassName(): string;
  44215. /**
  44216. * Get the friendly name associated with the input class.
  44217. * @returns the input friendly name
  44218. */
  44219. getSimpleName(): string;
  44220. }
  44221. }
  44222. declare module BABYLON {
  44223. /**
  44224. * This represents a FPS type of camera controlled by touch.
  44225. * This is like a universal camera minus the Gamepad controls.
  44226. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44227. */
  44228. export class TouchCamera extends FreeCamera {
  44229. /**
  44230. * Defines the touch sensibility for rotation.
  44231. * The higher the faster.
  44232. */
  44233. get touchAngularSensibility(): number;
  44234. set touchAngularSensibility(value: number);
  44235. /**
  44236. * Defines the touch sensibility for move.
  44237. * The higher the faster.
  44238. */
  44239. get touchMoveSensibility(): number;
  44240. set touchMoveSensibility(value: number);
  44241. /**
  44242. * Instantiates a new touch camera.
  44243. * This represents a FPS type of camera controlled by touch.
  44244. * This is like a universal camera minus the Gamepad controls.
  44245. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44246. * @param name Define the name of the camera in the scene
  44247. * @param position Define the start position of the camera in the scene
  44248. * @param scene Define the scene the camera belongs to
  44249. */
  44250. constructor(name: string, position: Vector3, scene: Scene);
  44251. /**
  44252. * Gets the current object class name.
  44253. * @return the class name
  44254. */
  44255. getClassName(): string;
  44256. /** @hidden */
  44257. _setupInputs(): void;
  44258. }
  44259. }
  44260. declare module BABYLON {
  44261. /**
  44262. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44263. * being tilted forward or back and left or right.
  44264. */
  44265. export class DeviceOrientationCamera extends FreeCamera {
  44266. private _initialQuaternion;
  44267. private _quaternionCache;
  44268. private _tmpDragQuaternion;
  44269. private _disablePointerInputWhenUsingDeviceOrientation;
  44270. /**
  44271. * Creates a new device orientation camera
  44272. * @param name The name of the camera
  44273. * @param position The start position camera
  44274. * @param scene The scene the camera belongs to
  44275. */
  44276. constructor(name: string, position: Vector3, scene: Scene);
  44277. /**
  44278. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44279. */
  44280. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44281. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44282. private _dragFactor;
  44283. /**
  44284. * Enabled turning on the y axis when the orientation sensor is active
  44285. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44286. */
  44287. enableHorizontalDragging(dragFactor?: number): void;
  44288. /**
  44289. * Gets the current instance class name ("DeviceOrientationCamera").
  44290. * This helps avoiding instanceof at run time.
  44291. * @returns the class name
  44292. */
  44293. getClassName(): string;
  44294. /**
  44295. * @hidden
  44296. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44297. */
  44298. _checkInputs(): void;
  44299. /**
  44300. * Reset the camera to its default orientation on the specified axis only.
  44301. * @param axis The axis to reset
  44302. */
  44303. resetToCurrentRotation(axis?: Axis): void;
  44304. }
  44305. }
  44306. declare module BABYLON {
  44307. /**
  44308. * Defines supported buttons for XBox360 compatible gamepads
  44309. */
  44310. export enum Xbox360Button {
  44311. /** A */
  44312. A = 0,
  44313. /** B */
  44314. B = 1,
  44315. /** X */
  44316. X = 2,
  44317. /** Y */
  44318. Y = 3,
  44319. /** Left button */
  44320. LB = 4,
  44321. /** Right button */
  44322. RB = 5,
  44323. /** Back */
  44324. Back = 8,
  44325. /** Start */
  44326. Start = 9,
  44327. /** Left stick */
  44328. LeftStick = 10,
  44329. /** Right stick */
  44330. RightStick = 11
  44331. }
  44332. /** Defines values for XBox360 DPad */
  44333. export enum Xbox360Dpad {
  44334. /** Up */
  44335. Up = 12,
  44336. /** Down */
  44337. Down = 13,
  44338. /** Left */
  44339. Left = 14,
  44340. /** Right */
  44341. Right = 15
  44342. }
  44343. /**
  44344. * Defines a XBox360 gamepad
  44345. */
  44346. export class Xbox360Pad extends Gamepad {
  44347. private _leftTrigger;
  44348. private _rightTrigger;
  44349. private _onlefttriggerchanged;
  44350. private _onrighttriggerchanged;
  44351. private _onbuttondown;
  44352. private _onbuttonup;
  44353. private _ondpaddown;
  44354. private _ondpadup;
  44355. /** Observable raised when a button is pressed */
  44356. onButtonDownObservable: Observable<Xbox360Button>;
  44357. /** Observable raised when a button is released */
  44358. onButtonUpObservable: Observable<Xbox360Button>;
  44359. /** Observable raised when a pad is pressed */
  44360. onPadDownObservable: Observable<Xbox360Dpad>;
  44361. /** Observable raised when a pad is released */
  44362. onPadUpObservable: Observable<Xbox360Dpad>;
  44363. private _buttonA;
  44364. private _buttonB;
  44365. private _buttonX;
  44366. private _buttonY;
  44367. private _buttonBack;
  44368. private _buttonStart;
  44369. private _buttonLB;
  44370. private _buttonRB;
  44371. private _buttonLeftStick;
  44372. private _buttonRightStick;
  44373. private _dPadUp;
  44374. private _dPadDown;
  44375. private _dPadLeft;
  44376. private _dPadRight;
  44377. private _isXboxOnePad;
  44378. /**
  44379. * Creates a new XBox360 gamepad object
  44380. * @param id defines the id of this gamepad
  44381. * @param index defines its index
  44382. * @param gamepad defines the internal HTML gamepad object
  44383. * @param xboxOne defines if it is a XBox One gamepad
  44384. */
  44385. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44386. /**
  44387. * Defines the callback to call when left trigger is pressed
  44388. * @param callback defines the callback to use
  44389. */
  44390. onlefttriggerchanged(callback: (value: number) => void): void;
  44391. /**
  44392. * Defines the callback to call when right trigger is pressed
  44393. * @param callback defines the callback to use
  44394. */
  44395. onrighttriggerchanged(callback: (value: number) => void): void;
  44396. /**
  44397. * Gets the left trigger value
  44398. */
  44399. get leftTrigger(): number;
  44400. /**
  44401. * Sets the left trigger value
  44402. */
  44403. set leftTrigger(newValue: number);
  44404. /**
  44405. * Gets the right trigger value
  44406. */
  44407. get rightTrigger(): number;
  44408. /**
  44409. * Sets the right trigger value
  44410. */
  44411. set rightTrigger(newValue: number);
  44412. /**
  44413. * Defines the callback to call when a button is pressed
  44414. * @param callback defines the callback to use
  44415. */
  44416. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44417. /**
  44418. * Defines the callback to call when a button is released
  44419. * @param callback defines the callback to use
  44420. */
  44421. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44422. /**
  44423. * Defines the callback to call when a pad is pressed
  44424. * @param callback defines the callback to use
  44425. */
  44426. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44427. /**
  44428. * Defines the callback to call when a pad is released
  44429. * @param callback defines the callback to use
  44430. */
  44431. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44432. private _setButtonValue;
  44433. private _setDPadValue;
  44434. /**
  44435. * Gets the value of the `A` button
  44436. */
  44437. get buttonA(): number;
  44438. /**
  44439. * Sets the value of the `A` button
  44440. */
  44441. set buttonA(value: number);
  44442. /**
  44443. * Gets the value of the `B` button
  44444. */
  44445. get buttonB(): number;
  44446. /**
  44447. * Sets the value of the `B` button
  44448. */
  44449. set buttonB(value: number);
  44450. /**
  44451. * Gets the value of the `X` button
  44452. */
  44453. get buttonX(): number;
  44454. /**
  44455. * Sets the value of the `X` button
  44456. */
  44457. set buttonX(value: number);
  44458. /**
  44459. * Gets the value of the `Y` button
  44460. */
  44461. get buttonY(): number;
  44462. /**
  44463. * Sets the value of the `Y` button
  44464. */
  44465. set buttonY(value: number);
  44466. /**
  44467. * Gets the value of the `Start` button
  44468. */
  44469. get buttonStart(): number;
  44470. /**
  44471. * Sets the value of the `Start` button
  44472. */
  44473. set buttonStart(value: number);
  44474. /**
  44475. * Gets the value of the `Back` button
  44476. */
  44477. get buttonBack(): number;
  44478. /**
  44479. * Sets the value of the `Back` button
  44480. */
  44481. set buttonBack(value: number);
  44482. /**
  44483. * Gets the value of the `Left` button
  44484. */
  44485. get buttonLB(): number;
  44486. /**
  44487. * Sets the value of the `Left` button
  44488. */
  44489. set buttonLB(value: number);
  44490. /**
  44491. * Gets the value of the `Right` button
  44492. */
  44493. get buttonRB(): number;
  44494. /**
  44495. * Sets the value of the `Right` button
  44496. */
  44497. set buttonRB(value: number);
  44498. /**
  44499. * Gets the value of the Left joystick
  44500. */
  44501. get buttonLeftStick(): number;
  44502. /**
  44503. * Sets the value of the Left joystick
  44504. */
  44505. set buttonLeftStick(value: number);
  44506. /**
  44507. * Gets the value of the Right joystick
  44508. */
  44509. get buttonRightStick(): number;
  44510. /**
  44511. * Sets the value of the Right joystick
  44512. */
  44513. set buttonRightStick(value: number);
  44514. /**
  44515. * Gets the value of D-pad up
  44516. */
  44517. get dPadUp(): number;
  44518. /**
  44519. * Sets the value of D-pad up
  44520. */
  44521. set dPadUp(value: number);
  44522. /**
  44523. * Gets the value of D-pad down
  44524. */
  44525. get dPadDown(): number;
  44526. /**
  44527. * Sets the value of D-pad down
  44528. */
  44529. set dPadDown(value: number);
  44530. /**
  44531. * Gets the value of D-pad left
  44532. */
  44533. get dPadLeft(): number;
  44534. /**
  44535. * Sets the value of D-pad left
  44536. */
  44537. set dPadLeft(value: number);
  44538. /**
  44539. * Gets the value of D-pad right
  44540. */
  44541. get dPadRight(): number;
  44542. /**
  44543. * Sets the value of D-pad right
  44544. */
  44545. set dPadRight(value: number);
  44546. /**
  44547. * Force the gamepad to synchronize with device values
  44548. */
  44549. update(): void;
  44550. /**
  44551. * Disposes the gamepad
  44552. */
  44553. dispose(): void;
  44554. }
  44555. }
  44556. declare module BABYLON {
  44557. /**
  44558. * Defines supported buttons for DualShock compatible gamepads
  44559. */
  44560. export enum DualShockButton {
  44561. /** Cross */
  44562. Cross = 0,
  44563. /** Circle */
  44564. Circle = 1,
  44565. /** Square */
  44566. Square = 2,
  44567. /** Triangle */
  44568. Triangle = 3,
  44569. /** L1 */
  44570. L1 = 4,
  44571. /** R1 */
  44572. R1 = 5,
  44573. /** Share */
  44574. Share = 8,
  44575. /** Options */
  44576. Options = 9,
  44577. /** Left stick */
  44578. LeftStick = 10,
  44579. /** Right stick */
  44580. RightStick = 11
  44581. }
  44582. /** Defines values for DualShock DPad */
  44583. export enum DualShockDpad {
  44584. /** Up */
  44585. Up = 12,
  44586. /** Down */
  44587. Down = 13,
  44588. /** Left */
  44589. Left = 14,
  44590. /** Right */
  44591. Right = 15
  44592. }
  44593. /**
  44594. * Defines a DualShock gamepad
  44595. */
  44596. export class DualShockPad extends Gamepad {
  44597. private _leftTrigger;
  44598. private _rightTrigger;
  44599. private _onlefttriggerchanged;
  44600. private _onrighttriggerchanged;
  44601. private _onbuttondown;
  44602. private _onbuttonup;
  44603. private _ondpaddown;
  44604. private _ondpadup;
  44605. /** Observable raised when a button is pressed */
  44606. onButtonDownObservable: Observable<DualShockButton>;
  44607. /** Observable raised when a button is released */
  44608. onButtonUpObservable: Observable<DualShockButton>;
  44609. /** Observable raised when a pad is pressed */
  44610. onPadDownObservable: Observable<DualShockDpad>;
  44611. /** Observable raised when a pad is released */
  44612. onPadUpObservable: Observable<DualShockDpad>;
  44613. private _buttonCross;
  44614. private _buttonCircle;
  44615. private _buttonSquare;
  44616. private _buttonTriangle;
  44617. private _buttonShare;
  44618. private _buttonOptions;
  44619. private _buttonL1;
  44620. private _buttonR1;
  44621. private _buttonLeftStick;
  44622. private _buttonRightStick;
  44623. private _dPadUp;
  44624. private _dPadDown;
  44625. private _dPadLeft;
  44626. private _dPadRight;
  44627. /**
  44628. * Creates a new DualShock gamepad object
  44629. * @param id defines the id of this gamepad
  44630. * @param index defines its index
  44631. * @param gamepad defines the internal HTML gamepad object
  44632. */
  44633. constructor(id: string, index: number, gamepad: any);
  44634. /**
  44635. * Defines the callback to call when left trigger is pressed
  44636. * @param callback defines the callback to use
  44637. */
  44638. onlefttriggerchanged(callback: (value: number) => void): void;
  44639. /**
  44640. * Defines the callback to call when right trigger is pressed
  44641. * @param callback defines the callback to use
  44642. */
  44643. onrighttriggerchanged(callback: (value: number) => void): void;
  44644. /**
  44645. * Gets the left trigger value
  44646. */
  44647. get leftTrigger(): number;
  44648. /**
  44649. * Sets the left trigger value
  44650. */
  44651. set leftTrigger(newValue: number);
  44652. /**
  44653. * Gets the right trigger value
  44654. */
  44655. get rightTrigger(): number;
  44656. /**
  44657. * Sets the right trigger value
  44658. */
  44659. set rightTrigger(newValue: number);
  44660. /**
  44661. * Defines the callback to call when a button is pressed
  44662. * @param callback defines the callback to use
  44663. */
  44664. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44665. /**
  44666. * Defines the callback to call when a button is released
  44667. * @param callback defines the callback to use
  44668. */
  44669. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44670. /**
  44671. * Defines the callback to call when a pad is pressed
  44672. * @param callback defines the callback to use
  44673. */
  44674. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44675. /**
  44676. * Defines the callback to call when a pad is released
  44677. * @param callback defines the callback to use
  44678. */
  44679. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44680. private _setButtonValue;
  44681. private _setDPadValue;
  44682. /**
  44683. * Gets the value of the `Cross` button
  44684. */
  44685. get buttonCross(): number;
  44686. /**
  44687. * Sets the value of the `Cross` button
  44688. */
  44689. set buttonCross(value: number);
  44690. /**
  44691. * Gets the value of the `Circle` button
  44692. */
  44693. get buttonCircle(): number;
  44694. /**
  44695. * Sets the value of the `Circle` button
  44696. */
  44697. set buttonCircle(value: number);
  44698. /**
  44699. * Gets the value of the `Square` button
  44700. */
  44701. get buttonSquare(): number;
  44702. /**
  44703. * Sets the value of the `Square` button
  44704. */
  44705. set buttonSquare(value: number);
  44706. /**
  44707. * Gets the value of the `Triangle` button
  44708. */
  44709. get buttonTriangle(): number;
  44710. /**
  44711. * Sets the value of the `Triangle` button
  44712. */
  44713. set buttonTriangle(value: number);
  44714. /**
  44715. * Gets the value of the `Options` button
  44716. */
  44717. get buttonOptions(): number;
  44718. /**
  44719. * Sets the value of the `Options` button
  44720. */
  44721. set buttonOptions(value: number);
  44722. /**
  44723. * Gets the value of the `Share` button
  44724. */
  44725. get buttonShare(): number;
  44726. /**
  44727. * Sets the value of the `Share` button
  44728. */
  44729. set buttonShare(value: number);
  44730. /**
  44731. * Gets the value of the `L1` button
  44732. */
  44733. get buttonL1(): number;
  44734. /**
  44735. * Sets the value of the `L1` button
  44736. */
  44737. set buttonL1(value: number);
  44738. /**
  44739. * Gets the value of the `R1` button
  44740. */
  44741. get buttonR1(): number;
  44742. /**
  44743. * Sets the value of the `R1` button
  44744. */
  44745. set buttonR1(value: number);
  44746. /**
  44747. * Gets the value of the Left joystick
  44748. */
  44749. get buttonLeftStick(): number;
  44750. /**
  44751. * Sets the value of the Left joystick
  44752. */
  44753. set buttonLeftStick(value: number);
  44754. /**
  44755. * Gets the value of the Right joystick
  44756. */
  44757. get buttonRightStick(): number;
  44758. /**
  44759. * Sets the value of the Right joystick
  44760. */
  44761. set buttonRightStick(value: number);
  44762. /**
  44763. * Gets the value of D-pad up
  44764. */
  44765. get dPadUp(): number;
  44766. /**
  44767. * Sets the value of D-pad up
  44768. */
  44769. set dPadUp(value: number);
  44770. /**
  44771. * Gets the value of D-pad down
  44772. */
  44773. get dPadDown(): number;
  44774. /**
  44775. * Sets the value of D-pad down
  44776. */
  44777. set dPadDown(value: number);
  44778. /**
  44779. * Gets the value of D-pad left
  44780. */
  44781. get dPadLeft(): number;
  44782. /**
  44783. * Sets the value of D-pad left
  44784. */
  44785. set dPadLeft(value: number);
  44786. /**
  44787. * Gets the value of D-pad right
  44788. */
  44789. get dPadRight(): number;
  44790. /**
  44791. * Sets the value of D-pad right
  44792. */
  44793. set dPadRight(value: number);
  44794. /**
  44795. * Force the gamepad to synchronize with device values
  44796. */
  44797. update(): void;
  44798. /**
  44799. * Disposes the gamepad
  44800. */
  44801. dispose(): void;
  44802. }
  44803. }
  44804. declare module BABYLON {
  44805. /**
  44806. * Manager for handling gamepads
  44807. */
  44808. export class GamepadManager {
  44809. private _scene?;
  44810. private _babylonGamepads;
  44811. private _oneGamepadConnected;
  44812. /** @hidden */
  44813. _isMonitoring: boolean;
  44814. private _gamepadEventSupported;
  44815. private _gamepadSupport?;
  44816. /**
  44817. * observable to be triggered when the gamepad controller has been connected
  44818. */
  44819. onGamepadConnectedObservable: Observable<Gamepad>;
  44820. /**
  44821. * observable to be triggered when the gamepad controller has been disconnected
  44822. */
  44823. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44824. private _onGamepadConnectedEvent;
  44825. private _onGamepadDisconnectedEvent;
  44826. /**
  44827. * Initializes the gamepad manager
  44828. * @param _scene BabylonJS scene
  44829. */
  44830. constructor(_scene?: Scene | undefined);
  44831. /**
  44832. * The gamepads in the game pad manager
  44833. */
  44834. get gamepads(): Gamepad[];
  44835. /**
  44836. * Get the gamepad controllers based on type
  44837. * @param type The type of gamepad controller
  44838. * @returns Nullable gamepad
  44839. */
  44840. getGamepadByType(type?: number): Nullable<Gamepad>;
  44841. /**
  44842. * Disposes the gamepad manager
  44843. */
  44844. dispose(): void;
  44845. private _addNewGamepad;
  44846. private _startMonitoringGamepads;
  44847. private _stopMonitoringGamepads;
  44848. /** @hidden */
  44849. _checkGamepadsStatus(): void;
  44850. private _updateGamepadObjects;
  44851. }
  44852. }
  44853. declare module BABYLON {
  44854. interface Scene {
  44855. /** @hidden */
  44856. _gamepadManager: Nullable<GamepadManager>;
  44857. /**
  44858. * Gets the gamepad manager associated with the scene
  44859. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44860. */
  44861. gamepadManager: GamepadManager;
  44862. }
  44863. /**
  44864. * Interface representing a free camera inputs manager
  44865. */
  44866. interface FreeCameraInputsManager {
  44867. /**
  44868. * Adds gamepad input support to the FreeCameraInputsManager.
  44869. * @returns the FreeCameraInputsManager
  44870. */
  44871. addGamepad(): FreeCameraInputsManager;
  44872. }
  44873. /**
  44874. * Interface representing an arc rotate camera inputs manager
  44875. */
  44876. interface ArcRotateCameraInputsManager {
  44877. /**
  44878. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44879. * @returns the camera inputs manager
  44880. */
  44881. addGamepad(): ArcRotateCameraInputsManager;
  44882. }
  44883. /**
  44884. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44885. */
  44886. export class GamepadSystemSceneComponent implements ISceneComponent {
  44887. /**
  44888. * The component name helpfull to identify the component in the list of scene components.
  44889. */
  44890. readonly name: string;
  44891. /**
  44892. * The scene the component belongs to.
  44893. */
  44894. scene: Scene;
  44895. /**
  44896. * Creates a new instance of the component for the given scene
  44897. * @param scene Defines the scene to register the component in
  44898. */
  44899. constructor(scene: Scene);
  44900. /**
  44901. * Registers the component in a given scene
  44902. */
  44903. register(): void;
  44904. /**
  44905. * Rebuilds the elements related to this component in case of
  44906. * context lost for instance.
  44907. */
  44908. rebuild(): void;
  44909. /**
  44910. * Disposes the component and the associated ressources
  44911. */
  44912. dispose(): void;
  44913. private _beforeCameraUpdate;
  44914. }
  44915. }
  44916. declare module BABYLON {
  44917. /**
  44918. * 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,
  44919. * which still works and will still be found in many Playgrounds.
  44920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44921. */
  44922. export class UniversalCamera extends TouchCamera {
  44923. /**
  44924. * Defines the gamepad rotation sensiblity.
  44925. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44926. */
  44927. get gamepadAngularSensibility(): number;
  44928. set gamepadAngularSensibility(value: number);
  44929. /**
  44930. * Defines the gamepad move sensiblity.
  44931. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44932. */
  44933. get gamepadMoveSensibility(): number;
  44934. set gamepadMoveSensibility(value: number);
  44935. /**
  44936. * 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,
  44937. * which still works and will still be found in many Playgrounds.
  44938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44939. * @param name Define the name of the camera in the scene
  44940. * @param position Define the start position of the camera in the scene
  44941. * @param scene Define the scene the camera belongs to
  44942. */
  44943. constructor(name: string, position: Vector3, scene: Scene);
  44944. /**
  44945. * Gets the current object class name.
  44946. * @return the class name
  44947. */
  44948. getClassName(): string;
  44949. }
  44950. }
  44951. declare module BABYLON {
  44952. /**
  44953. * This represents a FPS type of camera. This is only here for back compat purpose.
  44954. * Please use the UniversalCamera instead as both are identical.
  44955. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44956. */
  44957. export class GamepadCamera extends UniversalCamera {
  44958. /**
  44959. * Instantiates a new Gamepad Camera
  44960. * This represents a FPS type of camera. This is only here for back compat purpose.
  44961. * Please use the UniversalCamera instead as both are identical.
  44962. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44963. * @param name Define the name of the camera in the scene
  44964. * @param position Define the start position of the camera in the scene
  44965. * @param scene Define the scene the camera belongs to
  44966. */
  44967. constructor(name: string, position: Vector3, scene: Scene);
  44968. /**
  44969. * Gets the current object class name.
  44970. * @return the class name
  44971. */
  44972. getClassName(): string;
  44973. }
  44974. }
  44975. declare module BABYLON {
  44976. /** @hidden */
  44977. export var passPixelShader: {
  44978. name: string;
  44979. shader: string;
  44980. };
  44981. }
  44982. declare module BABYLON {
  44983. /** @hidden */
  44984. export var passCubePixelShader: {
  44985. name: string;
  44986. shader: string;
  44987. };
  44988. }
  44989. declare module BABYLON {
  44990. /**
  44991. * PassPostProcess which produces an output the same as it's input
  44992. */
  44993. export class PassPostProcess extends PostProcess {
  44994. /**
  44995. * Creates the PassPostProcess
  44996. * @param name The name of the effect.
  44997. * @param options The required width/height ratio to downsize to before computing the render pass.
  44998. * @param camera The camera to apply the render pass to.
  44999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45000. * @param engine The engine which the post process will be applied. (default: current engine)
  45001. * @param reusable If the post process can be reused on the same frame. (default: false)
  45002. * @param textureType The type of texture to be used when performing the post processing.
  45003. * @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)
  45004. */
  45005. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45006. }
  45007. /**
  45008. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45009. */
  45010. export class PassCubePostProcess extends PostProcess {
  45011. private _face;
  45012. /**
  45013. * Gets or sets the cube face to display.
  45014. * * 0 is +X
  45015. * * 1 is -X
  45016. * * 2 is +Y
  45017. * * 3 is -Y
  45018. * * 4 is +Z
  45019. * * 5 is -Z
  45020. */
  45021. get face(): number;
  45022. set face(value: number);
  45023. /**
  45024. * Creates the PassCubePostProcess
  45025. * @param name The name of the effect.
  45026. * @param options The required width/height ratio to downsize to before computing the render pass.
  45027. * @param camera The camera to apply the render pass to.
  45028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45029. * @param engine The engine which the post process will be applied. (default: current engine)
  45030. * @param reusable If the post process can be reused on the same frame. (default: false)
  45031. * @param textureType The type of texture to be used when performing the post processing.
  45032. * @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)
  45033. */
  45034. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45035. }
  45036. }
  45037. declare module BABYLON {
  45038. /** @hidden */
  45039. export var anaglyphPixelShader: {
  45040. name: string;
  45041. shader: string;
  45042. };
  45043. }
  45044. declare module BABYLON {
  45045. /**
  45046. * Postprocess used to generate anaglyphic rendering
  45047. */
  45048. export class AnaglyphPostProcess extends PostProcess {
  45049. private _passedProcess;
  45050. /**
  45051. * Creates a new AnaglyphPostProcess
  45052. * @param name defines postprocess name
  45053. * @param options defines creation options or target ratio scale
  45054. * @param rigCameras defines cameras using this postprocess
  45055. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45056. * @param engine defines hosting engine
  45057. * @param reusable defines if the postprocess will be reused multiple times per frame
  45058. */
  45059. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45060. }
  45061. }
  45062. declare module BABYLON {
  45063. /**
  45064. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45065. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45066. */
  45067. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45068. /**
  45069. * Creates a new AnaglyphArcRotateCamera
  45070. * @param name defines camera name
  45071. * @param alpha defines alpha angle (in radians)
  45072. * @param beta defines beta angle (in radians)
  45073. * @param radius defines radius
  45074. * @param target defines camera target
  45075. * @param interaxialDistance defines distance between each color axis
  45076. * @param scene defines the hosting scene
  45077. */
  45078. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45079. /**
  45080. * Gets camera class name
  45081. * @returns AnaglyphArcRotateCamera
  45082. */
  45083. getClassName(): string;
  45084. }
  45085. }
  45086. declare module BABYLON {
  45087. /**
  45088. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45089. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45090. */
  45091. export class AnaglyphFreeCamera extends FreeCamera {
  45092. /**
  45093. * Creates a new AnaglyphFreeCamera
  45094. * @param name defines camera name
  45095. * @param position defines initial position
  45096. * @param interaxialDistance defines distance between each color axis
  45097. * @param scene defines the hosting scene
  45098. */
  45099. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45100. /**
  45101. * Gets camera class name
  45102. * @returns AnaglyphFreeCamera
  45103. */
  45104. getClassName(): string;
  45105. }
  45106. }
  45107. declare module BABYLON {
  45108. /**
  45109. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45110. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45111. */
  45112. export class AnaglyphGamepadCamera extends GamepadCamera {
  45113. /**
  45114. * Creates a new AnaglyphGamepadCamera
  45115. * @param name defines camera name
  45116. * @param position defines initial position
  45117. * @param interaxialDistance defines distance between each color axis
  45118. * @param scene defines the hosting scene
  45119. */
  45120. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45121. /**
  45122. * Gets camera class name
  45123. * @returns AnaglyphGamepadCamera
  45124. */
  45125. getClassName(): string;
  45126. }
  45127. }
  45128. declare module BABYLON {
  45129. /**
  45130. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45131. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45132. */
  45133. export class AnaglyphUniversalCamera extends UniversalCamera {
  45134. /**
  45135. * Creates a new AnaglyphUniversalCamera
  45136. * @param name defines camera name
  45137. * @param position defines initial position
  45138. * @param interaxialDistance defines distance between each color axis
  45139. * @param scene defines the hosting scene
  45140. */
  45141. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45142. /**
  45143. * Gets camera class name
  45144. * @returns AnaglyphUniversalCamera
  45145. */
  45146. getClassName(): string;
  45147. }
  45148. }
  45149. declare module BABYLON {
  45150. /**
  45151. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45152. * @see http://doc.babylonjs.com/features/cameras
  45153. */
  45154. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45155. /**
  45156. * Creates a new StereoscopicArcRotateCamera
  45157. * @param name defines camera name
  45158. * @param alpha defines alpha angle (in radians)
  45159. * @param beta defines beta angle (in radians)
  45160. * @param radius defines radius
  45161. * @param target defines camera target
  45162. * @param interaxialDistance defines distance between each color axis
  45163. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45164. * @param scene defines the hosting scene
  45165. */
  45166. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45167. /**
  45168. * Gets camera class name
  45169. * @returns StereoscopicArcRotateCamera
  45170. */
  45171. getClassName(): string;
  45172. }
  45173. }
  45174. declare module BABYLON {
  45175. /**
  45176. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45177. * @see http://doc.babylonjs.com/features/cameras
  45178. */
  45179. export class StereoscopicFreeCamera extends FreeCamera {
  45180. /**
  45181. * Creates a new StereoscopicFreeCamera
  45182. * @param name defines camera name
  45183. * @param position defines initial position
  45184. * @param interaxialDistance defines distance between each color axis
  45185. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45186. * @param scene defines the hosting scene
  45187. */
  45188. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45189. /**
  45190. * Gets camera class name
  45191. * @returns StereoscopicFreeCamera
  45192. */
  45193. getClassName(): string;
  45194. }
  45195. }
  45196. declare module BABYLON {
  45197. /**
  45198. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45199. * @see http://doc.babylonjs.com/features/cameras
  45200. */
  45201. export class StereoscopicGamepadCamera extends GamepadCamera {
  45202. /**
  45203. * Creates a new StereoscopicGamepadCamera
  45204. * @param name defines camera name
  45205. * @param position defines initial position
  45206. * @param interaxialDistance defines distance between each color axis
  45207. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45208. * @param scene defines the hosting scene
  45209. */
  45210. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45211. /**
  45212. * Gets camera class name
  45213. * @returns StereoscopicGamepadCamera
  45214. */
  45215. getClassName(): string;
  45216. }
  45217. }
  45218. declare module BABYLON {
  45219. /**
  45220. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45221. * @see http://doc.babylonjs.com/features/cameras
  45222. */
  45223. export class StereoscopicUniversalCamera extends UniversalCamera {
  45224. /**
  45225. * Creates a new StereoscopicUniversalCamera
  45226. * @param name defines camera name
  45227. * @param position defines initial position
  45228. * @param interaxialDistance defines distance between each color axis
  45229. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45230. * @param scene defines the hosting scene
  45231. */
  45232. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45233. /**
  45234. * Gets camera class name
  45235. * @returns StereoscopicUniversalCamera
  45236. */
  45237. getClassName(): string;
  45238. }
  45239. }
  45240. declare module BABYLON {
  45241. /**
  45242. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45243. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45244. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45245. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45246. */
  45247. export class VirtualJoysticksCamera extends FreeCamera {
  45248. /**
  45249. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45250. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45251. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45252. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45253. * @param name Define the name of the camera in the scene
  45254. * @param position Define the start position of the camera in the scene
  45255. * @param scene Define the scene the camera belongs to
  45256. */
  45257. constructor(name: string, position: Vector3, scene: Scene);
  45258. /**
  45259. * Gets the current object class name.
  45260. * @return the class name
  45261. */
  45262. getClassName(): string;
  45263. }
  45264. }
  45265. declare module BABYLON {
  45266. /**
  45267. * This represents all the required metrics to create a VR camera.
  45268. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45269. */
  45270. export class VRCameraMetrics {
  45271. /**
  45272. * Define the horizontal resolution off the screen.
  45273. */
  45274. hResolution: number;
  45275. /**
  45276. * Define the vertical resolution off the screen.
  45277. */
  45278. vResolution: number;
  45279. /**
  45280. * Define the horizontal screen size.
  45281. */
  45282. hScreenSize: number;
  45283. /**
  45284. * Define the vertical screen size.
  45285. */
  45286. vScreenSize: number;
  45287. /**
  45288. * Define the vertical screen center position.
  45289. */
  45290. vScreenCenter: number;
  45291. /**
  45292. * Define the distance of the eyes to the screen.
  45293. */
  45294. eyeToScreenDistance: number;
  45295. /**
  45296. * Define the distance between both lenses
  45297. */
  45298. lensSeparationDistance: number;
  45299. /**
  45300. * Define the distance between both viewer's eyes.
  45301. */
  45302. interpupillaryDistance: number;
  45303. /**
  45304. * Define the distortion factor of the VR postprocess.
  45305. * Please, touch with care.
  45306. */
  45307. distortionK: number[];
  45308. /**
  45309. * Define the chromatic aberration correction factors for the VR post process.
  45310. */
  45311. chromaAbCorrection: number[];
  45312. /**
  45313. * Define the scale factor of the post process.
  45314. * The smaller the better but the slower.
  45315. */
  45316. postProcessScaleFactor: number;
  45317. /**
  45318. * Define an offset for the lens center.
  45319. */
  45320. lensCenterOffset: number;
  45321. /**
  45322. * Define if the current vr camera should compensate the distortion of the lense or not.
  45323. */
  45324. compensateDistortion: boolean;
  45325. /**
  45326. * Defines if multiview should be enabled when rendering (Default: false)
  45327. */
  45328. multiviewEnabled: boolean;
  45329. /**
  45330. * Gets the rendering aspect ratio based on the provided resolutions.
  45331. */
  45332. get aspectRatio(): number;
  45333. /**
  45334. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45335. */
  45336. get aspectRatioFov(): number;
  45337. /**
  45338. * @hidden
  45339. */
  45340. get leftHMatrix(): Matrix;
  45341. /**
  45342. * @hidden
  45343. */
  45344. get rightHMatrix(): Matrix;
  45345. /**
  45346. * @hidden
  45347. */
  45348. get leftPreViewMatrix(): Matrix;
  45349. /**
  45350. * @hidden
  45351. */
  45352. get rightPreViewMatrix(): Matrix;
  45353. /**
  45354. * Get the default VRMetrics based on the most generic setup.
  45355. * @returns the default vr metrics
  45356. */
  45357. static GetDefault(): VRCameraMetrics;
  45358. }
  45359. }
  45360. declare module BABYLON {
  45361. /** @hidden */
  45362. export var vrDistortionCorrectionPixelShader: {
  45363. name: string;
  45364. shader: string;
  45365. };
  45366. }
  45367. declare module BABYLON {
  45368. /**
  45369. * VRDistortionCorrectionPostProcess used for mobile VR
  45370. */
  45371. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45372. private _isRightEye;
  45373. private _distortionFactors;
  45374. private _postProcessScaleFactor;
  45375. private _lensCenterOffset;
  45376. private _scaleIn;
  45377. private _scaleFactor;
  45378. private _lensCenter;
  45379. /**
  45380. * Initializes the VRDistortionCorrectionPostProcess
  45381. * @param name The name of the effect.
  45382. * @param camera The camera to apply the render pass to.
  45383. * @param isRightEye If this is for the right eye distortion
  45384. * @param vrMetrics All the required metrics for the VR camera
  45385. */
  45386. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45387. }
  45388. }
  45389. declare module BABYLON {
  45390. /**
  45391. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45392. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45393. */
  45394. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45395. /**
  45396. * Creates a new VRDeviceOrientationArcRotateCamera
  45397. * @param name defines camera name
  45398. * @param alpha defines the camera rotation along the logitudinal axis
  45399. * @param beta defines the camera rotation along the latitudinal axis
  45400. * @param radius defines the camera distance from its target
  45401. * @param target defines the camera target
  45402. * @param scene defines the scene the camera belongs to
  45403. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45404. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45405. */
  45406. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45407. /**
  45408. * Gets camera class name
  45409. * @returns VRDeviceOrientationArcRotateCamera
  45410. */
  45411. getClassName(): string;
  45412. }
  45413. }
  45414. declare module BABYLON {
  45415. /**
  45416. * Camera used to simulate VR rendering (based on FreeCamera)
  45417. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45418. */
  45419. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45420. /**
  45421. * Creates a new VRDeviceOrientationFreeCamera
  45422. * @param name defines camera name
  45423. * @param position defines the start position of the camera
  45424. * @param scene defines the scene the camera belongs to
  45425. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45426. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45427. */
  45428. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45429. /**
  45430. * Gets camera class name
  45431. * @returns VRDeviceOrientationFreeCamera
  45432. */
  45433. getClassName(): string;
  45434. }
  45435. }
  45436. declare module BABYLON {
  45437. /**
  45438. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45439. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45440. */
  45441. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45442. /**
  45443. * Creates a new VRDeviceOrientationGamepadCamera
  45444. * @param name defines camera name
  45445. * @param position defines the start position of the camera
  45446. * @param scene defines the scene the camera belongs to
  45447. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45448. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45449. */
  45450. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45451. /**
  45452. * Gets camera class name
  45453. * @returns VRDeviceOrientationGamepadCamera
  45454. */
  45455. getClassName(): string;
  45456. }
  45457. }
  45458. declare module BABYLON {
  45459. /** @hidden */
  45460. export var imageProcessingPixelShader: {
  45461. name: string;
  45462. shader: string;
  45463. };
  45464. }
  45465. declare module BABYLON {
  45466. /**
  45467. * ImageProcessingPostProcess
  45468. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45469. */
  45470. export class ImageProcessingPostProcess extends PostProcess {
  45471. /**
  45472. * Default configuration related to image processing available in the PBR Material.
  45473. */
  45474. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45475. /**
  45476. * Gets the image processing configuration used either in this material.
  45477. */
  45478. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45479. /**
  45480. * Sets the Default image processing configuration used either in the this material.
  45481. *
  45482. * If sets to null, the scene one is in use.
  45483. */
  45484. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45485. /**
  45486. * Keep track of the image processing observer to allow dispose and replace.
  45487. */
  45488. private _imageProcessingObserver;
  45489. /**
  45490. * Attaches a new image processing configuration to the PBR Material.
  45491. * @param configuration
  45492. */
  45493. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45494. /**
  45495. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45496. */
  45497. get colorCurves(): Nullable<ColorCurves>;
  45498. /**
  45499. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45500. */
  45501. set colorCurves(value: Nullable<ColorCurves>);
  45502. /**
  45503. * Gets wether the color curves effect is enabled.
  45504. */
  45505. get colorCurvesEnabled(): boolean;
  45506. /**
  45507. * Sets wether the color curves effect is enabled.
  45508. */
  45509. set colorCurvesEnabled(value: boolean);
  45510. /**
  45511. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45512. */
  45513. get colorGradingTexture(): Nullable<BaseTexture>;
  45514. /**
  45515. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45516. */
  45517. set colorGradingTexture(value: Nullable<BaseTexture>);
  45518. /**
  45519. * Gets wether the color grading effect is enabled.
  45520. */
  45521. get colorGradingEnabled(): boolean;
  45522. /**
  45523. * Gets wether the color grading effect is enabled.
  45524. */
  45525. set colorGradingEnabled(value: boolean);
  45526. /**
  45527. * Gets exposure used in the effect.
  45528. */
  45529. get exposure(): number;
  45530. /**
  45531. * Sets exposure used in the effect.
  45532. */
  45533. set exposure(value: number);
  45534. /**
  45535. * Gets wether tonemapping is enabled or not.
  45536. */
  45537. get toneMappingEnabled(): boolean;
  45538. /**
  45539. * Sets wether tonemapping is enabled or not
  45540. */
  45541. set toneMappingEnabled(value: boolean);
  45542. /**
  45543. * Gets the type of tone mapping effect.
  45544. */
  45545. get toneMappingType(): number;
  45546. /**
  45547. * Sets the type of tone mapping effect.
  45548. */
  45549. set toneMappingType(value: number);
  45550. /**
  45551. * Gets contrast used in the effect.
  45552. */
  45553. get contrast(): number;
  45554. /**
  45555. * Sets contrast used in the effect.
  45556. */
  45557. set contrast(value: number);
  45558. /**
  45559. * Gets Vignette stretch size.
  45560. */
  45561. get vignetteStretch(): number;
  45562. /**
  45563. * Sets Vignette stretch size.
  45564. */
  45565. set vignetteStretch(value: number);
  45566. /**
  45567. * Gets Vignette centre X Offset.
  45568. */
  45569. get vignetteCentreX(): number;
  45570. /**
  45571. * Sets Vignette centre X Offset.
  45572. */
  45573. set vignetteCentreX(value: number);
  45574. /**
  45575. * Gets Vignette centre Y Offset.
  45576. */
  45577. get vignetteCentreY(): number;
  45578. /**
  45579. * Sets Vignette centre Y Offset.
  45580. */
  45581. set vignetteCentreY(value: number);
  45582. /**
  45583. * Gets Vignette weight or intensity of the vignette effect.
  45584. */
  45585. get vignetteWeight(): number;
  45586. /**
  45587. * Sets Vignette weight or intensity of the vignette effect.
  45588. */
  45589. set vignetteWeight(value: number);
  45590. /**
  45591. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45592. * if vignetteEnabled is set to true.
  45593. */
  45594. get vignetteColor(): Color4;
  45595. /**
  45596. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45597. * if vignetteEnabled is set to true.
  45598. */
  45599. set vignetteColor(value: Color4);
  45600. /**
  45601. * Gets Camera field of view used by the Vignette effect.
  45602. */
  45603. get vignetteCameraFov(): number;
  45604. /**
  45605. * Sets Camera field of view used by the Vignette effect.
  45606. */
  45607. set vignetteCameraFov(value: number);
  45608. /**
  45609. * Gets the vignette blend mode allowing different kind of effect.
  45610. */
  45611. get vignetteBlendMode(): number;
  45612. /**
  45613. * Sets the vignette blend mode allowing different kind of effect.
  45614. */
  45615. set vignetteBlendMode(value: number);
  45616. /**
  45617. * Gets wether the vignette effect is enabled.
  45618. */
  45619. get vignetteEnabled(): boolean;
  45620. /**
  45621. * Sets wether the vignette effect is enabled.
  45622. */
  45623. set vignetteEnabled(value: boolean);
  45624. private _fromLinearSpace;
  45625. /**
  45626. * Gets wether the input of the processing is in Gamma or Linear Space.
  45627. */
  45628. get fromLinearSpace(): boolean;
  45629. /**
  45630. * Sets wether the input of the processing is in Gamma or Linear Space.
  45631. */
  45632. set fromLinearSpace(value: boolean);
  45633. /**
  45634. * Defines cache preventing GC.
  45635. */
  45636. private _defines;
  45637. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45638. /**
  45639. * "ImageProcessingPostProcess"
  45640. * @returns "ImageProcessingPostProcess"
  45641. */
  45642. getClassName(): string;
  45643. protected _updateParameters(): void;
  45644. dispose(camera?: Camera): void;
  45645. }
  45646. }
  45647. declare module BABYLON {
  45648. /**
  45649. * Class containing static functions to help procedurally build meshes
  45650. */
  45651. export class GroundBuilder {
  45652. /**
  45653. * Creates a ground mesh
  45654. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45655. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45656. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45657. * @param name defines the name of the mesh
  45658. * @param options defines the options used to create the mesh
  45659. * @param scene defines the hosting scene
  45660. * @returns the ground mesh
  45661. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45662. */
  45663. static CreateGround(name: string, options: {
  45664. width?: number;
  45665. height?: number;
  45666. subdivisions?: number;
  45667. subdivisionsX?: number;
  45668. subdivisionsY?: number;
  45669. updatable?: boolean;
  45670. }, scene: any): Mesh;
  45671. /**
  45672. * Creates a tiled ground mesh
  45673. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45674. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45675. * * 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
  45676. * * 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
  45677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45678. * @param name defines the name of the mesh
  45679. * @param options defines the options used to create the mesh
  45680. * @param scene defines the hosting scene
  45681. * @returns the tiled ground mesh
  45682. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45683. */
  45684. static CreateTiledGround(name: string, options: {
  45685. xmin: number;
  45686. zmin: number;
  45687. xmax: number;
  45688. zmax: number;
  45689. subdivisions?: {
  45690. w: number;
  45691. h: number;
  45692. };
  45693. precision?: {
  45694. w: number;
  45695. h: number;
  45696. };
  45697. updatable?: boolean;
  45698. }, scene?: Nullable<Scene>): Mesh;
  45699. /**
  45700. * Creates a ground mesh from a height map
  45701. * * The parameter `url` sets the URL of the height map image resource.
  45702. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45703. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45704. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45705. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45706. * * 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.
  45707. * * 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).
  45708. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45710. * @param name defines the name of the mesh
  45711. * @param url defines the url to the height map
  45712. * @param options defines the options used to create the mesh
  45713. * @param scene defines the hosting scene
  45714. * @returns the ground mesh
  45715. * @see https://doc.babylonjs.com/babylon101/height_map
  45716. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45717. */
  45718. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45719. width?: number;
  45720. height?: number;
  45721. subdivisions?: number;
  45722. minHeight?: number;
  45723. maxHeight?: number;
  45724. colorFilter?: Color3;
  45725. alphaFilter?: number;
  45726. updatable?: boolean;
  45727. onReady?: (mesh: GroundMesh) => void;
  45728. }, scene?: Nullable<Scene>): GroundMesh;
  45729. }
  45730. }
  45731. declare module BABYLON {
  45732. /**
  45733. * Class containing static functions to help procedurally build meshes
  45734. */
  45735. export class TorusBuilder {
  45736. /**
  45737. * Creates a torus mesh
  45738. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45739. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45740. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45742. * * 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
  45743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45744. * @param name defines the name of the mesh
  45745. * @param options defines the options used to create the mesh
  45746. * @param scene defines the hosting scene
  45747. * @returns the torus mesh
  45748. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45749. */
  45750. static CreateTorus(name: string, options: {
  45751. diameter?: number;
  45752. thickness?: number;
  45753. tessellation?: number;
  45754. updatable?: boolean;
  45755. sideOrientation?: number;
  45756. frontUVs?: Vector4;
  45757. backUVs?: Vector4;
  45758. }, scene: any): Mesh;
  45759. }
  45760. }
  45761. declare module BABYLON {
  45762. /**
  45763. * Class containing static functions to help procedurally build meshes
  45764. */
  45765. export class CylinderBuilder {
  45766. /**
  45767. * Creates a cylinder or a cone mesh
  45768. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45769. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45770. * * 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.
  45771. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45772. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45773. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45774. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45775. * * 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).
  45776. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45777. * * 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).
  45778. * * 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
  45779. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45780. * * 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
  45781. * * 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.
  45782. * * If `enclose` is false, a ring surface is one element.
  45783. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45784. * * 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
  45785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45786. * * 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
  45787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45788. * @param name defines the name of the mesh
  45789. * @param options defines the options used to create the mesh
  45790. * @param scene defines the hosting scene
  45791. * @returns the cylinder mesh
  45792. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45793. */
  45794. static CreateCylinder(name: string, options: {
  45795. height?: number;
  45796. diameterTop?: number;
  45797. diameterBottom?: number;
  45798. diameter?: number;
  45799. tessellation?: number;
  45800. subdivisions?: number;
  45801. arc?: number;
  45802. faceColors?: Color4[];
  45803. faceUV?: Vector4[];
  45804. updatable?: boolean;
  45805. hasRings?: boolean;
  45806. enclose?: boolean;
  45807. cap?: number;
  45808. sideOrientation?: number;
  45809. frontUVs?: Vector4;
  45810. backUVs?: Vector4;
  45811. }, scene: any): Mesh;
  45812. }
  45813. }
  45814. declare module BABYLON {
  45815. /**
  45816. * States of the webXR experience
  45817. */
  45818. export enum WebXRState {
  45819. /**
  45820. * Transitioning to being in XR mode
  45821. */
  45822. ENTERING_XR = 0,
  45823. /**
  45824. * Transitioning to non XR mode
  45825. */
  45826. EXITING_XR = 1,
  45827. /**
  45828. * In XR mode and presenting
  45829. */
  45830. IN_XR = 2,
  45831. /**
  45832. * Not entered XR mode
  45833. */
  45834. NOT_IN_XR = 3
  45835. }
  45836. /**
  45837. * Abstraction of the XR render target
  45838. */
  45839. export interface WebXRRenderTarget extends IDisposable {
  45840. /**
  45841. * xrpresent context of the canvas which can be used to display/mirror xr content
  45842. */
  45843. canvasContext: WebGLRenderingContext;
  45844. /**
  45845. * xr layer for the canvas
  45846. */
  45847. xrLayer: Nullable<XRWebGLLayer>;
  45848. /**
  45849. * Initializes the xr layer for the session
  45850. * @param xrSession xr session
  45851. * @returns a promise that will resolve once the XR Layer has been created
  45852. */
  45853. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45854. }
  45855. }
  45856. declare module BABYLON {
  45857. /**
  45858. * COnfiguration object for WebXR output canvas
  45859. */
  45860. export class WebXRManagedOutputCanvasOptions {
  45861. /**
  45862. * An optional canvas in case you wish to create it yourself and provide it here.
  45863. * If not provided, a new canvas will be created
  45864. */
  45865. canvasElement?: HTMLCanvasElement;
  45866. /**
  45867. * Options for this XR Layer output
  45868. */
  45869. canvasOptions?: XRWebGLLayerOptions;
  45870. /**
  45871. * CSS styling for a newly created canvas (if not provided)
  45872. */
  45873. newCanvasCssStyle?: string;
  45874. /**
  45875. * Get the default values of the configuration object
  45876. * @returns default values of this configuration object
  45877. */
  45878. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45879. }
  45880. /**
  45881. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45882. */
  45883. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45884. private _options;
  45885. private _canvas;
  45886. private _engine;
  45887. /**
  45888. * Rendering context of the canvas which can be used to display/mirror xr content
  45889. */
  45890. canvasContext: WebGLRenderingContext;
  45891. /**
  45892. * xr layer for the canvas
  45893. */
  45894. xrLayer: Nullable<XRWebGLLayer>;
  45895. /**
  45896. * Initializes the canvas to be added/removed upon entering/exiting xr
  45897. * @param _xrSessionManager The XR Session manager
  45898. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45899. */
  45900. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45901. /**
  45902. * Disposes of the object
  45903. */
  45904. dispose(): void;
  45905. /**
  45906. * Initializes the xr layer for the session
  45907. * @param xrSession xr session
  45908. * @returns a promise that will resolve once the XR Layer has been created
  45909. */
  45910. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45911. private _addCanvas;
  45912. private _removeCanvas;
  45913. private _setManagedOutputCanvas;
  45914. }
  45915. }
  45916. declare module BABYLON {
  45917. /**
  45918. * Manages an XRSession to work with Babylon's engine
  45919. * @see https://doc.babylonjs.com/how_to/webxr
  45920. */
  45921. export class WebXRSessionManager implements IDisposable {
  45922. /** The scene which the session should be created for */
  45923. scene: Scene;
  45924. private _referenceSpace;
  45925. private _rttProvider;
  45926. private _sessionEnded;
  45927. private _xrNavigator;
  45928. private baseLayer;
  45929. /**
  45930. * The base reference space from which the session started. good if you want to reset your
  45931. * reference space
  45932. */
  45933. baseReferenceSpace: XRReferenceSpace;
  45934. /**
  45935. * Current XR frame
  45936. */
  45937. currentFrame: Nullable<XRFrame>;
  45938. /** WebXR timestamp updated every frame */
  45939. currentTimestamp: number;
  45940. /**
  45941. * Used just in case of a failure to initialize an immersive session.
  45942. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45943. */
  45944. defaultHeightCompensation: number;
  45945. /**
  45946. * Fires every time a new xrFrame arrives which can be used to update the camera
  45947. */
  45948. onXRFrameObservable: Observable<XRFrame>;
  45949. /**
  45950. * Fires when the reference space changed
  45951. */
  45952. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45953. /**
  45954. * Fires when the xr session is ended either by the device or manually done
  45955. */
  45956. onXRSessionEnded: Observable<any>;
  45957. /**
  45958. * Fires when the xr session is ended either by the device or manually done
  45959. */
  45960. onXRSessionInit: Observable<XRSession>;
  45961. /**
  45962. * Underlying xr session
  45963. */
  45964. session: XRSession;
  45965. /**
  45966. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45967. * or get the offset the player is currently at.
  45968. */
  45969. viewerReferenceSpace: XRReferenceSpace;
  45970. /**
  45971. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45972. * @param scene The scene which the session should be created for
  45973. */
  45974. constructor(
  45975. /** The scene which the session should be created for */
  45976. scene: Scene);
  45977. /**
  45978. * The current reference space used in this session. This reference space can constantly change!
  45979. * It is mainly used to offset the camera's position.
  45980. */
  45981. get referenceSpace(): XRReferenceSpace;
  45982. /**
  45983. * Set a new reference space and triggers the observable
  45984. */
  45985. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45986. /**
  45987. * Disposes of the session manager
  45988. */
  45989. dispose(): void;
  45990. /**
  45991. * Stops the xrSession and restores the render loop
  45992. * @returns Promise which resolves after it exits XR
  45993. */
  45994. exitXRAsync(): Promise<void>;
  45995. /**
  45996. * Gets the correct render target texture to be rendered this frame for this eye
  45997. * @param eye the eye for which to get the render target
  45998. * @returns the render target for the specified eye
  45999. */
  46000. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46001. /**
  46002. * Creates a WebXRRenderTarget object for the XR session
  46003. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46004. * @param options optional options to provide when creating a new render target
  46005. * @returns a WebXR render target to which the session can render
  46006. */
  46007. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46008. /**
  46009. * Initializes the manager
  46010. * After initialization enterXR can be called to start an XR session
  46011. * @returns Promise which resolves after it is initialized
  46012. */
  46013. initializeAsync(): Promise<void>;
  46014. /**
  46015. * Initializes an xr session
  46016. * @param xrSessionMode mode to initialize
  46017. * @param xrSessionInit defines optional and required values to pass to the session builder
  46018. * @returns a promise which will resolve once the session has been initialized
  46019. */
  46020. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46021. /**
  46022. * Checks if a session would be supported for the creation options specified
  46023. * @param sessionMode session mode to check if supported eg. immersive-vr
  46024. * @returns A Promise that resolves to true if supported and false if not
  46025. */
  46026. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46027. /**
  46028. * Resets the reference space to the one started the session
  46029. */
  46030. resetReferenceSpace(): void;
  46031. /**
  46032. * Starts rendering to the xr layer
  46033. */
  46034. runXRRenderLoop(): void;
  46035. /**
  46036. * Sets the reference space on the xr session
  46037. * @param referenceSpaceType space to set
  46038. * @returns a promise that will resolve once the reference space has been set
  46039. */
  46040. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46041. /**
  46042. * Updates the render state of the session
  46043. * @param state state to set
  46044. * @returns a promise that resolves once the render state has been updated
  46045. */
  46046. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46047. /**
  46048. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46049. * @param sessionMode defines the session to test
  46050. * @returns a promise with boolean as final value
  46051. */
  46052. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46053. private _createRenderTargetTexture;
  46054. }
  46055. }
  46056. declare module BABYLON {
  46057. /**
  46058. * WebXR Camera which holds the views for the xrSession
  46059. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46060. */
  46061. export class WebXRCamera extends FreeCamera {
  46062. private _xrSessionManager;
  46063. private _firstFrame;
  46064. private _referenceQuaternion;
  46065. private _referencedPosition;
  46066. private _xrInvPositionCache;
  46067. private _xrInvQuaternionCache;
  46068. /**
  46069. * Should position compensation execute on first frame.
  46070. * This is used when copying the position from a native (non XR) camera
  46071. */
  46072. compensateOnFirstFrame: boolean;
  46073. /**
  46074. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46075. * @param name the name of the camera
  46076. * @param scene the scene to add the camera to
  46077. * @param _xrSessionManager a constructed xr session manager
  46078. */
  46079. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46080. /**
  46081. * Return the user's height, unrelated to the current ground.
  46082. * This will be the y position of this camera, when ground level is 0.
  46083. */
  46084. get realWorldHeight(): number;
  46085. /** @hidden */
  46086. _updateForDualEyeDebugging(): void;
  46087. /**
  46088. * Sets this camera's transformation based on a non-vr camera
  46089. * @param otherCamera the non-vr camera to copy the transformation from
  46090. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46091. */
  46092. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46093. /**
  46094. * Gets the current instance class name ("WebXRCamera").
  46095. * @returns the class name
  46096. */
  46097. getClassName(): string;
  46098. /**
  46099. * Overriding the _getViewMatrix function, as it is computed by WebXR
  46100. */
  46101. _getViewMatrix(): Matrix;
  46102. private _updateFromXRSession;
  46103. private _updateNumberOfRigCameras;
  46104. private _updateReferenceSpace;
  46105. private _updateReferenceSpaceOffset;
  46106. }
  46107. }
  46108. declare module BABYLON {
  46109. /**
  46110. * Defining the interface required for a (webxr) feature
  46111. */
  46112. export interface IWebXRFeature extends IDisposable {
  46113. /**
  46114. * Is this feature attached
  46115. */
  46116. attached: boolean;
  46117. /**
  46118. * Should auto-attach be disabled?
  46119. */
  46120. disableAutoAttach: boolean;
  46121. /**
  46122. * Attach the feature to the session
  46123. * Will usually be called by the features manager
  46124. *
  46125. * @param force should attachment be forced (even when already attached)
  46126. * @returns true if successful.
  46127. */
  46128. attach(force?: boolean): boolean;
  46129. /**
  46130. * Detach the feature from the session
  46131. * Will usually be called by the features manager
  46132. *
  46133. * @returns true if successful.
  46134. */
  46135. detach(): boolean;
  46136. }
  46137. /**
  46138. * A list of the currently available features without referencing them
  46139. */
  46140. export class WebXRFeatureName {
  46141. /**
  46142. * The name of the anchor system feature
  46143. */
  46144. static ANCHOR_SYSTEM: string;
  46145. /**
  46146. * The name of the background remover feature
  46147. */
  46148. static BACKGROUND_REMOVER: string;
  46149. /**
  46150. * The name of the hit test feature
  46151. */
  46152. static HIT_TEST: string;
  46153. /**
  46154. * physics impostors for xr controllers feature
  46155. */
  46156. static PHYSICS_CONTROLLERS: string;
  46157. /**
  46158. * The name of the plane detection feature
  46159. */
  46160. static PLANE_DETECTION: string;
  46161. /**
  46162. * The name of the pointer selection feature
  46163. */
  46164. static POINTER_SELECTION: string;
  46165. /**
  46166. * The name of the teleportation feature
  46167. */
  46168. static TELEPORTATION: string;
  46169. }
  46170. /**
  46171. * Defining the constructor of a feature. Used to register the modules.
  46172. */
  46173. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46174. /**
  46175. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46176. * It is mainly used in AR sessions.
  46177. *
  46178. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46179. */
  46180. export class WebXRFeaturesManager implements IDisposable {
  46181. private _xrSessionManager;
  46182. private static readonly _AvailableFeatures;
  46183. private _features;
  46184. /**
  46185. * constructs a new features manages.
  46186. *
  46187. * @param _xrSessionManager an instance of WebXRSessionManager
  46188. */
  46189. constructor(_xrSessionManager: WebXRSessionManager);
  46190. /**
  46191. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46192. * Mainly used internally.
  46193. *
  46194. * @param featureName the name of the feature to register
  46195. * @param constructorFunction the function used to construct the module
  46196. * @param version the (babylon) version of the module
  46197. * @param stable is that a stable version of this module
  46198. */
  46199. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46200. /**
  46201. * Returns a constructor of a specific feature.
  46202. *
  46203. * @param featureName the name of the feature to construct
  46204. * @param version the version of the feature to load
  46205. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46206. * @param options optional options provided to the module.
  46207. * @returns a function that, when called, will return a new instance of this feature
  46208. */
  46209. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46210. /**
  46211. * Can be used to return the list of features currently registered
  46212. *
  46213. * @returns an Array of available features
  46214. */
  46215. static GetAvailableFeatures(): string[];
  46216. /**
  46217. * Gets the versions available for a specific feature
  46218. * @param featureName the name of the feature
  46219. * @returns an array with the available versions
  46220. */
  46221. static GetAvailableVersions(featureName: string): string[];
  46222. /**
  46223. * Return the latest unstable version of this feature
  46224. * @param featureName the name of the feature to search
  46225. * @returns the version number. if not found will return -1
  46226. */
  46227. static GetLatestVersionOfFeature(featureName: string): number;
  46228. /**
  46229. * Return the latest stable version of this feature
  46230. * @param featureName the name of the feature to search
  46231. * @returns the version number. if not found will return -1
  46232. */
  46233. static GetStableVersionOfFeature(featureName: string): number;
  46234. /**
  46235. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46236. * Can be used during a session to start a feature
  46237. * @param featureName the name of feature to attach
  46238. */
  46239. attachFeature(featureName: string): void;
  46240. /**
  46241. * Can be used inside a session or when the session ends to detach a specific feature
  46242. * @param featureName the name of the feature to detach
  46243. */
  46244. detachFeature(featureName: string): void;
  46245. /**
  46246. * Used to disable an already-enabled feature
  46247. * The feature will be disposed and will be recreated once enabled.
  46248. * @param featureName the feature to disable
  46249. * @returns true if disable was successful
  46250. */
  46251. disableFeature(featureName: string | {
  46252. Name: string;
  46253. }): boolean;
  46254. /**
  46255. * dispose this features manager
  46256. */
  46257. dispose(): void;
  46258. /**
  46259. * 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.
  46260. * 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.
  46261. *
  46262. * @param featureName the name of the feature to load or the class of the feature
  46263. * @param version optional version to load. if not provided the latest version will be enabled
  46264. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46265. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46266. * @returns a new constructed feature or throws an error if feature not found.
  46267. */
  46268. enableFeature(featureName: string | {
  46269. Name: string;
  46270. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46271. /**
  46272. * get the implementation of an enabled feature.
  46273. * @param featureName the name of the feature to load
  46274. * @returns the feature class, if found
  46275. */
  46276. getEnabledFeature(featureName: string): IWebXRFeature;
  46277. /**
  46278. * Get the list of enabled features
  46279. * @returns an array of enabled features
  46280. */
  46281. getEnabledFeatures(): string[];
  46282. }
  46283. }
  46284. declare module BABYLON {
  46285. /**
  46286. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46287. * @see https://doc.babylonjs.com/how_to/webxr
  46288. */
  46289. export class WebXRExperienceHelper implements IDisposable {
  46290. private scene;
  46291. private _nonVRCamera;
  46292. private _originalSceneAutoClear;
  46293. private _supported;
  46294. /**
  46295. * Camera used to render xr content
  46296. */
  46297. camera: WebXRCamera;
  46298. /** A features manager for this xr session */
  46299. featuresManager: WebXRFeaturesManager;
  46300. /**
  46301. * Observers registered here will be triggered after the camera's initial transformation is set
  46302. * This can be used to set a different ground level or an extra rotation.
  46303. *
  46304. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46305. * to the position set after this observable is done executing.
  46306. */
  46307. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46308. /**
  46309. * Fires when the state of the experience helper has changed
  46310. */
  46311. onStateChangedObservable: Observable<WebXRState>;
  46312. /** Session manager used to keep track of xr session */
  46313. sessionManager: WebXRSessionManager;
  46314. /**
  46315. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46316. */
  46317. state: WebXRState;
  46318. /**
  46319. * Creates a WebXRExperienceHelper
  46320. * @param scene The scene the helper should be created in
  46321. */
  46322. private constructor();
  46323. /**
  46324. * Creates the experience helper
  46325. * @param scene the scene to attach the experience helper to
  46326. * @returns a promise for the experience helper
  46327. */
  46328. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46329. /**
  46330. * Disposes of the experience helper
  46331. */
  46332. dispose(): void;
  46333. /**
  46334. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46335. * @param sessionMode options for the XR session
  46336. * @param referenceSpaceType frame of reference of the XR session
  46337. * @param renderTarget the output canvas that will be used to enter XR mode
  46338. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46339. * @returns promise that resolves after xr mode has entered
  46340. */
  46341. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46342. /**
  46343. * Exits XR mode and returns the scene to its original state
  46344. * @returns promise that resolves after xr mode has exited
  46345. */
  46346. exitXRAsync(): Promise<void>;
  46347. private _nonXRToXRCamera;
  46348. private _setState;
  46349. }
  46350. }
  46351. declare module BABYLON {
  46352. /**
  46353. * X-Y values for axes in WebXR
  46354. */
  46355. export interface IWebXRMotionControllerAxesValue {
  46356. /**
  46357. * The value of the x axis
  46358. */
  46359. x: number;
  46360. /**
  46361. * The value of the y-axis
  46362. */
  46363. y: number;
  46364. }
  46365. /**
  46366. * changed / previous values for the values of this component
  46367. */
  46368. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46369. /**
  46370. * current (this frame) value
  46371. */
  46372. current: T;
  46373. /**
  46374. * previous (last change) value
  46375. */
  46376. previous: T;
  46377. }
  46378. /**
  46379. * Represents changes in the component between current frame and last values recorded
  46380. */
  46381. export interface IWebXRMotionControllerComponentChanges {
  46382. /**
  46383. * will be populated with previous and current values if axes changed
  46384. */
  46385. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46386. /**
  46387. * will be populated with previous and current values if pressed changed
  46388. */
  46389. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46390. /**
  46391. * will be populated with previous and current values if touched changed
  46392. */
  46393. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46394. /**
  46395. * will be populated with previous and current values if value changed
  46396. */
  46397. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46398. }
  46399. /**
  46400. * This class represents a single component (for example button or thumbstick) of a motion controller
  46401. */
  46402. export class WebXRControllerComponent implements IDisposable {
  46403. /**
  46404. * the id of this component
  46405. */
  46406. id: string;
  46407. /**
  46408. * the type of the component
  46409. */
  46410. type: MotionControllerComponentType;
  46411. private _buttonIndex;
  46412. private _axesIndices;
  46413. private _axes;
  46414. private _changes;
  46415. private _currentValue;
  46416. private _hasChanges;
  46417. private _pressed;
  46418. private _touched;
  46419. /**
  46420. * button component type
  46421. */
  46422. static BUTTON_TYPE: MotionControllerComponentType;
  46423. /**
  46424. * squeeze component type
  46425. */
  46426. static SQUEEZE_TYPE: MotionControllerComponentType;
  46427. /**
  46428. * Thumbstick component type
  46429. */
  46430. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46431. /**
  46432. * Touchpad component type
  46433. */
  46434. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46435. /**
  46436. * trigger component type
  46437. */
  46438. static TRIGGER_TYPE: MotionControllerComponentType;
  46439. /**
  46440. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46441. * the axes data changes
  46442. */
  46443. onAxisValueChangedObservable: Observable<{
  46444. x: number;
  46445. y: number;
  46446. }>;
  46447. /**
  46448. * Observers registered here will be triggered when the state of a button changes
  46449. * State change is either pressed / touched / value
  46450. */
  46451. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46452. /**
  46453. * Creates a new component for a motion controller.
  46454. * It is created by the motion controller itself
  46455. *
  46456. * @param id the id of this component
  46457. * @param type the type of the component
  46458. * @param _buttonIndex index in the buttons array of the gamepad
  46459. * @param _axesIndices indices of the values in the axes array of the gamepad
  46460. */
  46461. constructor(
  46462. /**
  46463. * the id of this component
  46464. */
  46465. id: string,
  46466. /**
  46467. * the type of the component
  46468. */
  46469. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46470. /**
  46471. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46472. */
  46473. get axes(): IWebXRMotionControllerAxesValue;
  46474. /**
  46475. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46476. */
  46477. get changes(): IWebXRMotionControllerComponentChanges;
  46478. /**
  46479. * Return whether or not the component changed the last frame
  46480. */
  46481. get hasChanges(): boolean;
  46482. /**
  46483. * is the button currently pressed
  46484. */
  46485. get pressed(): boolean;
  46486. /**
  46487. * is the button currently touched
  46488. */
  46489. get touched(): boolean;
  46490. /**
  46491. * Get the current value of this component
  46492. */
  46493. get value(): number;
  46494. /**
  46495. * Dispose this component
  46496. */
  46497. dispose(): void;
  46498. /**
  46499. * Are there axes correlating to this component
  46500. * @return true is axes data is available
  46501. */
  46502. isAxes(): boolean;
  46503. /**
  46504. * Is this component a button (hence - pressable)
  46505. * @returns true if can be pressed
  46506. */
  46507. isButton(): boolean;
  46508. /**
  46509. * update this component using the gamepad object it is in. Called on every frame
  46510. * @param nativeController the native gamepad controller object
  46511. */
  46512. update(nativeController: IMinimalMotionControllerObject): void;
  46513. }
  46514. }
  46515. declare module BABYLON {
  46516. /**
  46517. * Class used to represent data loading progression
  46518. */
  46519. export class SceneLoaderProgressEvent {
  46520. /** defines if data length to load can be evaluated */
  46521. readonly lengthComputable: boolean;
  46522. /** defines the loaded data length */
  46523. readonly loaded: number;
  46524. /** defines the data length to load */
  46525. readonly total: number;
  46526. /**
  46527. * Create a new progress event
  46528. * @param lengthComputable defines if data length to load can be evaluated
  46529. * @param loaded defines the loaded data length
  46530. * @param total defines the data length to load
  46531. */
  46532. constructor(
  46533. /** defines if data length to load can be evaluated */
  46534. lengthComputable: boolean,
  46535. /** defines the loaded data length */
  46536. loaded: number,
  46537. /** defines the data length to load */
  46538. total: number);
  46539. /**
  46540. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46541. * @param event defines the source event
  46542. * @returns a new SceneLoaderProgressEvent
  46543. */
  46544. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46545. }
  46546. /**
  46547. * Interface used by SceneLoader plugins to define supported file extensions
  46548. */
  46549. export interface ISceneLoaderPluginExtensions {
  46550. /**
  46551. * Defines the list of supported extensions
  46552. */
  46553. [extension: string]: {
  46554. isBinary: boolean;
  46555. };
  46556. }
  46557. /**
  46558. * Interface used by SceneLoader plugin factory
  46559. */
  46560. export interface ISceneLoaderPluginFactory {
  46561. /**
  46562. * Defines the name of the factory
  46563. */
  46564. name: string;
  46565. /**
  46566. * Function called to create a new plugin
  46567. * @return the new plugin
  46568. */
  46569. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46570. /**
  46571. * The callback that returns true if the data can be directly loaded.
  46572. * @param data string containing the file data
  46573. * @returns if the data can be loaded directly
  46574. */
  46575. canDirectLoad?(data: string): boolean;
  46576. }
  46577. /**
  46578. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46579. */
  46580. export interface ISceneLoaderPluginBase {
  46581. /**
  46582. * The friendly name of this plugin.
  46583. */
  46584. name: string;
  46585. /**
  46586. * The file extensions supported by this plugin.
  46587. */
  46588. extensions: string | ISceneLoaderPluginExtensions;
  46589. /**
  46590. * The callback called when loading from a url.
  46591. * @param scene scene loading this url
  46592. * @param url url to load
  46593. * @param onSuccess callback called when the file successfully loads
  46594. * @param onProgress callback called while file is loading (if the server supports this mode)
  46595. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46596. * @param onError callback called when the file fails to load
  46597. * @returns a file request object
  46598. */
  46599. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46600. /**
  46601. * The callback called when loading from a file object.
  46602. * @param scene scene loading this file
  46603. * @param file defines the file to load
  46604. * @param onSuccess defines the callback to call when data is loaded
  46605. * @param onProgress defines the callback to call during loading process
  46606. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46607. * @param onError defines the callback to call when an error occurs
  46608. * @returns a file request object
  46609. */
  46610. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46611. /**
  46612. * The callback that returns true if the data can be directly loaded.
  46613. * @param data string containing the file data
  46614. * @returns if the data can be loaded directly
  46615. */
  46616. canDirectLoad?(data: string): boolean;
  46617. /**
  46618. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46619. * @param scene scene loading this data
  46620. * @param data string containing the data
  46621. * @returns data to pass to the plugin
  46622. */
  46623. directLoad?(scene: Scene, data: string): any;
  46624. /**
  46625. * The callback that allows custom handling of the root url based on the response url.
  46626. * @param rootUrl the original root url
  46627. * @param responseURL the response url if available
  46628. * @returns the new root url
  46629. */
  46630. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46631. }
  46632. /**
  46633. * Interface used to define a SceneLoader plugin
  46634. */
  46635. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46636. /**
  46637. * Import meshes into a scene.
  46638. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46639. * @param scene The scene to import into
  46640. * @param data The data to import
  46641. * @param rootUrl The root url for scene and resources
  46642. * @param meshes The meshes array to import into
  46643. * @param particleSystems The particle systems array to import into
  46644. * @param skeletons The skeletons array to import into
  46645. * @param onError The callback when import fails
  46646. * @returns True if successful or false otherwise
  46647. */
  46648. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46649. /**
  46650. * Load into a scene.
  46651. * @param scene The scene to load into
  46652. * @param data The data to import
  46653. * @param rootUrl The root url for scene and resources
  46654. * @param onError The callback when import fails
  46655. * @returns True if successful or false otherwise
  46656. */
  46657. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46658. /**
  46659. * Load into an asset container.
  46660. * @param scene The scene to load into
  46661. * @param data The data to import
  46662. * @param rootUrl The root url for scene and resources
  46663. * @param onError The callback when import fails
  46664. * @returns The loaded asset container
  46665. */
  46666. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46667. }
  46668. /**
  46669. * Interface used to define an async SceneLoader plugin
  46670. */
  46671. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46672. /**
  46673. * Import meshes into a scene.
  46674. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46675. * @param scene The scene to import into
  46676. * @param data The data to import
  46677. * @param rootUrl The root url for scene and resources
  46678. * @param onProgress The callback when the load progresses
  46679. * @param fileName Defines the name of the file to load
  46680. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46681. */
  46682. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46683. meshes: AbstractMesh[];
  46684. particleSystems: IParticleSystem[];
  46685. skeletons: Skeleton[];
  46686. animationGroups: AnimationGroup[];
  46687. }>;
  46688. /**
  46689. * Load into a scene.
  46690. * @param scene The scene to load into
  46691. * @param data The data to import
  46692. * @param rootUrl The root url for scene and resources
  46693. * @param onProgress The callback when the load progresses
  46694. * @param fileName Defines the name of the file to load
  46695. * @returns Nothing
  46696. */
  46697. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46698. /**
  46699. * Load into an asset container.
  46700. * @param scene The scene to load into
  46701. * @param data The data to import
  46702. * @param rootUrl The root url for scene and resources
  46703. * @param onProgress The callback when the load progresses
  46704. * @param fileName Defines the name of the file to load
  46705. * @returns The loaded asset container
  46706. */
  46707. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46708. }
  46709. /**
  46710. * Mode that determines how to handle old animation groups before loading new ones.
  46711. */
  46712. export enum SceneLoaderAnimationGroupLoadingMode {
  46713. /**
  46714. * Reset all old animations to initial state then dispose them.
  46715. */
  46716. Clean = 0,
  46717. /**
  46718. * Stop all old animations.
  46719. */
  46720. Stop = 1,
  46721. /**
  46722. * Restart old animations from first frame.
  46723. */
  46724. Sync = 2,
  46725. /**
  46726. * Old animations remains untouched.
  46727. */
  46728. NoSync = 3
  46729. }
  46730. /**
  46731. * Class used to load scene from various file formats using registered plugins
  46732. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46733. */
  46734. export class SceneLoader {
  46735. /**
  46736. * No logging while loading
  46737. */
  46738. static readonly NO_LOGGING: number;
  46739. /**
  46740. * Minimal logging while loading
  46741. */
  46742. static readonly MINIMAL_LOGGING: number;
  46743. /**
  46744. * Summary logging while loading
  46745. */
  46746. static readonly SUMMARY_LOGGING: number;
  46747. /**
  46748. * Detailled logging while loading
  46749. */
  46750. static readonly DETAILED_LOGGING: number;
  46751. /**
  46752. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46753. */
  46754. static get ForceFullSceneLoadingForIncremental(): boolean;
  46755. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46756. /**
  46757. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46758. */
  46759. static get ShowLoadingScreen(): boolean;
  46760. static set ShowLoadingScreen(value: boolean);
  46761. /**
  46762. * Defines the current logging level (while loading the scene)
  46763. * @ignorenaming
  46764. */
  46765. static get loggingLevel(): number;
  46766. static set loggingLevel(value: number);
  46767. /**
  46768. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46769. */
  46770. static get CleanBoneMatrixWeights(): boolean;
  46771. static set CleanBoneMatrixWeights(value: boolean);
  46772. /**
  46773. * Event raised when a plugin is used to load a scene
  46774. */
  46775. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46776. private static _registeredPlugins;
  46777. private static _getDefaultPlugin;
  46778. private static _getPluginForExtension;
  46779. private static _getPluginForDirectLoad;
  46780. private static _getPluginForFilename;
  46781. private static _getDirectLoad;
  46782. private static _loadData;
  46783. private static _getFileInfo;
  46784. /**
  46785. * Gets a plugin that can load the given extension
  46786. * @param extension defines the extension to load
  46787. * @returns a plugin or null if none works
  46788. */
  46789. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46790. /**
  46791. * Gets a boolean indicating that the given extension can be loaded
  46792. * @param extension defines the extension to load
  46793. * @returns true if the extension is supported
  46794. */
  46795. static IsPluginForExtensionAvailable(extension: string): boolean;
  46796. /**
  46797. * Adds a new plugin to the list of registered plugins
  46798. * @param plugin defines the plugin to add
  46799. */
  46800. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46801. /**
  46802. * Import meshes into a scene
  46803. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46804. * @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)
  46805. * @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)
  46806. * @param scene the instance of BABYLON.Scene to append to
  46807. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46808. * @param onProgress a callback with a progress event for each file being loaded
  46809. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46810. * @param pluginExtension the extension used to determine the plugin
  46811. * @returns The loaded plugin
  46812. */
  46813. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46814. /**
  46815. * Import meshes into a scene
  46816. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46817. * @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)
  46818. * @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)
  46819. * @param scene the instance of BABYLON.Scene to append to
  46820. * @param onProgress a callback with a progress event for each file being loaded
  46821. * @param pluginExtension the extension used to determine the plugin
  46822. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46823. */
  46824. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46825. meshes: AbstractMesh[];
  46826. particleSystems: IParticleSystem[];
  46827. skeletons: Skeleton[];
  46828. animationGroups: AnimationGroup[];
  46829. }>;
  46830. /**
  46831. * Load a scene
  46832. * @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)
  46833. * @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)
  46834. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46835. * @param onSuccess a callback with the scene when import succeeds
  46836. * @param onProgress a callback with a progress event for each file being loaded
  46837. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46838. * @param pluginExtension the extension used to determine the plugin
  46839. * @returns The loaded plugin
  46840. */
  46841. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46842. /**
  46843. * Load a scene
  46844. * @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)
  46845. * @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)
  46846. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46847. * @param onProgress a callback with a progress event for each file being loaded
  46848. * @param pluginExtension the extension used to determine the plugin
  46849. * @returns The loaded scene
  46850. */
  46851. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46852. /**
  46853. * Append a scene
  46854. * @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)
  46855. * @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)
  46856. * @param scene is the instance of BABYLON.Scene to append to
  46857. * @param onSuccess a callback with the scene when import succeeds
  46858. * @param onProgress a callback with a progress event for each file being loaded
  46859. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46860. * @param pluginExtension the extension used to determine the plugin
  46861. * @returns The loaded plugin
  46862. */
  46863. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46864. /**
  46865. * Append a scene
  46866. * @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)
  46867. * @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)
  46868. * @param scene is the instance of BABYLON.Scene to append to
  46869. * @param onProgress a callback with a progress event for each file being loaded
  46870. * @param pluginExtension the extension used to determine the plugin
  46871. * @returns The given scene
  46872. */
  46873. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46874. /**
  46875. * Load a scene into an asset container
  46876. * @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)
  46877. * @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)
  46878. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46879. * @param onSuccess a callback with the scene when import succeeds
  46880. * @param onProgress a callback with a progress event for each file being loaded
  46881. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46882. * @param pluginExtension the extension used to determine the plugin
  46883. * @returns The loaded plugin
  46884. */
  46885. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46886. /**
  46887. * Load a scene into an asset container
  46888. * @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)
  46889. * @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)
  46890. * @param scene is the instance of Scene to append to
  46891. * @param onProgress a callback with a progress event for each file being loaded
  46892. * @param pluginExtension the extension used to determine the plugin
  46893. * @returns The loaded asset container
  46894. */
  46895. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46896. /**
  46897. * Import animations from a file into a scene
  46898. * @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)
  46899. * @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)
  46900. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46901. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46902. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46903. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46904. * @param onSuccess a callback with the scene when import succeeds
  46905. * @param onProgress a callback with a progress event for each file being loaded
  46906. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46907. */
  46908. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  46909. /**
  46910. * Import animations from a file into a scene
  46911. * @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)
  46912. * @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)
  46913. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46914. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46915. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46916. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46917. * @param onSuccess a callback with the scene when import succeeds
  46918. * @param onProgress a callback with a progress event for each file being loaded
  46919. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46920. * @returns the updated scene with imported animations
  46921. */
  46922. 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: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  46923. }
  46924. }
  46925. declare module BABYLON {
  46926. /**
  46927. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46928. */
  46929. export type MotionControllerHandedness = "none" | "left" | "right";
  46930. /**
  46931. * The type of components available in motion controllers.
  46932. * This is not the name of the component.
  46933. */
  46934. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46935. /**
  46936. * The state of a controller component
  46937. */
  46938. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46939. /**
  46940. * The schema of motion controller layout.
  46941. * No object will be initialized using this interface
  46942. * This is used just to define the profile.
  46943. */
  46944. export interface IMotionControllerLayout {
  46945. /**
  46946. * Path to load the assets. Usually relative to the base path
  46947. */
  46948. assetPath: string;
  46949. /**
  46950. * Available components (unsorted)
  46951. */
  46952. components: {
  46953. /**
  46954. * A map of component Ids
  46955. */
  46956. [componentId: string]: {
  46957. /**
  46958. * The type of input the component outputs
  46959. */
  46960. type: MotionControllerComponentType;
  46961. /**
  46962. * The indices of this component in the gamepad object
  46963. */
  46964. gamepadIndices: {
  46965. /**
  46966. * Index of button
  46967. */
  46968. button?: number;
  46969. /**
  46970. * If available, index of x-axis
  46971. */
  46972. xAxis?: number;
  46973. /**
  46974. * If available, index of y-axis
  46975. */
  46976. yAxis?: number;
  46977. };
  46978. /**
  46979. * The mesh's root node name
  46980. */
  46981. rootNodeName: string;
  46982. /**
  46983. * Animation definitions for this model
  46984. */
  46985. visualResponses: {
  46986. [stateKey: string]: {
  46987. /**
  46988. * What property will be animated
  46989. */
  46990. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46991. /**
  46992. * What states influence this visual response
  46993. */
  46994. states: MotionControllerComponentStateType[];
  46995. /**
  46996. * Type of animation - movement or visibility
  46997. */
  46998. valueNodeProperty: "transform" | "visibility";
  46999. /**
  47000. * Base node name to move. Its position will be calculated according to the min and max nodes
  47001. */
  47002. valueNodeName?: string;
  47003. /**
  47004. * Minimum movement node
  47005. */
  47006. minNodeName?: string;
  47007. /**
  47008. * Max movement node
  47009. */
  47010. maxNodeName?: string;
  47011. };
  47012. };
  47013. /**
  47014. * If touch enabled, what is the name of node to display user feedback
  47015. */
  47016. touchPointNodeName?: string;
  47017. };
  47018. };
  47019. /**
  47020. * Is it xr standard mapping or not
  47021. */
  47022. gamepadMapping: "" | "xr-standard";
  47023. /**
  47024. * Base root node of this entire model
  47025. */
  47026. rootNodeName: string;
  47027. /**
  47028. * Defines the main button component id
  47029. */
  47030. selectComponentId: string;
  47031. }
  47032. /**
  47033. * A definition for the layout map in the input profile
  47034. */
  47035. export interface IMotionControllerLayoutMap {
  47036. /**
  47037. * Layouts with handedness type as a key
  47038. */
  47039. [handedness: string]: IMotionControllerLayout;
  47040. }
  47041. /**
  47042. * The XR Input profile schema
  47043. * Profiles can be found here:
  47044. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47045. */
  47046. export interface IMotionControllerProfile {
  47047. /**
  47048. * fallback profiles for this profileId
  47049. */
  47050. fallbackProfileIds: string[];
  47051. /**
  47052. * The layout map, with handedness as key
  47053. */
  47054. layouts: IMotionControllerLayoutMap;
  47055. /**
  47056. * The id of this profile
  47057. * correlates to the profile(s) in the xrInput.profiles array
  47058. */
  47059. profileId: string;
  47060. }
  47061. /**
  47062. * A helper-interface for the 3 meshes needed for controller button animation
  47063. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47064. */
  47065. export interface IMotionControllerButtonMeshMap {
  47066. /**
  47067. * the mesh that defines the pressed value mesh position.
  47068. * This is used to find the max-position of this button
  47069. */
  47070. pressedMesh: AbstractMesh;
  47071. /**
  47072. * the mesh that defines the unpressed value mesh position.
  47073. * This is used to find the min (or initial) position of this button
  47074. */
  47075. unpressedMesh: AbstractMesh;
  47076. /**
  47077. * The mesh that will be changed when value changes
  47078. */
  47079. valueMesh: AbstractMesh;
  47080. }
  47081. /**
  47082. * A helper-interface for the 3 meshes needed for controller axis animation.
  47083. * This will be expanded when touchpad animations are fully supported
  47084. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47085. */
  47086. export interface IMotionControllerMeshMap {
  47087. /**
  47088. * the mesh that defines the maximum value mesh position.
  47089. */
  47090. maxMesh?: AbstractMesh;
  47091. /**
  47092. * the mesh that defines the minimum value mesh position.
  47093. */
  47094. minMesh?: AbstractMesh;
  47095. /**
  47096. * The mesh that will be changed when axis value changes
  47097. */
  47098. valueMesh: AbstractMesh;
  47099. }
  47100. /**
  47101. * The elements needed for change-detection of the gamepad objects in motion controllers
  47102. */
  47103. export interface IMinimalMotionControllerObject {
  47104. /**
  47105. * Available axes of this controller
  47106. */
  47107. axes: number[];
  47108. /**
  47109. * An array of available buttons
  47110. */
  47111. buttons: Array<{
  47112. /**
  47113. * Value of the button/trigger
  47114. */
  47115. value: number;
  47116. /**
  47117. * If the button/trigger is currently touched
  47118. */
  47119. touched: boolean;
  47120. /**
  47121. * If the button/trigger is currently pressed
  47122. */
  47123. pressed: boolean;
  47124. }>;
  47125. /**
  47126. * EXPERIMENTAL haptic support.
  47127. */
  47128. hapticActuators?: Array<{
  47129. pulse: (value: number, duration: number) => Promise<boolean>;
  47130. }>;
  47131. }
  47132. /**
  47133. * An Abstract Motion controller
  47134. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47135. * Each component has an observable to check for changes in value and state
  47136. */
  47137. export abstract class WebXRAbstractMotionController implements IDisposable {
  47138. protected scene: Scene;
  47139. protected layout: IMotionControllerLayout;
  47140. /**
  47141. * The gamepad object correlating to this controller
  47142. */
  47143. gamepadObject: IMinimalMotionControllerObject;
  47144. /**
  47145. * handedness (left/right/none) of this controller
  47146. */
  47147. handedness: MotionControllerHandedness;
  47148. private _initComponent;
  47149. private _modelReady;
  47150. /**
  47151. * A map of components (WebXRControllerComponent) in this motion controller
  47152. * Components have a ComponentType and can also have both button and axis definitions
  47153. */
  47154. readonly components: {
  47155. [id: string]: WebXRControllerComponent;
  47156. };
  47157. /**
  47158. * Disable the model's animation. Can be set at any time.
  47159. */
  47160. disableAnimation: boolean;
  47161. /**
  47162. * Observers registered here will be triggered when the model of this controller is done loading
  47163. */
  47164. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47165. /**
  47166. * The profile id of this motion controller
  47167. */
  47168. abstract profileId: string;
  47169. /**
  47170. * The root mesh of the model. It is null if the model was not yet initialized
  47171. */
  47172. rootMesh: Nullable<AbstractMesh>;
  47173. /**
  47174. * constructs a new abstract motion controller
  47175. * @param scene the scene to which the model of the controller will be added
  47176. * @param layout The profile layout to load
  47177. * @param gamepadObject The gamepad object correlating to this controller
  47178. * @param handedness handedness (left/right/none) of this controller
  47179. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47180. */
  47181. constructor(scene: Scene, layout: IMotionControllerLayout,
  47182. /**
  47183. * The gamepad object correlating to this controller
  47184. */
  47185. gamepadObject: IMinimalMotionControllerObject,
  47186. /**
  47187. * handedness (left/right/none) of this controller
  47188. */
  47189. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47190. /**
  47191. * Dispose this controller, the model mesh and all its components
  47192. */
  47193. dispose(): void;
  47194. /**
  47195. * Returns all components of specific type
  47196. * @param type the type to search for
  47197. * @return an array of components with this type
  47198. */
  47199. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47200. /**
  47201. * get a component based an its component id as defined in layout.components
  47202. * @param id the id of the component
  47203. * @returns the component correlates to the id or undefined if not found
  47204. */
  47205. getComponent(id: string): WebXRControllerComponent;
  47206. /**
  47207. * Get the list of components available in this motion controller
  47208. * @returns an array of strings correlating to available components
  47209. */
  47210. getComponentIds(): string[];
  47211. /**
  47212. * Get the first component of specific type
  47213. * @param type type of component to find
  47214. * @return a controller component or null if not found
  47215. */
  47216. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47217. /**
  47218. * Get the main (Select) component of this controller as defined in the layout
  47219. * @returns the main component of this controller
  47220. */
  47221. getMainComponent(): WebXRControllerComponent;
  47222. /**
  47223. * Loads the model correlating to this controller
  47224. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47225. * @returns A promise fulfilled with the result of the model loading
  47226. */
  47227. loadModel(): Promise<boolean>;
  47228. /**
  47229. * Update this model using the current XRFrame
  47230. * @param xrFrame the current xr frame to use and update the model
  47231. */
  47232. updateFromXRFrame(xrFrame: XRFrame): void;
  47233. /**
  47234. * Backwards compatibility due to a deeply-integrated typo
  47235. */
  47236. get handness(): XREye;
  47237. /**
  47238. * Pulse (vibrate) this controller
  47239. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47240. * Consecutive calls to this function will cancel the last pulse call
  47241. *
  47242. * @param value the strength of the pulse in 0.0...1.0 range
  47243. * @param duration Duration of the pulse in milliseconds
  47244. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47245. * @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
  47246. */
  47247. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47248. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47249. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47250. /**
  47251. * Moves the axis on the controller mesh based on its current state
  47252. * @param axis the index of the axis
  47253. * @param axisValue the value of the axis which determines the meshes new position
  47254. * @hidden
  47255. */
  47256. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47257. /**
  47258. * Update the model itself with the current frame data
  47259. * @param xrFrame the frame to use for updating the model mesh
  47260. */
  47261. protected updateModel(xrFrame: XRFrame): void;
  47262. /**
  47263. * Get the filename and path for this controller's model
  47264. * @returns a map of filename and path
  47265. */
  47266. protected abstract _getFilenameAndPath(): {
  47267. filename: string;
  47268. path: string;
  47269. };
  47270. /**
  47271. * This function is called before the mesh is loaded. It checks for loading constraints.
  47272. * For example, this function can check if the GLB loader is available
  47273. * If this function returns false, the generic controller will be loaded instead
  47274. * @returns Is the client ready to load the mesh
  47275. */
  47276. protected abstract _getModelLoadingConstraints(): boolean;
  47277. /**
  47278. * This function will be called after the model was successfully loaded and can be used
  47279. * for mesh transformations before it is available for the user
  47280. * @param meshes the loaded meshes
  47281. */
  47282. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47283. /**
  47284. * Set the root mesh for this controller. Important for the WebXR controller class
  47285. * @param meshes the loaded meshes
  47286. */
  47287. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47288. /**
  47289. * A function executed each frame that updates the mesh (if needed)
  47290. * @param xrFrame the current xrFrame
  47291. */
  47292. protected abstract _updateModel(xrFrame: XRFrame): void;
  47293. private _getGenericFilenameAndPath;
  47294. private _getGenericParentMesh;
  47295. }
  47296. }
  47297. declare module BABYLON {
  47298. /**
  47299. * A generic trigger-only motion controller for WebXR
  47300. */
  47301. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47302. /**
  47303. * Static version of the profile id of this controller
  47304. */
  47305. static ProfileId: string;
  47306. profileId: string;
  47307. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47308. protected _getFilenameAndPath(): {
  47309. filename: string;
  47310. path: string;
  47311. };
  47312. protected _getModelLoadingConstraints(): boolean;
  47313. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47314. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47315. protected _updateModel(): void;
  47316. }
  47317. }
  47318. declare module BABYLON {
  47319. /**
  47320. * Class containing static functions to help procedurally build meshes
  47321. */
  47322. export class SphereBuilder {
  47323. /**
  47324. * Creates a sphere mesh
  47325. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47326. * * 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`)
  47327. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47328. * * 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
  47329. * * 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)
  47330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47331. * * 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
  47332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47333. * @param name defines the name of the mesh
  47334. * @param options defines the options used to create the mesh
  47335. * @param scene defines the hosting scene
  47336. * @returns the sphere mesh
  47337. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47338. */
  47339. static CreateSphere(name: string, options: {
  47340. segments?: number;
  47341. diameter?: number;
  47342. diameterX?: number;
  47343. diameterY?: number;
  47344. diameterZ?: number;
  47345. arc?: number;
  47346. slice?: number;
  47347. sideOrientation?: number;
  47348. frontUVs?: Vector4;
  47349. backUVs?: Vector4;
  47350. updatable?: boolean;
  47351. }, scene?: Nullable<Scene>): Mesh;
  47352. }
  47353. }
  47354. declare module BABYLON {
  47355. /**
  47356. * A profiled motion controller has its profile loaded from an online repository.
  47357. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47358. */
  47359. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47360. private _repositoryUrl;
  47361. private _buttonMeshMapping;
  47362. private _touchDots;
  47363. /**
  47364. * The profile ID of this controller. Will be populated when the controller initializes.
  47365. */
  47366. profileId: string;
  47367. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47368. dispose(): void;
  47369. protected _getFilenameAndPath(): {
  47370. filename: string;
  47371. path: string;
  47372. };
  47373. protected _getModelLoadingConstraints(): boolean;
  47374. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47375. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47376. protected _updateModel(_xrFrame: XRFrame): void;
  47377. }
  47378. }
  47379. declare module BABYLON {
  47380. /**
  47381. * A construction function type to create a new controller based on an xrInput object
  47382. */
  47383. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47384. /**
  47385. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47386. *
  47387. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47388. * it should be replaced with auto-loaded controllers.
  47389. *
  47390. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47391. */
  47392. export class WebXRMotionControllerManager {
  47393. private static _AvailableControllers;
  47394. private static _Fallbacks;
  47395. private static _ProfileLoadingPromises;
  47396. private static _ProfilesList;
  47397. /**
  47398. * The base URL of the online controller repository. Can be changed at any time.
  47399. */
  47400. static BaseRepositoryUrl: string;
  47401. /**
  47402. * Which repository gets priority - local or online
  47403. */
  47404. static PrioritizeOnlineRepository: boolean;
  47405. /**
  47406. * Use the online repository, or use only locally-defined controllers
  47407. */
  47408. static UseOnlineRepository: boolean;
  47409. /**
  47410. * Clear the cache used for profile loading and reload when requested again
  47411. */
  47412. static ClearProfilesCache(): void;
  47413. /**
  47414. * Register the default fallbacks.
  47415. * This function is called automatically when this file is imported.
  47416. */
  47417. static DefaultFallbacks(): void;
  47418. /**
  47419. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47420. * @param profileId the profile to which a fallback needs to be found
  47421. * @return an array with corresponding fallback profiles
  47422. */
  47423. static FindFallbackWithProfileId(profileId: string): string[];
  47424. /**
  47425. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47426. * The order of search:
  47427. *
  47428. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47429. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47430. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47431. * 4) return the generic trigger controller if none were found
  47432. *
  47433. * @param xrInput the xrInput to which a new controller is initialized
  47434. * @param scene the scene to which the model will be added
  47435. * @param forceProfile force a certain profile for this controller
  47436. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47437. */
  47438. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47439. /**
  47440. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47441. *
  47442. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47443. *
  47444. * @param type the profile type to register
  47445. * @param constructFunction the function to be called when loading this profile
  47446. */
  47447. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47448. /**
  47449. * Register a fallback to a specific profile.
  47450. * @param profileId the profileId that will receive the fallbacks
  47451. * @param fallbacks A list of fallback profiles
  47452. */
  47453. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47454. /**
  47455. * Will update the list of profiles available in the repository
  47456. * @return a promise that resolves to a map of profiles available online
  47457. */
  47458. static UpdateProfilesList(): Promise<{
  47459. [profile: string]: string;
  47460. }>;
  47461. private static _LoadProfileFromRepository;
  47462. private static _LoadProfilesFromAvailableControllers;
  47463. }
  47464. }
  47465. declare module BABYLON {
  47466. /**
  47467. * Configuration options for the WebXR controller creation
  47468. */
  47469. export interface IWebXRControllerOptions {
  47470. /**
  47471. * Should the controller mesh be animated when a user interacts with it
  47472. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47473. */
  47474. disableMotionControllerAnimation?: boolean;
  47475. /**
  47476. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47477. */
  47478. doNotLoadControllerMesh?: boolean;
  47479. /**
  47480. * Force a specific controller type for this controller.
  47481. * This can be used when creating your own profile or when testing different controllers
  47482. */
  47483. forceControllerProfile?: string;
  47484. /**
  47485. * Defines a rendering group ID for meshes that will be loaded.
  47486. * This is for the default controllers only.
  47487. */
  47488. renderingGroupId?: number;
  47489. }
  47490. /**
  47491. * Represents an XR controller
  47492. */
  47493. export class WebXRInputSource {
  47494. private _scene;
  47495. /** The underlying input source for the controller */
  47496. inputSource: XRInputSource;
  47497. private _options;
  47498. private _tmpVector;
  47499. private _uniqueId;
  47500. /**
  47501. * 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
  47502. */
  47503. grip?: AbstractMesh;
  47504. /**
  47505. * If available, this is the gamepad object related to this controller.
  47506. * Using this object it is possible to get click events and trackpad changes of the
  47507. * webxr controller that is currently being used.
  47508. */
  47509. motionController?: WebXRAbstractMotionController;
  47510. /**
  47511. * Event that fires when the controller is removed/disposed.
  47512. * The object provided as event data is this controller, after associated assets were disposed.
  47513. * uniqueId is still available.
  47514. */
  47515. onDisposeObservable: Observable<WebXRInputSource>;
  47516. /**
  47517. * Will be triggered when the mesh associated with the motion controller is done loading.
  47518. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47519. * A shortened version of controller -> motion controller -> on mesh loaded.
  47520. */
  47521. onMeshLoadedObservable: Observable<AbstractMesh>;
  47522. /**
  47523. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47524. */
  47525. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47526. /**
  47527. * Pointer which can be used to select objects or attach a visible laser to
  47528. */
  47529. pointer: AbstractMesh;
  47530. /**
  47531. * Creates the controller
  47532. * @see https://doc.babylonjs.com/how_to/webxr
  47533. * @param _scene the scene which the controller should be associated to
  47534. * @param inputSource the underlying input source for the controller
  47535. * @param _options options for this controller creation
  47536. */
  47537. constructor(_scene: Scene,
  47538. /** The underlying input source for the controller */
  47539. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47540. /**
  47541. * Get this controllers unique id
  47542. */
  47543. get uniqueId(): string;
  47544. /**
  47545. * Disposes of the object
  47546. */
  47547. dispose(): void;
  47548. /**
  47549. * Gets a world space ray coming from the pointer or grip
  47550. * @param result the resulting ray
  47551. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47552. */
  47553. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47554. /**
  47555. * Updates the controller pose based on the given XRFrame
  47556. * @param xrFrame xr frame to update the pose with
  47557. * @param referenceSpace reference space to use
  47558. */
  47559. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47560. }
  47561. }
  47562. declare module BABYLON {
  47563. /**
  47564. * The schema for initialization options of the XR Input class
  47565. */
  47566. export interface IWebXRInputOptions {
  47567. /**
  47568. * If set to true no model will be automatically loaded
  47569. */
  47570. doNotLoadControllerMeshes?: boolean;
  47571. /**
  47572. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47573. * If not found, the xr input profile data will be used.
  47574. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47575. */
  47576. forceInputProfile?: string;
  47577. /**
  47578. * Do not send a request to the controller repository to load the profile.
  47579. *
  47580. * Instead, use the controllers available in babylon itself.
  47581. */
  47582. disableOnlineControllerRepository?: boolean;
  47583. /**
  47584. * A custom URL for the controllers repository
  47585. */
  47586. customControllersRepositoryURL?: string;
  47587. /**
  47588. * Should the controller model's components not move according to the user input
  47589. */
  47590. disableControllerAnimation?: boolean;
  47591. /**
  47592. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47593. */
  47594. controllerOptions?: IWebXRControllerOptions;
  47595. }
  47596. /**
  47597. * XR input used to track XR inputs such as controllers/rays
  47598. */
  47599. export class WebXRInput implements IDisposable {
  47600. /**
  47601. * the xr session manager for this session
  47602. */
  47603. xrSessionManager: WebXRSessionManager;
  47604. /**
  47605. * the WebXR camera for this session. Mainly used for teleportation
  47606. */
  47607. xrCamera: WebXRCamera;
  47608. private readonly options;
  47609. /**
  47610. * XR controllers being tracked
  47611. */
  47612. controllers: Array<WebXRInputSource>;
  47613. private _frameObserver;
  47614. private _sessionEndedObserver;
  47615. private _sessionInitObserver;
  47616. /**
  47617. * Event when a controller has been connected/added
  47618. */
  47619. onControllerAddedObservable: Observable<WebXRInputSource>;
  47620. /**
  47621. * Event when a controller has been removed/disconnected
  47622. */
  47623. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47624. /**
  47625. * Initializes the WebXRInput
  47626. * @param xrSessionManager the xr session manager for this session
  47627. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47628. * @param options = initialization options for this xr input
  47629. */
  47630. constructor(
  47631. /**
  47632. * the xr session manager for this session
  47633. */
  47634. xrSessionManager: WebXRSessionManager,
  47635. /**
  47636. * the WebXR camera for this session. Mainly used for teleportation
  47637. */
  47638. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47639. private _onInputSourcesChange;
  47640. private _addAndRemoveControllers;
  47641. /**
  47642. * Disposes of the object
  47643. */
  47644. dispose(): void;
  47645. }
  47646. }
  47647. declare module BABYLON {
  47648. /**
  47649. * This is the base class for all WebXR features.
  47650. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47651. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47652. */
  47653. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47654. protected _xrSessionManager: WebXRSessionManager;
  47655. private _attached;
  47656. private _removeOnDetach;
  47657. /**
  47658. * Should auto-attach be disabled?
  47659. */
  47660. disableAutoAttach: boolean;
  47661. /**
  47662. * Construct a new (abstract) WebXR feature
  47663. * @param _xrSessionManager the xr session manager for this feature
  47664. */
  47665. constructor(_xrSessionManager: WebXRSessionManager);
  47666. /**
  47667. * Is this feature attached
  47668. */
  47669. get attached(): boolean;
  47670. /**
  47671. * attach this feature
  47672. *
  47673. * @param force should attachment be forced (even when already attached)
  47674. * @returns true if successful, false is failed or already attached
  47675. */
  47676. attach(force?: boolean): boolean;
  47677. /**
  47678. * detach this feature.
  47679. *
  47680. * @returns true if successful, false if failed or already detached
  47681. */
  47682. detach(): boolean;
  47683. /**
  47684. * Dispose this feature and all of the resources attached
  47685. */
  47686. dispose(): void;
  47687. /**
  47688. * This is used to register callbacks that will automatically be removed when detach is called.
  47689. * @param observable the observable to which the observer will be attached
  47690. * @param callback the callback to register
  47691. */
  47692. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47693. /**
  47694. * Code in this function will be executed on each xrFrame received from the browser.
  47695. * This function will not execute after the feature is detached.
  47696. * @param _xrFrame the current frame
  47697. */
  47698. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47699. }
  47700. }
  47701. declare module BABYLON {
  47702. /**
  47703. * Renders a layer on top of an existing scene
  47704. */
  47705. export class UtilityLayerRenderer implements IDisposable {
  47706. /** the original scene that will be rendered on top of */
  47707. originalScene: Scene;
  47708. private _pointerCaptures;
  47709. private _lastPointerEvents;
  47710. private static _DefaultUtilityLayer;
  47711. private static _DefaultKeepDepthUtilityLayer;
  47712. private _sharedGizmoLight;
  47713. private _renderCamera;
  47714. /**
  47715. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47716. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47717. * @returns the camera that is used when rendering the utility layer
  47718. */
  47719. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47720. /**
  47721. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47722. * @param cam the camera that should be used when rendering the utility layer
  47723. */
  47724. setRenderCamera(cam: Nullable<Camera>): void;
  47725. /**
  47726. * @hidden
  47727. * Light which used by gizmos to get light shading
  47728. */
  47729. _getSharedGizmoLight(): HemisphericLight;
  47730. /**
  47731. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47732. */
  47733. pickUtilitySceneFirst: boolean;
  47734. /**
  47735. * 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)
  47736. */
  47737. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47738. /**
  47739. * 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)
  47740. */
  47741. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47742. /**
  47743. * The scene that is rendered on top of the original scene
  47744. */
  47745. utilityLayerScene: Scene;
  47746. /**
  47747. * If the utility layer should automatically be rendered on top of existing scene
  47748. */
  47749. shouldRender: boolean;
  47750. /**
  47751. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47752. */
  47753. onlyCheckPointerDownEvents: boolean;
  47754. /**
  47755. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47756. */
  47757. processAllEvents: boolean;
  47758. /**
  47759. * Observable raised when the pointer move from the utility layer scene to the main scene
  47760. */
  47761. onPointerOutObservable: Observable<number>;
  47762. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47763. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47764. private _afterRenderObserver;
  47765. private _sceneDisposeObserver;
  47766. private _originalPointerObserver;
  47767. /**
  47768. * Instantiates a UtilityLayerRenderer
  47769. * @param originalScene the original scene that will be rendered on top of
  47770. * @param handleEvents boolean indicating if the utility layer should handle events
  47771. */
  47772. constructor(
  47773. /** the original scene that will be rendered on top of */
  47774. originalScene: Scene, handleEvents?: boolean);
  47775. private _notifyObservers;
  47776. /**
  47777. * Renders the utility layers scene on top of the original scene
  47778. */
  47779. render(): void;
  47780. /**
  47781. * Disposes of the renderer
  47782. */
  47783. dispose(): void;
  47784. private _updateCamera;
  47785. }
  47786. }
  47787. declare module BABYLON {
  47788. /**
  47789. * Options interface for the pointer selection module
  47790. */
  47791. export interface IWebXRControllerPointerSelectionOptions {
  47792. /**
  47793. * if provided, this scene will be used to render meshes.
  47794. */
  47795. customUtilityLayerScene?: Scene;
  47796. /**
  47797. * 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)
  47798. * If not disabled, the last picked point will be used to execute a pointer up event
  47799. * If disabled, pointer up event will be triggered right after the pointer down event.
  47800. * Used in screen and gaze target ray mode only
  47801. */
  47802. disablePointerUpOnTouchOut: boolean;
  47803. /**
  47804. * For gaze mode (time to select instead of press)
  47805. */
  47806. forceGazeMode: boolean;
  47807. /**
  47808. * 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
  47809. * to start a new countdown to the pointer down event.
  47810. * Defaults to 1.
  47811. */
  47812. gazeModePointerMovedFactor?: number;
  47813. /**
  47814. * Different button type to use instead of the main component
  47815. */
  47816. overrideButtonId?: string;
  47817. /**
  47818. * use this rendering group id for the meshes (optional)
  47819. */
  47820. renderingGroupId?: number;
  47821. /**
  47822. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47823. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47824. * 3000 means 3 seconds between pointing at something and selecting it
  47825. */
  47826. timeToSelect?: number;
  47827. /**
  47828. * Should meshes created here be added to a utility layer or the main scene
  47829. */
  47830. useUtilityLayer?: boolean;
  47831. /**
  47832. * the xr input to use with this pointer selection
  47833. */
  47834. xrInput: WebXRInput;
  47835. }
  47836. /**
  47837. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47838. */
  47839. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47840. private readonly _options;
  47841. private static _idCounter;
  47842. private _attachController;
  47843. private _controllers;
  47844. private _scene;
  47845. private _tmpVectorForPickCompare;
  47846. /**
  47847. * The module's name
  47848. */
  47849. static readonly Name: string;
  47850. /**
  47851. * The (Babylon) version of this module.
  47852. * This is an integer representing the implementation version.
  47853. * This number does not correspond to the WebXR specs version
  47854. */
  47855. static readonly Version: number;
  47856. /**
  47857. * Disable lighting on the laser pointer (so it will always be visible)
  47858. */
  47859. disablePointerLighting: boolean;
  47860. /**
  47861. * Disable lighting on the selection mesh (so it will always be visible)
  47862. */
  47863. disableSelectionMeshLighting: boolean;
  47864. /**
  47865. * Should the laser pointer be displayed
  47866. */
  47867. displayLaserPointer: boolean;
  47868. /**
  47869. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47870. */
  47871. displaySelectionMesh: boolean;
  47872. /**
  47873. * This color will be set to the laser pointer when selection is triggered
  47874. */
  47875. laserPointerPickedColor: Color3;
  47876. /**
  47877. * Default color of the laser pointer
  47878. */
  47879. laserPointerDefaultColor: Color3;
  47880. /**
  47881. * default color of the selection ring
  47882. */
  47883. selectionMeshDefaultColor: Color3;
  47884. /**
  47885. * This color will be applied to the selection ring when selection is triggered
  47886. */
  47887. selectionMeshPickedColor: Color3;
  47888. /**
  47889. * Optional filter to be used for ray selection. This predicate shares behavior with
  47890. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47891. */
  47892. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47893. /**
  47894. * constructs a new background remover module
  47895. * @param _xrSessionManager the session manager for this module
  47896. * @param _options read-only options to be used in this module
  47897. */
  47898. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47899. /**
  47900. * attach this feature
  47901. * Will usually be called by the features manager
  47902. *
  47903. * @returns true if successful.
  47904. */
  47905. attach(): boolean;
  47906. /**
  47907. * detach this feature.
  47908. * Will usually be called by the features manager
  47909. *
  47910. * @returns true if successful.
  47911. */
  47912. detach(): boolean;
  47913. /**
  47914. * Will get the mesh under a specific pointer.
  47915. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47916. * @param controllerId the controllerId to check
  47917. * @returns The mesh under pointer or null if no mesh is under the pointer
  47918. */
  47919. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47920. /**
  47921. * Get the xr controller that correlates to the pointer id in the pointer event
  47922. *
  47923. * @param id the pointer id to search for
  47924. * @returns the controller that correlates to this id or null if not found
  47925. */
  47926. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47927. protected _onXRFrame(_xrFrame: XRFrame): void;
  47928. private _attachGazeMode;
  47929. private _attachScreenRayMode;
  47930. private _attachTrackedPointerRayMode;
  47931. private _convertNormalToDirectionOfRay;
  47932. private _detachController;
  47933. private _generateNewMeshPair;
  47934. private _pickingMoved;
  47935. private _updatePointerDistance;
  47936. /** @hidden */
  47937. get lasterPointerDefaultColor(): Color3;
  47938. }
  47939. }
  47940. declare module BABYLON {
  47941. /**
  47942. * Button which can be used to enter a different mode of XR
  47943. */
  47944. export class WebXREnterExitUIButton {
  47945. /** button element */
  47946. element: HTMLElement;
  47947. /** XR initialization options for the button */
  47948. sessionMode: XRSessionMode;
  47949. /** Reference space type */
  47950. referenceSpaceType: XRReferenceSpaceType;
  47951. /**
  47952. * Creates a WebXREnterExitUIButton
  47953. * @param element button element
  47954. * @param sessionMode XR initialization session mode
  47955. * @param referenceSpaceType the type of reference space to be used
  47956. */
  47957. constructor(
  47958. /** button element */
  47959. element: HTMLElement,
  47960. /** XR initialization options for the button */
  47961. sessionMode: XRSessionMode,
  47962. /** Reference space type */
  47963. referenceSpaceType: XRReferenceSpaceType);
  47964. /**
  47965. * Extendable function which can be used to update the button's visuals when the state changes
  47966. * @param activeButton the current active button in the UI
  47967. */
  47968. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47969. }
  47970. /**
  47971. * Options to create the webXR UI
  47972. */
  47973. export class WebXREnterExitUIOptions {
  47974. /**
  47975. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47976. */
  47977. customButtons?: Array<WebXREnterExitUIButton>;
  47978. /**
  47979. * A reference space type to use when creating the default button.
  47980. * Default is local-floor
  47981. */
  47982. referenceSpaceType?: XRReferenceSpaceType;
  47983. /**
  47984. * Context to enter xr with
  47985. */
  47986. renderTarget?: Nullable<WebXRRenderTarget>;
  47987. /**
  47988. * A session mode to use when creating the default button.
  47989. * Default is immersive-vr
  47990. */
  47991. sessionMode?: XRSessionMode;
  47992. /**
  47993. * A list of optional features to init the session with
  47994. */
  47995. optionalFeatures?: string[];
  47996. }
  47997. /**
  47998. * UI to allow the user to enter/exit XR mode
  47999. */
  48000. export class WebXREnterExitUI implements IDisposable {
  48001. private scene;
  48002. /** version of the options passed to this UI */
  48003. options: WebXREnterExitUIOptions;
  48004. private _activeButton;
  48005. private _buttons;
  48006. private _overlay;
  48007. /**
  48008. * Fired every time the active button is changed.
  48009. *
  48010. * When xr is entered via a button that launches xr that button will be the callback parameter
  48011. *
  48012. * When exiting xr the callback parameter will be null)
  48013. */
  48014. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48015. /**
  48016. *
  48017. * @param scene babylon scene object to use
  48018. * @param options (read-only) version of the options passed to this UI
  48019. */
  48020. private constructor();
  48021. /**
  48022. * Creates UI to allow the user to enter/exit XR mode
  48023. * @param scene the scene to add the ui to
  48024. * @param helper the xr experience helper to enter/exit xr with
  48025. * @param options options to configure the UI
  48026. * @returns the created ui
  48027. */
  48028. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48029. /**
  48030. * Disposes of the XR UI component
  48031. */
  48032. dispose(): void;
  48033. private _updateButtons;
  48034. }
  48035. }
  48036. declare module BABYLON {
  48037. /**
  48038. * Class containing static functions to help procedurally build meshes
  48039. */
  48040. export class LinesBuilder {
  48041. /**
  48042. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48043. * * 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
  48044. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48045. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48046. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48047. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48048. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48049. * * 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
  48050. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48053. * @param name defines the name of the new line system
  48054. * @param options defines the options used to create the line system
  48055. * @param scene defines the hosting scene
  48056. * @returns a new line system mesh
  48057. */
  48058. static CreateLineSystem(name: string, options: {
  48059. lines: Vector3[][];
  48060. updatable?: boolean;
  48061. instance?: Nullable<LinesMesh>;
  48062. colors?: Nullable<Color4[][]>;
  48063. useVertexAlpha?: boolean;
  48064. }, scene: Nullable<Scene>): LinesMesh;
  48065. /**
  48066. * Creates a line mesh
  48067. * 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
  48068. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48069. * * The parameter `points` is an array successive Vector3
  48070. * * 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
  48071. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48072. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48073. * * When updating an instance, remember that only point positions can change, not the number of points
  48074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48075. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48076. * @param name defines the name of the new line system
  48077. * @param options defines the options used to create the line system
  48078. * @param scene defines the hosting scene
  48079. * @returns a new line mesh
  48080. */
  48081. static CreateLines(name: string, options: {
  48082. points: Vector3[];
  48083. updatable?: boolean;
  48084. instance?: Nullable<LinesMesh>;
  48085. colors?: Color4[];
  48086. useVertexAlpha?: boolean;
  48087. }, scene?: Nullable<Scene>): LinesMesh;
  48088. /**
  48089. * Creates a dashed line mesh
  48090. * * 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
  48091. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48092. * * The parameter `points` is an array successive Vector3
  48093. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48094. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48095. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48096. * * 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
  48097. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48098. * * When updating an instance, remember that only point positions can change, not the number of points
  48099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48100. * @param name defines the name of the mesh
  48101. * @param options defines the options used to create the mesh
  48102. * @param scene defines the hosting scene
  48103. * @returns the dashed line mesh
  48104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48105. */
  48106. static CreateDashedLines(name: string, options: {
  48107. points: Vector3[];
  48108. dashSize?: number;
  48109. gapSize?: number;
  48110. dashNb?: number;
  48111. updatable?: boolean;
  48112. instance?: LinesMesh;
  48113. useVertexAlpha?: boolean;
  48114. }, scene?: Nullable<Scene>): LinesMesh;
  48115. }
  48116. }
  48117. declare module BABYLON {
  48118. /**
  48119. * Construction options for a timer
  48120. */
  48121. export interface ITimerOptions<T> {
  48122. /**
  48123. * Time-to-end
  48124. */
  48125. timeout: number;
  48126. /**
  48127. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48128. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48129. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48130. */
  48131. contextObservable: Observable<T>;
  48132. /**
  48133. * Optional parameters when adding an observer to the observable
  48134. */
  48135. observableParameters?: {
  48136. mask?: number;
  48137. insertFirst?: boolean;
  48138. scope?: any;
  48139. };
  48140. /**
  48141. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48142. */
  48143. breakCondition?: (data?: ITimerData<T>) => boolean;
  48144. /**
  48145. * Will be triggered when the time condition has met
  48146. */
  48147. onEnded?: (data: ITimerData<any>) => void;
  48148. /**
  48149. * Will be triggered when the break condition has met (prematurely ended)
  48150. */
  48151. onAborted?: (data: ITimerData<any>) => void;
  48152. /**
  48153. * Optional function to execute on each tick (or count)
  48154. */
  48155. onTick?: (data: ITimerData<any>) => void;
  48156. }
  48157. /**
  48158. * An interface defining the data sent by the timer
  48159. */
  48160. export interface ITimerData<T> {
  48161. /**
  48162. * When did it start
  48163. */
  48164. startTime: number;
  48165. /**
  48166. * Time now
  48167. */
  48168. currentTime: number;
  48169. /**
  48170. * Time passed since started
  48171. */
  48172. deltaTime: number;
  48173. /**
  48174. * How much is completed, in [0.0...1.0].
  48175. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48176. */
  48177. completeRate: number;
  48178. /**
  48179. * What the registered observable sent in the last count
  48180. */
  48181. payload: T;
  48182. }
  48183. /**
  48184. * The current state of the timer
  48185. */
  48186. export enum TimerState {
  48187. /**
  48188. * Timer initialized, not yet started
  48189. */
  48190. INIT = 0,
  48191. /**
  48192. * Timer started and counting
  48193. */
  48194. STARTED = 1,
  48195. /**
  48196. * Timer ended (whether aborted or time reached)
  48197. */
  48198. ENDED = 2
  48199. }
  48200. /**
  48201. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48202. *
  48203. * @param options options with which to initialize this timer
  48204. */
  48205. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48206. /**
  48207. * An advanced implementation of a timer class
  48208. */
  48209. export class AdvancedTimer<T = any> implements IDisposable {
  48210. /**
  48211. * Will notify each time the timer calculates the remaining time
  48212. */
  48213. onEachCountObservable: Observable<ITimerData<T>>;
  48214. /**
  48215. * Will trigger when the timer was aborted due to the break condition
  48216. */
  48217. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48218. /**
  48219. * Will trigger when the timer ended successfully
  48220. */
  48221. onTimerEndedObservable: Observable<ITimerData<T>>;
  48222. /**
  48223. * Will trigger when the timer state has changed
  48224. */
  48225. onStateChangedObservable: Observable<TimerState>;
  48226. private _observer;
  48227. private _contextObservable;
  48228. private _observableParameters;
  48229. private _startTime;
  48230. private _timer;
  48231. private _state;
  48232. private _breakCondition;
  48233. private _timeToEnd;
  48234. private _breakOnNextTick;
  48235. /**
  48236. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48237. * @param options construction options for this advanced timer
  48238. */
  48239. constructor(options: ITimerOptions<T>);
  48240. /**
  48241. * set a breaking condition for this timer. Default is to never break during count
  48242. * @param predicate the new break condition. Returns true to break, false otherwise
  48243. */
  48244. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48245. /**
  48246. * Reset ALL associated observables in this advanced timer
  48247. */
  48248. clearObservables(): void;
  48249. /**
  48250. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48251. *
  48252. * @param timeToEnd how much time to measure until timer ended
  48253. */
  48254. start(timeToEnd?: number): void;
  48255. /**
  48256. * Will force a stop on the next tick.
  48257. */
  48258. stop(): void;
  48259. /**
  48260. * Dispose this timer, clearing all resources
  48261. */
  48262. dispose(): void;
  48263. private _setState;
  48264. private _tick;
  48265. private _stop;
  48266. }
  48267. }
  48268. declare module BABYLON {
  48269. /**
  48270. * The options container for the teleportation module
  48271. */
  48272. export interface IWebXRTeleportationOptions {
  48273. /**
  48274. * if provided, this scene will be used to render meshes.
  48275. */
  48276. customUtilityLayerScene?: Scene;
  48277. /**
  48278. * Values to configure the default target mesh
  48279. */
  48280. defaultTargetMeshOptions?: {
  48281. /**
  48282. * Fill color of the teleportation area
  48283. */
  48284. teleportationFillColor?: string;
  48285. /**
  48286. * Border color for the teleportation area
  48287. */
  48288. teleportationBorderColor?: string;
  48289. /**
  48290. * Disable the mesh's animation sequence
  48291. */
  48292. disableAnimation?: boolean;
  48293. /**
  48294. * Disable lighting on the material or the ring and arrow
  48295. */
  48296. disableLighting?: boolean;
  48297. /**
  48298. * Override the default material of the torus and arrow
  48299. */
  48300. torusArrowMaterial?: Material;
  48301. };
  48302. /**
  48303. * A list of meshes to use as floor meshes.
  48304. * Meshes can be added and removed after initializing the feature using the
  48305. * addFloorMesh and removeFloorMesh functions
  48306. * If empty, rotation will still work
  48307. */
  48308. floorMeshes?: AbstractMesh[];
  48309. /**
  48310. * use this rendering group id for the meshes (optional)
  48311. */
  48312. renderingGroupId?: number;
  48313. /**
  48314. * Should teleportation move only to snap points
  48315. */
  48316. snapPointsOnly?: boolean;
  48317. /**
  48318. * An array of points to which the teleportation will snap to.
  48319. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48320. */
  48321. snapPositions?: Vector3[];
  48322. /**
  48323. * How close should the teleportation ray be in order to snap to position.
  48324. * Default to 0.8 units (meters)
  48325. */
  48326. snapToPositionRadius?: number;
  48327. /**
  48328. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48329. * If you want to support rotation, make sure your mesh has a direction indicator.
  48330. *
  48331. * When left untouched, the default mesh will be initialized.
  48332. */
  48333. teleportationTargetMesh?: AbstractMesh;
  48334. /**
  48335. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48336. */
  48337. timeToTeleport?: number;
  48338. /**
  48339. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48340. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48341. */
  48342. useMainComponentOnly?: boolean;
  48343. /**
  48344. * Should meshes created here be added to a utility layer or the main scene
  48345. */
  48346. useUtilityLayer?: boolean;
  48347. /**
  48348. * Babylon XR Input class for controller
  48349. */
  48350. xrInput: WebXRInput;
  48351. }
  48352. /**
  48353. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48354. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48355. * the input of the attached controllers.
  48356. */
  48357. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48358. private _options;
  48359. private _controllers;
  48360. private _currentTeleportationControllerId;
  48361. private _floorMeshes;
  48362. private _quadraticBezierCurve;
  48363. private _selectionFeature;
  48364. private _snapToPositions;
  48365. private _snappedToPoint;
  48366. private _teleportationRingMaterial?;
  48367. private _tmpRay;
  48368. private _tmpVector;
  48369. /**
  48370. * The module's name
  48371. */
  48372. static readonly Name: string;
  48373. /**
  48374. * The (Babylon) version of this module.
  48375. * This is an integer representing the implementation version.
  48376. * This number does not correspond to the webxr specs version
  48377. */
  48378. static readonly Version: number;
  48379. /**
  48380. * Is movement backwards enabled
  48381. */
  48382. backwardsMovementEnabled: boolean;
  48383. /**
  48384. * Distance to travel when moving backwards
  48385. */
  48386. backwardsTeleportationDistance: number;
  48387. /**
  48388. * The distance from the user to the inspection point in the direction of the controller
  48389. * A higher number will allow the user to move further
  48390. * defaults to 5 (meters, in xr units)
  48391. */
  48392. parabolicCheckRadius: number;
  48393. /**
  48394. * Should the module support parabolic ray on top of direct ray
  48395. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48396. * Very helpful when moving between floors / different heights
  48397. */
  48398. parabolicRayEnabled: boolean;
  48399. /**
  48400. * How much rotation should be applied when rotating right and left
  48401. */
  48402. rotationAngle: number;
  48403. /**
  48404. * Is rotation enabled when moving forward?
  48405. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48406. */
  48407. rotationEnabled: boolean;
  48408. /**
  48409. * constructs a new anchor system
  48410. * @param _xrSessionManager an instance of WebXRSessionManager
  48411. * @param _options configuration object for this feature
  48412. */
  48413. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48414. /**
  48415. * Get the snapPointsOnly flag
  48416. */
  48417. get snapPointsOnly(): boolean;
  48418. /**
  48419. * Sets the snapPointsOnly flag
  48420. * @param snapToPoints should teleportation be exclusively to snap points
  48421. */
  48422. set snapPointsOnly(snapToPoints: boolean);
  48423. /**
  48424. * Add a new mesh to the floor meshes array
  48425. * @param mesh the mesh to use as floor mesh
  48426. */
  48427. addFloorMesh(mesh: AbstractMesh): void;
  48428. /**
  48429. * Add a new snap-to point to fix teleportation to this position
  48430. * @param newSnapPoint The new Snap-To point
  48431. */
  48432. addSnapPoint(newSnapPoint: Vector3): void;
  48433. attach(): boolean;
  48434. detach(): boolean;
  48435. dispose(): void;
  48436. /**
  48437. * Remove a mesh from the floor meshes array
  48438. * @param mesh the mesh to remove
  48439. */
  48440. removeFloorMesh(mesh: AbstractMesh): void;
  48441. /**
  48442. * Remove a mesh from the floor meshes array using its name
  48443. * @param name the mesh name to remove
  48444. */
  48445. removeFloorMeshByName(name: string): void;
  48446. /**
  48447. * 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
  48448. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48449. * @returns was the point found and removed or not
  48450. */
  48451. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48452. /**
  48453. * This function sets a selection feature that will be disabled when
  48454. * the forward ray is shown and will be reattached when hidden.
  48455. * This is used to remove the selection rays when moving.
  48456. * @param selectionFeature the feature to disable when forward movement is enabled
  48457. */
  48458. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48459. protected _onXRFrame(_xrFrame: XRFrame): void;
  48460. private _attachController;
  48461. private _createDefaultTargetMesh;
  48462. private _detachController;
  48463. private _findClosestSnapPointWithRadius;
  48464. private _setTargetMeshPosition;
  48465. private _setTargetMeshVisibility;
  48466. private _showParabolicPath;
  48467. private _teleportForward;
  48468. }
  48469. }
  48470. declare module BABYLON {
  48471. /**
  48472. * Options for the default xr helper
  48473. */
  48474. export class WebXRDefaultExperienceOptions {
  48475. /**
  48476. * Enable or disable default UI to enter XR
  48477. */
  48478. disableDefaultUI?: boolean;
  48479. /**
  48480. * Should teleportation not initialize. defaults to false.
  48481. */
  48482. disableTeleportation?: boolean;
  48483. /**
  48484. * Floor meshes that will be used for teleport
  48485. */
  48486. floorMeshes?: Array<AbstractMesh>;
  48487. /**
  48488. * If set to true, the first frame will not be used to reset position
  48489. * The first frame is mainly used when copying transformation from the old camera
  48490. * Mainly used in AR
  48491. */
  48492. ignoreNativeCameraTransformation?: boolean;
  48493. /**
  48494. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48495. */
  48496. inputOptions?: IWebXRInputOptions;
  48497. /**
  48498. * optional configuration for the output canvas
  48499. */
  48500. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48501. /**
  48502. * optional UI options. This can be used among other to change session mode and reference space type
  48503. */
  48504. uiOptions?: WebXREnterExitUIOptions;
  48505. /**
  48506. * When loading teleportation and pointer select, use stable versions instead of latest.
  48507. */
  48508. useStablePlugins?: boolean;
  48509. /**
  48510. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48511. */
  48512. renderingGroupId?: number;
  48513. /**
  48514. * A list of optional features to init the session with
  48515. * If set to true, all features we support will be added
  48516. */
  48517. optionalFeatures?: boolean | string[];
  48518. }
  48519. /**
  48520. * Default experience which provides a similar setup to the previous webVRExperience
  48521. */
  48522. export class WebXRDefaultExperience {
  48523. /**
  48524. * Base experience
  48525. */
  48526. baseExperience: WebXRExperienceHelper;
  48527. /**
  48528. * Enables ui for entering/exiting xr
  48529. */
  48530. enterExitUI: WebXREnterExitUI;
  48531. /**
  48532. * Input experience extension
  48533. */
  48534. input: WebXRInput;
  48535. /**
  48536. * Enables laser pointer and selection
  48537. */
  48538. pointerSelection: WebXRControllerPointerSelection;
  48539. /**
  48540. * Default target xr should render to
  48541. */
  48542. renderTarget: WebXRRenderTarget;
  48543. /**
  48544. * Enables teleportation
  48545. */
  48546. teleportation: WebXRMotionControllerTeleportation;
  48547. private constructor();
  48548. /**
  48549. * Creates the default xr experience
  48550. * @param scene scene
  48551. * @param options options for basic configuration
  48552. * @returns resulting WebXRDefaultExperience
  48553. */
  48554. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48555. /**
  48556. * DIsposes of the experience helper
  48557. */
  48558. dispose(): void;
  48559. }
  48560. }
  48561. declare module BABYLON {
  48562. /**
  48563. * Options to modify the vr teleportation behavior.
  48564. */
  48565. export interface VRTeleportationOptions {
  48566. /**
  48567. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48568. */
  48569. floorMeshName?: string;
  48570. /**
  48571. * A list of meshes to be used as the teleportation floor. (default: empty)
  48572. */
  48573. floorMeshes?: Mesh[];
  48574. /**
  48575. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48576. */
  48577. teleportationMode?: number;
  48578. /**
  48579. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48580. */
  48581. teleportationTime?: number;
  48582. /**
  48583. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48584. */
  48585. teleportationSpeed?: number;
  48586. /**
  48587. * The easing function used in the animation or null for Linear. (default CircleEase)
  48588. */
  48589. easingFunction?: EasingFunction;
  48590. }
  48591. /**
  48592. * Options to modify the vr experience helper's behavior.
  48593. */
  48594. export interface VRExperienceHelperOptions extends WebVROptions {
  48595. /**
  48596. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48597. */
  48598. createDeviceOrientationCamera?: boolean;
  48599. /**
  48600. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48601. */
  48602. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48603. /**
  48604. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48605. */
  48606. laserToggle?: boolean;
  48607. /**
  48608. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48609. */
  48610. floorMeshes?: Mesh[];
  48611. /**
  48612. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48613. */
  48614. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48615. /**
  48616. * Defines if WebXR should be used instead of WebVR (if available)
  48617. */
  48618. useXR?: boolean;
  48619. }
  48620. /**
  48621. * Event containing information after VR has been entered
  48622. */
  48623. export class OnAfterEnteringVRObservableEvent {
  48624. /**
  48625. * If entering vr was successful
  48626. */
  48627. success: boolean;
  48628. }
  48629. /**
  48630. * Helps to quickly add VR support to an existing scene.
  48631. * See http://doc.babylonjs.com/how_to/webvr_helper
  48632. */
  48633. export class VRExperienceHelper {
  48634. /** Options to modify the vr experience helper's behavior. */
  48635. webVROptions: VRExperienceHelperOptions;
  48636. private _scene;
  48637. private _position;
  48638. private _btnVR;
  48639. private _btnVRDisplayed;
  48640. private _webVRsupported;
  48641. private _webVRready;
  48642. private _webVRrequesting;
  48643. private _webVRpresenting;
  48644. private _hasEnteredVR;
  48645. private _fullscreenVRpresenting;
  48646. private _inputElement;
  48647. private _webVRCamera;
  48648. private _vrDeviceOrientationCamera;
  48649. private _deviceOrientationCamera;
  48650. private _existingCamera;
  48651. private _onKeyDown;
  48652. private _onVrDisplayPresentChange;
  48653. private _onVRDisplayChanged;
  48654. private _onVRRequestPresentStart;
  48655. private _onVRRequestPresentComplete;
  48656. /**
  48657. * 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)
  48658. */
  48659. enableGazeEvenWhenNoPointerLock: boolean;
  48660. /**
  48661. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48662. */
  48663. exitVROnDoubleTap: boolean;
  48664. /**
  48665. * Observable raised right before entering VR.
  48666. */
  48667. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48668. /**
  48669. * Observable raised when entering VR has completed.
  48670. */
  48671. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48672. /**
  48673. * Observable raised when exiting VR.
  48674. */
  48675. onExitingVRObservable: Observable<VRExperienceHelper>;
  48676. /**
  48677. * Observable raised when controller mesh is loaded.
  48678. */
  48679. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48680. /** Return this.onEnteringVRObservable
  48681. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48682. */
  48683. get onEnteringVR(): Observable<VRExperienceHelper>;
  48684. /** Return this.onExitingVRObservable
  48685. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48686. */
  48687. get onExitingVR(): Observable<VRExperienceHelper>;
  48688. /** Return this.onControllerMeshLoadedObservable
  48689. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48690. */
  48691. get onControllerMeshLoaded(): Observable<WebVRController>;
  48692. private _rayLength;
  48693. private _useCustomVRButton;
  48694. private _teleportationRequested;
  48695. private _teleportActive;
  48696. private _floorMeshName;
  48697. private _floorMeshesCollection;
  48698. private _teleportationMode;
  48699. private _teleportationTime;
  48700. private _teleportationSpeed;
  48701. private _teleportationEasing;
  48702. private _rotationAllowed;
  48703. private _teleportBackwardsVector;
  48704. private _teleportationTarget;
  48705. private _isDefaultTeleportationTarget;
  48706. private _postProcessMove;
  48707. private _teleportationFillColor;
  48708. private _teleportationBorderColor;
  48709. private _rotationAngle;
  48710. private _haloCenter;
  48711. private _cameraGazer;
  48712. private _padSensibilityUp;
  48713. private _padSensibilityDown;
  48714. private _leftController;
  48715. private _rightController;
  48716. private _gazeColor;
  48717. private _laserColor;
  48718. private _pickedLaserColor;
  48719. private _pickedGazeColor;
  48720. /**
  48721. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48722. */
  48723. onNewMeshSelected: Observable<AbstractMesh>;
  48724. /**
  48725. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48726. * This observable will provide the mesh and the controller used to select the mesh
  48727. */
  48728. onMeshSelectedWithController: Observable<{
  48729. mesh: AbstractMesh;
  48730. controller: WebVRController;
  48731. }>;
  48732. /**
  48733. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48734. */
  48735. onNewMeshPicked: Observable<PickingInfo>;
  48736. private _circleEase;
  48737. /**
  48738. * Observable raised before camera teleportation
  48739. */
  48740. onBeforeCameraTeleport: Observable<Vector3>;
  48741. /**
  48742. * Observable raised after camera teleportation
  48743. */
  48744. onAfterCameraTeleport: Observable<Vector3>;
  48745. /**
  48746. * Observable raised when current selected mesh gets unselected
  48747. */
  48748. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48749. private _raySelectionPredicate;
  48750. /**
  48751. * To be optionaly changed by user to define custom ray selection
  48752. */
  48753. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48754. /**
  48755. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48756. */
  48757. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48758. /**
  48759. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48760. */
  48761. teleportationEnabled: boolean;
  48762. private _defaultHeight;
  48763. private _teleportationInitialized;
  48764. private _interactionsEnabled;
  48765. private _interactionsRequested;
  48766. private _displayGaze;
  48767. private _displayLaserPointer;
  48768. /**
  48769. * The mesh used to display where the user is going to teleport.
  48770. */
  48771. get teleportationTarget(): Mesh;
  48772. /**
  48773. * Sets the mesh to be used to display where the user is going to teleport.
  48774. */
  48775. set teleportationTarget(value: Mesh);
  48776. /**
  48777. * 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
  48778. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48779. * See http://doc.babylonjs.com/resources/baking_transformations
  48780. */
  48781. get gazeTrackerMesh(): Mesh;
  48782. set gazeTrackerMesh(value: Mesh);
  48783. /**
  48784. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48785. */
  48786. updateGazeTrackerScale: boolean;
  48787. /**
  48788. * If the gaze trackers color should be updated when selecting meshes
  48789. */
  48790. updateGazeTrackerColor: boolean;
  48791. /**
  48792. * If the controller laser color should be updated when selecting meshes
  48793. */
  48794. updateControllerLaserColor: boolean;
  48795. /**
  48796. * The gaze tracking mesh corresponding to the left controller
  48797. */
  48798. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48799. /**
  48800. * The gaze tracking mesh corresponding to the right controller
  48801. */
  48802. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48803. /**
  48804. * If the ray of the gaze should be displayed.
  48805. */
  48806. get displayGaze(): boolean;
  48807. /**
  48808. * Sets if the ray of the gaze should be displayed.
  48809. */
  48810. set displayGaze(value: boolean);
  48811. /**
  48812. * If the ray of the LaserPointer should be displayed.
  48813. */
  48814. get displayLaserPointer(): boolean;
  48815. /**
  48816. * Sets if the ray of the LaserPointer should be displayed.
  48817. */
  48818. set displayLaserPointer(value: boolean);
  48819. /**
  48820. * The deviceOrientationCamera used as the camera when not in VR.
  48821. */
  48822. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48823. /**
  48824. * Based on the current WebVR support, returns the current VR camera used.
  48825. */
  48826. get currentVRCamera(): Nullable<Camera>;
  48827. /**
  48828. * The webVRCamera which is used when in VR.
  48829. */
  48830. get webVRCamera(): WebVRFreeCamera;
  48831. /**
  48832. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48833. */
  48834. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48835. /**
  48836. * The html button that is used to trigger entering into VR.
  48837. */
  48838. get vrButton(): Nullable<HTMLButtonElement>;
  48839. private get _teleportationRequestInitiated();
  48840. /**
  48841. * Defines whether or not Pointer lock should be requested when switching to
  48842. * full screen.
  48843. */
  48844. requestPointerLockOnFullScreen: boolean;
  48845. /**
  48846. * If asking to force XR, this will be populated with the default xr experience
  48847. */
  48848. xr: WebXRDefaultExperience;
  48849. /**
  48850. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48851. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48852. */
  48853. xrTestDone: boolean;
  48854. /**
  48855. * Instantiates a VRExperienceHelper.
  48856. * Helps to quickly add VR support to an existing scene.
  48857. * @param scene The scene the VRExperienceHelper belongs to.
  48858. * @param webVROptions Options to modify the vr experience helper's behavior.
  48859. */
  48860. constructor(scene: Scene,
  48861. /** Options to modify the vr experience helper's behavior. */
  48862. webVROptions?: VRExperienceHelperOptions);
  48863. private completeVRInit;
  48864. private _onDefaultMeshLoaded;
  48865. private _onResize;
  48866. private _onFullscreenChange;
  48867. /**
  48868. * Gets a value indicating if we are currently in VR mode.
  48869. */
  48870. get isInVRMode(): boolean;
  48871. private onVrDisplayPresentChange;
  48872. private onVRDisplayChanged;
  48873. private moveButtonToBottomRight;
  48874. private displayVRButton;
  48875. private updateButtonVisibility;
  48876. private _cachedAngularSensibility;
  48877. /**
  48878. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48879. * Otherwise, will use the fullscreen API.
  48880. */
  48881. enterVR(): void;
  48882. /**
  48883. * Attempt to exit VR, or fullscreen.
  48884. */
  48885. exitVR(): void;
  48886. /**
  48887. * The position of the vr experience helper.
  48888. */
  48889. get position(): Vector3;
  48890. /**
  48891. * Sets the position of the vr experience helper.
  48892. */
  48893. set position(value: Vector3);
  48894. /**
  48895. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48896. */
  48897. enableInteractions(): void;
  48898. private get _noControllerIsActive();
  48899. private beforeRender;
  48900. private _isTeleportationFloor;
  48901. /**
  48902. * Adds a floor mesh to be used for teleportation.
  48903. * @param floorMesh the mesh to be used for teleportation.
  48904. */
  48905. addFloorMesh(floorMesh: Mesh): void;
  48906. /**
  48907. * Removes a floor mesh from being used for teleportation.
  48908. * @param floorMesh the mesh to be removed.
  48909. */
  48910. removeFloorMesh(floorMesh: Mesh): void;
  48911. /**
  48912. * Enables interactions and teleportation using the VR controllers and gaze.
  48913. * @param vrTeleportationOptions options to modify teleportation behavior.
  48914. */
  48915. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48916. private _onNewGamepadConnected;
  48917. private _tryEnableInteractionOnController;
  48918. private _onNewGamepadDisconnected;
  48919. private _enableInteractionOnController;
  48920. private _checkTeleportWithRay;
  48921. private _checkRotate;
  48922. private _checkTeleportBackwards;
  48923. private _enableTeleportationOnController;
  48924. private _createTeleportationCircles;
  48925. private _displayTeleportationTarget;
  48926. private _hideTeleportationTarget;
  48927. private _rotateCamera;
  48928. private _moveTeleportationSelectorTo;
  48929. private _workingVector;
  48930. private _workingQuaternion;
  48931. private _workingMatrix;
  48932. /**
  48933. * Time Constant Teleportation Mode
  48934. */
  48935. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48936. /**
  48937. * Speed Constant Teleportation Mode
  48938. */
  48939. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48940. /**
  48941. * Teleports the users feet to the desired location
  48942. * @param location The location where the user's feet should be placed
  48943. */
  48944. teleportCamera(location: Vector3): void;
  48945. private _convertNormalToDirectionOfRay;
  48946. private _castRayAndSelectObject;
  48947. private _notifySelectedMeshUnselected;
  48948. /**
  48949. * Permanently set new colors for the laser pointer
  48950. * @param color the new laser color
  48951. * @param pickedColor the new laser color when picked mesh detected
  48952. */
  48953. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48954. /**
  48955. * Set lighting enabled / disabled on the laser pointer of both controllers
  48956. * @param enabled should the lighting be enabled on the laser pointer
  48957. */
  48958. setLaserLightingState(enabled?: boolean): void;
  48959. /**
  48960. * Permanently set new colors for the gaze pointer
  48961. * @param color the new gaze color
  48962. * @param pickedColor the new gaze color when picked mesh detected
  48963. */
  48964. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48965. /**
  48966. * Sets the color of the laser ray from the vr controllers.
  48967. * @param color new color for the ray.
  48968. */
  48969. changeLaserColor(color: Color3): void;
  48970. /**
  48971. * Sets the color of the ray from the vr headsets gaze.
  48972. * @param color new color for the ray.
  48973. */
  48974. changeGazeColor(color: Color3): void;
  48975. /**
  48976. * Exits VR and disposes of the vr experience helper
  48977. */
  48978. dispose(): void;
  48979. /**
  48980. * Gets the name of the VRExperienceHelper class
  48981. * @returns "VRExperienceHelper"
  48982. */
  48983. getClassName(): string;
  48984. }
  48985. }
  48986. declare module BABYLON {
  48987. /**
  48988. * Contains an array of blocks representing the octree
  48989. */
  48990. export interface IOctreeContainer<T> {
  48991. /**
  48992. * Blocks within the octree
  48993. */
  48994. blocks: Array<OctreeBlock<T>>;
  48995. }
  48996. /**
  48997. * Class used to store a cell in an octree
  48998. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  48999. */
  49000. export class OctreeBlock<T> {
  49001. /**
  49002. * Gets the content of the current block
  49003. */
  49004. entries: T[];
  49005. /**
  49006. * Gets the list of block children
  49007. */
  49008. blocks: Array<OctreeBlock<T>>;
  49009. private _depth;
  49010. private _maxDepth;
  49011. private _capacity;
  49012. private _minPoint;
  49013. private _maxPoint;
  49014. private _boundingVectors;
  49015. private _creationFunc;
  49016. /**
  49017. * Creates a new block
  49018. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49019. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49020. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49021. * @param depth defines the current depth of this block in the octree
  49022. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49023. * @param creationFunc defines a callback to call when an element is added to the block
  49024. */
  49025. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49026. /**
  49027. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49028. */
  49029. get capacity(): number;
  49030. /**
  49031. * Gets the minimum vector (in world space) of the block's bounding box
  49032. */
  49033. get minPoint(): Vector3;
  49034. /**
  49035. * Gets the maximum vector (in world space) of the block's bounding box
  49036. */
  49037. get maxPoint(): Vector3;
  49038. /**
  49039. * Add a new element to this block
  49040. * @param entry defines the element to add
  49041. */
  49042. addEntry(entry: T): void;
  49043. /**
  49044. * Remove an element from this block
  49045. * @param entry defines the element to remove
  49046. */
  49047. removeEntry(entry: T): void;
  49048. /**
  49049. * Add an array of elements to this block
  49050. * @param entries defines the array of elements to add
  49051. */
  49052. addEntries(entries: T[]): void;
  49053. /**
  49054. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49055. * @param frustumPlanes defines the frustum planes to test
  49056. * @param selection defines the array to store current content if selection is positive
  49057. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49058. */
  49059. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49060. /**
  49061. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49062. * @param sphereCenter defines the bounding sphere center
  49063. * @param sphereRadius defines the bounding sphere radius
  49064. * @param selection defines the array to store current content if selection is positive
  49065. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49066. */
  49067. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49068. /**
  49069. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49070. * @param ray defines the ray to test with
  49071. * @param selection defines the array to store current content if selection is positive
  49072. */
  49073. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49074. /**
  49075. * Subdivide the content into child blocks (this block will then be empty)
  49076. */
  49077. createInnerBlocks(): void;
  49078. /**
  49079. * @hidden
  49080. */
  49081. 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;
  49082. }
  49083. }
  49084. declare module BABYLON {
  49085. /**
  49086. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49087. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49088. */
  49089. export class Octree<T> {
  49090. /** 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.) */
  49091. maxDepth: number;
  49092. /**
  49093. * Blocks within the octree containing objects
  49094. */
  49095. blocks: Array<OctreeBlock<T>>;
  49096. /**
  49097. * Content stored in the octree
  49098. */
  49099. dynamicContent: T[];
  49100. private _maxBlockCapacity;
  49101. private _selectionContent;
  49102. private _creationFunc;
  49103. /**
  49104. * Creates a octree
  49105. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49106. * @param creationFunc function to be used to instatiate the octree
  49107. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49108. * @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.)
  49109. */
  49110. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49111. /** 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.) */
  49112. maxDepth?: number);
  49113. /**
  49114. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49115. * @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);
  49116. * @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);
  49117. * @param entries meshes to be added to the octree blocks
  49118. */
  49119. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49120. /**
  49121. * Adds a mesh to the octree
  49122. * @param entry Mesh to add to the octree
  49123. */
  49124. addMesh(entry: T): void;
  49125. /**
  49126. * Remove an element from the octree
  49127. * @param entry defines the element to remove
  49128. */
  49129. removeMesh(entry: T): void;
  49130. /**
  49131. * Selects an array of meshes within the frustum
  49132. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49133. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49134. * @returns array of meshes within the frustum
  49135. */
  49136. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49137. /**
  49138. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49139. * @param sphereCenter defines the bounding sphere center
  49140. * @param sphereRadius defines the bounding sphere radius
  49141. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49142. * @returns an array of objects that intersect the sphere
  49143. */
  49144. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49145. /**
  49146. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49147. * @param ray defines the ray to test with
  49148. * @returns array of intersected objects
  49149. */
  49150. intersectsRay(ray: Ray): SmartArray<T>;
  49151. /**
  49152. * Adds a mesh into the octree block if it intersects the block
  49153. */
  49154. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49155. /**
  49156. * Adds a submesh into the octree block if it intersects the block
  49157. */
  49158. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49159. }
  49160. }
  49161. declare module BABYLON {
  49162. interface Scene {
  49163. /**
  49164. * @hidden
  49165. * Backing Filed
  49166. */
  49167. _selectionOctree: Octree<AbstractMesh>;
  49168. /**
  49169. * Gets the octree used to boost mesh selection (picking)
  49170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49171. */
  49172. selectionOctree: Octree<AbstractMesh>;
  49173. /**
  49174. * Creates or updates the octree used to boost selection (picking)
  49175. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49176. * @param maxCapacity defines the maximum capacity per leaf
  49177. * @param maxDepth defines the maximum depth of the octree
  49178. * @returns an octree of AbstractMesh
  49179. */
  49180. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49181. }
  49182. interface AbstractMesh {
  49183. /**
  49184. * @hidden
  49185. * Backing Field
  49186. */
  49187. _submeshesOctree: Octree<SubMesh>;
  49188. /**
  49189. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49190. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49191. * @param maxCapacity defines the maximum size of each block (64 by default)
  49192. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49193. * @returns the new octree
  49194. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49195. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49196. */
  49197. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49198. }
  49199. /**
  49200. * Defines the octree scene component responsible to manage any octrees
  49201. * in a given scene.
  49202. */
  49203. export class OctreeSceneComponent {
  49204. /**
  49205. * The component name help to identify the component in the list of scene components.
  49206. */
  49207. readonly name: string;
  49208. /**
  49209. * The scene the component belongs to.
  49210. */
  49211. scene: Scene;
  49212. /**
  49213. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49214. */
  49215. readonly checksIsEnabled: boolean;
  49216. /**
  49217. * Creates a new instance of the component for the given scene
  49218. * @param scene Defines the scene to register the component in
  49219. */
  49220. constructor(scene: Scene);
  49221. /**
  49222. * Registers the component in a given scene
  49223. */
  49224. register(): void;
  49225. /**
  49226. * Return the list of active meshes
  49227. * @returns the list of active meshes
  49228. */
  49229. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49230. /**
  49231. * Return the list of active sub meshes
  49232. * @param mesh The mesh to get the candidates sub meshes from
  49233. * @returns the list of active sub meshes
  49234. */
  49235. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49236. private _tempRay;
  49237. /**
  49238. * Return the list of sub meshes intersecting with a given local ray
  49239. * @param mesh defines the mesh to find the submesh for
  49240. * @param localRay defines the ray in local space
  49241. * @returns the list of intersecting sub meshes
  49242. */
  49243. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49244. /**
  49245. * Return the list of sub meshes colliding with a collider
  49246. * @param mesh defines the mesh to find the submesh for
  49247. * @param collider defines the collider to evaluate the collision against
  49248. * @returns the list of colliding sub meshes
  49249. */
  49250. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49251. /**
  49252. * Rebuilds the elements related to this component in case of
  49253. * context lost for instance.
  49254. */
  49255. rebuild(): void;
  49256. /**
  49257. * Disposes the component and the associated ressources.
  49258. */
  49259. dispose(): void;
  49260. }
  49261. }
  49262. declare module BABYLON {
  49263. /**
  49264. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49265. */
  49266. export class Gizmo implements IDisposable {
  49267. /** The utility layer the gizmo will be added to */
  49268. gizmoLayer: UtilityLayerRenderer;
  49269. /**
  49270. * The root mesh of the gizmo
  49271. */
  49272. _rootMesh: Mesh;
  49273. private _attachedMesh;
  49274. /**
  49275. * Ratio for the scale of the gizmo (Default: 1)
  49276. */
  49277. scaleRatio: number;
  49278. /**
  49279. * If a custom mesh has been set (Default: false)
  49280. */
  49281. protected _customMeshSet: boolean;
  49282. /**
  49283. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49284. * * When set, interactions will be enabled
  49285. */
  49286. get attachedMesh(): Nullable<AbstractMesh>;
  49287. set attachedMesh(value: Nullable<AbstractMesh>);
  49288. /**
  49289. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49290. * @param mesh The mesh to replace the default mesh of the gizmo
  49291. */
  49292. setCustomMesh(mesh: Mesh): void;
  49293. /**
  49294. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49295. */
  49296. updateGizmoRotationToMatchAttachedMesh: boolean;
  49297. /**
  49298. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49299. */
  49300. updateGizmoPositionToMatchAttachedMesh: boolean;
  49301. /**
  49302. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49303. */
  49304. updateScale: boolean;
  49305. protected _interactionsEnabled: boolean;
  49306. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49307. private _beforeRenderObserver;
  49308. private _tempVector;
  49309. /**
  49310. * Creates a gizmo
  49311. * @param gizmoLayer The utility layer the gizmo will be added to
  49312. */
  49313. constructor(
  49314. /** The utility layer the gizmo will be added to */
  49315. gizmoLayer?: UtilityLayerRenderer);
  49316. /**
  49317. * Updates the gizmo to match the attached mesh's position/rotation
  49318. */
  49319. protected _update(): void;
  49320. /**
  49321. * Disposes of the gizmo
  49322. */
  49323. dispose(): void;
  49324. }
  49325. }
  49326. declare module BABYLON {
  49327. /**
  49328. * Single plane drag gizmo
  49329. */
  49330. export class PlaneDragGizmo extends Gizmo {
  49331. /**
  49332. * Drag behavior responsible for the gizmos dragging interactions
  49333. */
  49334. dragBehavior: PointerDragBehavior;
  49335. private _pointerObserver;
  49336. /**
  49337. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49338. */
  49339. snapDistance: number;
  49340. /**
  49341. * Event that fires each time the gizmo snaps to a new location.
  49342. * * snapDistance is the the change in distance
  49343. */
  49344. onSnapObservable: Observable<{
  49345. snapDistance: number;
  49346. }>;
  49347. private _plane;
  49348. private _coloredMaterial;
  49349. private _hoverMaterial;
  49350. private _isEnabled;
  49351. private _parent;
  49352. /** @hidden */
  49353. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49354. /** @hidden */
  49355. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49356. /**
  49357. * Creates a PlaneDragGizmo
  49358. * @param gizmoLayer The utility layer the gizmo will be added to
  49359. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49360. * @param color The color of the gizmo
  49361. */
  49362. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49363. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49364. /**
  49365. * If the gizmo is enabled
  49366. */
  49367. set isEnabled(value: boolean);
  49368. get isEnabled(): boolean;
  49369. /**
  49370. * Disposes of the gizmo
  49371. */
  49372. dispose(): void;
  49373. }
  49374. }
  49375. declare module BABYLON {
  49376. /**
  49377. * Gizmo that enables dragging a mesh along 3 axis
  49378. */
  49379. export class PositionGizmo extends Gizmo {
  49380. /**
  49381. * Internal gizmo used for interactions on the x axis
  49382. */
  49383. xGizmo: AxisDragGizmo;
  49384. /**
  49385. * Internal gizmo used for interactions on the y axis
  49386. */
  49387. yGizmo: AxisDragGizmo;
  49388. /**
  49389. * Internal gizmo used for interactions on the z axis
  49390. */
  49391. zGizmo: AxisDragGizmo;
  49392. /**
  49393. * Internal gizmo used for interactions on the yz plane
  49394. */
  49395. xPlaneGizmo: PlaneDragGizmo;
  49396. /**
  49397. * Internal gizmo used for interactions on the xz plane
  49398. */
  49399. yPlaneGizmo: PlaneDragGizmo;
  49400. /**
  49401. * Internal gizmo used for interactions on the xy plane
  49402. */
  49403. zPlaneGizmo: PlaneDragGizmo;
  49404. /**
  49405. * private variables
  49406. */
  49407. private _meshAttached;
  49408. private _updateGizmoRotationToMatchAttachedMesh;
  49409. private _snapDistance;
  49410. private _scaleRatio;
  49411. /** Fires an event when any of it's sub gizmos are dragged */
  49412. onDragStartObservable: Observable<unknown>;
  49413. /** Fires an event when any of it's sub gizmos are released from dragging */
  49414. onDragEndObservable: Observable<unknown>;
  49415. /**
  49416. * If set to true, planar drag is enabled
  49417. */
  49418. private _planarGizmoEnabled;
  49419. get attachedMesh(): Nullable<AbstractMesh>;
  49420. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49421. /**
  49422. * Creates a PositionGizmo
  49423. * @param gizmoLayer The utility layer the gizmo will be added to
  49424. */
  49425. constructor(gizmoLayer?: UtilityLayerRenderer);
  49426. /**
  49427. * If the planar drag gizmo is enabled
  49428. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49429. */
  49430. set planarGizmoEnabled(value: boolean);
  49431. get planarGizmoEnabled(): boolean;
  49432. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49433. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49434. /**
  49435. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49436. */
  49437. set snapDistance(value: number);
  49438. get snapDistance(): number;
  49439. /**
  49440. * Ratio for the scale of the gizmo (Default: 1)
  49441. */
  49442. set scaleRatio(value: number);
  49443. get scaleRatio(): number;
  49444. /**
  49445. * Disposes of the gizmo
  49446. */
  49447. dispose(): void;
  49448. /**
  49449. * CustomMeshes are not supported by this gizmo
  49450. * @param mesh The mesh to replace the default mesh of the gizmo
  49451. */
  49452. setCustomMesh(mesh: Mesh): void;
  49453. }
  49454. }
  49455. declare module BABYLON {
  49456. /**
  49457. * Single axis drag gizmo
  49458. */
  49459. export class AxisDragGizmo extends Gizmo {
  49460. /**
  49461. * Drag behavior responsible for the gizmos dragging interactions
  49462. */
  49463. dragBehavior: PointerDragBehavior;
  49464. private _pointerObserver;
  49465. /**
  49466. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49467. */
  49468. snapDistance: number;
  49469. /**
  49470. * Event that fires each time the gizmo snaps to a new location.
  49471. * * snapDistance is the the change in distance
  49472. */
  49473. onSnapObservable: Observable<{
  49474. snapDistance: number;
  49475. }>;
  49476. private _isEnabled;
  49477. private _parent;
  49478. private _arrow;
  49479. private _coloredMaterial;
  49480. private _hoverMaterial;
  49481. /** @hidden */
  49482. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49483. /** @hidden */
  49484. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49485. /**
  49486. * Creates an AxisDragGizmo
  49487. * @param gizmoLayer The utility layer the gizmo will be added to
  49488. * @param dragAxis The axis which the gizmo will be able to drag on
  49489. * @param color The color of the gizmo
  49490. */
  49491. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49492. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49493. /**
  49494. * If the gizmo is enabled
  49495. */
  49496. set isEnabled(value: boolean);
  49497. get isEnabled(): boolean;
  49498. /**
  49499. * Disposes of the gizmo
  49500. */
  49501. dispose(): void;
  49502. }
  49503. }
  49504. declare module BABYLON.Debug {
  49505. /**
  49506. * The Axes viewer will show 3 axes in a specific point in space
  49507. */
  49508. export class AxesViewer {
  49509. private _xAxis;
  49510. private _yAxis;
  49511. private _zAxis;
  49512. private _scaleLinesFactor;
  49513. private _instanced;
  49514. /**
  49515. * Gets the hosting scene
  49516. */
  49517. scene: Scene;
  49518. /**
  49519. * Gets or sets a number used to scale line length
  49520. */
  49521. scaleLines: number;
  49522. /** Gets the node hierarchy used to render x-axis */
  49523. get xAxis(): TransformNode;
  49524. /** Gets the node hierarchy used to render y-axis */
  49525. get yAxis(): TransformNode;
  49526. /** Gets the node hierarchy used to render z-axis */
  49527. get zAxis(): TransformNode;
  49528. /**
  49529. * Creates a new AxesViewer
  49530. * @param scene defines the hosting scene
  49531. * @param scaleLines defines a number used to scale line length (1 by default)
  49532. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49533. * @param xAxis defines the node hierarchy used to render the x-axis
  49534. * @param yAxis defines the node hierarchy used to render the y-axis
  49535. * @param zAxis defines the node hierarchy used to render the z-axis
  49536. */
  49537. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49538. /**
  49539. * Force the viewer to update
  49540. * @param position defines the position of the viewer
  49541. * @param xaxis defines the x axis of the viewer
  49542. * @param yaxis defines the y axis of the viewer
  49543. * @param zaxis defines the z axis of the viewer
  49544. */
  49545. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49546. /**
  49547. * Creates an instance of this axes viewer.
  49548. * @returns a new axes viewer with instanced meshes
  49549. */
  49550. createInstance(): AxesViewer;
  49551. /** Releases resources */
  49552. dispose(): void;
  49553. private static _SetRenderingGroupId;
  49554. }
  49555. }
  49556. declare module BABYLON.Debug {
  49557. /**
  49558. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49559. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49560. */
  49561. export class BoneAxesViewer extends AxesViewer {
  49562. /**
  49563. * Gets or sets the target mesh where to display the axes viewer
  49564. */
  49565. mesh: Nullable<Mesh>;
  49566. /**
  49567. * Gets or sets the target bone where to display the axes viewer
  49568. */
  49569. bone: Nullable<Bone>;
  49570. /** Gets current position */
  49571. pos: Vector3;
  49572. /** Gets direction of X axis */
  49573. xaxis: Vector3;
  49574. /** Gets direction of Y axis */
  49575. yaxis: Vector3;
  49576. /** Gets direction of Z axis */
  49577. zaxis: Vector3;
  49578. /**
  49579. * Creates a new BoneAxesViewer
  49580. * @param scene defines the hosting scene
  49581. * @param bone defines the target bone
  49582. * @param mesh defines the target mesh
  49583. * @param scaleLines defines a scaling factor for line length (1 by default)
  49584. */
  49585. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49586. /**
  49587. * Force the viewer to update
  49588. */
  49589. update(): void;
  49590. /** Releases resources */
  49591. dispose(): void;
  49592. }
  49593. }
  49594. declare module BABYLON {
  49595. /**
  49596. * Interface used to define scene explorer extensibility option
  49597. */
  49598. export interface IExplorerExtensibilityOption {
  49599. /**
  49600. * Define the option label
  49601. */
  49602. label: string;
  49603. /**
  49604. * Defines the action to execute on click
  49605. */
  49606. action: (entity: any) => void;
  49607. }
  49608. /**
  49609. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49610. */
  49611. export interface IExplorerExtensibilityGroup {
  49612. /**
  49613. * Defines a predicate to test if a given type mut be extended
  49614. */
  49615. predicate: (entity: any) => boolean;
  49616. /**
  49617. * Gets the list of options added to a type
  49618. */
  49619. entries: IExplorerExtensibilityOption[];
  49620. }
  49621. /**
  49622. * Interface used to define the options to use to create the Inspector
  49623. */
  49624. export interface IInspectorOptions {
  49625. /**
  49626. * Display in overlay mode (default: false)
  49627. */
  49628. overlay?: boolean;
  49629. /**
  49630. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49631. */
  49632. globalRoot?: HTMLElement;
  49633. /**
  49634. * Display the Scene explorer
  49635. */
  49636. showExplorer?: boolean;
  49637. /**
  49638. * Display the property inspector
  49639. */
  49640. showInspector?: boolean;
  49641. /**
  49642. * Display in embed mode (both panes on the right)
  49643. */
  49644. embedMode?: boolean;
  49645. /**
  49646. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49647. */
  49648. handleResize?: boolean;
  49649. /**
  49650. * Allow the panes to popup (default: true)
  49651. */
  49652. enablePopup?: boolean;
  49653. /**
  49654. * Allow the panes to be closed by users (default: true)
  49655. */
  49656. enableClose?: boolean;
  49657. /**
  49658. * Optional list of extensibility entries
  49659. */
  49660. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49661. /**
  49662. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49663. */
  49664. inspectorURL?: string;
  49665. /**
  49666. * Optional initial tab (default to DebugLayerTab.Properties)
  49667. */
  49668. initialTab?: DebugLayerTab;
  49669. }
  49670. interface Scene {
  49671. /**
  49672. * @hidden
  49673. * Backing field
  49674. */
  49675. _debugLayer: DebugLayer;
  49676. /**
  49677. * Gets the debug layer (aka Inspector) associated with the scene
  49678. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49679. */
  49680. debugLayer: DebugLayer;
  49681. }
  49682. /**
  49683. * Enum of inspector action tab
  49684. */
  49685. export enum DebugLayerTab {
  49686. /**
  49687. * Properties tag (default)
  49688. */
  49689. Properties = 0,
  49690. /**
  49691. * Debug tab
  49692. */
  49693. Debug = 1,
  49694. /**
  49695. * Statistics tab
  49696. */
  49697. Statistics = 2,
  49698. /**
  49699. * Tools tab
  49700. */
  49701. Tools = 3,
  49702. /**
  49703. * Settings tab
  49704. */
  49705. Settings = 4
  49706. }
  49707. /**
  49708. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49709. * what is happening in your scene
  49710. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49711. */
  49712. export class DebugLayer {
  49713. /**
  49714. * Define the url to get the inspector script from.
  49715. * By default it uses the babylonjs CDN.
  49716. * @ignoreNaming
  49717. */
  49718. static InspectorURL: string;
  49719. private _scene;
  49720. private BJSINSPECTOR;
  49721. private _onPropertyChangedObservable?;
  49722. /**
  49723. * Observable triggered when a property is changed through the inspector.
  49724. */
  49725. get onPropertyChangedObservable(): any;
  49726. /**
  49727. * Instantiates a new debug layer.
  49728. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49729. * what is happening in your scene
  49730. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49731. * @param scene Defines the scene to inspect
  49732. */
  49733. constructor(scene: Scene);
  49734. /** Creates the inspector window. */
  49735. private _createInspector;
  49736. /**
  49737. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49738. * @param entity defines the entity to select
  49739. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49740. */
  49741. select(entity: any, lineContainerTitles?: string | string[]): void;
  49742. /** Get the inspector from bundle or global */
  49743. private _getGlobalInspector;
  49744. /**
  49745. * Get if the inspector is visible or not.
  49746. * @returns true if visible otherwise, false
  49747. */
  49748. isVisible(): boolean;
  49749. /**
  49750. * Hide the inspector and close its window.
  49751. */
  49752. hide(): void;
  49753. /**
  49754. * Update the scene in the inspector
  49755. */
  49756. setAsActiveScene(): void;
  49757. /**
  49758. * Launch the debugLayer.
  49759. * @param config Define the configuration of the inspector
  49760. * @return a promise fulfilled when the debug layer is visible
  49761. */
  49762. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49763. }
  49764. }
  49765. declare module BABYLON {
  49766. /**
  49767. * Class containing static functions to help procedurally build meshes
  49768. */
  49769. export class BoxBuilder {
  49770. /**
  49771. * Creates a box mesh
  49772. * * The parameter `size` sets the size (float) of each box side (default 1)
  49773. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49774. * * 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)
  49775. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49777. * * 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
  49778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49779. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49780. * @param name defines the name of the mesh
  49781. * @param options defines the options used to create the mesh
  49782. * @param scene defines the hosting scene
  49783. * @returns the box mesh
  49784. */
  49785. static CreateBox(name: string, options: {
  49786. size?: number;
  49787. width?: number;
  49788. height?: number;
  49789. depth?: number;
  49790. faceUV?: Vector4[];
  49791. faceColors?: Color4[];
  49792. sideOrientation?: number;
  49793. frontUVs?: Vector4;
  49794. backUVs?: Vector4;
  49795. wrap?: boolean;
  49796. topBaseAt?: number;
  49797. bottomBaseAt?: number;
  49798. updatable?: boolean;
  49799. }, scene?: Nullable<Scene>): Mesh;
  49800. }
  49801. }
  49802. declare module BABYLON.Debug {
  49803. /**
  49804. * Used to show the physics impostor around the specific mesh
  49805. */
  49806. export class PhysicsViewer {
  49807. /** @hidden */
  49808. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49809. /** @hidden */
  49810. protected _meshes: Array<Nullable<AbstractMesh>>;
  49811. /** @hidden */
  49812. protected _scene: Nullable<Scene>;
  49813. /** @hidden */
  49814. protected _numMeshes: number;
  49815. /** @hidden */
  49816. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49817. private _renderFunction;
  49818. private _utilityLayer;
  49819. private _debugBoxMesh;
  49820. private _debugSphereMesh;
  49821. private _debugCylinderMesh;
  49822. private _debugMaterial;
  49823. private _debugMeshMeshes;
  49824. /**
  49825. * Creates a new PhysicsViewer
  49826. * @param scene defines the hosting scene
  49827. */
  49828. constructor(scene: Scene);
  49829. /** @hidden */
  49830. protected _updateDebugMeshes(): void;
  49831. /**
  49832. * Renders a specified physic impostor
  49833. * @param impostor defines the impostor to render
  49834. * @param targetMesh defines the mesh represented by the impostor
  49835. * @returns the new debug mesh used to render the impostor
  49836. */
  49837. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49838. /**
  49839. * Hides a specified physic impostor
  49840. * @param impostor defines the impostor to hide
  49841. */
  49842. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49843. private _getDebugMaterial;
  49844. private _getDebugBoxMesh;
  49845. private _getDebugSphereMesh;
  49846. private _getDebugCylinderMesh;
  49847. private _getDebugMeshMesh;
  49848. private _getDebugMesh;
  49849. /** Releases all resources */
  49850. dispose(): void;
  49851. }
  49852. }
  49853. declare module BABYLON {
  49854. /**
  49855. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49856. * in order to better appreciate the issue one might have.
  49857. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49858. */
  49859. export class RayHelper {
  49860. /**
  49861. * Defines the ray we are currently tryin to visualize.
  49862. */
  49863. ray: Nullable<Ray>;
  49864. private _renderPoints;
  49865. private _renderLine;
  49866. private _renderFunction;
  49867. private _scene;
  49868. private _updateToMeshFunction;
  49869. private _attachedToMesh;
  49870. private _meshSpaceDirection;
  49871. private _meshSpaceOrigin;
  49872. /**
  49873. * Helper function to create a colored helper in a scene in one line.
  49874. * @param ray Defines the ray we are currently tryin to visualize
  49875. * @param scene Defines the scene the ray is used in
  49876. * @param color Defines the color we want to see the ray in
  49877. * @returns The newly created ray helper.
  49878. */
  49879. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49880. /**
  49881. * Instantiate a new ray helper.
  49882. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49883. * in order to better appreciate the issue one might have.
  49884. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49885. * @param ray Defines the ray we are currently tryin to visualize
  49886. */
  49887. constructor(ray: Ray);
  49888. /**
  49889. * Shows the ray we are willing to debug.
  49890. * @param scene Defines the scene the ray needs to be rendered in
  49891. * @param color Defines the color the ray needs to be rendered in
  49892. */
  49893. show(scene: Scene, color?: Color3): void;
  49894. /**
  49895. * Hides the ray we are debugging.
  49896. */
  49897. hide(): void;
  49898. private _render;
  49899. /**
  49900. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49901. * @param mesh Defines the mesh we want the helper attached to
  49902. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49903. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49904. * @param length Defines the length of the ray
  49905. */
  49906. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49907. /**
  49908. * Detach the ray helper from the mesh it has previously been attached to.
  49909. */
  49910. detachFromMesh(): void;
  49911. private _updateToMesh;
  49912. /**
  49913. * Dispose the helper and release its associated resources.
  49914. */
  49915. dispose(): void;
  49916. }
  49917. }
  49918. declare module BABYLON.Debug {
  49919. /**
  49920. * Class used to render a debug view of a given skeleton
  49921. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49922. */
  49923. export class SkeletonViewer {
  49924. /** defines the skeleton to render */
  49925. skeleton: Skeleton;
  49926. /** defines the mesh attached to the skeleton */
  49927. mesh: AbstractMesh;
  49928. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49929. autoUpdateBonesMatrices: boolean;
  49930. /** defines the rendering group id to use with the viewer */
  49931. renderingGroupId: number;
  49932. /** Gets or sets the color used to render the skeleton */
  49933. color: Color3;
  49934. private _scene;
  49935. private _debugLines;
  49936. private _debugMesh;
  49937. private _isEnabled;
  49938. private _renderFunction;
  49939. private _utilityLayer;
  49940. /**
  49941. * Returns the mesh used to render the bones
  49942. */
  49943. get debugMesh(): Nullable<LinesMesh>;
  49944. /**
  49945. * Creates a new SkeletonViewer
  49946. * @param skeleton defines the skeleton to render
  49947. * @param mesh defines the mesh attached to the skeleton
  49948. * @param scene defines the hosting scene
  49949. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49950. * @param renderingGroupId defines the rendering group id to use with the viewer
  49951. */
  49952. constructor(
  49953. /** defines the skeleton to render */
  49954. skeleton: Skeleton,
  49955. /** defines the mesh attached to the skeleton */
  49956. mesh: AbstractMesh, scene: Scene,
  49957. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49958. autoUpdateBonesMatrices?: boolean,
  49959. /** defines the rendering group id to use with the viewer */
  49960. renderingGroupId?: number);
  49961. /** Gets or sets a boolean indicating if the viewer is enabled */
  49962. set isEnabled(value: boolean);
  49963. get isEnabled(): boolean;
  49964. private _getBonePosition;
  49965. private _getLinesForBonesWithLength;
  49966. private _getLinesForBonesNoLength;
  49967. /** Update the viewer to sync with current skeleton state */
  49968. update(): void;
  49969. /** Release associated resources */
  49970. dispose(): void;
  49971. }
  49972. }
  49973. declare module BABYLON {
  49974. /**
  49975. * Enum for Device Types
  49976. */
  49977. export enum DeviceType {
  49978. /** Generic */
  49979. Generic = 0,
  49980. /** Keyboard */
  49981. Keyboard = 1,
  49982. /** Mouse */
  49983. Mouse = 2,
  49984. /** Touch Pointers */
  49985. Touch = 3,
  49986. /** PS4 Dual Shock */
  49987. DualShock = 4,
  49988. /** Xbox */
  49989. Xbox = 5,
  49990. /** Switch Controller */
  49991. Switch = 6
  49992. }
  49993. /**
  49994. * Enum for All Pointers (Touch/Mouse)
  49995. */
  49996. export enum PointerInput {
  49997. /** Horizontal Axis */
  49998. Horizontal = 0,
  49999. /** Vertical Axis */
  50000. Vertical = 1,
  50001. /** Left Click or Touch */
  50002. LeftClick = 2,
  50003. /** Middle Click */
  50004. MiddleClick = 3,
  50005. /** Right Click */
  50006. RightClick = 4,
  50007. /** Browser Back */
  50008. BrowserBack = 5,
  50009. /** Browser Forward */
  50010. BrowserForward = 6
  50011. }
  50012. /**
  50013. * Enum for Dual Shock Gamepad
  50014. */
  50015. export enum DualShockInput {
  50016. /** Cross */
  50017. Cross = 0,
  50018. /** Circle */
  50019. Circle = 1,
  50020. /** Square */
  50021. Square = 2,
  50022. /** Triangle */
  50023. Triangle = 3,
  50024. /** L1 */
  50025. L1 = 4,
  50026. /** R1 */
  50027. R1 = 5,
  50028. /** L2 */
  50029. L2 = 6,
  50030. /** R2 */
  50031. R2 = 7,
  50032. /** Share */
  50033. Share = 8,
  50034. /** Options */
  50035. Options = 9,
  50036. /** L3 */
  50037. L3 = 10,
  50038. /** R3 */
  50039. R3 = 11,
  50040. /** DPadUp */
  50041. DPadUp = 12,
  50042. /** DPadDown */
  50043. DPadDown = 13,
  50044. /** DPadLeft */
  50045. DPadLeft = 14,
  50046. /** DRight */
  50047. DPadRight = 15,
  50048. /** Home */
  50049. Home = 16,
  50050. /** TouchPad */
  50051. TouchPad = 17,
  50052. /** LStickXAxis */
  50053. LStickXAxis = 18,
  50054. /** LStickYAxis */
  50055. LStickYAxis = 19,
  50056. /** RStickXAxis */
  50057. RStickXAxis = 20,
  50058. /** RStickYAxis */
  50059. RStickYAxis = 21
  50060. }
  50061. /**
  50062. * Enum for Xbox Gamepad
  50063. */
  50064. export enum XboxInput {
  50065. /** A */
  50066. A = 0,
  50067. /** B */
  50068. B = 1,
  50069. /** X */
  50070. X = 2,
  50071. /** Y */
  50072. Y = 3,
  50073. /** LB */
  50074. LB = 4,
  50075. /** RB */
  50076. RB = 5,
  50077. /** LT */
  50078. LT = 6,
  50079. /** RT */
  50080. RT = 7,
  50081. /** Back */
  50082. Back = 8,
  50083. /** Start */
  50084. Start = 9,
  50085. /** LS */
  50086. LS = 10,
  50087. /** RS */
  50088. RS = 11,
  50089. /** DPadUp */
  50090. DPadUp = 12,
  50091. /** DPadDown */
  50092. DPadDown = 13,
  50093. /** DPadLeft */
  50094. DPadLeft = 14,
  50095. /** DRight */
  50096. DPadRight = 15,
  50097. /** Home */
  50098. Home = 16,
  50099. /** LStickXAxis */
  50100. LStickXAxis = 17,
  50101. /** LStickYAxis */
  50102. LStickYAxis = 18,
  50103. /** RStickXAxis */
  50104. RStickXAxis = 19,
  50105. /** RStickYAxis */
  50106. RStickYAxis = 20
  50107. }
  50108. /**
  50109. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50110. */
  50111. export enum SwitchInput {
  50112. /** B */
  50113. B = 0,
  50114. /** A */
  50115. A = 1,
  50116. /** Y */
  50117. Y = 2,
  50118. /** X */
  50119. X = 3,
  50120. /** L */
  50121. L = 4,
  50122. /** R */
  50123. R = 5,
  50124. /** ZL */
  50125. ZL = 6,
  50126. /** ZR */
  50127. ZR = 7,
  50128. /** Minus */
  50129. Minus = 8,
  50130. /** Plus */
  50131. Plus = 9,
  50132. /** LS */
  50133. LS = 10,
  50134. /** RS */
  50135. RS = 11,
  50136. /** DPadUp */
  50137. DPadUp = 12,
  50138. /** DPadDown */
  50139. DPadDown = 13,
  50140. /** DPadLeft */
  50141. DPadLeft = 14,
  50142. /** DRight */
  50143. DPadRight = 15,
  50144. /** Home */
  50145. Home = 16,
  50146. /** Capture */
  50147. Capture = 17,
  50148. /** LStickXAxis */
  50149. LStickXAxis = 18,
  50150. /** LStickYAxis */
  50151. LStickYAxis = 19,
  50152. /** RStickXAxis */
  50153. RStickXAxis = 20,
  50154. /** RStickYAxis */
  50155. RStickYAxis = 21
  50156. }
  50157. }
  50158. declare module BABYLON {
  50159. /**
  50160. * This class will take all inputs from Keyboard, Pointer, and
  50161. * any Gamepads and provide a polling system that all devices
  50162. * will use. This class assumes that there will only be one
  50163. * pointer device and one keyboard.
  50164. */
  50165. export class DeviceInputSystem implements IDisposable {
  50166. /**
  50167. * Callback to be triggered when a device is connected
  50168. */
  50169. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50170. /**
  50171. * Callback to be triggered when a device is disconnected
  50172. */
  50173. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50174. /**
  50175. * Callback to be triggered when event driven input is updated
  50176. */
  50177. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50178. private _inputs;
  50179. private _gamepads;
  50180. private _keyboardActive;
  50181. private _pointerActive;
  50182. private _elementToAttachTo;
  50183. private _keyboardDownEvent;
  50184. private _keyboardUpEvent;
  50185. private _pointerMoveEvent;
  50186. private _pointerDownEvent;
  50187. private _pointerUpEvent;
  50188. private _gamepadConnectedEvent;
  50189. private _gamepadDisconnectedEvent;
  50190. private static _MAX_KEYCODES;
  50191. private static _MAX_POINTER_INPUTS;
  50192. private constructor();
  50193. /**
  50194. * Creates a new DeviceInputSystem instance
  50195. * @param engine Engine to pull input element from
  50196. * @returns The new instance
  50197. */
  50198. static Create(engine: Engine): DeviceInputSystem;
  50199. /**
  50200. * Checks for current device input value, given an id and input index
  50201. * @param deviceName Id of connected device
  50202. * @param inputIndex Index of device input
  50203. * @returns Current value of input
  50204. */
  50205. /**
  50206. * Checks for current device input value, given an id and input index
  50207. * @param deviceType Enum specifiying device type
  50208. * @param deviceSlot "Slot" or index that device is referenced in
  50209. * @param inputIndex Id of input to be checked
  50210. * @returns Current value of input
  50211. */
  50212. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50213. /**
  50214. * Dispose of all the eventlisteners
  50215. */
  50216. dispose(): void;
  50217. /**
  50218. * Add device and inputs to device array
  50219. * @param deviceType Enum specifiying device type
  50220. * @param deviceSlot "Slot" or index that device is referenced in
  50221. * @param numberOfInputs Number of input entries to create for given device
  50222. */
  50223. private _registerDevice;
  50224. /**
  50225. * Given a specific device name, remove that device from the device map
  50226. * @param deviceType Enum specifiying device type
  50227. * @param deviceSlot "Slot" or index that device is referenced in
  50228. */
  50229. private _unregisterDevice;
  50230. /**
  50231. * Handle all actions that come from keyboard interaction
  50232. */
  50233. private _handleKeyActions;
  50234. /**
  50235. * Handle all actions that come from pointer interaction
  50236. */
  50237. private _handlePointerActions;
  50238. /**
  50239. * Handle all actions that come from gamepad interaction
  50240. */
  50241. private _handleGamepadActions;
  50242. /**
  50243. * Update all non-event based devices with each frame
  50244. * @param deviceType Enum specifiying device type
  50245. * @param deviceSlot "Slot" or index that device is referenced in
  50246. * @param inputIndex Id of input to be checked
  50247. */
  50248. private _updateDevice;
  50249. /**
  50250. * Gets DeviceType from the device name
  50251. * @param deviceName Name of Device from DeviceInputSystem
  50252. * @returns DeviceType enum value
  50253. */
  50254. private _getGamepadDeviceType;
  50255. }
  50256. }
  50257. declare module BABYLON {
  50258. /**
  50259. * Type to handle enforcement of inputs
  50260. */
  50261. 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;
  50262. }
  50263. declare module BABYLON {
  50264. /**
  50265. * Class that handles all input for a specific device
  50266. */
  50267. export class DeviceSource<T extends DeviceType> {
  50268. /** Type of device */
  50269. readonly deviceType: DeviceType;
  50270. /** "Slot" or index that device is referenced in */
  50271. readonly deviceSlot: number;
  50272. /**
  50273. * Observable to handle device input changes per device
  50274. */
  50275. readonly onInputChangedObservable: Observable<{
  50276. inputIndex: DeviceInput<T>;
  50277. previousState: Nullable<number>;
  50278. currentState: Nullable<number>;
  50279. }>;
  50280. private readonly _deviceInputSystem;
  50281. /**
  50282. * Default Constructor
  50283. * @param deviceInputSystem Reference to DeviceInputSystem
  50284. * @param deviceType Type of device
  50285. * @param deviceSlot "Slot" or index that device is referenced in
  50286. */
  50287. constructor(deviceInputSystem: DeviceInputSystem,
  50288. /** Type of device */
  50289. deviceType: DeviceType,
  50290. /** "Slot" or index that device is referenced in */
  50291. deviceSlot?: number);
  50292. /**
  50293. * Get input for specific input
  50294. * @param inputIndex index of specific input on device
  50295. * @returns Input value from DeviceInputSystem
  50296. */
  50297. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50298. }
  50299. /**
  50300. * Class to keep track of devices
  50301. */
  50302. export class DeviceSourceManager implements IDisposable {
  50303. /**
  50304. * Observable to be triggered when before a device is connected
  50305. */
  50306. readonly onBeforeDeviceConnectedObservable: Observable<{
  50307. deviceType: DeviceType;
  50308. deviceSlot: number;
  50309. }>;
  50310. /**
  50311. * Observable to be triggered when before a device is disconnected
  50312. */
  50313. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50314. deviceType: DeviceType;
  50315. deviceSlot: number;
  50316. }>;
  50317. /**
  50318. * Observable to be triggered when after a device is connected
  50319. */
  50320. readonly onAfterDeviceConnectedObservable: Observable<{
  50321. deviceType: DeviceType;
  50322. deviceSlot: number;
  50323. }>;
  50324. /**
  50325. * Observable to be triggered when after a device is disconnected
  50326. */
  50327. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50328. deviceType: DeviceType;
  50329. deviceSlot: number;
  50330. }>;
  50331. private readonly _devices;
  50332. private readonly _firstDevice;
  50333. private readonly _deviceInputSystem;
  50334. /**
  50335. * Default Constructor
  50336. * @param engine engine to pull input element from
  50337. */
  50338. constructor(engine: Engine);
  50339. /**
  50340. * Gets a DeviceSource, given a type and slot
  50341. * @param deviceType Enum specifying device type
  50342. * @param deviceSlot "Slot" or index that device is referenced in
  50343. * @returns DeviceSource object
  50344. */
  50345. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50346. /**
  50347. * Gets an array of DeviceSource objects for a given device type
  50348. * @param deviceType Enum specifying device type
  50349. * @returns Array of DeviceSource objects
  50350. */
  50351. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50352. /**
  50353. * Dispose of DeviceInputSystem and other parts
  50354. */
  50355. dispose(): void;
  50356. /**
  50357. * Function to add device name to device list
  50358. * @param deviceType Enum specifying device type
  50359. * @param deviceSlot "Slot" or index that device is referenced in
  50360. */
  50361. private _addDevice;
  50362. /**
  50363. * Function to remove device name to device list
  50364. * @param deviceType Enum specifying device type
  50365. * @param deviceSlot "Slot" or index that device is referenced in
  50366. */
  50367. private _removeDevice;
  50368. /**
  50369. * Updates array storing first connected device of each type
  50370. * @param type Type of Device
  50371. */
  50372. private _updateFirstDevices;
  50373. }
  50374. }
  50375. declare module BABYLON {
  50376. /**
  50377. * Options to create the null engine
  50378. */
  50379. export class NullEngineOptions {
  50380. /**
  50381. * Render width (Default: 512)
  50382. */
  50383. renderWidth: number;
  50384. /**
  50385. * Render height (Default: 256)
  50386. */
  50387. renderHeight: number;
  50388. /**
  50389. * Texture size (Default: 512)
  50390. */
  50391. textureSize: number;
  50392. /**
  50393. * If delta time between frames should be constant
  50394. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50395. */
  50396. deterministicLockstep: boolean;
  50397. /**
  50398. * Maximum about of steps between frames (Default: 4)
  50399. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50400. */
  50401. lockstepMaxSteps: number;
  50402. }
  50403. /**
  50404. * The null engine class provides support for headless version of babylon.js.
  50405. * This can be used in server side scenario or for testing purposes
  50406. */
  50407. export class NullEngine extends Engine {
  50408. private _options;
  50409. /**
  50410. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50411. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50412. * @returns true if engine is in deterministic lock step mode
  50413. */
  50414. isDeterministicLockStep(): boolean;
  50415. /**
  50416. * Gets the max steps when engine is running in deterministic lock step
  50417. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50418. * @returns the max steps
  50419. */
  50420. getLockstepMaxSteps(): number;
  50421. /**
  50422. * Gets the current hardware scaling level.
  50423. * By default the hardware scaling level is computed from the window device ratio.
  50424. * 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.
  50425. * @returns a number indicating the current hardware scaling level
  50426. */
  50427. getHardwareScalingLevel(): number;
  50428. constructor(options?: NullEngineOptions);
  50429. /**
  50430. * Creates a vertex buffer
  50431. * @param vertices the data for the vertex buffer
  50432. * @returns the new WebGL static buffer
  50433. */
  50434. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50435. /**
  50436. * Creates a new index buffer
  50437. * @param indices defines the content of the index buffer
  50438. * @param updatable defines if the index buffer must be updatable
  50439. * @returns a new webGL buffer
  50440. */
  50441. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50442. /**
  50443. * Clear the current render buffer or the current render target (if any is set up)
  50444. * @param color defines the color to use
  50445. * @param backBuffer defines if the back buffer must be cleared
  50446. * @param depth defines if the depth buffer must be cleared
  50447. * @param stencil defines if the stencil buffer must be cleared
  50448. */
  50449. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50450. /**
  50451. * Gets the current render width
  50452. * @param useScreen defines if screen size must be used (or the current render target if any)
  50453. * @returns a number defining the current render width
  50454. */
  50455. getRenderWidth(useScreen?: boolean): number;
  50456. /**
  50457. * Gets the current render height
  50458. * @param useScreen defines if screen size must be used (or the current render target if any)
  50459. * @returns a number defining the current render height
  50460. */
  50461. getRenderHeight(useScreen?: boolean): number;
  50462. /**
  50463. * Set the WebGL's viewport
  50464. * @param viewport defines the viewport element to be used
  50465. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50466. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50467. */
  50468. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50469. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50470. /**
  50471. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50472. * @param pipelineContext defines the pipeline context to use
  50473. * @param uniformsNames defines the list of uniform names
  50474. * @returns an array of webGL uniform locations
  50475. */
  50476. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50477. /**
  50478. * Gets the lsit of active attributes for a given webGL program
  50479. * @param pipelineContext defines the pipeline context to use
  50480. * @param attributesNames defines the list of attribute names to get
  50481. * @returns an array of indices indicating the offset of each attribute
  50482. */
  50483. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50484. /**
  50485. * Binds an effect to the webGL context
  50486. * @param effect defines the effect to bind
  50487. */
  50488. bindSamplers(effect: Effect): void;
  50489. /**
  50490. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50491. * @param effect defines the effect to activate
  50492. */
  50493. enableEffect(effect: Effect): void;
  50494. /**
  50495. * Set various states to the webGL context
  50496. * @param culling defines backface culling state
  50497. * @param zOffset defines the value to apply to zOffset (0 by default)
  50498. * @param force defines if states must be applied even if cache is up to date
  50499. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50500. */
  50501. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50502. /**
  50503. * Set the value of an uniform to an array of int32
  50504. * @param uniform defines the webGL uniform location where to store the value
  50505. * @param array defines the array of int32 to store
  50506. */
  50507. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50508. /**
  50509. * Set the value of an uniform to an array of int32 (stored as vec2)
  50510. * @param uniform defines the webGL uniform location where to store the value
  50511. * @param array defines the array of int32 to store
  50512. */
  50513. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50514. /**
  50515. * Set the value of an uniform to an array of int32 (stored as vec3)
  50516. * @param uniform defines the webGL uniform location where to store the value
  50517. * @param array defines the array of int32 to store
  50518. */
  50519. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50520. /**
  50521. * Set the value of an uniform to an array of int32 (stored as vec4)
  50522. * @param uniform defines the webGL uniform location where to store the value
  50523. * @param array defines the array of int32 to store
  50524. */
  50525. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50526. /**
  50527. * Set the value of an uniform to an array of float32
  50528. * @param uniform defines the webGL uniform location where to store the value
  50529. * @param array defines the array of float32 to store
  50530. */
  50531. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50532. /**
  50533. * Set the value of an uniform to an array of float32 (stored as vec2)
  50534. * @param uniform defines the webGL uniform location where to store the value
  50535. * @param array defines the array of float32 to store
  50536. */
  50537. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50538. /**
  50539. * Set the value of an uniform to an array of float32 (stored as vec3)
  50540. * @param uniform defines the webGL uniform location where to store the value
  50541. * @param array defines the array of float32 to store
  50542. */
  50543. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50544. /**
  50545. * Set the value of an uniform to an array of float32 (stored as vec4)
  50546. * @param uniform defines the webGL uniform location where to store the value
  50547. * @param array defines the array of float32 to store
  50548. */
  50549. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50550. /**
  50551. * Set the value of an uniform to an array of number
  50552. * @param uniform defines the webGL uniform location where to store the value
  50553. * @param array defines the array of number to store
  50554. */
  50555. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50556. /**
  50557. * Set the value of an uniform to an array of number (stored as vec2)
  50558. * @param uniform defines the webGL uniform location where to store the value
  50559. * @param array defines the array of number to store
  50560. */
  50561. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50562. /**
  50563. * Set the value of an uniform to an array of number (stored as vec3)
  50564. * @param uniform defines the webGL uniform location where to store the value
  50565. * @param array defines the array of number to store
  50566. */
  50567. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50568. /**
  50569. * Set the value of an uniform to an array of number (stored as vec4)
  50570. * @param uniform defines the webGL uniform location where to store the value
  50571. * @param array defines the array of number to store
  50572. */
  50573. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50574. /**
  50575. * Set the value of an uniform to an array of float32 (stored as matrices)
  50576. * @param uniform defines the webGL uniform location where to store the value
  50577. * @param matrices defines the array of float32 to store
  50578. */
  50579. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50580. /**
  50581. * Set the value of an uniform to a matrix (3x3)
  50582. * @param uniform defines the webGL uniform location where to store the value
  50583. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50584. */
  50585. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50586. /**
  50587. * Set the value of an uniform to a matrix (2x2)
  50588. * @param uniform defines the webGL uniform location where to store the value
  50589. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50590. */
  50591. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50592. /**
  50593. * Set the value of an uniform to a number (float)
  50594. * @param uniform defines the webGL uniform location where to store the value
  50595. * @param value defines the float number to store
  50596. */
  50597. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50598. /**
  50599. * Set the value of an uniform to a vec2
  50600. * @param uniform defines the webGL uniform location where to store the value
  50601. * @param x defines the 1st component of the value
  50602. * @param y defines the 2nd component of the value
  50603. */
  50604. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50605. /**
  50606. * Set the value of an uniform to a vec3
  50607. * @param uniform defines the webGL uniform location where to store the value
  50608. * @param x defines the 1st component of the value
  50609. * @param y defines the 2nd component of the value
  50610. * @param z defines the 3rd component of the value
  50611. */
  50612. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50613. /**
  50614. * Set the value of an uniform to a boolean
  50615. * @param uniform defines the webGL uniform location where to store the value
  50616. * @param bool defines the boolean to store
  50617. */
  50618. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50619. /**
  50620. * Set the value of an uniform to a vec4
  50621. * @param uniform defines the webGL uniform location where to store the value
  50622. * @param x defines the 1st component of the value
  50623. * @param y defines the 2nd component of the value
  50624. * @param z defines the 3rd component of the value
  50625. * @param w defines the 4th component of the value
  50626. */
  50627. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50628. /**
  50629. * Sets the current alpha mode
  50630. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50631. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50632. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50633. */
  50634. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50635. /**
  50636. * Bind webGl buffers directly to the webGL context
  50637. * @param vertexBuffers defines the vertex buffer to bind
  50638. * @param indexBuffer defines the index buffer to bind
  50639. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50640. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50641. * @param effect defines the effect associated with the vertex buffer
  50642. */
  50643. bindBuffers(vertexBuffers: {
  50644. [key: string]: VertexBuffer;
  50645. }, indexBuffer: DataBuffer, effect: Effect): void;
  50646. /**
  50647. * Force the entire cache to be cleared
  50648. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50649. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50650. */
  50651. wipeCaches(bruteForce?: boolean): void;
  50652. /**
  50653. * Send a draw order
  50654. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50655. * @param indexStart defines the starting index
  50656. * @param indexCount defines the number of index to draw
  50657. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50658. */
  50659. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50660. /**
  50661. * Draw a list of indexed primitives
  50662. * @param fillMode defines the primitive to use
  50663. * @param indexStart defines the starting index
  50664. * @param indexCount defines the number of index to draw
  50665. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50666. */
  50667. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50668. /**
  50669. * Draw a list of unindexed primitives
  50670. * @param fillMode defines the primitive to use
  50671. * @param verticesStart defines the index of first vertex to draw
  50672. * @param verticesCount defines the count of vertices to draw
  50673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50674. */
  50675. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50676. /** @hidden */
  50677. _createTexture(): WebGLTexture;
  50678. /** @hidden */
  50679. _releaseTexture(texture: InternalTexture): void;
  50680. /**
  50681. * Usually called from Texture.ts.
  50682. * Passed information to create a WebGLTexture
  50683. * @param urlArg defines a value which contains one of the following:
  50684. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50685. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50686. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50687. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50688. * @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)
  50689. * @param scene needed for loading to the correct scene
  50690. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50691. * @param onLoad optional callback to be called upon successful completion
  50692. * @param onError optional callback to be called upon failure
  50693. * @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
  50694. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50695. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50696. * @param forcedExtension defines the extension to use to pick the right loader
  50697. * @param mimeType defines an optional mime type
  50698. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50699. */
  50700. 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;
  50701. /**
  50702. * Creates a new render target texture
  50703. * @param size defines the size of the texture
  50704. * @param options defines the options used to create the texture
  50705. * @returns a new render target texture stored in an InternalTexture
  50706. */
  50707. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50708. /**
  50709. * Update the sampling mode of a given texture
  50710. * @param samplingMode defines the required sampling mode
  50711. * @param texture defines the texture to update
  50712. */
  50713. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50714. /**
  50715. * Binds the frame buffer to the specified texture.
  50716. * @param texture The texture to render to or null for the default canvas
  50717. * @param faceIndex The face of the texture to render to in case of cube texture
  50718. * @param requiredWidth The width of the target to render to
  50719. * @param requiredHeight The height of the target to render to
  50720. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50721. * @param lodLevel defines le lod level to bind to the frame buffer
  50722. */
  50723. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50724. /**
  50725. * Unbind the current render target texture from the webGL context
  50726. * @param texture defines the render target texture to unbind
  50727. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50728. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50729. */
  50730. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50731. /**
  50732. * Creates a dynamic vertex buffer
  50733. * @param vertices the data for the dynamic vertex buffer
  50734. * @returns the new WebGL dynamic buffer
  50735. */
  50736. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50737. /**
  50738. * Update the content of a dynamic texture
  50739. * @param texture defines the texture to update
  50740. * @param canvas defines the canvas containing the source
  50741. * @param invertY defines if data must be stored with Y axis inverted
  50742. * @param premulAlpha defines if alpha is stored as premultiplied
  50743. * @param format defines the format of the data
  50744. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50745. */
  50746. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50747. /**
  50748. * Gets a boolean indicating if all created effects are ready
  50749. * @returns true if all effects are ready
  50750. */
  50751. areAllEffectsReady(): boolean;
  50752. /**
  50753. * @hidden
  50754. * Get the current error code of the webGL context
  50755. * @returns the error code
  50756. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50757. */
  50758. getError(): number;
  50759. /** @hidden */
  50760. _getUnpackAlignement(): number;
  50761. /** @hidden */
  50762. _unpackFlipY(value: boolean): void;
  50763. /**
  50764. * Update a dynamic index buffer
  50765. * @param indexBuffer defines the target index buffer
  50766. * @param indices defines the data to update
  50767. * @param offset defines the offset in the target index buffer where update should start
  50768. */
  50769. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50770. /**
  50771. * Updates a dynamic vertex buffer.
  50772. * @param vertexBuffer the vertex buffer to update
  50773. * @param vertices the data used to update the vertex buffer
  50774. * @param byteOffset the byte offset of the data (optional)
  50775. * @param byteLength the byte length of the data (optional)
  50776. */
  50777. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50778. /** @hidden */
  50779. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50780. /** @hidden */
  50781. _bindTexture(channel: number, texture: InternalTexture): void;
  50782. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50783. /**
  50784. * 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
  50785. */
  50786. releaseEffects(): void;
  50787. displayLoadingUI(): void;
  50788. hideLoadingUI(): void;
  50789. /** @hidden */
  50790. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50791. /** @hidden */
  50792. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50793. /** @hidden */
  50794. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50795. /** @hidden */
  50796. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50797. }
  50798. }
  50799. declare module BABYLON {
  50800. /**
  50801. * @hidden
  50802. **/
  50803. export class _TimeToken {
  50804. _startTimeQuery: Nullable<WebGLQuery>;
  50805. _endTimeQuery: Nullable<WebGLQuery>;
  50806. _timeElapsedQuery: Nullable<WebGLQuery>;
  50807. _timeElapsedQueryEnded: boolean;
  50808. }
  50809. }
  50810. declare module BABYLON {
  50811. /** @hidden */
  50812. export class _OcclusionDataStorage {
  50813. /** @hidden */
  50814. occlusionInternalRetryCounter: number;
  50815. /** @hidden */
  50816. isOcclusionQueryInProgress: boolean;
  50817. /** @hidden */
  50818. isOccluded: boolean;
  50819. /** @hidden */
  50820. occlusionRetryCount: number;
  50821. /** @hidden */
  50822. occlusionType: number;
  50823. /** @hidden */
  50824. occlusionQueryAlgorithmType: number;
  50825. }
  50826. interface Engine {
  50827. /**
  50828. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50829. * @return the new query
  50830. */
  50831. createQuery(): WebGLQuery;
  50832. /**
  50833. * Delete and release a webGL query
  50834. * @param query defines the query to delete
  50835. * @return the current engine
  50836. */
  50837. deleteQuery(query: WebGLQuery): Engine;
  50838. /**
  50839. * Check if a given query has resolved and got its value
  50840. * @param query defines the query to check
  50841. * @returns true if the query got its value
  50842. */
  50843. isQueryResultAvailable(query: WebGLQuery): boolean;
  50844. /**
  50845. * Gets the value of a given query
  50846. * @param query defines the query to check
  50847. * @returns the value of the query
  50848. */
  50849. getQueryResult(query: WebGLQuery): number;
  50850. /**
  50851. * Initiates an occlusion query
  50852. * @param algorithmType defines the algorithm to use
  50853. * @param query defines the query to use
  50854. * @returns the current engine
  50855. * @see http://doc.babylonjs.com/features/occlusionquery
  50856. */
  50857. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50858. /**
  50859. * Ends an occlusion query
  50860. * @see http://doc.babylonjs.com/features/occlusionquery
  50861. * @param algorithmType defines the algorithm to use
  50862. * @returns the current engine
  50863. */
  50864. endOcclusionQuery(algorithmType: number): Engine;
  50865. /**
  50866. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50867. * Please note that only one query can be issued at a time
  50868. * @returns a time token used to track the time span
  50869. */
  50870. startTimeQuery(): Nullable<_TimeToken>;
  50871. /**
  50872. * Ends a time query
  50873. * @param token defines the token used to measure the time span
  50874. * @returns the time spent (in ns)
  50875. */
  50876. endTimeQuery(token: _TimeToken): int;
  50877. /** @hidden */
  50878. _currentNonTimestampToken: Nullable<_TimeToken>;
  50879. /** @hidden */
  50880. _createTimeQuery(): WebGLQuery;
  50881. /** @hidden */
  50882. _deleteTimeQuery(query: WebGLQuery): void;
  50883. /** @hidden */
  50884. _getGlAlgorithmType(algorithmType: number): number;
  50885. /** @hidden */
  50886. _getTimeQueryResult(query: WebGLQuery): any;
  50887. /** @hidden */
  50888. _getTimeQueryAvailability(query: WebGLQuery): any;
  50889. }
  50890. interface AbstractMesh {
  50891. /**
  50892. * Backing filed
  50893. * @hidden
  50894. */
  50895. __occlusionDataStorage: _OcclusionDataStorage;
  50896. /**
  50897. * Access property
  50898. * @hidden
  50899. */
  50900. _occlusionDataStorage: _OcclusionDataStorage;
  50901. /**
  50902. * 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.
  50903. * The default value is -1 which means don't break the query and wait till the result
  50904. * @see http://doc.babylonjs.com/features/occlusionquery
  50905. */
  50906. occlusionRetryCount: number;
  50907. /**
  50908. * 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:
  50909. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50910. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50911. * * 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.
  50912. * @see http://doc.babylonjs.com/features/occlusionquery
  50913. */
  50914. occlusionType: number;
  50915. /**
  50916. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50917. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50918. * * 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.
  50919. * @see http://doc.babylonjs.com/features/occlusionquery
  50920. */
  50921. occlusionQueryAlgorithmType: number;
  50922. /**
  50923. * 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
  50924. * @see http://doc.babylonjs.com/features/occlusionquery
  50925. */
  50926. isOccluded: boolean;
  50927. /**
  50928. * Flag to check the progress status of the query
  50929. * @see http://doc.babylonjs.com/features/occlusionquery
  50930. */
  50931. isOcclusionQueryInProgress: boolean;
  50932. }
  50933. }
  50934. declare module BABYLON {
  50935. /** @hidden */
  50936. export var _forceTransformFeedbackToBundle: boolean;
  50937. interface Engine {
  50938. /**
  50939. * Creates a webGL transform feedback object
  50940. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50941. * @returns the webGL transform feedback object
  50942. */
  50943. createTransformFeedback(): WebGLTransformFeedback;
  50944. /**
  50945. * Delete a webGL transform feedback object
  50946. * @param value defines the webGL transform feedback object to delete
  50947. */
  50948. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50949. /**
  50950. * Bind a webGL transform feedback object to the webgl context
  50951. * @param value defines the webGL transform feedback object to bind
  50952. */
  50953. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50954. /**
  50955. * Begins a transform feedback operation
  50956. * @param usePoints defines if points or triangles must be used
  50957. */
  50958. beginTransformFeedback(usePoints: boolean): void;
  50959. /**
  50960. * Ends a transform feedback operation
  50961. */
  50962. endTransformFeedback(): void;
  50963. /**
  50964. * Specify the varyings to use with transform feedback
  50965. * @param program defines the associated webGL program
  50966. * @param value defines the list of strings representing the varying names
  50967. */
  50968. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50969. /**
  50970. * Bind a webGL buffer for a transform feedback operation
  50971. * @param value defines the webGL buffer to bind
  50972. */
  50973. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50974. }
  50975. }
  50976. declare module BABYLON {
  50977. /**
  50978. * Creation options of the multi render target texture.
  50979. */
  50980. export interface IMultiRenderTargetOptions {
  50981. /**
  50982. * Define if the texture needs to create mip maps after render.
  50983. */
  50984. generateMipMaps?: boolean;
  50985. /**
  50986. * Define the types of all the draw buffers we want to create
  50987. */
  50988. types?: number[];
  50989. /**
  50990. * Define the sampling modes of all the draw buffers we want to create
  50991. */
  50992. samplingModes?: number[];
  50993. /**
  50994. * Define if a depth buffer is required
  50995. */
  50996. generateDepthBuffer?: boolean;
  50997. /**
  50998. * Define if a stencil buffer is required
  50999. */
  51000. generateStencilBuffer?: boolean;
  51001. /**
  51002. * Define if a depth texture is required instead of a depth buffer
  51003. */
  51004. generateDepthTexture?: boolean;
  51005. /**
  51006. * Define the number of desired draw buffers
  51007. */
  51008. textureCount?: number;
  51009. /**
  51010. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51011. */
  51012. doNotChangeAspectRatio?: boolean;
  51013. /**
  51014. * Define the default type of the buffers we are creating
  51015. */
  51016. defaultType?: number;
  51017. }
  51018. /**
  51019. * A multi render target, like a render target provides the ability to render to a texture.
  51020. * Unlike the render target, it can render to several draw buffers in one draw.
  51021. * This is specially interesting in deferred rendering or for any effects requiring more than
  51022. * just one color from a single pass.
  51023. */
  51024. export class MultiRenderTarget extends RenderTargetTexture {
  51025. private _internalTextures;
  51026. private _textures;
  51027. private _multiRenderTargetOptions;
  51028. /**
  51029. * Get if draw buffers are currently supported by the used hardware and browser.
  51030. */
  51031. get isSupported(): boolean;
  51032. /**
  51033. * Get the list of textures generated by the multi render target.
  51034. */
  51035. get textures(): Texture[];
  51036. /**
  51037. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51038. */
  51039. get depthTexture(): Texture;
  51040. /**
  51041. * Set the wrapping mode on U of all the textures we are rendering to.
  51042. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51043. */
  51044. set wrapU(wrap: number);
  51045. /**
  51046. * Set the wrapping mode on V of all the textures we are rendering to.
  51047. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51048. */
  51049. set wrapV(wrap: number);
  51050. /**
  51051. * Instantiate a new multi render target texture.
  51052. * A multi render target, like a render target provides the ability to render to a texture.
  51053. * Unlike the render target, it can render to several draw buffers in one draw.
  51054. * This is specially interesting in deferred rendering or for any effects requiring more than
  51055. * just one color from a single pass.
  51056. * @param name Define the name of the texture
  51057. * @param size Define the size of the buffers to render to
  51058. * @param count Define the number of target we are rendering into
  51059. * @param scene Define the scene the texture belongs to
  51060. * @param options Define the options used to create the multi render target
  51061. */
  51062. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51063. /** @hidden */
  51064. _rebuild(): void;
  51065. private _createInternalTextures;
  51066. private _createTextures;
  51067. /**
  51068. * Define the number of samples used if MSAA is enabled.
  51069. */
  51070. get samples(): number;
  51071. set samples(value: number);
  51072. /**
  51073. * Resize all the textures in the multi render target.
  51074. * Be carrefull as it will recreate all the data in the new texture.
  51075. * @param size Define the new size
  51076. */
  51077. resize(size: any): void;
  51078. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51079. /**
  51080. * Dispose the render targets and their associated resources
  51081. */
  51082. dispose(): void;
  51083. /**
  51084. * Release all the underlying texture used as draw buffers.
  51085. */
  51086. releaseInternalTextures(): void;
  51087. }
  51088. }
  51089. declare module BABYLON {
  51090. interface ThinEngine {
  51091. /**
  51092. * Unbind a list of render target textures from the webGL context
  51093. * This is used only when drawBuffer extension or webGL2 are active
  51094. * @param textures defines the render target textures to unbind
  51095. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51096. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51097. */
  51098. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51099. /**
  51100. * Create a multi render target texture
  51101. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  51102. * @param size defines the size of the texture
  51103. * @param options defines the creation options
  51104. * @returns the cube texture as an InternalTexture
  51105. */
  51106. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51107. /**
  51108. * Update the sample count for a given multiple render target texture
  51109. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51110. * @param textures defines the textures to update
  51111. * @param samples defines the sample count to set
  51112. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51113. */
  51114. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51115. }
  51116. }
  51117. declare module BABYLON {
  51118. /**
  51119. * Class used to define an additional view for the engine
  51120. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51121. */
  51122. export class EngineView {
  51123. /** Defines the canvas where to render the view */
  51124. target: HTMLCanvasElement;
  51125. /** Defines an optional camera used to render the view (will use active camera else) */
  51126. camera?: Camera;
  51127. }
  51128. interface Engine {
  51129. /**
  51130. * Gets or sets the HTML element to use for attaching events
  51131. */
  51132. inputElement: Nullable<HTMLElement>;
  51133. /**
  51134. * Gets the current engine view
  51135. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51136. */
  51137. activeView: Nullable<EngineView>;
  51138. /** Gets or sets the list of views */
  51139. views: EngineView[];
  51140. /**
  51141. * Register a new child canvas
  51142. * @param canvas defines the canvas to register
  51143. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51144. * @returns the associated view
  51145. */
  51146. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51147. /**
  51148. * Remove a registered child canvas
  51149. * @param canvas defines the canvas to remove
  51150. * @returns the current engine
  51151. */
  51152. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51153. }
  51154. }
  51155. declare module BABYLON {
  51156. interface Engine {
  51157. /** @hidden */
  51158. _excludedCompressedTextures: string[];
  51159. /** @hidden */
  51160. _textureFormatInUse: string;
  51161. /**
  51162. * Gets the list of texture formats supported
  51163. */
  51164. readonly texturesSupported: Array<string>;
  51165. /**
  51166. * Gets the texture format in use
  51167. */
  51168. readonly textureFormatInUse: Nullable<string>;
  51169. /**
  51170. * Set the compressed texture extensions or file names to skip.
  51171. *
  51172. * @param skippedFiles defines the list of those texture files you want to skip
  51173. * Example: [".dds", ".env", "myfile.png"]
  51174. */
  51175. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51176. /**
  51177. * Set the compressed texture format to use, based on the formats you have, and the formats
  51178. * supported by the hardware / browser.
  51179. *
  51180. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51181. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51182. * to API arguments needed to compressed textures. This puts the burden on the container
  51183. * generator to house the arcane code for determining these for current & future formats.
  51184. *
  51185. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51186. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51187. *
  51188. * Note: The result of this call is not taken into account when a texture is base64.
  51189. *
  51190. * @param formatsAvailable defines the list of those format families you have created
  51191. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51192. *
  51193. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51194. * @returns The extension selected.
  51195. */
  51196. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51197. }
  51198. }
  51199. declare module BABYLON {
  51200. /**
  51201. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51202. */
  51203. export interface CubeMapInfo {
  51204. /**
  51205. * The pixel array for the front face.
  51206. * This is stored in format, left to right, up to down format.
  51207. */
  51208. front: Nullable<ArrayBufferView>;
  51209. /**
  51210. * The pixel array for the back face.
  51211. * This is stored in format, left to right, up to down format.
  51212. */
  51213. back: Nullable<ArrayBufferView>;
  51214. /**
  51215. * The pixel array for the left face.
  51216. * This is stored in format, left to right, up to down format.
  51217. */
  51218. left: Nullable<ArrayBufferView>;
  51219. /**
  51220. * The pixel array for the right face.
  51221. * This is stored in format, left to right, up to down format.
  51222. */
  51223. right: Nullable<ArrayBufferView>;
  51224. /**
  51225. * The pixel array for the up face.
  51226. * This is stored in format, left to right, up to down format.
  51227. */
  51228. up: Nullable<ArrayBufferView>;
  51229. /**
  51230. * The pixel array for the down face.
  51231. * This is stored in format, left to right, up to down format.
  51232. */
  51233. down: Nullable<ArrayBufferView>;
  51234. /**
  51235. * The size of the cubemap stored.
  51236. *
  51237. * Each faces will be size * size pixels.
  51238. */
  51239. size: number;
  51240. /**
  51241. * The format of the texture.
  51242. *
  51243. * RGBA, RGB.
  51244. */
  51245. format: number;
  51246. /**
  51247. * The type of the texture data.
  51248. *
  51249. * UNSIGNED_INT, FLOAT.
  51250. */
  51251. type: number;
  51252. /**
  51253. * Specifies whether the texture is in gamma space.
  51254. */
  51255. gammaSpace: boolean;
  51256. }
  51257. /**
  51258. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51259. */
  51260. export class PanoramaToCubeMapTools {
  51261. private static FACE_LEFT;
  51262. private static FACE_RIGHT;
  51263. private static FACE_FRONT;
  51264. private static FACE_BACK;
  51265. private static FACE_DOWN;
  51266. private static FACE_UP;
  51267. /**
  51268. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51269. *
  51270. * @param float32Array The source data.
  51271. * @param inputWidth The width of the input panorama.
  51272. * @param inputHeight The height of the input panorama.
  51273. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51274. * @return The cubemap data
  51275. */
  51276. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51277. private static CreateCubemapTexture;
  51278. private static CalcProjectionSpherical;
  51279. }
  51280. }
  51281. declare module BABYLON {
  51282. /**
  51283. * Helper class dealing with the extraction of spherical polynomial dataArray
  51284. * from a cube map.
  51285. */
  51286. export class CubeMapToSphericalPolynomialTools {
  51287. private static FileFaces;
  51288. /**
  51289. * Converts a texture to the according Spherical Polynomial data.
  51290. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51291. *
  51292. * @param texture The texture to extract the information from.
  51293. * @return The Spherical Polynomial data.
  51294. */
  51295. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51296. /**
  51297. * Converts a cubemap to the according Spherical Polynomial data.
  51298. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51299. *
  51300. * @param cubeInfo The Cube map to extract the information from.
  51301. * @return The Spherical Polynomial data.
  51302. */
  51303. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51304. }
  51305. }
  51306. declare module BABYLON {
  51307. interface BaseTexture {
  51308. /**
  51309. * Get the polynomial representation of the texture data.
  51310. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51311. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51312. */
  51313. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51314. }
  51315. }
  51316. declare module BABYLON {
  51317. /** @hidden */
  51318. export var rgbdEncodePixelShader: {
  51319. name: string;
  51320. shader: string;
  51321. };
  51322. }
  51323. declare module BABYLON {
  51324. /** @hidden */
  51325. export var rgbdDecodePixelShader: {
  51326. name: string;
  51327. shader: string;
  51328. };
  51329. }
  51330. declare module BABYLON {
  51331. /**
  51332. * Raw texture data and descriptor sufficient for WebGL texture upload
  51333. */
  51334. export interface EnvironmentTextureInfo {
  51335. /**
  51336. * Version of the environment map
  51337. */
  51338. version: number;
  51339. /**
  51340. * Width of image
  51341. */
  51342. width: number;
  51343. /**
  51344. * Irradiance information stored in the file.
  51345. */
  51346. irradiance: any;
  51347. /**
  51348. * Specular information stored in the file.
  51349. */
  51350. specular: any;
  51351. }
  51352. /**
  51353. * Defines One Image in the file. It requires only the position in the file
  51354. * as well as the length.
  51355. */
  51356. interface BufferImageData {
  51357. /**
  51358. * Length of the image data.
  51359. */
  51360. length: number;
  51361. /**
  51362. * Position of the data from the null terminator delimiting the end of the JSON.
  51363. */
  51364. position: number;
  51365. }
  51366. /**
  51367. * Defines the specular data enclosed in the file.
  51368. * This corresponds to the version 1 of the data.
  51369. */
  51370. export interface EnvironmentTextureSpecularInfoV1 {
  51371. /**
  51372. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51373. */
  51374. specularDataPosition?: number;
  51375. /**
  51376. * This contains all the images data needed to reconstruct the cubemap.
  51377. */
  51378. mipmaps: Array<BufferImageData>;
  51379. /**
  51380. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51381. */
  51382. lodGenerationScale: number;
  51383. }
  51384. /**
  51385. * Sets of helpers addressing the serialization and deserialization of environment texture
  51386. * stored in a BabylonJS env file.
  51387. * Those files are usually stored as .env files.
  51388. */
  51389. export class EnvironmentTextureTools {
  51390. /**
  51391. * Magic number identifying the env file.
  51392. */
  51393. private static _MagicBytes;
  51394. /**
  51395. * Gets the environment info from an env file.
  51396. * @param data The array buffer containing the .env bytes.
  51397. * @returns the environment file info (the json header) if successfully parsed.
  51398. */
  51399. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51400. /**
  51401. * Creates an environment texture from a loaded cube texture.
  51402. * @param texture defines the cube texture to convert in env file
  51403. * @return a promise containing the environment data if succesfull.
  51404. */
  51405. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51406. /**
  51407. * Creates a JSON representation of the spherical data.
  51408. * @param texture defines the texture containing the polynomials
  51409. * @return the JSON representation of the spherical info
  51410. */
  51411. private static _CreateEnvTextureIrradiance;
  51412. /**
  51413. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51414. * @param data the image data
  51415. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51416. * @return the views described by info providing access to the underlying buffer
  51417. */
  51418. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51419. /**
  51420. * Uploads the texture info contained in the env file to the GPU.
  51421. * @param texture defines the internal texture to upload to
  51422. * @param data defines the data to load
  51423. * @param info defines the texture info retrieved through the GetEnvInfo method
  51424. * @returns a promise
  51425. */
  51426. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51427. private static _OnImageReadyAsync;
  51428. /**
  51429. * Uploads the levels of image data to the GPU.
  51430. * @param texture defines the internal texture to upload to
  51431. * @param imageData defines the array buffer views of image data [mipmap][face]
  51432. * @returns a promise
  51433. */
  51434. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51435. /**
  51436. * Uploads spherical polynomials information to the texture.
  51437. * @param texture defines the texture we are trying to upload the information to
  51438. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51439. */
  51440. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51441. /** @hidden */
  51442. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51443. }
  51444. }
  51445. declare module BABYLON {
  51446. /** @hidden */
  51447. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51448. private _genericAttributeLocation;
  51449. private _varyingLocationCount;
  51450. private _varyingLocationMap;
  51451. private _replacements;
  51452. private _textureCount;
  51453. private _uniforms;
  51454. lineProcessor(line: string): string;
  51455. attributeProcessor(attribute: string): string;
  51456. varyingProcessor(varying: string, isFragment: boolean): string;
  51457. uniformProcessor(uniform: string): string;
  51458. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51459. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51460. }
  51461. }
  51462. declare module BABYLON {
  51463. /**
  51464. * Class used to inline functions in shader code
  51465. */
  51466. export class ShaderCodeInliner {
  51467. private static readonly _RegexpFindFunctionNameAndType;
  51468. private _sourceCode;
  51469. private _functionDescr;
  51470. private _numMaxIterations;
  51471. /** Gets or sets the token used to mark the functions to inline */
  51472. inlineToken: string;
  51473. /** Gets or sets the debug mode */
  51474. debug: boolean;
  51475. /** Gets the code after the inlining process */
  51476. get code(): string;
  51477. /**
  51478. * Initializes the inliner
  51479. * @param sourceCode shader code source to inline
  51480. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51481. */
  51482. constructor(sourceCode: string, numMaxIterations?: number);
  51483. /**
  51484. * Start the processing of the shader code
  51485. */
  51486. processCode(): void;
  51487. private _collectFunctions;
  51488. private _processInlining;
  51489. private _extractBetweenMarkers;
  51490. private _skipWhitespaces;
  51491. private _removeComments;
  51492. private _replaceFunctionCallsByCode;
  51493. private _findBackward;
  51494. private _escapeRegExp;
  51495. private _replaceNames;
  51496. }
  51497. }
  51498. declare module BABYLON {
  51499. /**
  51500. * Container for accessors for natively-stored mesh data buffers.
  51501. */
  51502. class NativeDataBuffer extends DataBuffer {
  51503. /**
  51504. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51505. */
  51506. nativeIndexBuffer?: any;
  51507. /**
  51508. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51509. */
  51510. nativeVertexBuffer?: any;
  51511. }
  51512. /** @hidden */
  51513. class NativeTexture extends InternalTexture {
  51514. getInternalTexture(): InternalTexture;
  51515. getViewCount(): number;
  51516. }
  51517. /** @hidden */
  51518. export class NativeEngine extends Engine {
  51519. private readonly _native;
  51520. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51521. private readonly INVALID_HANDLE;
  51522. getHardwareScalingLevel(): number;
  51523. constructor();
  51524. dispose(): void;
  51525. /**
  51526. * Can be used to override the current requestAnimationFrame requester.
  51527. * @hidden
  51528. */
  51529. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51530. /**
  51531. * Override default engine behavior.
  51532. * @param color
  51533. * @param backBuffer
  51534. * @param depth
  51535. * @param stencil
  51536. */
  51537. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51538. /**
  51539. * Gets host document
  51540. * @returns the host document object
  51541. */
  51542. getHostDocument(): Nullable<Document>;
  51543. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51544. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51545. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51546. recordVertexArrayObject(vertexBuffers: {
  51547. [key: string]: VertexBuffer;
  51548. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51549. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51550. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51551. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51552. /**
  51553. * Draw a list of indexed primitives
  51554. * @param fillMode defines the primitive to use
  51555. * @param indexStart defines the starting index
  51556. * @param indexCount defines the number of index to draw
  51557. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51558. */
  51559. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51560. /**
  51561. * Draw a list of unindexed primitives
  51562. * @param fillMode defines the primitive to use
  51563. * @param verticesStart defines the index of first vertex to draw
  51564. * @param verticesCount defines the count of vertices to draw
  51565. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51566. */
  51567. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51568. createPipelineContext(): IPipelineContext;
  51569. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51570. /** @hidden */
  51571. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51572. /** @hidden */
  51573. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51574. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51575. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51576. protected _setProgram(program: WebGLProgram): void;
  51577. _releaseEffect(effect: Effect): void;
  51578. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51579. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51580. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51581. bindSamplers(effect: Effect): void;
  51582. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51583. getRenderWidth(useScreen?: boolean): number;
  51584. getRenderHeight(useScreen?: boolean): number;
  51585. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51586. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51587. /**
  51588. * Set the z offset to apply to current rendering
  51589. * @param value defines the offset to apply
  51590. */
  51591. setZOffset(value: number): void;
  51592. /**
  51593. * Gets the current value of the zOffset
  51594. * @returns the current zOffset state
  51595. */
  51596. getZOffset(): number;
  51597. /**
  51598. * Enable or disable depth buffering
  51599. * @param enable defines the state to set
  51600. */
  51601. setDepthBuffer(enable: boolean): void;
  51602. /**
  51603. * Gets a boolean indicating if depth writing is enabled
  51604. * @returns the current depth writing state
  51605. */
  51606. getDepthWrite(): boolean;
  51607. /**
  51608. * Enable or disable depth writing
  51609. * @param enable defines the state to set
  51610. */
  51611. setDepthWrite(enable: boolean): void;
  51612. /**
  51613. * Enable or disable color writing
  51614. * @param enable defines the state to set
  51615. */
  51616. setColorWrite(enable: boolean): void;
  51617. /**
  51618. * Gets a boolean indicating if color writing is enabled
  51619. * @returns the current color writing state
  51620. */
  51621. getColorWrite(): boolean;
  51622. /**
  51623. * Sets alpha constants used by some alpha blending modes
  51624. * @param r defines the red component
  51625. * @param g defines the green component
  51626. * @param b defines the blue component
  51627. * @param a defines the alpha component
  51628. */
  51629. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51630. /**
  51631. * Sets the current alpha mode
  51632. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51633. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51634. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51635. */
  51636. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51637. /**
  51638. * Gets the current alpha mode
  51639. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51640. * @returns the current alpha mode
  51641. */
  51642. getAlphaMode(): number;
  51643. setInt(uniform: WebGLUniformLocation, int: number): void;
  51644. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51645. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51646. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51647. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51648. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51649. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51650. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51651. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51652. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51653. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51654. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51655. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51656. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51657. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51658. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51659. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51660. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51661. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51662. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51663. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51664. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51665. wipeCaches(bruteForce?: boolean): void;
  51666. _createTexture(): WebGLTexture;
  51667. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51668. /**
  51669. * Usually called from Texture.ts.
  51670. * Passed information to create a WebGLTexture
  51671. * @param url defines a value which contains one of the following:
  51672. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51673. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51674. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51675. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51676. * @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)
  51677. * @param scene needed for loading to the correct scene
  51678. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51679. * @param onLoad optional callback to be called upon successful completion
  51680. * @param onError optional callback to be called upon failure
  51681. * @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
  51682. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51683. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51684. * @param forcedExtension defines the extension to use to pick the right loader
  51685. * @param mimeType defines an optional mime type
  51686. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51687. */
  51688. 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;
  51689. /**
  51690. * Creates a cube texture
  51691. * @param rootUrl defines the url where the files to load is located
  51692. * @param scene defines the current scene
  51693. * @param files defines the list of files to load (1 per face)
  51694. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51695. * @param onLoad defines an optional callback raised when the texture is loaded
  51696. * @param onError defines an optional callback raised if there is an issue to load the texture
  51697. * @param format defines the format of the data
  51698. * @param forcedExtension defines the extension to use to pick the right loader
  51699. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51700. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51701. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51702. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51703. * @returns the cube texture as an InternalTexture
  51704. */
  51705. 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;
  51706. private _getSamplingFilter;
  51707. private static _GetNativeTextureFormat;
  51708. createRenderTargetTexture(size: number | {
  51709. width: number;
  51710. height: number;
  51711. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51712. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51713. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51714. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51715. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51716. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51717. /**
  51718. * Updates a dynamic vertex buffer.
  51719. * @param vertexBuffer the vertex buffer to update
  51720. * @param data the data used to update the vertex buffer
  51721. * @param byteOffset the byte offset of the data (optional)
  51722. * @param byteLength the byte length of the data (optional)
  51723. */
  51724. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51725. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51726. private _updateAnisotropicLevel;
  51727. private _getAddressMode;
  51728. /** @hidden */
  51729. _bindTexture(channel: number, texture: InternalTexture): void;
  51730. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51731. releaseEffects(): void;
  51732. /** @hidden */
  51733. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51734. /** @hidden */
  51735. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51736. /** @hidden */
  51737. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51738. /** @hidden */
  51739. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51740. }
  51741. }
  51742. declare module BABYLON {
  51743. /**
  51744. * Gather the list of clipboard event types as constants.
  51745. */
  51746. export class ClipboardEventTypes {
  51747. /**
  51748. * The clipboard event is fired when a copy command is active (pressed).
  51749. */
  51750. static readonly COPY: number;
  51751. /**
  51752. * The clipboard event is fired when a cut command is active (pressed).
  51753. */
  51754. static readonly CUT: number;
  51755. /**
  51756. * The clipboard event is fired when a paste command is active (pressed).
  51757. */
  51758. static readonly PASTE: number;
  51759. }
  51760. /**
  51761. * This class is used to store clipboard related info for the onClipboardObservable event.
  51762. */
  51763. export class ClipboardInfo {
  51764. /**
  51765. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51766. */
  51767. type: number;
  51768. /**
  51769. * Defines the related dom event
  51770. */
  51771. event: ClipboardEvent;
  51772. /**
  51773. *Creates an instance of ClipboardInfo.
  51774. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51775. * @param event Defines the related dom event
  51776. */
  51777. constructor(
  51778. /**
  51779. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51780. */
  51781. type: number,
  51782. /**
  51783. * Defines the related dom event
  51784. */
  51785. event: ClipboardEvent);
  51786. /**
  51787. * Get the clipboard event's type from the keycode.
  51788. * @param keyCode Defines the keyCode for the current keyboard event.
  51789. * @return {number}
  51790. */
  51791. static GetTypeFromCharacter(keyCode: number): number;
  51792. }
  51793. }
  51794. declare module BABYLON {
  51795. /**
  51796. * Google Daydream controller
  51797. */
  51798. export class DaydreamController extends WebVRController {
  51799. /**
  51800. * Base Url for the controller model.
  51801. */
  51802. static MODEL_BASE_URL: string;
  51803. /**
  51804. * File name for the controller model.
  51805. */
  51806. static MODEL_FILENAME: string;
  51807. /**
  51808. * Gamepad Id prefix used to identify Daydream Controller.
  51809. */
  51810. static readonly GAMEPAD_ID_PREFIX: string;
  51811. /**
  51812. * Creates a new DaydreamController from a gamepad
  51813. * @param vrGamepad the gamepad that the controller should be created from
  51814. */
  51815. constructor(vrGamepad: any);
  51816. /**
  51817. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51818. * @param scene scene in which to add meshes
  51819. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51820. */
  51821. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51822. /**
  51823. * Called once for each button that changed state since the last frame
  51824. * @param buttonIdx Which button index changed
  51825. * @param state New state of the button
  51826. * @param changes Which properties on the state changed since last frame
  51827. */
  51828. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51829. }
  51830. }
  51831. declare module BABYLON {
  51832. /**
  51833. * Gear VR Controller
  51834. */
  51835. export class GearVRController extends WebVRController {
  51836. /**
  51837. * Base Url for the controller model.
  51838. */
  51839. static MODEL_BASE_URL: string;
  51840. /**
  51841. * File name for the controller model.
  51842. */
  51843. static MODEL_FILENAME: string;
  51844. /**
  51845. * Gamepad Id prefix used to identify this controller.
  51846. */
  51847. static readonly GAMEPAD_ID_PREFIX: string;
  51848. private readonly _buttonIndexToObservableNameMap;
  51849. /**
  51850. * Creates a new GearVRController from a gamepad
  51851. * @param vrGamepad the gamepad that the controller should be created from
  51852. */
  51853. constructor(vrGamepad: any);
  51854. /**
  51855. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51856. * @param scene scene in which to add meshes
  51857. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51858. */
  51859. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51860. /**
  51861. * Called once for each button that changed state since the last frame
  51862. * @param buttonIdx Which button index changed
  51863. * @param state New state of the button
  51864. * @param changes Which properties on the state changed since last frame
  51865. */
  51866. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51867. }
  51868. }
  51869. declare module BABYLON {
  51870. /**
  51871. * Generic Controller
  51872. */
  51873. export class GenericController extends WebVRController {
  51874. /**
  51875. * Base Url for the controller model.
  51876. */
  51877. static readonly MODEL_BASE_URL: string;
  51878. /**
  51879. * File name for the controller model.
  51880. */
  51881. static readonly MODEL_FILENAME: string;
  51882. /**
  51883. * Creates a new GenericController from a gamepad
  51884. * @param vrGamepad the gamepad that the controller should be created from
  51885. */
  51886. constructor(vrGamepad: any);
  51887. /**
  51888. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51889. * @param scene scene in which to add meshes
  51890. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51891. */
  51892. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51893. /**
  51894. * Called once for each button that changed state since the last frame
  51895. * @param buttonIdx Which button index changed
  51896. * @param state New state of the button
  51897. * @param changes Which properties on the state changed since last frame
  51898. */
  51899. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51900. }
  51901. }
  51902. declare module BABYLON {
  51903. /**
  51904. * Oculus Touch Controller
  51905. */
  51906. export class OculusTouchController extends WebVRController {
  51907. /**
  51908. * Base Url for the controller model.
  51909. */
  51910. static MODEL_BASE_URL: string;
  51911. /**
  51912. * File name for the left controller model.
  51913. */
  51914. static MODEL_LEFT_FILENAME: string;
  51915. /**
  51916. * File name for the right controller model.
  51917. */
  51918. static MODEL_RIGHT_FILENAME: string;
  51919. /**
  51920. * Base Url for the Quest controller model.
  51921. */
  51922. static QUEST_MODEL_BASE_URL: string;
  51923. /**
  51924. * @hidden
  51925. * If the controllers are running on a device that needs the updated Quest controller models
  51926. */
  51927. static _IsQuest: boolean;
  51928. /**
  51929. * Fired when the secondary trigger on this controller is modified
  51930. */
  51931. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51932. /**
  51933. * Fired when the thumb rest on this controller is modified
  51934. */
  51935. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51936. /**
  51937. * Creates a new OculusTouchController from a gamepad
  51938. * @param vrGamepad the gamepad that the controller should be created from
  51939. */
  51940. constructor(vrGamepad: any);
  51941. /**
  51942. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51943. * @param scene scene in which to add meshes
  51944. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51945. */
  51946. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51947. /**
  51948. * Fired when the A button on this controller is modified
  51949. */
  51950. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51951. /**
  51952. * Fired when the B button on this controller is modified
  51953. */
  51954. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51955. /**
  51956. * Fired when the X button on this controller is modified
  51957. */
  51958. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51959. /**
  51960. * Fired when the Y button on this controller is modified
  51961. */
  51962. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51963. /**
  51964. * Called once for each button that changed state since the last frame
  51965. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51966. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51967. * 2) secondary trigger (same)
  51968. * 3) A (right) X (left), touch, pressed = value
  51969. * 4) B / Y
  51970. * 5) thumb rest
  51971. * @param buttonIdx Which button index changed
  51972. * @param state New state of the button
  51973. * @param changes Which properties on the state changed since last frame
  51974. */
  51975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51976. }
  51977. }
  51978. declare module BABYLON {
  51979. /**
  51980. * Vive Controller
  51981. */
  51982. export class ViveController extends WebVRController {
  51983. /**
  51984. * Base Url for the controller model.
  51985. */
  51986. static MODEL_BASE_URL: string;
  51987. /**
  51988. * File name for the controller model.
  51989. */
  51990. static MODEL_FILENAME: string;
  51991. /**
  51992. * Creates a new ViveController from a gamepad
  51993. * @param vrGamepad the gamepad that the controller should be created from
  51994. */
  51995. constructor(vrGamepad: any);
  51996. /**
  51997. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51998. * @param scene scene in which to add meshes
  51999. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52000. */
  52001. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52002. /**
  52003. * Fired when the left button on this controller is modified
  52004. */
  52005. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52006. /**
  52007. * Fired when the right button on this controller is modified
  52008. */
  52009. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52010. /**
  52011. * Fired when the menu button on this controller is modified
  52012. */
  52013. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52014. /**
  52015. * Called once for each button that changed state since the last frame
  52016. * Vive mapping:
  52017. * 0: touchpad
  52018. * 1: trigger
  52019. * 2: left AND right buttons
  52020. * 3: menu button
  52021. * @param buttonIdx Which button index changed
  52022. * @param state New state of the button
  52023. * @param changes Which properties on the state changed since last frame
  52024. */
  52025. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52026. }
  52027. }
  52028. declare module BABYLON {
  52029. /**
  52030. * Defines the WindowsMotionController object that the state of the windows motion controller
  52031. */
  52032. export class WindowsMotionController extends WebVRController {
  52033. /**
  52034. * The base url used to load the left and right controller models
  52035. */
  52036. static MODEL_BASE_URL: string;
  52037. /**
  52038. * The name of the left controller model file
  52039. */
  52040. static MODEL_LEFT_FILENAME: string;
  52041. /**
  52042. * The name of the right controller model file
  52043. */
  52044. static MODEL_RIGHT_FILENAME: string;
  52045. /**
  52046. * The controller name prefix for this controller type
  52047. */
  52048. static readonly GAMEPAD_ID_PREFIX: string;
  52049. /**
  52050. * The controller id pattern for this controller type
  52051. */
  52052. private static readonly GAMEPAD_ID_PATTERN;
  52053. private _loadedMeshInfo;
  52054. protected readonly _mapping: {
  52055. buttons: string[];
  52056. buttonMeshNames: {
  52057. trigger: string;
  52058. menu: string;
  52059. grip: string;
  52060. thumbstick: string;
  52061. trackpad: string;
  52062. };
  52063. buttonObservableNames: {
  52064. trigger: string;
  52065. menu: string;
  52066. grip: string;
  52067. thumbstick: string;
  52068. trackpad: string;
  52069. };
  52070. axisMeshNames: string[];
  52071. pointingPoseMeshName: string;
  52072. };
  52073. /**
  52074. * Fired when the trackpad on this controller is clicked
  52075. */
  52076. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52077. /**
  52078. * Fired when the trackpad on this controller is modified
  52079. */
  52080. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52081. /**
  52082. * The current x and y values of this controller's trackpad
  52083. */
  52084. trackpad: StickValues;
  52085. /**
  52086. * Creates a new WindowsMotionController from a gamepad
  52087. * @param vrGamepad the gamepad that the controller should be created from
  52088. */
  52089. constructor(vrGamepad: any);
  52090. /**
  52091. * Fired when the trigger on this controller is modified
  52092. */
  52093. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52094. /**
  52095. * Fired when the menu button on this controller is modified
  52096. */
  52097. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52098. /**
  52099. * Fired when the grip button on this controller is modified
  52100. */
  52101. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52102. /**
  52103. * Fired when the thumbstick button on this controller is modified
  52104. */
  52105. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52106. /**
  52107. * Fired when the touchpad button on this controller is modified
  52108. */
  52109. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52110. /**
  52111. * Fired when the touchpad values on this controller are modified
  52112. */
  52113. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52114. protected _updateTrackpad(): void;
  52115. /**
  52116. * Called once per frame by the engine.
  52117. */
  52118. update(): void;
  52119. /**
  52120. * Called once for each button that changed state since the last frame
  52121. * @param buttonIdx Which button index changed
  52122. * @param state New state of the button
  52123. * @param changes Which properties on the state changed since last frame
  52124. */
  52125. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52126. /**
  52127. * Moves the buttons on the controller mesh based on their current state
  52128. * @param buttonName the name of the button to move
  52129. * @param buttonValue the value of the button which determines the buttons new position
  52130. */
  52131. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52132. /**
  52133. * Moves the axis on the controller mesh based on its current state
  52134. * @param axis the index of the axis
  52135. * @param axisValue the value of the axis which determines the meshes new position
  52136. * @hidden
  52137. */
  52138. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52139. /**
  52140. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52141. * @param scene scene in which to add meshes
  52142. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52143. */
  52144. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52145. /**
  52146. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52147. * can be transformed by button presses and axes values, based on this._mapping.
  52148. *
  52149. * @param scene scene in which the meshes exist
  52150. * @param meshes list of meshes that make up the controller model to process
  52151. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52152. */
  52153. private processModel;
  52154. private createMeshInfo;
  52155. /**
  52156. * Gets the ray of the controller in the direction the controller is pointing
  52157. * @param length the length the resulting ray should be
  52158. * @returns a ray in the direction the controller is pointing
  52159. */
  52160. getForwardRay(length?: number): Ray;
  52161. /**
  52162. * Disposes of the controller
  52163. */
  52164. dispose(): void;
  52165. }
  52166. /**
  52167. * This class represents a new windows motion controller in XR.
  52168. */
  52169. export class XRWindowsMotionController extends WindowsMotionController {
  52170. /**
  52171. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52172. */
  52173. protected readonly _mapping: {
  52174. buttons: string[];
  52175. buttonMeshNames: {
  52176. trigger: string;
  52177. menu: string;
  52178. grip: string;
  52179. thumbstick: string;
  52180. trackpad: string;
  52181. };
  52182. buttonObservableNames: {
  52183. trigger: string;
  52184. menu: string;
  52185. grip: string;
  52186. thumbstick: string;
  52187. trackpad: string;
  52188. };
  52189. axisMeshNames: string[];
  52190. pointingPoseMeshName: string;
  52191. };
  52192. /**
  52193. * Construct a new XR-Based windows motion controller
  52194. *
  52195. * @param gamepadInfo the gamepad object from the browser
  52196. */
  52197. constructor(gamepadInfo: any);
  52198. /**
  52199. * holds the thumbstick values (X,Y)
  52200. */
  52201. thumbstickValues: StickValues;
  52202. /**
  52203. * Fired when the thumbstick on this controller is clicked
  52204. */
  52205. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52206. /**
  52207. * Fired when the thumbstick on this controller is modified
  52208. */
  52209. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52210. /**
  52211. * Fired when the touchpad button on this controller is modified
  52212. */
  52213. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52214. /**
  52215. * Fired when the touchpad values on this controller are modified
  52216. */
  52217. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52218. /**
  52219. * Fired when the thumbstick button on this controller is modified
  52220. * here to prevent breaking changes
  52221. */
  52222. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52223. /**
  52224. * updating the thumbstick(!) and not the trackpad.
  52225. * This is named this way due to the difference between WebVR and XR and to avoid
  52226. * changing the parent class.
  52227. */
  52228. protected _updateTrackpad(): void;
  52229. /**
  52230. * Disposes the class with joy
  52231. */
  52232. dispose(): void;
  52233. }
  52234. }
  52235. declare module BABYLON {
  52236. /**
  52237. * Class containing static functions to help procedurally build meshes
  52238. */
  52239. export class PolyhedronBuilder {
  52240. /**
  52241. * Creates a polyhedron mesh
  52242. * * 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
  52243. * * The parameter `size` (positive float, default 1) sets the polygon size
  52244. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52245. * * 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`
  52246. * * 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
  52247. * * 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)`)
  52248. * * 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
  52249. * * 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
  52250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52251. * * 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
  52252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52253. * @param name defines the name of the mesh
  52254. * @param options defines the options used to create the mesh
  52255. * @param scene defines the hosting scene
  52256. * @returns the polyhedron mesh
  52257. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52258. */
  52259. static CreatePolyhedron(name: string, options: {
  52260. type?: number;
  52261. size?: number;
  52262. sizeX?: number;
  52263. sizeY?: number;
  52264. sizeZ?: number;
  52265. custom?: any;
  52266. faceUV?: Vector4[];
  52267. faceColors?: Color4[];
  52268. flat?: boolean;
  52269. updatable?: boolean;
  52270. sideOrientation?: number;
  52271. frontUVs?: Vector4;
  52272. backUVs?: Vector4;
  52273. }, scene?: Nullable<Scene>): Mesh;
  52274. }
  52275. }
  52276. declare module BABYLON {
  52277. /**
  52278. * Gizmo that enables scaling a mesh along 3 axis
  52279. */
  52280. export class ScaleGizmo extends Gizmo {
  52281. /**
  52282. * Internal gizmo used for interactions on the x axis
  52283. */
  52284. xGizmo: AxisScaleGizmo;
  52285. /**
  52286. * Internal gizmo used for interactions on the y axis
  52287. */
  52288. yGizmo: AxisScaleGizmo;
  52289. /**
  52290. * Internal gizmo used for interactions on the z axis
  52291. */
  52292. zGizmo: AxisScaleGizmo;
  52293. /**
  52294. * Internal gizmo used to scale all axis equally
  52295. */
  52296. uniformScaleGizmo: AxisScaleGizmo;
  52297. private _meshAttached;
  52298. private _updateGizmoRotationToMatchAttachedMesh;
  52299. private _snapDistance;
  52300. private _scaleRatio;
  52301. private _uniformScalingMesh;
  52302. private _octahedron;
  52303. private _sensitivity;
  52304. /** Fires an event when any of it's sub gizmos are dragged */
  52305. onDragStartObservable: Observable<unknown>;
  52306. /** Fires an event when any of it's sub gizmos are released from dragging */
  52307. onDragEndObservable: Observable<unknown>;
  52308. get attachedMesh(): Nullable<AbstractMesh>;
  52309. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52310. /**
  52311. * Creates a ScaleGizmo
  52312. * @param gizmoLayer The utility layer the gizmo will be added to
  52313. */
  52314. constructor(gizmoLayer?: UtilityLayerRenderer);
  52315. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52316. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52317. /**
  52318. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52319. */
  52320. set snapDistance(value: number);
  52321. get snapDistance(): number;
  52322. /**
  52323. * Ratio for the scale of the gizmo (Default: 1)
  52324. */
  52325. set scaleRatio(value: number);
  52326. get scaleRatio(): number;
  52327. /**
  52328. * Sensitivity factor for dragging (Default: 1)
  52329. */
  52330. set sensitivity(value: number);
  52331. get sensitivity(): number;
  52332. /**
  52333. * Disposes of the gizmo
  52334. */
  52335. dispose(): void;
  52336. }
  52337. }
  52338. declare module BABYLON {
  52339. /**
  52340. * Single axis scale gizmo
  52341. */
  52342. export class AxisScaleGizmo extends Gizmo {
  52343. /**
  52344. * Drag behavior responsible for the gizmos dragging interactions
  52345. */
  52346. dragBehavior: PointerDragBehavior;
  52347. private _pointerObserver;
  52348. /**
  52349. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52350. */
  52351. snapDistance: number;
  52352. /**
  52353. * Event that fires each time the gizmo snaps to a new location.
  52354. * * snapDistance is the the change in distance
  52355. */
  52356. onSnapObservable: Observable<{
  52357. snapDistance: number;
  52358. }>;
  52359. /**
  52360. * If the scaling operation should be done on all axis (default: false)
  52361. */
  52362. uniformScaling: boolean;
  52363. /**
  52364. * Custom sensitivity value for the drag strength
  52365. */
  52366. sensitivity: number;
  52367. private _isEnabled;
  52368. private _parent;
  52369. private _arrow;
  52370. private _coloredMaterial;
  52371. private _hoverMaterial;
  52372. /**
  52373. * Creates an AxisScaleGizmo
  52374. * @param gizmoLayer The utility layer the gizmo will be added to
  52375. * @param dragAxis The axis which the gizmo will be able to scale on
  52376. * @param color The color of the gizmo
  52377. */
  52378. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52379. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52380. /**
  52381. * If the gizmo is enabled
  52382. */
  52383. set isEnabled(value: boolean);
  52384. get isEnabled(): boolean;
  52385. /**
  52386. * Disposes of the gizmo
  52387. */
  52388. dispose(): void;
  52389. /**
  52390. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52391. * @param mesh The mesh to replace the default mesh of the gizmo
  52392. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52393. */
  52394. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52395. }
  52396. }
  52397. declare module BABYLON {
  52398. /**
  52399. * Bounding box gizmo
  52400. */
  52401. export class BoundingBoxGizmo extends Gizmo {
  52402. private _lineBoundingBox;
  52403. private _rotateSpheresParent;
  52404. private _scaleBoxesParent;
  52405. private _boundingDimensions;
  52406. private _renderObserver;
  52407. private _pointerObserver;
  52408. private _scaleDragSpeed;
  52409. private _tmpQuaternion;
  52410. private _tmpVector;
  52411. private _tmpRotationMatrix;
  52412. /**
  52413. * 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)
  52414. */
  52415. ignoreChildren: boolean;
  52416. /**
  52417. * 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)
  52418. */
  52419. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52420. /**
  52421. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52422. */
  52423. rotationSphereSize: number;
  52424. /**
  52425. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52426. */
  52427. scaleBoxSize: number;
  52428. /**
  52429. * 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)
  52430. */
  52431. fixedDragMeshScreenSize: boolean;
  52432. /**
  52433. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52434. */
  52435. fixedDragMeshScreenSizeDistanceFactor: number;
  52436. /**
  52437. * Fired when a rotation sphere or scale box is dragged
  52438. */
  52439. onDragStartObservable: Observable<{}>;
  52440. /**
  52441. * Fired when a scale box is dragged
  52442. */
  52443. onScaleBoxDragObservable: Observable<{}>;
  52444. /**
  52445. * Fired when a scale box drag is ended
  52446. */
  52447. onScaleBoxDragEndObservable: Observable<{}>;
  52448. /**
  52449. * Fired when a rotation sphere is dragged
  52450. */
  52451. onRotationSphereDragObservable: Observable<{}>;
  52452. /**
  52453. * Fired when a rotation sphere drag is ended
  52454. */
  52455. onRotationSphereDragEndObservable: Observable<{}>;
  52456. /**
  52457. * Relative bounding box pivot used when scaling the attached mesh. 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)
  52458. */
  52459. scalePivot: Nullable<Vector3>;
  52460. /**
  52461. * Mesh used as a pivot to rotate the attached mesh
  52462. */
  52463. private _anchorMesh;
  52464. private _existingMeshScale;
  52465. private _dragMesh;
  52466. private pointerDragBehavior;
  52467. private coloredMaterial;
  52468. private hoverColoredMaterial;
  52469. /**
  52470. * Sets the color of the bounding box gizmo
  52471. * @param color the color to set
  52472. */
  52473. setColor(color: Color3): void;
  52474. /**
  52475. * Creates an BoundingBoxGizmo
  52476. * @param gizmoLayer The utility layer the gizmo will be added to
  52477. * @param color The color of the gizmo
  52478. */
  52479. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52480. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52481. private _selectNode;
  52482. /**
  52483. * Updates the bounding box information for the Gizmo
  52484. */
  52485. updateBoundingBox(): void;
  52486. private _updateRotationSpheres;
  52487. private _updateScaleBoxes;
  52488. /**
  52489. * Enables rotation on the specified axis and disables rotation on the others
  52490. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52491. */
  52492. setEnabledRotationAxis(axis: string): void;
  52493. /**
  52494. * Enables/disables scaling
  52495. * @param enable if scaling should be enabled
  52496. * @param homogeneousScaling defines if scaling should only be homogeneous
  52497. */
  52498. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52499. private _updateDummy;
  52500. /**
  52501. * Enables a pointer drag behavior on the bounding box of the gizmo
  52502. */
  52503. enableDragBehavior(): void;
  52504. /**
  52505. * Disposes of the gizmo
  52506. */
  52507. dispose(): void;
  52508. /**
  52509. * 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)
  52510. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52511. * @returns the bounding box mesh with the passed in mesh as a child
  52512. */
  52513. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52514. /**
  52515. * CustomMeshes are not supported by this gizmo
  52516. * @param mesh The mesh to replace the default mesh of the gizmo
  52517. */
  52518. setCustomMesh(mesh: Mesh): void;
  52519. }
  52520. }
  52521. declare module BABYLON {
  52522. /**
  52523. * Single plane rotation gizmo
  52524. */
  52525. export class PlaneRotationGizmo extends Gizmo {
  52526. /**
  52527. * Drag behavior responsible for the gizmos dragging interactions
  52528. */
  52529. dragBehavior: PointerDragBehavior;
  52530. private _pointerObserver;
  52531. /**
  52532. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52533. */
  52534. snapDistance: number;
  52535. /**
  52536. * Event that fires each time the gizmo snaps to a new location.
  52537. * * snapDistance is the the change in distance
  52538. */
  52539. onSnapObservable: Observable<{
  52540. snapDistance: number;
  52541. }>;
  52542. private _isEnabled;
  52543. private _parent;
  52544. /**
  52545. * Creates a PlaneRotationGizmo
  52546. * @param gizmoLayer The utility layer the gizmo will be added to
  52547. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52548. * @param color The color of the gizmo
  52549. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52550. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52551. */
  52552. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52553. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52554. /**
  52555. * If the gizmo is enabled
  52556. */
  52557. set isEnabled(value: boolean);
  52558. get isEnabled(): boolean;
  52559. /**
  52560. * Disposes of the gizmo
  52561. */
  52562. dispose(): void;
  52563. }
  52564. }
  52565. declare module BABYLON {
  52566. /**
  52567. * Gizmo that enables rotating a mesh along 3 axis
  52568. */
  52569. export class RotationGizmo extends Gizmo {
  52570. /**
  52571. * Internal gizmo used for interactions on the x axis
  52572. */
  52573. xGizmo: PlaneRotationGizmo;
  52574. /**
  52575. * Internal gizmo used for interactions on the y axis
  52576. */
  52577. yGizmo: PlaneRotationGizmo;
  52578. /**
  52579. * Internal gizmo used for interactions on the z axis
  52580. */
  52581. zGizmo: PlaneRotationGizmo;
  52582. /** Fires an event when any of it's sub gizmos are dragged */
  52583. onDragStartObservable: Observable<unknown>;
  52584. /** Fires an event when any of it's sub gizmos are released from dragging */
  52585. onDragEndObservable: Observable<unknown>;
  52586. private _meshAttached;
  52587. get attachedMesh(): Nullable<AbstractMesh>;
  52588. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52589. /**
  52590. * Creates a RotationGizmo
  52591. * @param gizmoLayer The utility layer the gizmo will be added to
  52592. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52593. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52594. */
  52595. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52596. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52597. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52598. /**
  52599. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52600. */
  52601. set snapDistance(value: number);
  52602. get snapDistance(): number;
  52603. /**
  52604. * Ratio for the scale of the gizmo (Default: 1)
  52605. */
  52606. set scaleRatio(value: number);
  52607. get scaleRatio(): number;
  52608. /**
  52609. * Disposes of the gizmo
  52610. */
  52611. dispose(): void;
  52612. /**
  52613. * CustomMeshes are not supported by this gizmo
  52614. * @param mesh The mesh to replace the default mesh of the gizmo
  52615. */
  52616. setCustomMesh(mesh: Mesh): void;
  52617. }
  52618. }
  52619. declare module BABYLON {
  52620. /**
  52621. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52622. */
  52623. export class GizmoManager implements IDisposable {
  52624. private scene;
  52625. /**
  52626. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52627. */
  52628. gizmos: {
  52629. positionGizmo: Nullable<PositionGizmo>;
  52630. rotationGizmo: Nullable<RotationGizmo>;
  52631. scaleGizmo: Nullable<ScaleGizmo>;
  52632. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52633. };
  52634. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52635. clearGizmoOnEmptyPointerEvent: boolean;
  52636. /** Fires an event when the manager is attached to a mesh */
  52637. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52638. private _gizmosEnabled;
  52639. private _pointerObserver;
  52640. private _attachedMesh;
  52641. private _boundingBoxColor;
  52642. private _defaultUtilityLayer;
  52643. private _defaultKeepDepthUtilityLayer;
  52644. /**
  52645. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52646. */
  52647. boundingBoxDragBehavior: SixDofDragBehavior;
  52648. /**
  52649. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52650. */
  52651. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52652. /**
  52653. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52654. */
  52655. usePointerToAttachGizmos: boolean;
  52656. /**
  52657. * Utility layer that the bounding box gizmo belongs to
  52658. */
  52659. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52660. /**
  52661. * Utility layer that all gizmos besides bounding box belong to
  52662. */
  52663. get utilityLayer(): UtilityLayerRenderer;
  52664. /**
  52665. * Instatiates a gizmo manager
  52666. * @param scene the scene to overlay the gizmos on top of
  52667. */
  52668. constructor(scene: Scene);
  52669. /**
  52670. * Attaches a set of gizmos to the specified mesh
  52671. * @param mesh The mesh the gizmo's should be attached to
  52672. */
  52673. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52674. /**
  52675. * If the position gizmo is enabled
  52676. */
  52677. set positionGizmoEnabled(value: boolean);
  52678. get positionGizmoEnabled(): boolean;
  52679. /**
  52680. * If the rotation gizmo is enabled
  52681. */
  52682. set rotationGizmoEnabled(value: boolean);
  52683. get rotationGizmoEnabled(): boolean;
  52684. /**
  52685. * If the scale gizmo is enabled
  52686. */
  52687. set scaleGizmoEnabled(value: boolean);
  52688. get scaleGizmoEnabled(): boolean;
  52689. /**
  52690. * If the boundingBox gizmo is enabled
  52691. */
  52692. set boundingBoxGizmoEnabled(value: boolean);
  52693. get boundingBoxGizmoEnabled(): boolean;
  52694. /**
  52695. * Disposes of the gizmo manager
  52696. */
  52697. dispose(): void;
  52698. }
  52699. }
  52700. declare module BABYLON {
  52701. /**
  52702. * A directional light is defined by a direction (what a surprise!).
  52703. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52704. * 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.
  52705. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52706. */
  52707. export class DirectionalLight extends ShadowLight {
  52708. private _shadowFrustumSize;
  52709. /**
  52710. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52711. */
  52712. get shadowFrustumSize(): number;
  52713. /**
  52714. * Specifies a fix frustum size for the shadow generation.
  52715. */
  52716. set shadowFrustumSize(value: number);
  52717. private _shadowOrthoScale;
  52718. /**
  52719. * Gets the shadow projection scale against the optimal computed one.
  52720. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52721. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52722. */
  52723. get shadowOrthoScale(): number;
  52724. /**
  52725. * Sets the shadow projection scale against the optimal computed one.
  52726. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52727. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52728. */
  52729. set shadowOrthoScale(value: number);
  52730. /**
  52731. * Automatically compute the projection matrix to best fit (including all the casters)
  52732. * on each frame.
  52733. */
  52734. autoUpdateExtends: boolean;
  52735. /**
  52736. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52737. * on each frame. autoUpdateExtends must be set to true for this to work
  52738. */
  52739. autoCalcShadowZBounds: boolean;
  52740. private _orthoLeft;
  52741. private _orthoRight;
  52742. private _orthoTop;
  52743. private _orthoBottom;
  52744. /**
  52745. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52746. * The directional light is emitted from everywhere in the given direction.
  52747. * It can cast shadows.
  52748. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52749. * @param name The friendly name of the light
  52750. * @param direction The direction of the light
  52751. * @param scene The scene the light belongs to
  52752. */
  52753. constructor(name: string, direction: Vector3, scene: Scene);
  52754. /**
  52755. * Returns the string "DirectionalLight".
  52756. * @return The class name
  52757. */
  52758. getClassName(): string;
  52759. /**
  52760. * Returns the integer 1.
  52761. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52762. */
  52763. getTypeID(): number;
  52764. /**
  52765. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52766. * Returns the DirectionalLight Shadow projection matrix.
  52767. */
  52768. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52769. /**
  52770. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52771. * Returns the DirectionalLight Shadow projection matrix.
  52772. */
  52773. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52774. /**
  52775. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52776. * Returns the DirectionalLight Shadow projection matrix.
  52777. */
  52778. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52779. protected _buildUniformLayout(): void;
  52780. /**
  52781. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52782. * @param effect The effect to update
  52783. * @param lightIndex The index of the light in the effect to update
  52784. * @returns The directional light
  52785. */
  52786. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52787. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52788. /**
  52789. * Gets the minZ used for shadow according to both the scene and the light.
  52790. *
  52791. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52792. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52793. * @param activeCamera The camera we are returning the min for
  52794. * @returns the depth min z
  52795. */
  52796. getDepthMinZ(activeCamera: Camera): number;
  52797. /**
  52798. * Gets the maxZ used for shadow according to both the scene and the light.
  52799. *
  52800. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52801. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52802. * @param activeCamera The camera we are returning the max for
  52803. * @returns the depth max z
  52804. */
  52805. getDepthMaxZ(activeCamera: Camera): number;
  52806. /**
  52807. * Prepares the list of defines specific to the light type.
  52808. * @param defines the list of defines
  52809. * @param lightIndex defines the index of the light for the effect
  52810. */
  52811. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52812. }
  52813. }
  52814. declare module BABYLON {
  52815. /**
  52816. * Class containing static functions to help procedurally build meshes
  52817. */
  52818. export class HemisphereBuilder {
  52819. /**
  52820. * Creates a hemisphere mesh
  52821. * @param name defines the name of the mesh
  52822. * @param options defines the options used to create the mesh
  52823. * @param scene defines the hosting scene
  52824. * @returns the hemisphere mesh
  52825. */
  52826. static CreateHemisphere(name: string, options: {
  52827. segments?: number;
  52828. diameter?: number;
  52829. sideOrientation?: number;
  52830. }, scene: any): Mesh;
  52831. }
  52832. }
  52833. declare module BABYLON {
  52834. /**
  52835. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52836. * These values define a cone of light starting from the position, emitting toward the direction.
  52837. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52838. * and the exponent defines the speed of the decay of the light with distance (reach).
  52839. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52840. */
  52841. export class SpotLight extends ShadowLight {
  52842. private _angle;
  52843. private _innerAngle;
  52844. private _cosHalfAngle;
  52845. private _lightAngleScale;
  52846. private _lightAngleOffset;
  52847. /**
  52848. * Gets the cone angle of the spot light in Radians.
  52849. */
  52850. get angle(): number;
  52851. /**
  52852. * Sets the cone angle of the spot light in Radians.
  52853. */
  52854. set angle(value: number);
  52855. /**
  52856. * Only used in gltf falloff mode, this defines the angle where
  52857. * the directional falloff will start before cutting at angle which could be seen
  52858. * as outer angle.
  52859. */
  52860. get innerAngle(): number;
  52861. /**
  52862. * Only used in gltf falloff mode, this defines the angle where
  52863. * the directional falloff will start before cutting at angle which could be seen
  52864. * as outer angle.
  52865. */
  52866. set innerAngle(value: number);
  52867. private _shadowAngleScale;
  52868. /**
  52869. * Allows scaling the angle of the light for shadow generation only.
  52870. */
  52871. get shadowAngleScale(): number;
  52872. /**
  52873. * Allows scaling the angle of the light for shadow generation only.
  52874. */
  52875. set shadowAngleScale(value: number);
  52876. /**
  52877. * The light decay speed with the distance from the emission spot.
  52878. */
  52879. exponent: number;
  52880. private _projectionTextureMatrix;
  52881. /**
  52882. * Allows reading the projecton texture
  52883. */
  52884. get projectionTextureMatrix(): Matrix;
  52885. protected _projectionTextureLightNear: number;
  52886. /**
  52887. * Gets the near clip of the Spotlight for texture projection.
  52888. */
  52889. get projectionTextureLightNear(): number;
  52890. /**
  52891. * Sets the near clip of the Spotlight for texture projection.
  52892. */
  52893. set projectionTextureLightNear(value: number);
  52894. protected _projectionTextureLightFar: number;
  52895. /**
  52896. * Gets the far clip of the Spotlight for texture projection.
  52897. */
  52898. get projectionTextureLightFar(): number;
  52899. /**
  52900. * Sets the far clip of the Spotlight for texture projection.
  52901. */
  52902. set projectionTextureLightFar(value: number);
  52903. protected _projectionTextureUpDirection: Vector3;
  52904. /**
  52905. * Gets the Up vector of the Spotlight for texture projection.
  52906. */
  52907. get projectionTextureUpDirection(): Vector3;
  52908. /**
  52909. * Sets the Up vector of the Spotlight for texture projection.
  52910. */
  52911. set projectionTextureUpDirection(value: Vector3);
  52912. private _projectionTexture;
  52913. /**
  52914. * Gets the projection texture of the light.
  52915. */
  52916. get projectionTexture(): Nullable<BaseTexture>;
  52917. /**
  52918. * Sets the projection texture of the light.
  52919. */
  52920. set projectionTexture(value: Nullable<BaseTexture>);
  52921. private _projectionTextureViewLightDirty;
  52922. private _projectionTextureProjectionLightDirty;
  52923. private _projectionTextureDirty;
  52924. private _projectionTextureViewTargetVector;
  52925. private _projectionTextureViewLightMatrix;
  52926. private _projectionTextureProjectionLightMatrix;
  52927. private _projectionTextureScalingMatrix;
  52928. /**
  52929. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52930. * It can cast shadows.
  52931. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52932. * @param name The light friendly name
  52933. * @param position The position of the spot light in the scene
  52934. * @param direction The direction of the light in the scene
  52935. * @param angle The cone angle of the light in Radians
  52936. * @param exponent The light decay speed with the distance from the emission spot
  52937. * @param scene The scene the lights belongs to
  52938. */
  52939. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52940. /**
  52941. * Returns the string "SpotLight".
  52942. * @returns the class name
  52943. */
  52944. getClassName(): string;
  52945. /**
  52946. * Returns the integer 2.
  52947. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52948. */
  52949. getTypeID(): number;
  52950. /**
  52951. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52952. */
  52953. protected _setDirection(value: Vector3): void;
  52954. /**
  52955. * Overrides the position setter to recompute the projection texture view light Matrix.
  52956. */
  52957. protected _setPosition(value: Vector3): void;
  52958. /**
  52959. * 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.
  52960. * Returns the SpotLight.
  52961. */
  52962. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52963. protected _computeProjectionTextureViewLightMatrix(): void;
  52964. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52965. /**
  52966. * Main function for light texture projection matrix computing.
  52967. */
  52968. protected _computeProjectionTextureMatrix(): void;
  52969. protected _buildUniformLayout(): void;
  52970. private _computeAngleValues;
  52971. /**
  52972. * Sets the passed Effect "effect" with the Light textures.
  52973. * @param effect The effect to update
  52974. * @param lightIndex The index of the light in the effect to update
  52975. * @returns The light
  52976. */
  52977. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52978. /**
  52979. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52980. * @param effect The effect to update
  52981. * @param lightIndex The index of the light in the effect to update
  52982. * @returns The spot light
  52983. */
  52984. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52985. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52986. /**
  52987. * Disposes the light and the associated resources.
  52988. */
  52989. dispose(): void;
  52990. /**
  52991. * Prepares the list of defines specific to the light type.
  52992. * @param defines the list of defines
  52993. * @param lightIndex defines the index of the light for the effect
  52994. */
  52995. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52996. }
  52997. }
  52998. declare module BABYLON {
  52999. /**
  53000. * Gizmo that enables viewing a light
  53001. */
  53002. export class LightGizmo extends Gizmo {
  53003. private _lightMesh;
  53004. private _material;
  53005. private _cachedPosition;
  53006. private _cachedForward;
  53007. private _attachedMeshParent;
  53008. /**
  53009. * Creates a LightGizmo
  53010. * @param gizmoLayer The utility layer the gizmo will be added to
  53011. */
  53012. constructor(gizmoLayer?: UtilityLayerRenderer);
  53013. private _light;
  53014. /**
  53015. * The light that the gizmo is attached to
  53016. */
  53017. set light(light: Nullable<Light>);
  53018. get light(): Nullable<Light>;
  53019. /**
  53020. * Gets the material used to render the light gizmo
  53021. */
  53022. get material(): StandardMaterial;
  53023. /**
  53024. * @hidden
  53025. * Updates the gizmo to match the attached mesh's position/rotation
  53026. */
  53027. protected _update(): void;
  53028. private static _Scale;
  53029. /**
  53030. * Creates the lines for a light mesh
  53031. */
  53032. private static _CreateLightLines;
  53033. /**
  53034. * Disposes of the light gizmo
  53035. */
  53036. dispose(): void;
  53037. private static _CreateHemisphericLightMesh;
  53038. private static _CreatePointLightMesh;
  53039. private static _CreateSpotLightMesh;
  53040. private static _CreateDirectionalLightMesh;
  53041. }
  53042. }
  53043. declare module BABYLON {
  53044. /** @hidden */
  53045. export var backgroundFragmentDeclaration: {
  53046. name: string;
  53047. shader: string;
  53048. };
  53049. }
  53050. declare module BABYLON {
  53051. /** @hidden */
  53052. export var backgroundUboDeclaration: {
  53053. name: string;
  53054. shader: string;
  53055. };
  53056. }
  53057. declare module BABYLON {
  53058. /** @hidden */
  53059. export var backgroundPixelShader: {
  53060. name: string;
  53061. shader: string;
  53062. };
  53063. }
  53064. declare module BABYLON {
  53065. /** @hidden */
  53066. export var backgroundVertexDeclaration: {
  53067. name: string;
  53068. shader: string;
  53069. };
  53070. }
  53071. declare module BABYLON {
  53072. /** @hidden */
  53073. export var backgroundVertexShader: {
  53074. name: string;
  53075. shader: string;
  53076. };
  53077. }
  53078. declare module BABYLON {
  53079. /**
  53080. * Background material used to create an efficient environement around your scene.
  53081. */
  53082. export class BackgroundMaterial extends PushMaterial {
  53083. /**
  53084. * Standard reflectance value at parallel view angle.
  53085. */
  53086. static StandardReflectance0: number;
  53087. /**
  53088. * Standard reflectance value at grazing angle.
  53089. */
  53090. static StandardReflectance90: number;
  53091. protected _primaryColor: Color3;
  53092. /**
  53093. * Key light Color (multiply against the environement texture)
  53094. */
  53095. primaryColor: Color3;
  53096. protected __perceptualColor: Nullable<Color3>;
  53097. /**
  53098. * Experimental Internal Use Only.
  53099. *
  53100. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53101. * This acts as a helper to set the primary color to a more "human friendly" value.
  53102. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53103. * output color as close as possible from the chosen value.
  53104. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53105. * part of lighting setup.)
  53106. */
  53107. get _perceptualColor(): Nullable<Color3>;
  53108. set _perceptualColor(value: Nullable<Color3>);
  53109. protected _primaryColorShadowLevel: float;
  53110. /**
  53111. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53112. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53113. */
  53114. get primaryColorShadowLevel(): float;
  53115. set primaryColorShadowLevel(value: float);
  53116. protected _primaryColorHighlightLevel: float;
  53117. /**
  53118. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53119. * The primary color is used at the level chosen to define what the white area would look.
  53120. */
  53121. get primaryColorHighlightLevel(): float;
  53122. set primaryColorHighlightLevel(value: float);
  53123. protected _reflectionTexture: Nullable<BaseTexture>;
  53124. /**
  53125. * Reflection Texture used in the material.
  53126. * Should be author in a specific way for the best result (refer to the documentation).
  53127. */
  53128. reflectionTexture: Nullable<BaseTexture>;
  53129. protected _reflectionBlur: float;
  53130. /**
  53131. * Reflection Texture level of blur.
  53132. *
  53133. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53134. * texture twice.
  53135. */
  53136. reflectionBlur: float;
  53137. protected _diffuseTexture: Nullable<BaseTexture>;
  53138. /**
  53139. * Diffuse Texture used in the material.
  53140. * Should be author in a specific way for the best result (refer to the documentation).
  53141. */
  53142. diffuseTexture: Nullable<BaseTexture>;
  53143. protected _shadowLights: Nullable<IShadowLight[]>;
  53144. /**
  53145. * Specify the list of lights casting shadow on the material.
  53146. * All scene shadow lights will be included if null.
  53147. */
  53148. shadowLights: Nullable<IShadowLight[]>;
  53149. protected _shadowLevel: float;
  53150. /**
  53151. * Helps adjusting the shadow to a softer level if required.
  53152. * 0 means black shadows and 1 means no shadows.
  53153. */
  53154. shadowLevel: float;
  53155. protected _sceneCenter: Vector3;
  53156. /**
  53157. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53158. * It is usually zero but might be interesting to modify according to your setup.
  53159. */
  53160. sceneCenter: Vector3;
  53161. protected _opacityFresnel: boolean;
  53162. /**
  53163. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53164. * This helps ensuring a nice transition when the camera goes under the ground.
  53165. */
  53166. opacityFresnel: boolean;
  53167. protected _reflectionFresnel: boolean;
  53168. /**
  53169. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53170. * This helps adding a mirror texture on the ground.
  53171. */
  53172. reflectionFresnel: boolean;
  53173. protected _reflectionFalloffDistance: number;
  53174. /**
  53175. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53176. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53177. */
  53178. reflectionFalloffDistance: number;
  53179. protected _reflectionAmount: number;
  53180. /**
  53181. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53182. */
  53183. reflectionAmount: number;
  53184. protected _reflectionReflectance0: number;
  53185. /**
  53186. * This specifies the weight of the reflection at grazing angle.
  53187. */
  53188. reflectionReflectance0: number;
  53189. protected _reflectionReflectance90: number;
  53190. /**
  53191. * This specifies the weight of the reflection at a perpendicular point of view.
  53192. */
  53193. reflectionReflectance90: number;
  53194. /**
  53195. * Sets the reflection reflectance fresnel values according to the default standard
  53196. * empirically know to work well :-)
  53197. */
  53198. set reflectionStandardFresnelWeight(value: number);
  53199. protected _useRGBColor: boolean;
  53200. /**
  53201. * Helps to directly use the maps channels instead of their level.
  53202. */
  53203. useRGBColor: boolean;
  53204. protected _enableNoise: boolean;
  53205. /**
  53206. * This helps reducing the banding effect that could occur on the background.
  53207. */
  53208. enableNoise: boolean;
  53209. /**
  53210. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53211. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53212. * Recommended to be keep at 1.0 except for special cases.
  53213. */
  53214. get fovMultiplier(): number;
  53215. set fovMultiplier(value: number);
  53216. private _fovMultiplier;
  53217. /**
  53218. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53219. */
  53220. useEquirectangularFOV: boolean;
  53221. private _maxSimultaneousLights;
  53222. /**
  53223. * Number of Simultaneous lights allowed on the material.
  53224. */
  53225. maxSimultaneousLights: int;
  53226. /**
  53227. * Default configuration related to image processing available in the Background Material.
  53228. */
  53229. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53230. /**
  53231. * Keep track of the image processing observer to allow dispose and replace.
  53232. */
  53233. private _imageProcessingObserver;
  53234. /**
  53235. * Attaches a new image processing configuration to the PBR Material.
  53236. * @param configuration (if null the scene configuration will be use)
  53237. */
  53238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53239. /**
  53240. * Gets the image processing configuration used either in this material.
  53241. */
  53242. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53243. /**
  53244. * Sets the Default image processing configuration used either in the this material.
  53245. *
  53246. * If sets to null, the scene one is in use.
  53247. */
  53248. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53249. /**
  53250. * Gets wether the color curves effect is enabled.
  53251. */
  53252. get cameraColorCurvesEnabled(): boolean;
  53253. /**
  53254. * Sets wether the color curves effect is enabled.
  53255. */
  53256. set cameraColorCurvesEnabled(value: boolean);
  53257. /**
  53258. * Gets wether the color grading effect is enabled.
  53259. */
  53260. get cameraColorGradingEnabled(): boolean;
  53261. /**
  53262. * Gets wether the color grading effect is enabled.
  53263. */
  53264. set cameraColorGradingEnabled(value: boolean);
  53265. /**
  53266. * Gets wether tonemapping is enabled or not.
  53267. */
  53268. get cameraToneMappingEnabled(): boolean;
  53269. /**
  53270. * Sets wether tonemapping is enabled or not
  53271. */
  53272. set cameraToneMappingEnabled(value: boolean);
  53273. /**
  53274. * The camera exposure used on this material.
  53275. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53276. * This corresponds to a photographic exposure.
  53277. */
  53278. get cameraExposure(): float;
  53279. /**
  53280. * The camera exposure used on this material.
  53281. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53282. * This corresponds to a photographic exposure.
  53283. */
  53284. set cameraExposure(value: float);
  53285. /**
  53286. * Gets The camera contrast used on this material.
  53287. */
  53288. get cameraContrast(): float;
  53289. /**
  53290. * Sets The camera contrast used on this material.
  53291. */
  53292. set cameraContrast(value: float);
  53293. /**
  53294. * Gets the Color Grading 2D Lookup Texture.
  53295. */
  53296. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53297. /**
  53298. * Sets the Color Grading 2D Lookup Texture.
  53299. */
  53300. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53301. /**
  53302. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53303. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53304. * 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;
  53305. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53306. */
  53307. get cameraColorCurves(): Nullable<ColorCurves>;
  53308. /**
  53309. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53310. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53311. * 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;
  53312. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53313. */
  53314. set cameraColorCurves(value: Nullable<ColorCurves>);
  53315. /**
  53316. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53317. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53318. */
  53319. switchToBGR: boolean;
  53320. private _renderTargets;
  53321. private _reflectionControls;
  53322. private _white;
  53323. private _primaryShadowColor;
  53324. private _primaryHighlightColor;
  53325. /**
  53326. * Instantiates a Background Material in the given scene
  53327. * @param name The friendly name of the material
  53328. * @param scene The scene to add the material to
  53329. */
  53330. constructor(name: string, scene: Scene);
  53331. /**
  53332. * Gets a boolean indicating that current material needs to register RTT
  53333. */
  53334. get hasRenderTargetTextures(): boolean;
  53335. /**
  53336. * The entire material has been created in order to prevent overdraw.
  53337. * @returns false
  53338. */
  53339. needAlphaTesting(): boolean;
  53340. /**
  53341. * The entire material has been created in order to prevent overdraw.
  53342. * @returns true if blending is enable
  53343. */
  53344. needAlphaBlending(): boolean;
  53345. /**
  53346. * Checks wether the material is ready to be rendered for a given mesh.
  53347. * @param mesh The mesh to render
  53348. * @param subMesh The submesh to check against
  53349. * @param useInstances Specify wether or not the material is used with instances
  53350. * @returns true if all the dependencies are ready (Textures, Effects...)
  53351. */
  53352. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53353. /**
  53354. * Compute the primary color according to the chosen perceptual color.
  53355. */
  53356. private _computePrimaryColorFromPerceptualColor;
  53357. /**
  53358. * Compute the highlights and shadow colors according to their chosen levels.
  53359. */
  53360. private _computePrimaryColors;
  53361. /**
  53362. * Build the uniform buffer used in the material.
  53363. */
  53364. buildUniformLayout(): void;
  53365. /**
  53366. * Unbind the material.
  53367. */
  53368. unbind(): void;
  53369. /**
  53370. * Bind only the world matrix to the material.
  53371. * @param world The world matrix to bind.
  53372. */
  53373. bindOnlyWorldMatrix(world: Matrix): void;
  53374. /**
  53375. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53376. * @param world The world matrix to bind.
  53377. * @param subMesh The submesh to bind for.
  53378. */
  53379. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53380. /**
  53381. * Checks to see if a texture is used in the material.
  53382. * @param texture - Base texture to use.
  53383. * @returns - Boolean specifying if a texture is used in the material.
  53384. */
  53385. hasTexture(texture: BaseTexture): boolean;
  53386. /**
  53387. * Dispose the material.
  53388. * @param forceDisposeEffect Force disposal of the associated effect.
  53389. * @param forceDisposeTextures Force disposal of the associated textures.
  53390. */
  53391. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53392. /**
  53393. * Clones the material.
  53394. * @param name The cloned name.
  53395. * @returns The cloned material.
  53396. */
  53397. clone(name: string): BackgroundMaterial;
  53398. /**
  53399. * Serializes the current material to its JSON representation.
  53400. * @returns The JSON representation.
  53401. */
  53402. serialize(): any;
  53403. /**
  53404. * Gets the class name of the material
  53405. * @returns "BackgroundMaterial"
  53406. */
  53407. getClassName(): string;
  53408. /**
  53409. * Parse a JSON input to create back a background material.
  53410. * @param source The JSON data to parse
  53411. * @param scene The scene to create the parsed material in
  53412. * @param rootUrl The root url of the assets the material depends upon
  53413. * @returns the instantiated BackgroundMaterial.
  53414. */
  53415. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53416. }
  53417. }
  53418. declare module BABYLON {
  53419. /**
  53420. * Represents the different options available during the creation of
  53421. * a Environment helper.
  53422. *
  53423. * This can control the default ground, skybox and image processing setup of your scene.
  53424. */
  53425. export interface IEnvironmentHelperOptions {
  53426. /**
  53427. * Specifies whether or not to create a ground.
  53428. * True by default.
  53429. */
  53430. createGround: boolean;
  53431. /**
  53432. * Specifies the ground size.
  53433. * 15 by default.
  53434. */
  53435. groundSize: number;
  53436. /**
  53437. * The texture used on the ground for the main color.
  53438. * Comes from the BabylonJS CDN by default.
  53439. *
  53440. * Remarks: Can be either a texture or a url.
  53441. */
  53442. groundTexture: string | BaseTexture;
  53443. /**
  53444. * The color mixed in the ground texture by default.
  53445. * BabylonJS clearColor by default.
  53446. */
  53447. groundColor: Color3;
  53448. /**
  53449. * Specifies the ground opacity.
  53450. * 1 by default.
  53451. */
  53452. groundOpacity: number;
  53453. /**
  53454. * Enables the ground to receive shadows.
  53455. * True by default.
  53456. */
  53457. enableGroundShadow: boolean;
  53458. /**
  53459. * Helps preventing the shadow to be fully black on the ground.
  53460. * 0.5 by default.
  53461. */
  53462. groundShadowLevel: number;
  53463. /**
  53464. * Creates a mirror texture attach to the ground.
  53465. * false by default.
  53466. */
  53467. enableGroundMirror: boolean;
  53468. /**
  53469. * Specifies the ground mirror size ratio.
  53470. * 0.3 by default as the default kernel is 64.
  53471. */
  53472. groundMirrorSizeRatio: number;
  53473. /**
  53474. * Specifies the ground mirror blur kernel size.
  53475. * 64 by default.
  53476. */
  53477. groundMirrorBlurKernel: number;
  53478. /**
  53479. * Specifies the ground mirror visibility amount.
  53480. * 1 by default
  53481. */
  53482. groundMirrorAmount: number;
  53483. /**
  53484. * Specifies the ground mirror reflectance weight.
  53485. * This uses the standard weight of the background material to setup the fresnel effect
  53486. * of the mirror.
  53487. * 1 by default.
  53488. */
  53489. groundMirrorFresnelWeight: number;
  53490. /**
  53491. * Specifies the ground mirror Falloff distance.
  53492. * This can helps reducing the size of the reflection.
  53493. * 0 by Default.
  53494. */
  53495. groundMirrorFallOffDistance: number;
  53496. /**
  53497. * Specifies the ground mirror texture type.
  53498. * Unsigned Int by Default.
  53499. */
  53500. groundMirrorTextureType: number;
  53501. /**
  53502. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53503. * the shown objects.
  53504. */
  53505. groundYBias: number;
  53506. /**
  53507. * Specifies whether or not to create a skybox.
  53508. * True by default.
  53509. */
  53510. createSkybox: boolean;
  53511. /**
  53512. * Specifies the skybox size.
  53513. * 20 by default.
  53514. */
  53515. skyboxSize: number;
  53516. /**
  53517. * The texture used on the skybox for the main color.
  53518. * Comes from the BabylonJS CDN by default.
  53519. *
  53520. * Remarks: Can be either a texture or a url.
  53521. */
  53522. skyboxTexture: string | BaseTexture;
  53523. /**
  53524. * The color mixed in the skybox texture by default.
  53525. * BabylonJS clearColor by default.
  53526. */
  53527. skyboxColor: Color3;
  53528. /**
  53529. * The background rotation around the Y axis of the scene.
  53530. * This helps aligning the key lights of your scene with the background.
  53531. * 0 by default.
  53532. */
  53533. backgroundYRotation: number;
  53534. /**
  53535. * Compute automatically the size of the elements to best fit with the scene.
  53536. */
  53537. sizeAuto: boolean;
  53538. /**
  53539. * Default position of the rootMesh if autoSize is not true.
  53540. */
  53541. rootPosition: Vector3;
  53542. /**
  53543. * Sets up the image processing in the scene.
  53544. * true by default.
  53545. */
  53546. setupImageProcessing: boolean;
  53547. /**
  53548. * The texture used as your environment texture in the scene.
  53549. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53550. *
  53551. * Remarks: Can be either a texture or a url.
  53552. */
  53553. environmentTexture: string | BaseTexture;
  53554. /**
  53555. * The value of the exposure to apply to the scene.
  53556. * 0.6 by default if setupImageProcessing is true.
  53557. */
  53558. cameraExposure: number;
  53559. /**
  53560. * The value of the contrast to apply to the scene.
  53561. * 1.6 by default if setupImageProcessing is true.
  53562. */
  53563. cameraContrast: number;
  53564. /**
  53565. * Specifies whether or not tonemapping should be enabled in the scene.
  53566. * true by default if setupImageProcessing is true.
  53567. */
  53568. toneMappingEnabled: boolean;
  53569. }
  53570. /**
  53571. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53572. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53573. * It also helps with the default setup of your imageProcessing configuration.
  53574. */
  53575. export class EnvironmentHelper {
  53576. /**
  53577. * Default ground texture URL.
  53578. */
  53579. private static _groundTextureCDNUrl;
  53580. /**
  53581. * Default skybox texture URL.
  53582. */
  53583. private static _skyboxTextureCDNUrl;
  53584. /**
  53585. * Default environment texture URL.
  53586. */
  53587. private static _environmentTextureCDNUrl;
  53588. /**
  53589. * Creates the default options for the helper.
  53590. */
  53591. private static _getDefaultOptions;
  53592. private _rootMesh;
  53593. /**
  53594. * Gets the root mesh created by the helper.
  53595. */
  53596. get rootMesh(): Mesh;
  53597. private _skybox;
  53598. /**
  53599. * Gets the skybox created by the helper.
  53600. */
  53601. get skybox(): Nullable<Mesh>;
  53602. private _skyboxTexture;
  53603. /**
  53604. * Gets the skybox texture created by the helper.
  53605. */
  53606. get skyboxTexture(): Nullable<BaseTexture>;
  53607. private _skyboxMaterial;
  53608. /**
  53609. * Gets the skybox material created by the helper.
  53610. */
  53611. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53612. private _ground;
  53613. /**
  53614. * Gets the ground mesh created by the helper.
  53615. */
  53616. get ground(): Nullable<Mesh>;
  53617. private _groundTexture;
  53618. /**
  53619. * Gets the ground texture created by the helper.
  53620. */
  53621. get groundTexture(): Nullable<BaseTexture>;
  53622. private _groundMirror;
  53623. /**
  53624. * Gets the ground mirror created by the helper.
  53625. */
  53626. get groundMirror(): Nullable<MirrorTexture>;
  53627. /**
  53628. * Gets the ground mirror render list to helps pushing the meshes
  53629. * you wish in the ground reflection.
  53630. */
  53631. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53632. private _groundMaterial;
  53633. /**
  53634. * Gets the ground material created by the helper.
  53635. */
  53636. get groundMaterial(): Nullable<BackgroundMaterial>;
  53637. /**
  53638. * Stores the creation options.
  53639. */
  53640. private readonly _scene;
  53641. private _options;
  53642. /**
  53643. * This observable will be notified with any error during the creation of the environment,
  53644. * mainly texture creation errors.
  53645. */
  53646. onErrorObservable: Observable<{
  53647. message?: string;
  53648. exception?: any;
  53649. }>;
  53650. /**
  53651. * constructor
  53652. * @param options Defines the options we want to customize the helper
  53653. * @param scene The scene to add the material to
  53654. */
  53655. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53656. /**
  53657. * Updates the background according to the new options
  53658. * @param options
  53659. */
  53660. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53661. /**
  53662. * Sets the primary color of all the available elements.
  53663. * @param color the main color to affect to the ground and the background
  53664. */
  53665. setMainColor(color: Color3): void;
  53666. /**
  53667. * Setup the image processing according to the specified options.
  53668. */
  53669. private _setupImageProcessing;
  53670. /**
  53671. * Setup the environment texture according to the specified options.
  53672. */
  53673. private _setupEnvironmentTexture;
  53674. /**
  53675. * Setup the background according to the specified options.
  53676. */
  53677. private _setupBackground;
  53678. /**
  53679. * Get the scene sizes according to the setup.
  53680. */
  53681. private _getSceneSize;
  53682. /**
  53683. * Setup the ground according to the specified options.
  53684. */
  53685. private _setupGround;
  53686. /**
  53687. * Setup the ground material according to the specified options.
  53688. */
  53689. private _setupGroundMaterial;
  53690. /**
  53691. * Setup the ground diffuse texture according to the specified options.
  53692. */
  53693. private _setupGroundDiffuseTexture;
  53694. /**
  53695. * Setup the ground mirror texture according to the specified options.
  53696. */
  53697. private _setupGroundMirrorTexture;
  53698. /**
  53699. * Setup the ground to receive the mirror texture.
  53700. */
  53701. private _setupMirrorInGroundMaterial;
  53702. /**
  53703. * Setup the skybox according to the specified options.
  53704. */
  53705. private _setupSkybox;
  53706. /**
  53707. * Setup the skybox material according to the specified options.
  53708. */
  53709. private _setupSkyboxMaterial;
  53710. /**
  53711. * Setup the skybox reflection texture according to the specified options.
  53712. */
  53713. private _setupSkyboxReflectionTexture;
  53714. private _errorHandler;
  53715. /**
  53716. * Dispose all the elements created by the Helper.
  53717. */
  53718. dispose(): void;
  53719. }
  53720. }
  53721. declare module BABYLON {
  53722. /**
  53723. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53724. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53725. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53726. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53727. */
  53728. export class PhotoDome extends TransformNode {
  53729. /**
  53730. * Define the image as a Monoscopic panoramic 360 image.
  53731. */
  53732. static readonly MODE_MONOSCOPIC: number;
  53733. /**
  53734. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53735. */
  53736. static readonly MODE_TOPBOTTOM: number;
  53737. /**
  53738. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53739. */
  53740. static readonly MODE_SIDEBYSIDE: number;
  53741. private _useDirectMapping;
  53742. /**
  53743. * The texture being displayed on the sphere
  53744. */
  53745. protected _photoTexture: Texture;
  53746. /**
  53747. * Gets or sets the texture being displayed on the sphere
  53748. */
  53749. get photoTexture(): Texture;
  53750. set photoTexture(value: Texture);
  53751. /**
  53752. * Observable raised when an error occured while loading the 360 image
  53753. */
  53754. onLoadErrorObservable: Observable<string>;
  53755. /**
  53756. * The skybox material
  53757. */
  53758. protected _material: BackgroundMaterial;
  53759. /**
  53760. * The surface used for the skybox
  53761. */
  53762. protected _mesh: Mesh;
  53763. /**
  53764. * Gets the mesh used for the skybox.
  53765. */
  53766. get mesh(): Mesh;
  53767. /**
  53768. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53769. * Also see the options.resolution property.
  53770. */
  53771. get fovMultiplier(): number;
  53772. set fovMultiplier(value: number);
  53773. private _imageMode;
  53774. /**
  53775. * Gets or set the current video mode for the video. It can be:
  53776. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53777. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53778. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53779. */
  53780. get imageMode(): number;
  53781. set imageMode(value: number);
  53782. /**
  53783. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53784. * @param name Element's name, child elements will append suffixes for their own names.
  53785. * @param urlsOfPhoto defines the url of the photo to display
  53786. * @param options defines an object containing optional or exposed sub element properties
  53787. * @param onError defines a callback called when an error occured while loading the texture
  53788. */
  53789. constructor(name: string, urlOfPhoto: string, options: {
  53790. resolution?: number;
  53791. size?: number;
  53792. useDirectMapping?: boolean;
  53793. faceForward?: boolean;
  53794. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53795. private _onBeforeCameraRenderObserver;
  53796. private _changeImageMode;
  53797. /**
  53798. * Releases resources associated with this node.
  53799. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53800. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53801. */
  53802. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53803. }
  53804. }
  53805. declare module BABYLON {
  53806. /**
  53807. * Class used to host RGBD texture specific utilities
  53808. */
  53809. export class RGBDTextureTools {
  53810. /**
  53811. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53812. * @param texture the texture to expand.
  53813. */
  53814. static ExpandRGBDTexture(texture: Texture): void;
  53815. }
  53816. }
  53817. declare module BABYLON {
  53818. /**
  53819. * Class used to host texture specific utilities
  53820. */
  53821. export class BRDFTextureTools {
  53822. /**
  53823. * Prevents texture cache collision
  53824. */
  53825. private static _instanceNumber;
  53826. /**
  53827. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53828. * @param scene defines the hosting scene
  53829. * @returns the environment BRDF texture
  53830. */
  53831. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53832. private static _environmentBRDFBase64Texture;
  53833. }
  53834. }
  53835. declare module BABYLON {
  53836. /**
  53837. * @hidden
  53838. */
  53839. export interface IMaterialClearCoatDefines {
  53840. CLEARCOAT: boolean;
  53841. CLEARCOAT_DEFAULTIOR: boolean;
  53842. CLEARCOAT_TEXTURE: boolean;
  53843. CLEARCOAT_TEXTUREDIRECTUV: number;
  53844. CLEARCOAT_BUMP: boolean;
  53845. CLEARCOAT_BUMPDIRECTUV: number;
  53846. CLEARCOAT_TINT: boolean;
  53847. CLEARCOAT_TINT_TEXTURE: boolean;
  53848. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53849. /** @hidden */
  53850. _areTexturesDirty: boolean;
  53851. }
  53852. /**
  53853. * Define the code related to the clear coat parameters of the pbr material.
  53854. */
  53855. export class PBRClearCoatConfiguration {
  53856. /**
  53857. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53858. * The default fits with a polyurethane material.
  53859. */
  53860. private static readonly _DefaultIndexOfRefraction;
  53861. private _isEnabled;
  53862. /**
  53863. * Defines if the clear coat is enabled in the material.
  53864. */
  53865. isEnabled: boolean;
  53866. /**
  53867. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53868. */
  53869. intensity: number;
  53870. /**
  53871. * Defines the clear coat layer roughness.
  53872. */
  53873. roughness: number;
  53874. private _indexOfRefraction;
  53875. /**
  53876. * Defines the index of refraction of the clear coat.
  53877. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53878. * The default fits with a polyurethane material.
  53879. * Changing the default value is more performance intensive.
  53880. */
  53881. indexOfRefraction: number;
  53882. private _texture;
  53883. /**
  53884. * Stores the clear coat values in a texture.
  53885. */
  53886. texture: Nullable<BaseTexture>;
  53887. private _bumpTexture;
  53888. /**
  53889. * Define the clear coat specific bump texture.
  53890. */
  53891. bumpTexture: Nullable<BaseTexture>;
  53892. private _isTintEnabled;
  53893. /**
  53894. * Defines if the clear coat tint is enabled in the material.
  53895. */
  53896. isTintEnabled: boolean;
  53897. /**
  53898. * Defines the clear coat tint of the material.
  53899. * This is only use if tint is enabled
  53900. */
  53901. tintColor: Color3;
  53902. /**
  53903. * Defines the distance at which the tint color should be found in the
  53904. * clear coat media.
  53905. * This is only use if tint is enabled
  53906. */
  53907. tintColorAtDistance: number;
  53908. /**
  53909. * Defines the clear coat layer thickness.
  53910. * This is only use if tint is enabled
  53911. */
  53912. tintThickness: number;
  53913. private _tintTexture;
  53914. /**
  53915. * Stores the clear tint values in a texture.
  53916. * rgb is tint
  53917. * a is a thickness factor
  53918. */
  53919. tintTexture: Nullable<BaseTexture>;
  53920. /** @hidden */
  53921. private _internalMarkAllSubMeshesAsTexturesDirty;
  53922. /** @hidden */
  53923. _markAllSubMeshesAsTexturesDirty(): void;
  53924. /**
  53925. * Instantiate a new istance of clear coat configuration.
  53926. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53927. */
  53928. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53929. /**
  53930. * Gets wehter the submesh is ready to be used or not.
  53931. * @param defines the list of "defines" to update.
  53932. * @param scene defines the scene the material belongs to.
  53933. * @param engine defines the engine the material belongs to.
  53934. * @param disableBumpMap defines wether the material disables bump or not.
  53935. * @returns - boolean indicating that the submesh is ready or not.
  53936. */
  53937. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53938. /**
  53939. * Checks to see if a texture is used in the material.
  53940. * @param defines the list of "defines" to update.
  53941. * @param scene defines the scene to the material belongs to.
  53942. */
  53943. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53944. /**
  53945. * Binds the material data.
  53946. * @param uniformBuffer defines the Uniform buffer to fill in.
  53947. * @param scene defines the scene the material belongs to.
  53948. * @param engine defines the engine the material belongs to.
  53949. * @param disableBumpMap defines wether the material disables bump or not.
  53950. * @param isFrozen defines wether the material is frozen or not.
  53951. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53952. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53953. */
  53954. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53955. /**
  53956. * Checks to see if a texture is used in the material.
  53957. * @param texture - Base texture to use.
  53958. * @returns - Boolean specifying if a texture is used in the material.
  53959. */
  53960. hasTexture(texture: BaseTexture): boolean;
  53961. /**
  53962. * Returns an array of the actively used textures.
  53963. * @param activeTextures Array of BaseTextures
  53964. */
  53965. getActiveTextures(activeTextures: BaseTexture[]): void;
  53966. /**
  53967. * Returns the animatable textures.
  53968. * @param animatables Array of animatable textures.
  53969. */
  53970. getAnimatables(animatables: IAnimatable[]): void;
  53971. /**
  53972. * Disposes the resources of the material.
  53973. * @param forceDisposeTextures - Forces the disposal of all textures.
  53974. */
  53975. dispose(forceDisposeTextures?: boolean): void;
  53976. /**
  53977. * Get the current class name of the texture useful for serialization or dynamic coding.
  53978. * @returns "PBRClearCoatConfiguration"
  53979. */
  53980. getClassName(): string;
  53981. /**
  53982. * Add fallbacks to the effect fallbacks list.
  53983. * @param defines defines the Base texture to use.
  53984. * @param fallbacks defines the current fallback list.
  53985. * @param currentRank defines the current fallback rank.
  53986. * @returns the new fallback rank.
  53987. */
  53988. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53989. /**
  53990. * Add the required uniforms to the current list.
  53991. * @param uniforms defines the current uniform list.
  53992. */
  53993. static AddUniforms(uniforms: string[]): void;
  53994. /**
  53995. * Add the required samplers to the current list.
  53996. * @param samplers defines the current sampler list.
  53997. */
  53998. static AddSamplers(samplers: string[]): void;
  53999. /**
  54000. * Add the required uniforms to the current buffer.
  54001. * @param uniformBuffer defines the current uniform buffer.
  54002. */
  54003. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54004. /**
  54005. * Makes a duplicate of the current configuration into another one.
  54006. * @param clearCoatConfiguration define the config where to copy the info
  54007. */
  54008. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54009. /**
  54010. * Serializes this clear coat configuration.
  54011. * @returns - An object with the serialized config.
  54012. */
  54013. serialize(): any;
  54014. /**
  54015. * Parses a anisotropy Configuration from a serialized object.
  54016. * @param source - Serialized object.
  54017. * @param scene Defines the scene we are parsing for
  54018. * @param rootUrl Defines the rootUrl to load from
  54019. */
  54020. parse(source: any, scene: Scene, rootUrl: string): void;
  54021. }
  54022. }
  54023. declare module BABYLON {
  54024. /**
  54025. * @hidden
  54026. */
  54027. export interface IMaterialAnisotropicDefines {
  54028. ANISOTROPIC: boolean;
  54029. ANISOTROPIC_TEXTURE: boolean;
  54030. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54031. MAINUV1: boolean;
  54032. _areTexturesDirty: boolean;
  54033. _needUVs: boolean;
  54034. }
  54035. /**
  54036. * Define the code related to the anisotropic parameters of the pbr material.
  54037. */
  54038. export class PBRAnisotropicConfiguration {
  54039. private _isEnabled;
  54040. /**
  54041. * Defines if the anisotropy is enabled in the material.
  54042. */
  54043. isEnabled: boolean;
  54044. /**
  54045. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54046. */
  54047. intensity: number;
  54048. /**
  54049. * Defines if the effect is along the tangents, bitangents or in between.
  54050. * By default, the effect is "strectching" the highlights along the tangents.
  54051. */
  54052. direction: Vector2;
  54053. private _texture;
  54054. /**
  54055. * Stores the anisotropy values in a texture.
  54056. * rg is direction (like normal from -1 to 1)
  54057. * b is a intensity
  54058. */
  54059. texture: Nullable<BaseTexture>;
  54060. /** @hidden */
  54061. private _internalMarkAllSubMeshesAsTexturesDirty;
  54062. /** @hidden */
  54063. _markAllSubMeshesAsTexturesDirty(): void;
  54064. /**
  54065. * Instantiate a new istance of anisotropy configuration.
  54066. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54067. */
  54068. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54069. /**
  54070. * Specifies that the submesh is ready to be used.
  54071. * @param defines the list of "defines" to update.
  54072. * @param scene defines the scene the material belongs to.
  54073. * @returns - boolean indicating that the submesh is ready or not.
  54074. */
  54075. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54076. /**
  54077. * Checks to see if a texture is used in the material.
  54078. * @param defines the list of "defines" to update.
  54079. * @param mesh the mesh we are preparing the defines for.
  54080. * @param scene defines the scene the material belongs to.
  54081. */
  54082. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54083. /**
  54084. * Binds the material data.
  54085. * @param uniformBuffer defines the Uniform buffer to fill in.
  54086. * @param scene defines the scene the material belongs to.
  54087. * @param isFrozen defines wether the material is frozen or not.
  54088. */
  54089. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54090. /**
  54091. * Checks to see if a texture is used in the material.
  54092. * @param texture - Base texture to use.
  54093. * @returns - Boolean specifying if a texture is used in the material.
  54094. */
  54095. hasTexture(texture: BaseTexture): boolean;
  54096. /**
  54097. * Returns an array of the actively used textures.
  54098. * @param activeTextures Array of BaseTextures
  54099. */
  54100. getActiveTextures(activeTextures: BaseTexture[]): void;
  54101. /**
  54102. * Returns the animatable textures.
  54103. * @param animatables Array of animatable textures.
  54104. */
  54105. getAnimatables(animatables: IAnimatable[]): void;
  54106. /**
  54107. * Disposes the resources of the material.
  54108. * @param forceDisposeTextures - Forces the disposal of all textures.
  54109. */
  54110. dispose(forceDisposeTextures?: boolean): void;
  54111. /**
  54112. * Get the current class name of the texture useful for serialization or dynamic coding.
  54113. * @returns "PBRAnisotropicConfiguration"
  54114. */
  54115. getClassName(): string;
  54116. /**
  54117. * Add fallbacks to the effect fallbacks list.
  54118. * @param defines defines the Base texture to use.
  54119. * @param fallbacks defines the current fallback list.
  54120. * @param currentRank defines the current fallback rank.
  54121. * @returns the new fallback rank.
  54122. */
  54123. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54124. /**
  54125. * Add the required uniforms to the current list.
  54126. * @param uniforms defines the current uniform list.
  54127. */
  54128. static AddUniforms(uniforms: string[]): void;
  54129. /**
  54130. * Add the required uniforms to the current buffer.
  54131. * @param uniformBuffer defines the current uniform buffer.
  54132. */
  54133. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54134. /**
  54135. * Add the required samplers to the current list.
  54136. * @param samplers defines the current sampler list.
  54137. */
  54138. static AddSamplers(samplers: string[]): void;
  54139. /**
  54140. * Makes a duplicate of the current configuration into another one.
  54141. * @param anisotropicConfiguration define the config where to copy the info
  54142. */
  54143. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54144. /**
  54145. * Serializes this anisotropy configuration.
  54146. * @returns - An object with the serialized config.
  54147. */
  54148. serialize(): any;
  54149. /**
  54150. * Parses a anisotropy Configuration from a serialized object.
  54151. * @param source - Serialized object.
  54152. * @param scene Defines the scene we are parsing for
  54153. * @param rootUrl Defines the rootUrl to load from
  54154. */
  54155. parse(source: any, scene: Scene, rootUrl: string): void;
  54156. }
  54157. }
  54158. declare module BABYLON {
  54159. /**
  54160. * @hidden
  54161. */
  54162. export interface IMaterialBRDFDefines {
  54163. BRDF_V_HEIGHT_CORRELATED: boolean;
  54164. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54165. SPHERICAL_HARMONICS: boolean;
  54166. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54167. /** @hidden */
  54168. _areMiscDirty: boolean;
  54169. }
  54170. /**
  54171. * Define the code related to the BRDF parameters of the pbr material.
  54172. */
  54173. export class PBRBRDFConfiguration {
  54174. /**
  54175. * Default value used for the energy conservation.
  54176. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54177. */
  54178. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54179. /**
  54180. * Default value used for the Smith Visibility Height Correlated mode.
  54181. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54182. */
  54183. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54184. /**
  54185. * Default value used for the IBL diffuse part.
  54186. * This can help switching back to the polynomials mode globally which is a tiny bit
  54187. * less GPU intensive at the drawback of a lower quality.
  54188. */
  54189. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54190. /**
  54191. * Default value used for activating energy conservation for the specular workflow.
  54192. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54193. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54194. */
  54195. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54196. private _useEnergyConservation;
  54197. /**
  54198. * Defines if the material uses energy conservation.
  54199. */
  54200. useEnergyConservation: boolean;
  54201. private _useSmithVisibilityHeightCorrelated;
  54202. /**
  54203. * LEGACY Mode set to false
  54204. * Defines if the material uses height smith correlated visibility term.
  54205. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54206. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54207. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54208. * Not relying on height correlated will also disable energy conservation.
  54209. */
  54210. useSmithVisibilityHeightCorrelated: boolean;
  54211. private _useSphericalHarmonics;
  54212. /**
  54213. * LEGACY Mode set to false
  54214. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54215. * diffuse part of the IBL.
  54216. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54217. * to the ground truth.
  54218. */
  54219. useSphericalHarmonics: boolean;
  54220. private _useSpecularGlossinessInputEnergyConservation;
  54221. /**
  54222. * Defines if the material uses energy conservation, when the specular workflow is active.
  54223. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54224. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54225. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54226. */
  54227. useSpecularGlossinessInputEnergyConservation: boolean;
  54228. /** @hidden */
  54229. private _internalMarkAllSubMeshesAsMiscDirty;
  54230. /** @hidden */
  54231. _markAllSubMeshesAsMiscDirty(): void;
  54232. /**
  54233. * Instantiate a new istance of clear coat configuration.
  54234. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54235. */
  54236. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54237. /**
  54238. * Checks to see if a texture is used in the material.
  54239. * @param defines the list of "defines" to update.
  54240. */
  54241. prepareDefines(defines: IMaterialBRDFDefines): void;
  54242. /**
  54243. * Get the current class name of the texture useful for serialization or dynamic coding.
  54244. * @returns "PBRClearCoatConfiguration"
  54245. */
  54246. getClassName(): string;
  54247. /**
  54248. * Makes a duplicate of the current configuration into another one.
  54249. * @param brdfConfiguration define the config where to copy the info
  54250. */
  54251. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54252. /**
  54253. * Serializes this BRDF configuration.
  54254. * @returns - An object with the serialized config.
  54255. */
  54256. serialize(): any;
  54257. /**
  54258. * Parses a anisotropy Configuration from a serialized object.
  54259. * @param source - Serialized object.
  54260. * @param scene Defines the scene we are parsing for
  54261. * @param rootUrl Defines the rootUrl to load from
  54262. */
  54263. parse(source: any, scene: Scene, rootUrl: string): void;
  54264. }
  54265. }
  54266. declare module BABYLON {
  54267. /**
  54268. * @hidden
  54269. */
  54270. export interface IMaterialSheenDefines {
  54271. SHEEN: boolean;
  54272. SHEEN_TEXTURE: boolean;
  54273. SHEEN_TEXTUREDIRECTUV: number;
  54274. SHEEN_LINKWITHALBEDO: boolean;
  54275. SHEEN_ROUGHNESS: boolean;
  54276. SHEEN_ALBEDOSCALING: boolean;
  54277. /** @hidden */
  54278. _areTexturesDirty: boolean;
  54279. }
  54280. /**
  54281. * Define the code related to the Sheen parameters of the pbr material.
  54282. */
  54283. export class PBRSheenConfiguration {
  54284. private _isEnabled;
  54285. /**
  54286. * Defines if the material uses sheen.
  54287. */
  54288. isEnabled: boolean;
  54289. private _linkSheenWithAlbedo;
  54290. /**
  54291. * Defines if the sheen is linked to the sheen color.
  54292. */
  54293. linkSheenWithAlbedo: boolean;
  54294. /**
  54295. * Defines the sheen intensity.
  54296. */
  54297. intensity: number;
  54298. /**
  54299. * Defines the sheen color.
  54300. */
  54301. color: Color3;
  54302. private _texture;
  54303. /**
  54304. * Stores the sheen tint values in a texture.
  54305. * rgb is tint
  54306. * a is a intensity
  54307. */
  54308. texture: Nullable<BaseTexture>;
  54309. private _roughness;
  54310. /**
  54311. * Defines the sheen roughness.
  54312. * It is not taken into account if linkSheenWithAlbedo is true.
  54313. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54314. */
  54315. roughness: Nullable<number>;
  54316. private _albedoScaling;
  54317. /**
  54318. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54319. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54320. * making it easier to setup and tweak the effect
  54321. */
  54322. albedoScaling: boolean;
  54323. /** @hidden */
  54324. private _internalMarkAllSubMeshesAsTexturesDirty;
  54325. /** @hidden */
  54326. _markAllSubMeshesAsTexturesDirty(): void;
  54327. /**
  54328. * Instantiate a new istance of clear coat configuration.
  54329. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54330. */
  54331. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54332. /**
  54333. * Specifies that the submesh is ready to be used.
  54334. * @param defines the list of "defines" to update.
  54335. * @param scene defines the scene the material belongs to.
  54336. * @returns - boolean indicating that the submesh is ready or not.
  54337. */
  54338. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54339. /**
  54340. * Checks to see if a texture is used in the material.
  54341. * @param defines the list of "defines" to update.
  54342. * @param scene defines the scene the material belongs to.
  54343. */
  54344. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54345. /**
  54346. * Binds the material data.
  54347. * @param uniformBuffer defines the Uniform buffer to fill in.
  54348. * @param scene defines the scene the material belongs to.
  54349. * @param isFrozen defines wether the material is frozen or not.
  54350. */
  54351. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54352. /**
  54353. * Checks to see if a texture is used in the material.
  54354. * @param texture - Base texture to use.
  54355. * @returns - Boolean specifying if a texture is used in the material.
  54356. */
  54357. hasTexture(texture: BaseTexture): boolean;
  54358. /**
  54359. * Returns an array of the actively used textures.
  54360. * @param activeTextures Array of BaseTextures
  54361. */
  54362. getActiveTextures(activeTextures: BaseTexture[]): void;
  54363. /**
  54364. * Returns the animatable textures.
  54365. * @param animatables Array of animatable textures.
  54366. */
  54367. getAnimatables(animatables: IAnimatable[]): void;
  54368. /**
  54369. * Disposes the resources of the material.
  54370. * @param forceDisposeTextures - Forces the disposal of all textures.
  54371. */
  54372. dispose(forceDisposeTextures?: boolean): void;
  54373. /**
  54374. * Get the current class name of the texture useful for serialization or dynamic coding.
  54375. * @returns "PBRSheenConfiguration"
  54376. */
  54377. getClassName(): string;
  54378. /**
  54379. * Add fallbacks to the effect fallbacks list.
  54380. * @param defines defines the Base texture to use.
  54381. * @param fallbacks defines the current fallback list.
  54382. * @param currentRank defines the current fallback rank.
  54383. * @returns the new fallback rank.
  54384. */
  54385. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54386. /**
  54387. * Add the required uniforms to the current list.
  54388. * @param uniforms defines the current uniform list.
  54389. */
  54390. static AddUniforms(uniforms: string[]): void;
  54391. /**
  54392. * Add the required uniforms to the current buffer.
  54393. * @param uniformBuffer defines the current uniform buffer.
  54394. */
  54395. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54396. /**
  54397. * Add the required samplers to the current list.
  54398. * @param samplers defines the current sampler list.
  54399. */
  54400. static AddSamplers(samplers: string[]): void;
  54401. /**
  54402. * Makes a duplicate of the current configuration into another one.
  54403. * @param sheenConfiguration define the config where to copy the info
  54404. */
  54405. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54406. /**
  54407. * Serializes this BRDF configuration.
  54408. * @returns - An object with the serialized config.
  54409. */
  54410. serialize(): any;
  54411. /**
  54412. * Parses a anisotropy Configuration from a serialized object.
  54413. * @param source - Serialized object.
  54414. * @param scene Defines the scene we are parsing for
  54415. * @param rootUrl Defines the rootUrl to load from
  54416. */
  54417. parse(source: any, scene: Scene, rootUrl: string): void;
  54418. }
  54419. }
  54420. declare module BABYLON {
  54421. /**
  54422. * @hidden
  54423. */
  54424. export interface IMaterialSubSurfaceDefines {
  54425. SUBSURFACE: boolean;
  54426. SS_REFRACTION: boolean;
  54427. SS_TRANSLUCENCY: boolean;
  54428. SS_SCATTERING: boolean;
  54429. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54430. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54431. SS_REFRACTIONMAP_3D: boolean;
  54432. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54433. SS_LODINREFRACTIONALPHA: boolean;
  54434. SS_GAMMAREFRACTION: boolean;
  54435. SS_RGBDREFRACTION: boolean;
  54436. SS_LINEARSPECULARREFRACTION: boolean;
  54437. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54438. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54439. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54440. /** @hidden */
  54441. _areTexturesDirty: boolean;
  54442. }
  54443. /**
  54444. * Define the code related to the sub surface parameters of the pbr material.
  54445. */
  54446. export class PBRSubSurfaceConfiguration {
  54447. private _isRefractionEnabled;
  54448. /**
  54449. * Defines if the refraction is enabled in the material.
  54450. */
  54451. isRefractionEnabled: boolean;
  54452. private _isTranslucencyEnabled;
  54453. /**
  54454. * Defines if the translucency is enabled in the material.
  54455. */
  54456. isTranslucencyEnabled: boolean;
  54457. private _isScatteringEnabled;
  54458. /**
  54459. * Defines the refraction intensity of the material.
  54460. * The refraction when enabled replaces the Diffuse part of the material.
  54461. * The intensity helps transitionning between diffuse and refraction.
  54462. */
  54463. refractionIntensity: number;
  54464. /**
  54465. * Defines the translucency intensity of the material.
  54466. * When translucency has been enabled, this defines how much of the "translucency"
  54467. * is addded to the diffuse part of the material.
  54468. */
  54469. translucencyIntensity: number;
  54470. /**
  54471. * Defines the scattering intensity of the material.
  54472. * When scattering has been enabled, this defines how much of the "scattered light"
  54473. * is addded to the diffuse part of the material.
  54474. */
  54475. scatteringIntensity: number;
  54476. /**
  54477. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54478. */
  54479. useAlbedoToTintRefraction: boolean;
  54480. private _thicknessTexture;
  54481. /**
  54482. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54483. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54484. * 0 would mean minimumThickness
  54485. * 1 would mean maximumThickness
  54486. * The other channels might be use as a mask to vary the different effects intensity.
  54487. */
  54488. thicknessTexture: Nullable<BaseTexture>;
  54489. private _refractionTexture;
  54490. /**
  54491. * Defines the texture to use for refraction.
  54492. */
  54493. refractionTexture: Nullable<BaseTexture>;
  54494. private _indexOfRefraction;
  54495. /**
  54496. * Index of refraction of the material base layer.
  54497. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54498. *
  54499. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54500. *
  54501. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54502. */
  54503. indexOfRefraction: number;
  54504. private _volumeIndexOfRefraction;
  54505. /**
  54506. * Index of refraction of the material's volume.
  54507. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54508. *
  54509. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54510. * the volume will use the same IOR as the surface.
  54511. */
  54512. get volumeIndexOfRefraction(): number;
  54513. set volumeIndexOfRefraction(value: number);
  54514. private _invertRefractionY;
  54515. /**
  54516. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54517. */
  54518. invertRefractionY: boolean;
  54519. private _linkRefractionWithTransparency;
  54520. /**
  54521. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54522. * Materials half opaque for instance using refraction could benefit from this control.
  54523. */
  54524. linkRefractionWithTransparency: boolean;
  54525. /**
  54526. * Defines the minimum thickness stored in the thickness map.
  54527. * If no thickness map is defined, this value will be used to simulate thickness.
  54528. */
  54529. minimumThickness: number;
  54530. /**
  54531. * Defines the maximum thickness stored in the thickness map.
  54532. */
  54533. maximumThickness: number;
  54534. /**
  54535. * Defines the volume tint of the material.
  54536. * This is used for both translucency and scattering.
  54537. */
  54538. tintColor: Color3;
  54539. /**
  54540. * Defines the distance at which the tint color should be found in the media.
  54541. * This is used for refraction only.
  54542. */
  54543. tintColorAtDistance: number;
  54544. /**
  54545. * Defines how far each channel transmit through the media.
  54546. * It is defined as a color to simplify it selection.
  54547. */
  54548. diffusionDistance: Color3;
  54549. private _useMaskFromThicknessTexture;
  54550. /**
  54551. * Stores the intensity of the different subsurface effects in the thickness texture.
  54552. * * the green channel is the translucency intensity.
  54553. * * the blue channel is the scattering intensity.
  54554. * * the alpha channel is the refraction intensity.
  54555. */
  54556. useMaskFromThicknessTexture: boolean;
  54557. /** @hidden */
  54558. private _internalMarkAllSubMeshesAsTexturesDirty;
  54559. /** @hidden */
  54560. _markAllSubMeshesAsTexturesDirty(): void;
  54561. /**
  54562. * Instantiate a new istance of sub surface configuration.
  54563. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54564. */
  54565. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54566. /**
  54567. * Gets wehter the submesh is ready to be used or not.
  54568. * @param defines the list of "defines" to update.
  54569. * @param scene defines the scene the material belongs to.
  54570. * @returns - boolean indicating that the submesh is ready or not.
  54571. */
  54572. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54573. /**
  54574. * Checks to see if a texture is used in the material.
  54575. * @param defines the list of "defines" to update.
  54576. * @param scene defines the scene to the material belongs to.
  54577. */
  54578. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54579. /**
  54580. * Binds the material data.
  54581. * @param uniformBuffer defines the Uniform buffer to fill in.
  54582. * @param scene defines the scene the material belongs to.
  54583. * @param engine defines the engine the material belongs to.
  54584. * @param isFrozen defines whether the material is frozen or not.
  54585. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54586. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54587. */
  54588. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54589. /**
  54590. * Unbinds the material from the mesh.
  54591. * @param activeEffect defines the effect that should be unbound from.
  54592. * @returns true if unbound, otherwise false
  54593. */
  54594. unbind(activeEffect: Effect): boolean;
  54595. /**
  54596. * Returns the texture used for refraction or null if none is used.
  54597. * @param scene defines the scene the material belongs to.
  54598. * @returns - Refraction texture if present. If no refraction texture and refraction
  54599. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54600. */
  54601. private _getRefractionTexture;
  54602. /**
  54603. * Returns true if alpha blending should be disabled.
  54604. */
  54605. get disableAlphaBlending(): boolean;
  54606. /**
  54607. * Fills the list of render target textures.
  54608. * @param renderTargets the list of render targets to update
  54609. */
  54610. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54611. /**
  54612. * Checks to see if a texture is used in the material.
  54613. * @param texture - Base texture to use.
  54614. * @returns - Boolean specifying if a texture is used in the material.
  54615. */
  54616. hasTexture(texture: BaseTexture): boolean;
  54617. /**
  54618. * Gets a boolean indicating that current material needs to register RTT
  54619. * @returns true if this uses a render target otherwise false.
  54620. */
  54621. hasRenderTargetTextures(): boolean;
  54622. /**
  54623. * Returns an array of the actively used textures.
  54624. * @param activeTextures Array of BaseTextures
  54625. */
  54626. getActiveTextures(activeTextures: BaseTexture[]): void;
  54627. /**
  54628. * Returns the animatable textures.
  54629. * @param animatables Array of animatable textures.
  54630. */
  54631. getAnimatables(animatables: IAnimatable[]): void;
  54632. /**
  54633. * Disposes the resources of the material.
  54634. * @param forceDisposeTextures - Forces the disposal of all textures.
  54635. */
  54636. dispose(forceDisposeTextures?: boolean): void;
  54637. /**
  54638. * Get the current class name of the texture useful for serialization or dynamic coding.
  54639. * @returns "PBRSubSurfaceConfiguration"
  54640. */
  54641. getClassName(): string;
  54642. /**
  54643. * Add fallbacks to the effect fallbacks list.
  54644. * @param defines defines the Base texture to use.
  54645. * @param fallbacks defines the current fallback list.
  54646. * @param currentRank defines the current fallback rank.
  54647. * @returns the new fallback rank.
  54648. */
  54649. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54650. /**
  54651. * Add the required uniforms to the current list.
  54652. * @param uniforms defines the current uniform list.
  54653. */
  54654. static AddUniforms(uniforms: string[]): void;
  54655. /**
  54656. * Add the required samplers to the current list.
  54657. * @param samplers defines the current sampler list.
  54658. */
  54659. static AddSamplers(samplers: string[]): void;
  54660. /**
  54661. * Add the required uniforms to the current buffer.
  54662. * @param uniformBuffer defines the current uniform buffer.
  54663. */
  54664. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54665. /**
  54666. * Makes a duplicate of the current configuration into another one.
  54667. * @param configuration define the config where to copy the info
  54668. */
  54669. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54670. /**
  54671. * Serializes this Sub Surface configuration.
  54672. * @returns - An object with the serialized config.
  54673. */
  54674. serialize(): any;
  54675. /**
  54676. * Parses a anisotropy Configuration from a serialized object.
  54677. * @param source - Serialized object.
  54678. * @param scene Defines the scene we are parsing for
  54679. * @param rootUrl Defines the rootUrl to load from
  54680. */
  54681. parse(source: any, scene: Scene, rootUrl: string): void;
  54682. }
  54683. }
  54684. declare module BABYLON {
  54685. /** @hidden */
  54686. export var pbrFragmentDeclaration: {
  54687. name: string;
  54688. shader: string;
  54689. };
  54690. }
  54691. declare module BABYLON {
  54692. /** @hidden */
  54693. export var pbrUboDeclaration: {
  54694. name: string;
  54695. shader: string;
  54696. };
  54697. }
  54698. declare module BABYLON {
  54699. /** @hidden */
  54700. export var pbrFragmentExtraDeclaration: {
  54701. name: string;
  54702. shader: string;
  54703. };
  54704. }
  54705. declare module BABYLON {
  54706. /** @hidden */
  54707. export var pbrFragmentSamplersDeclaration: {
  54708. name: string;
  54709. shader: string;
  54710. };
  54711. }
  54712. declare module BABYLON {
  54713. /** @hidden */
  54714. export var importanceSampling: {
  54715. name: string;
  54716. shader: string;
  54717. };
  54718. }
  54719. declare module BABYLON {
  54720. /** @hidden */
  54721. export var pbrHelperFunctions: {
  54722. name: string;
  54723. shader: string;
  54724. };
  54725. }
  54726. declare module BABYLON {
  54727. /** @hidden */
  54728. export var harmonicsFunctions: {
  54729. name: string;
  54730. shader: string;
  54731. };
  54732. }
  54733. declare module BABYLON {
  54734. /** @hidden */
  54735. export var pbrDirectLightingSetupFunctions: {
  54736. name: string;
  54737. shader: string;
  54738. };
  54739. }
  54740. declare module BABYLON {
  54741. /** @hidden */
  54742. export var pbrDirectLightingFalloffFunctions: {
  54743. name: string;
  54744. shader: string;
  54745. };
  54746. }
  54747. declare module BABYLON {
  54748. /** @hidden */
  54749. export var pbrBRDFFunctions: {
  54750. name: string;
  54751. shader: string;
  54752. };
  54753. }
  54754. declare module BABYLON {
  54755. /** @hidden */
  54756. export var hdrFilteringFunctions: {
  54757. name: string;
  54758. shader: string;
  54759. };
  54760. }
  54761. declare module BABYLON {
  54762. /** @hidden */
  54763. export var pbrDirectLightingFunctions: {
  54764. name: string;
  54765. shader: string;
  54766. };
  54767. }
  54768. declare module BABYLON {
  54769. /** @hidden */
  54770. export var pbrIBLFunctions: {
  54771. name: string;
  54772. shader: string;
  54773. };
  54774. }
  54775. declare module BABYLON {
  54776. /** @hidden */
  54777. export var pbrBlockAlbedoOpacity: {
  54778. name: string;
  54779. shader: string;
  54780. };
  54781. }
  54782. declare module BABYLON {
  54783. /** @hidden */
  54784. export var pbrBlockReflectivity: {
  54785. name: string;
  54786. shader: string;
  54787. };
  54788. }
  54789. declare module BABYLON {
  54790. /** @hidden */
  54791. export var pbrBlockAmbientOcclusion: {
  54792. name: string;
  54793. shader: string;
  54794. };
  54795. }
  54796. declare module BABYLON {
  54797. /** @hidden */
  54798. export var pbrBlockAlphaFresnel: {
  54799. name: string;
  54800. shader: string;
  54801. };
  54802. }
  54803. declare module BABYLON {
  54804. /** @hidden */
  54805. export var pbrBlockAnisotropic: {
  54806. name: string;
  54807. shader: string;
  54808. };
  54809. }
  54810. declare module BABYLON {
  54811. /** @hidden */
  54812. export var pbrBlockReflection: {
  54813. name: string;
  54814. shader: string;
  54815. };
  54816. }
  54817. declare module BABYLON {
  54818. /** @hidden */
  54819. export var pbrBlockSheen: {
  54820. name: string;
  54821. shader: string;
  54822. };
  54823. }
  54824. declare module BABYLON {
  54825. /** @hidden */
  54826. export var pbrBlockClearcoat: {
  54827. name: string;
  54828. shader: string;
  54829. };
  54830. }
  54831. declare module BABYLON {
  54832. /** @hidden */
  54833. export var pbrBlockSubSurface: {
  54834. name: string;
  54835. shader: string;
  54836. };
  54837. }
  54838. declare module BABYLON {
  54839. /** @hidden */
  54840. export var pbrBlockNormalGeometric: {
  54841. name: string;
  54842. shader: string;
  54843. };
  54844. }
  54845. declare module BABYLON {
  54846. /** @hidden */
  54847. export var pbrBlockNormalFinal: {
  54848. name: string;
  54849. shader: string;
  54850. };
  54851. }
  54852. declare module BABYLON {
  54853. /** @hidden */
  54854. export var pbrBlockGeometryInfo: {
  54855. name: string;
  54856. shader: string;
  54857. };
  54858. }
  54859. declare module BABYLON {
  54860. /** @hidden */
  54861. export var pbrBlockReflectance0: {
  54862. name: string;
  54863. shader: string;
  54864. };
  54865. }
  54866. declare module BABYLON {
  54867. /** @hidden */
  54868. export var pbrBlockReflectance: {
  54869. name: string;
  54870. shader: string;
  54871. };
  54872. }
  54873. declare module BABYLON {
  54874. /** @hidden */
  54875. export var pbrBlockDirectLighting: {
  54876. name: string;
  54877. shader: string;
  54878. };
  54879. }
  54880. declare module BABYLON {
  54881. /** @hidden */
  54882. export var pbrBlockFinalLitComponents: {
  54883. name: string;
  54884. shader: string;
  54885. };
  54886. }
  54887. declare module BABYLON {
  54888. /** @hidden */
  54889. export var pbrBlockFinalUnlitComponents: {
  54890. name: string;
  54891. shader: string;
  54892. };
  54893. }
  54894. declare module BABYLON {
  54895. /** @hidden */
  54896. export var pbrBlockFinalColorComposition: {
  54897. name: string;
  54898. shader: string;
  54899. };
  54900. }
  54901. declare module BABYLON {
  54902. /** @hidden */
  54903. export var pbrBlockImageProcessing: {
  54904. name: string;
  54905. shader: string;
  54906. };
  54907. }
  54908. declare module BABYLON {
  54909. /** @hidden */
  54910. export var pbrDebug: {
  54911. name: string;
  54912. shader: string;
  54913. };
  54914. }
  54915. declare module BABYLON {
  54916. /** @hidden */
  54917. export var pbrPixelShader: {
  54918. name: string;
  54919. shader: string;
  54920. };
  54921. }
  54922. declare module BABYLON {
  54923. /** @hidden */
  54924. export var pbrVertexDeclaration: {
  54925. name: string;
  54926. shader: string;
  54927. };
  54928. }
  54929. declare module BABYLON {
  54930. /** @hidden */
  54931. export var pbrVertexShader: {
  54932. name: string;
  54933. shader: string;
  54934. };
  54935. }
  54936. declare module BABYLON {
  54937. /**
  54938. * Manages the defines for the PBR Material.
  54939. * @hidden
  54940. */
  54941. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  54942. PBR: boolean;
  54943. NUM_SAMPLES: string;
  54944. REALTIME_FILTERING: boolean;
  54945. MAINUV1: boolean;
  54946. MAINUV2: boolean;
  54947. UV1: boolean;
  54948. UV2: boolean;
  54949. ALBEDO: boolean;
  54950. GAMMAALBEDO: boolean;
  54951. ALBEDODIRECTUV: number;
  54952. VERTEXCOLOR: boolean;
  54953. DETAIL: boolean;
  54954. DETAILDIRECTUV: number;
  54955. DETAIL_NORMALBLENDMETHOD: number;
  54956. AMBIENT: boolean;
  54957. AMBIENTDIRECTUV: number;
  54958. AMBIENTINGRAYSCALE: boolean;
  54959. OPACITY: boolean;
  54960. VERTEXALPHA: boolean;
  54961. OPACITYDIRECTUV: number;
  54962. OPACITYRGB: boolean;
  54963. ALPHATEST: boolean;
  54964. DEPTHPREPASS: boolean;
  54965. ALPHABLEND: boolean;
  54966. ALPHAFROMALBEDO: boolean;
  54967. ALPHATESTVALUE: string;
  54968. SPECULAROVERALPHA: boolean;
  54969. RADIANCEOVERALPHA: boolean;
  54970. ALPHAFRESNEL: boolean;
  54971. LINEARALPHAFRESNEL: boolean;
  54972. PREMULTIPLYALPHA: boolean;
  54973. EMISSIVE: boolean;
  54974. EMISSIVEDIRECTUV: number;
  54975. REFLECTIVITY: boolean;
  54976. REFLECTIVITYDIRECTUV: number;
  54977. SPECULARTERM: boolean;
  54978. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54979. MICROSURFACEAUTOMATIC: boolean;
  54980. LODBASEDMICROSFURACE: boolean;
  54981. MICROSURFACEMAP: boolean;
  54982. MICROSURFACEMAPDIRECTUV: number;
  54983. METALLICWORKFLOW: boolean;
  54984. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54985. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54986. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54987. AOSTOREINMETALMAPRED: boolean;
  54988. METALLIC_REFLECTANCE: boolean;
  54989. METALLIC_REFLECTANCEDIRECTUV: number;
  54990. ENVIRONMENTBRDF: boolean;
  54991. ENVIRONMENTBRDF_RGBD: boolean;
  54992. NORMAL: boolean;
  54993. TANGENT: boolean;
  54994. BUMP: boolean;
  54995. BUMPDIRECTUV: number;
  54996. OBJECTSPACE_NORMALMAP: boolean;
  54997. PARALLAX: boolean;
  54998. PARALLAXOCCLUSION: boolean;
  54999. NORMALXYSCALE: boolean;
  55000. LIGHTMAP: boolean;
  55001. LIGHTMAPDIRECTUV: number;
  55002. USELIGHTMAPASSHADOWMAP: boolean;
  55003. GAMMALIGHTMAP: boolean;
  55004. RGBDLIGHTMAP: boolean;
  55005. REFLECTION: boolean;
  55006. REFLECTIONMAP_3D: boolean;
  55007. REFLECTIONMAP_SPHERICAL: boolean;
  55008. REFLECTIONMAP_PLANAR: boolean;
  55009. REFLECTIONMAP_CUBIC: boolean;
  55010. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55011. REFLECTIONMAP_PROJECTION: boolean;
  55012. REFLECTIONMAP_SKYBOX: boolean;
  55013. REFLECTIONMAP_EXPLICIT: boolean;
  55014. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55015. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55016. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55017. INVERTCUBICMAP: boolean;
  55018. USESPHERICALFROMREFLECTIONMAP: boolean;
  55019. USEIRRADIANCEMAP: boolean;
  55020. SPHERICAL_HARMONICS: boolean;
  55021. USESPHERICALINVERTEX: boolean;
  55022. REFLECTIONMAP_OPPOSITEZ: boolean;
  55023. LODINREFLECTIONALPHA: boolean;
  55024. GAMMAREFLECTION: boolean;
  55025. RGBDREFLECTION: boolean;
  55026. LINEARSPECULARREFLECTION: boolean;
  55027. RADIANCEOCCLUSION: boolean;
  55028. HORIZONOCCLUSION: boolean;
  55029. INSTANCES: boolean;
  55030. THIN_INSTANCES: boolean;
  55031. NUM_BONE_INFLUENCERS: number;
  55032. BonesPerMesh: number;
  55033. BONETEXTURE: boolean;
  55034. NONUNIFORMSCALING: boolean;
  55035. MORPHTARGETS: boolean;
  55036. MORPHTARGETS_NORMAL: boolean;
  55037. MORPHTARGETS_TANGENT: boolean;
  55038. MORPHTARGETS_UV: boolean;
  55039. NUM_MORPH_INFLUENCERS: number;
  55040. IMAGEPROCESSING: boolean;
  55041. VIGNETTE: boolean;
  55042. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55043. VIGNETTEBLENDMODEOPAQUE: boolean;
  55044. TONEMAPPING: boolean;
  55045. TONEMAPPING_ACES: boolean;
  55046. CONTRAST: boolean;
  55047. COLORCURVES: boolean;
  55048. COLORGRADING: boolean;
  55049. COLORGRADING3D: boolean;
  55050. SAMPLER3DGREENDEPTH: boolean;
  55051. SAMPLER3DBGRMAP: boolean;
  55052. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55053. EXPOSURE: boolean;
  55054. MULTIVIEW: boolean;
  55055. USEPHYSICALLIGHTFALLOFF: boolean;
  55056. USEGLTFLIGHTFALLOFF: boolean;
  55057. TWOSIDEDLIGHTING: boolean;
  55058. SHADOWFLOAT: boolean;
  55059. CLIPPLANE: boolean;
  55060. CLIPPLANE2: boolean;
  55061. CLIPPLANE3: boolean;
  55062. CLIPPLANE4: boolean;
  55063. CLIPPLANE5: boolean;
  55064. CLIPPLANE6: boolean;
  55065. POINTSIZE: boolean;
  55066. FOG: boolean;
  55067. LOGARITHMICDEPTH: boolean;
  55068. FORCENORMALFORWARD: boolean;
  55069. SPECULARAA: boolean;
  55070. CLEARCOAT: boolean;
  55071. CLEARCOAT_DEFAULTIOR: boolean;
  55072. CLEARCOAT_TEXTURE: boolean;
  55073. CLEARCOAT_TEXTUREDIRECTUV: number;
  55074. CLEARCOAT_BUMP: boolean;
  55075. CLEARCOAT_BUMPDIRECTUV: number;
  55076. CLEARCOAT_TINT: boolean;
  55077. CLEARCOAT_TINT_TEXTURE: boolean;
  55078. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55079. ANISOTROPIC: boolean;
  55080. ANISOTROPIC_TEXTURE: boolean;
  55081. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55082. BRDF_V_HEIGHT_CORRELATED: boolean;
  55083. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55084. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55085. SHEEN: boolean;
  55086. SHEEN_TEXTURE: boolean;
  55087. SHEEN_TEXTUREDIRECTUV: number;
  55088. SHEEN_LINKWITHALBEDO: boolean;
  55089. SHEEN_ROUGHNESS: boolean;
  55090. SHEEN_ALBEDOSCALING: boolean;
  55091. SUBSURFACE: boolean;
  55092. SS_REFRACTION: boolean;
  55093. SS_TRANSLUCENCY: boolean;
  55094. SS_SCATTERING: boolean;
  55095. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55096. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55097. SS_REFRACTIONMAP_3D: boolean;
  55098. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55099. SS_LODINREFRACTIONALPHA: boolean;
  55100. SS_GAMMAREFRACTION: boolean;
  55101. SS_RGBDREFRACTION: boolean;
  55102. SS_LINEARSPECULARREFRACTION: boolean;
  55103. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55104. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55105. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55106. UNLIT: boolean;
  55107. DEBUGMODE: number;
  55108. /**
  55109. * Initializes the PBR Material defines.
  55110. */
  55111. constructor();
  55112. /**
  55113. * Resets the PBR Material defines.
  55114. */
  55115. reset(): void;
  55116. }
  55117. /**
  55118. * The Physically based material base class of BJS.
  55119. *
  55120. * This offers the main features of a standard PBR material.
  55121. * For more information, please refer to the documentation :
  55122. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55123. */
  55124. export abstract class PBRBaseMaterial extends PushMaterial {
  55125. /**
  55126. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55127. */
  55128. static readonly PBRMATERIAL_OPAQUE: number;
  55129. /**
  55130. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55131. */
  55132. static readonly PBRMATERIAL_ALPHATEST: number;
  55133. /**
  55134. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55135. */
  55136. static readonly PBRMATERIAL_ALPHABLEND: number;
  55137. /**
  55138. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55139. * They are also discarded below the alpha cutoff threshold to improve performances.
  55140. */
  55141. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55142. /**
  55143. * Defines the default value of how much AO map is occluding the analytical lights
  55144. * (point spot...).
  55145. */
  55146. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55147. /**
  55148. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55149. */
  55150. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55151. /**
  55152. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55153. * to enhance interoperability with other engines.
  55154. */
  55155. static readonly LIGHTFALLOFF_GLTF: number;
  55156. /**
  55157. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55158. * to enhance interoperability with other materials.
  55159. */
  55160. static readonly LIGHTFALLOFF_STANDARD: number;
  55161. /**
  55162. * Intensity of the direct lights e.g. the four lights available in your scene.
  55163. * This impacts both the direct diffuse and specular highlights.
  55164. */
  55165. protected _directIntensity: number;
  55166. /**
  55167. * Intensity of the emissive part of the material.
  55168. * This helps controlling the emissive effect without modifying the emissive color.
  55169. */
  55170. protected _emissiveIntensity: number;
  55171. /**
  55172. * Intensity of the environment e.g. how much the environment will light the object
  55173. * either through harmonics for rough material or through the refelction for shiny ones.
  55174. */
  55175. protected _environmentIntensity: number;
  55176. /**
  55177. * This is a special control allowing the reduction of the specular highlights coming from the
  55178. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55179. */
  55180. protected _specularIntensity: number;
  55181. /**
  55182. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55183. */
  55184. private _lightingInfos;
  55185. /**
  55186. * Debug Control allowing disabling the bump map on this material.
  55187. */
  55188. protected _disableBumpMap: boolean;
  55189. /**
  55190. * AKA Diffuse Texture in standard nomenclature.
  55191. */
  55192. protected _albedoTexture: Nullable<BaseTexture>;
  55193. /**
  55194. * AKA Occlusion Texture in other nomenclature.
  55195. */
  55196. protected _ambientTexture: Nullable<BaseTexture>;
  55197. /**
  55198. * AKA Occlusion Texture Intensity in other nomenclature.
  55199. */
  55200. protected _ambientTextureStrength: number;
  55201. /**
  55202. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55203. * 1 means it completely occludes it
  55204. * 0 mean it has no impact
  55205. */
  55206. protected _ambientTextureImpactOnAnalyticalLights: number;
  55207. /**
  55208. * Stores the alpha values in a texture.
  55209. */
  55210. protected _opacityTexture: Nullable<BaseTexture>;
  55211. /**
  55212. * Stores the reflection values in a texture.
  55213. */
  55214. protected _reflectionTexture: Nullable<BaseTexture>;
  55215. /**
  55216. * Stores the emissive values in a texture.
  55217. */
  55218. protected _emissiveTexture: Nullable<BaseTexture>;
  55219. /**
  55220. * AKA Specular texture in other nomenclature.
  55221. */
  55222. protected _reflectivityTexture: Nullable<BaseTexture>;
  55223. /**
  55224. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55225. */
  55226. protected _metallicTexture: Nullable<BaseTexture>;
  55227. /**
  55228. * Specifies the metallic scalar of the metallic/roughness workflow.
  55229. * Can also be used to scale the metalness values of the metallic texture.
  55230. */
  55231. protected _metallic: Nullable<number>;
  55232. /**
  55233. * Specifies the roughness scalar of the metallic/roughness workflow.
  55234. * Can also be used to scale the roughness values of the metallic texture.
  55235. */
  55236. protected _roughness: Nullable<number>;
  55237. /**
  55238. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55239. * By default the indexOfrefraction is used to compute F0;
  55240. *
  55241. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55242. *
  55243. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55244. * F90 = metallicReflectanceColor;
  55245. */
  55246. protected _metallicF0Factor: number;
  55247. /**
  55248. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55249. * By default the F90 is always 1;
  55250. *
  55251. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55252. *
  55253. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55254. * F90 = metallicReflectanceColor;
  55255. */
  55256. protected _metallicReflectanceColor: Color3;
  55257. /**
  55258. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55259. * This is multiply against the scalar values defined in the material.
  55260. */
  55261. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55262. /**
  55263. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55264. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55265. */
  55266. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55267. /**
  55268. * Stores surface normal data used to displace a mesh in a texture.
  55269. */
  55270. protected _bumpTexture: Nullable<BaseTexture>;
  55271. /**
  55272. * Stores the pre-calculated light information of a mesh in a texture.
  55273. */
  55274. protected _lightmapTexture: Nullable<BaseTexture>;
  55275. /**
  55276. * The color of a material in ambient lighting.
  55277. */
  55278. protected _ambientColor: Color3;
  55279. /**
  55280. * AKA Diffuse Color in other nomenclature.
  55281. */
  55282. protected _albedoColor: Color3;
  55283. /**
  55284. * AKA Specular Color in other nomenclature.
  55285. */
  55286. protected _reflectivityColor: Color3;
  55287. /**
  55288. * The color applied when light is reflected from a material.
  55289. */
  55290. protected _reflectionColor: Color3;
  55291. /**
  55292. * The color applied when light is emitted from a material.
  55293. */
  55294. protected _emissiveColor: Color3;
  55295. /**
  55296. * AKA Glossiness in other nomenclature.
  55297. */
  55298. protected _microSurface: number;
  55299. /**
  55300. * Specifies that the material will use the light map as a show map.
  55301. */
  55302. protected _useLightmapAsShadowmap: boolean;
  55303. /**
  55304. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55305. * makes the reflect vector face the model (under horizon).
  55306. */
  55307. protected _useHorizonOcclusion: boolean;
  55308. /**
  55309. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55310. * too much the area relying on ambient texture to define their ambient occlusion.
  55311. */
  55312. protected _useRadianceOcclusion: boolean;
  55313. /**
  55314. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55315. */
  55316. protected _useAlphaFromAlbedoTexture: boolean;
  55317. /**
  55318. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55319. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55320. */
  55321. protected _useSpecularOverAlpha: boolean;
  55322. /**
  55323. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55324. */
  55325. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55326. /**
  55327. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55328. */
  55329. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55330. /**
  55331. * Specifies if the metallic texture contains the roughness information in its green channel.
  55332. */
  55333. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55334. /**
  55335. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55336. */
  55337. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55338. /**
  55339. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55340. */
  55341. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55342. /**
  55343. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55344. */
  55345. protected _useAmbientInGrayScale: boolean;
  55346. /**
  55347. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55348. * The material will try to infer what glossiness each pixel should be.
  55349. */
  55350. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55351. /**
  55352. * Defines the falloff type used in this material.
  55353. * It by default is Physical.
  55354. */
  55355. protected _lightFalloff: number;
  55356. /**
  55357. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55358. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55359. */
  55360. protected _useRadianceOverAlpha: boolean;
  55361. /**
  55362. * Allows using an object space normal map (instead of tangent space).
  55363. */
  55364. protected _useObjectSpaceNormalMap: boolean;
  55365. /**
  55366. * Allows using the bump map in parallax mode.
  55367. */
  55368. protected _useParallax: boolean;
  55369. /**
  55370. * Allows using the bump map in parallax occlusion mode.
  55371. */
  55372. protected _useParallaxOcclusion: boolean;
  55373. /**
  55374. * Controls the scale bias of the parallax mode.
  55375. */
  55376. protected _parallaxScaleBias: number;
  55377. /**
  55378. * If sets to true, disables all the lights affecting the material.
  55379. */
  55380. protected _disableLighting: boolean;
  55381. /**
  55382. * Number of Simultaneous lights allowed on the material.
  55383. */
  55384. protected _maxSimultaneousLights: number;
  55385. /**
  55386. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55387. */
  55388. protected _invertNormalMapX: boolean;
  55389. /**
  55390. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55391. */
  55392. protected _invertNormalMapY: boolean;
  55393. /**
  55394. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55395. */
  55396. protected _twoSidedLighting: boolean;
  55397. /**
  55398. * Defines the alpha limits in alpha test mode.
  55399. */
  55400. protected _alphaCutOff: number;
  55401. /**
  55402. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55403. */
  55404. protected _forceAlphaTest: boolean;
  55405. /**
  55406. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55407. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55408. */
  55409. protected _useAlphaFresnel: boolean;
  55410. /**
  55411. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55412. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55413. */
  55414. protected _useLinearAlphaFresnel: boolean;
  55415. /**
  55416. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55417. * from cos thetav and roughness:
  55418. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55419. */
  55420. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55421. /**
  55422. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55423. */
  55424. protected _forceIrradianceInFragment: boolean;
  55425. private _realTimeFiltering;
  55426. /**
  55427. * Enables realtime filtering on the texture.
  55428. */
  55429. get realTimeFiltering(): boolean;
  55430. set realTimeFiltering(b: boolean);
  55431. private _realTimeFilteringQuality;
  55432. /**
  55433. * Quality switch for realtime filtering
  55434. */
  55435. get realTimeFilteringQuality(): number;
  55436. set realTimeFilteringQuality(n: number);
  55437. /**
  55438. * Force normal to face away from face.
  55439. */
  55440. protected _forceNormalForward: boolean;
  55441. /**
  55442. * Enables specular anti aliasing in the PBR shader.
  55443. * It will both interacts on the Geometry for analytical and IBL lighting.
  55444. * It also prefilter the roughness map based on the bump values.
  55445. */
  55446. protected _enableSpecularAntiAliasing: boolean;
  55447. /**
  55448. * Default configuration related to image processing available in the PBR Material.
  55449. */
  55450. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55451. /**
  55452. * Keep track of the image processing observer to allow dispose and replace.
  55453. */
  55454. private _imageProcessingObserver;
  55455. /**
  55456. * Attaches a new image processing configuration to the PBR Material.
  55457. * @param configuration
  55458. */
  55459. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55460. /**
  55461. * Stores the available render targets.
  55462. */
  55463. private _renderTargets;
  55464. /**
  55465. * Sets the global ambient color for the material used in lighting calculations.
  55466. */
  55467. private _globalAmbientColor;
  55468. /**
  55469. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55470. */
  55471. private _useLogarithmicDepth;
  55472. /**
  55473. * If set to true, no lighting calculations will be applied.
  55474. */
  55475. private _unlit;
  55476. private _debugMode;
  55477. /**
  55478. * @hidden
  55479. * This is reserved for the inspector.
  55480. * Defines the material debug mode.
  55481. * It helps seeing only some components of the material while troubleshooting.
  55482. */
  55483. debugMode: number;
  55484. /**
  55485. * @hidden
  55486. * This is reserved for the inspector.
  55487. * Specify from where on screen the debug mode should start.
  55488. * The value goes from -1 (full screen) to 1 (not visible)
  55489. * It helps with side by side comparison against the final render
  55490. * This defaults to -1
  55491. */
  55492. private debugLimit;
  55493. /**
  55494. * @hidden
  55495. * This is reserved for the inspector.
  55496. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55497. * You can use the factor to better multiply the final value.
  55498. */
  55499. private debugFactor;
  55500. /**
  55501. * Defines the clear coat layer parameters for the material.
  55502. */
  55503. readonly clearCoat: PBRClearCoatConfiguration;
  55504. /**
  55505. * Defines the anisotropic parameters for the material.
  55506. */
  55507. readonly anisotropy: PBRAnisotropicConfiguration;
  55508. /**
  55509. * Defines the BRDF parameters for the material.
  55510. */
  55511. readonly brdf: PBRBRDFConfiguration;
  55512. /**
  55513. * Defines the Sheen parameters for the material.
  55514. */
  55515. readonly sheen: PBRSheenConfiguration;
  55516. /**
  55517. * Defines the SubSurface parameters for the material.
  55518. */
  55519. readonly subSurface: PBRSubSurfaceConfiguration;
  55520. /**
  55521. * Defines the detail map parameters for the material.
  55522. */
  55523. readonly detailMap: DetailMapConfiguration;
  55524. protected _rebuildInParallel: boolean;
  55525. /**
  55526. * Instantiates a new PBRMaterial instance.
  55527. *
  55528. * @param name The material name
  55529. * @param scene The scene the material will be use in.
  55530. */
  55531. constructor(name: string, scene: Scene);
  55532. /**
  55533. * Gets a boolean indicating that current material needs to register RTT
  55534. */
  55535. get hasRenderTargetTextures(): boolean;
  55536. /**
  55537. * Gets the name of the material class.
  55538. */
  55539. getClassName(): string;
  55540. /**
  55541. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55542. */
  55543. get useLogarithmicDepth(): boolean;
  55544. /**
  55545. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55546. */
  55547. set useLogarithmicDepth(value: boolean);
  55548. /**
  55549. * Returns true if alpha blending should be disabled.
  55550. */
  55551. protected get _disableAlphaBlending(): boolean;
  55552. /**
  55553. * Specifies whether or not this material should be rendered in alpha blend mode.
  55554. */
  55555. needAlphaBlending(): boolean;
  55556. /**
  55557. * Specifies whether or not this material should be rendered in alpha test mode.
  55558. */
  55559. needAlphaTesting(): boolean;
  55560. /**
  55561. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55562. */
  55563. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55564. /**
  55565. * Gets the texture used for the alpha test.
  55566. */
  55567. getAlphaTestTexture(): Nullable<BaseTexture>;
  55568. /**
  55569. * Specifies that the submesh is ready to be used.
  55570. * @param mesh - BJS mesh.
  55571. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55572. * @param useInstances - Specifies that instances should be used.
  55573. * @returns - boolean indicating that the submesh is ready or not.
  55574. */
  55575. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55576. /**
  55577. * Specifies if the material uses metallic roughness workflow.
  55578. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55579. */
  55580. isMetallicWorkflow(): boolean;
  55581. private _prepareEffect;
  55582. private _prepareDefines;
  55583. /**
  55584. * Force shader compilation
  55585. */
  55586. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55587. /**
  55588. * Initializes the uniform buffer layout for the shader.
  55589. */
  55590. buildUniformLayout(): void;
  55591. /**
  55592. * Unbinds the material from the mesh
  55593. */
  55594. unbind(): void;
  55595. /**
  55596. * Binds the submesh data.
  55597. * @param world - The world matrix.
  55598. * @param mesh - The BJS mesh.
  55599. * @param subMesh - A submesh of the BJS mesh.
  55600. */
  55601. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55602. /**
  55603. * Returns the animatable textures.
  55604. * @returns - Array of animatable textures.
  55605. */
  55606. getAnimatables(): IAnimatable[];
  55607. /**
  55608. * Returns the texture used for reflections.
  55609. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55610. */
  55611. private _getReflectionTexture;
  55612. /**
  55613. * Returns an array of the actively used textures.
  55614. * @returns - Array of BaseTextures
  55615. */
  55616. getActiveTextures(): BaseTexture[];
  55617. /**
  55618. * Checks to see if a texture is used in the material.
  55619. * @param texture - Base texture to use.
  55620. * @returns - Boolean specifying if a texture is used in the material.
  55621. */
  55622. hasTexture(texture: BaseTexture): boolean;
  55623. /**
  55624. * Disposes the resources of the material.
  55625. * @param forceDisposeEffect - Forces the disposal of effects.
  55626. * @param forceDisposeTextures - Forces the disposal of all textures.
  55627. */
  55628. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55629. }
  55630. }
  55631. declare module BABYLON {
  55632. /**
  55633. * The Physically based material of BJS.
  55634. *
  55635. * This offers the main features of a standard PBR material.
  55636. * For more information, please refer to the documentation :
  55637. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55638. */
  55639. export class PBRMaterial extends PBRBaseMaterial {
  55640. /**
  55641. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55642. */
  55643. static readonly PBRMATERIAL_OPAQUE: number;
  55644. /**
  55645. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55646. */
  55647. static readonly PBRMATERIAL_ALPHATEST: number;
  55648. /**
  55649. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55650. */
  55651. static readonly PBRMATERIAL_ALPHABLEND: number;
  55652. /**
  55653. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55654. * They are also discarded below the alpha cutoff threshold to improve performances.
  55655. */
  55656. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55657. /**
  55658. * Defines the default value of how much AO map is occluding the analytical lights
  55659. * (point spot...).
  55660. */
  55661. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55662. /**
  55663. * Intensity of the direct lights e.g. the four lights available in your scene.
  55664. * This impacts both the direct diffuse and specular highlights.
  55665. */
  55666. directIntensity: number;
  55667. /**
  55668. * Intensity of the emissive part of the material.
  55669. * This helps controlling the emissive effect without modifying the emissive color.
  55670. */
  55671. emissiveIntensity: number;
  55672. /**
  55673. * Intensity of the environment e.g. how much the environment will light the object
  55674. * either through harmonics for rough material or through the refelction for shiny ones.
  55675. */
  55676. environmentIntensity: number;
  55677. /**
  55678. * This is a special control allowing the reduction of the specular highlights coming from the
  55679. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55680. */
  55681. specularIntensity: number;
  55682. /**
  55683. * Debug Control allowing disabling the bump map on this material.
  55684. */
  55685. disableBumpMap: boolean;
  55686. /**
  55687. * AKA Diffuse Texture in standard nomenclature.
  55688. */
  55689. albedoTexture: BaseTexture;
  55690. /**
  55691. * AKA Occlusion Texture in other nomenclature.
  55692. */
  55693. ambientTexture: BaseTexture;
  55694. /**
  55695. * AKA Occlusion Texture Intensity in other nomenclature.
  55696. */
  55697. ambientTextureStrength: number;
  55698. /**
  55699. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55700. * 1 means it completely occludes it
  55701. * 0 mean it has no impact
  55702. */
  55703. ambientTextureImpactOnAnalyticalLights: number;
  55704. /**
  55705. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55706. */
  55707. opacityTexture: BaseTexture;
  55708. /**
  55709. * Stores the reflection values in a texture.
  55710. */
  55711. reflectionTexture: Nullable<BaseTexture>;
  55712. /**
  55713. * Stores the emissive values in a texture.
  55714. */
  55715. emissiveTexture: BaseTexture;
  55716. /**
  55717. * AKA Specular texture in other nomenclature.
  55718. */
  55719. reflectivityTexture: BaseTexture;
  55720. /**
  55721. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55722. */
  55723. metallicTexture: BaseTexture;
  55724. /**
  55725. * Specifies the metallic scalar of the metallic/roughness workflow.
  55726. * Can also be used to scale the metalness values of the metallic texture.
  55727. */
  55728. metallic: Nullable<number>;
  55729. /**
  55730. * Specifies the roughness scalar of the metallic/roughness workflow.
  55731. * Can also be used to scale the roughness values of the metallic texture.
  55732. */
  55733. roughness: Nullable<number>;
  55734. /**
  55735. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55736. * By default the indexOfrefraction is used to compute F0;
  55737. *
  55738. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55739. *
  55740. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55741. * F90 = metallicReflectanceColor;
  55742. */
  55743. metallicF0Factor: number;
  55744. /**
  55745. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55746. * By default the F90 is always 1;
  55747. *
  55748. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55749. *
  55750. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55751. * F90 = metallicReflectanceColor;
  55752. */
  55753. metallicReflectanceColor: Color3;
  55754. /**
  55755. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55756. * This is multiply against the scalar values defined in the material.
  55757. */
  55758. metallicReflectanceTexture: Nullable<BaseTexture>;
  55759. /**
  55760. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55761. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55762. */
  55763. microSurfaceTexture: BaseTexture;
  55764. /**
  55765. * Stores surface normal data used to displace a mesh in a texture.
  55766. */
  55767. bumpTexture: BaseTexture;
  55768. /**
  55769. * Stores the pre-calculated light information of a mesh in a texture.
  55770. */
  55771. lightmapTexture: BaseTexture;
  55772. /**
  55773. * Stores the refracted light information in a texture.
  55774. */
  55775. get refractionTexture(): Nullable<BaseTexture>;
  55776. set refractionTexture(value: Nullable<BaseTexture>);
  55777. /**
  55778. * The color of a material in ambient lighting.
  55779. */
  55780. ambientColor: Color3;
  55781. /**
  55782. * AKA Diffuse Color in other nomenclature.
  55783. */
  55784. albedoColor: Color3;
  55785. /**
  55786. * AKA Specular Color in other nomenclature.
  55787. */
  55788. reflectivityColor: Color3;
  55789. /**
  55790. * The color reflected from the material.
  55791. */
  55792. reflectionColor: Color3;
  55793. /**
  55794. * The color emitted from the material.
  55795. */
  55796. emissiveColor: Color3;
  55797. /**
  55798. * AKA Glossiness in other nomenclature.
  55799. */
  55800. microSurface: number;
  55801. /**
  55802. * Index of refraction of the material base layer.
  55803. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55804. *
  55805. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55806. *
  55807. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55808. */
  55809. get indexOfRefraction(): number;
  55810. set indexOfRefraction(value: number);
  55811. /**
  55812. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55813. */
  55814. get invertRefractionY(): boolean;
  55815. set invertRefractionY(value: boolean);
  55816. /**
  55817. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55818. * Materials half opaque for instance using refraction could benefit from this control.
  55819. */
  55820. get linkRefractionWithTransparency(): boolean;
  55821. set linkRefractionWithTransparency(value: boolean);
  55822. /**
  55823. * If true, the light map contains occlusion information instead of lighting info.
  55824. */
  55825. useLightmapAsShadowmap: boolean;
  55826. /**
  55827. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55828. */
  55829. useAlphaFromAlbedoTexture: boolean;
  55830. /**
  55831. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55832. */
  55833. forceAlphaTest: boolean;
  55834. /**
  55835. * Defines the alpha limits in alpha test mode.
  55836. */
  55837. alphaCutOff: number;
  55838. /**
  55839. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55840. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55841. */
  55842. useSpecularOverAlpha: boolean;
  55843. /**
  55844. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55845. */
  55846. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55847. /**
  55848. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55849. */
  55850. useRoughnessFromMetallicTextureAlpha: boolean;
  55851. /**
  55852. * Specifies if the metallic texture contains the roughness information in its green channel.
  55853. */
  55854. useRoughnessFromMetallicTextureGreen: boolean;
  55855. /**
  55856. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55857. */
  55858. useMetallnessFromMetallicTextureBlue: boolean;
  55859. /**
  55860. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55861. */
  55862. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55863. /**
  55864. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55865. */
  55866. useAmbientInGrayScale: boolean;
  55867. /**
  55868. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55869. * The material will try to infer what glossiness each pixel should be.
  55870. */
  55871. useAutoMicroSurfaceFromReflectivityMap: boolean;
  55872. /**
  55873. * BJS is using an harcoded light falloff based on a manually sets up range.
  55874. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55875. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55876. */
  55877. get usePhysicalLightFalloff(): boolean;
  55878. /**
  55879. * BJS is using an harcoded light falloff based on a manually sets up range.
  55880. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55881. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55882. */
  55883. set usePhysicalLightFalloff(value: boolean);
  55884. /**
  55885. * In order to support the falloff compatibility with gltf, a special mode has been added
  55886. * to reproduce the gltf light falloff.
  55887. */
  55888. get useGLTFLightFalloff(): boolean;
  55889. /**
  55890. * In order to support the falloff compatibility with gltf, a special mode has been added
  55891. * to reproduce the gltf light falloff.
  55892. */
  55893. set useGLTFLightFalloff(value: boolean);
  55894. /**
  55895. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55896. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55897. */
  55898. useRadianceOverAlpha: boolean;
  55899. /**
  55900. * Allows using an object space normal map (instead of tangent space).
  55901. */
  55902. useObjectSpaceNormalMap: boolean;
  55903. /**
  55904. * Allows using the bump map in parallax mode.
  55905. */
  55906. useParallax: boolean;
  55907. /**
  55908. * Allows using the bump map in parallax occlusion mode.
  55909. */
  55910. useParallaxOcclusion: boolean;
  55911. /**
  55912. * Controls the scale bias of the parallax mode.
  55913. */
  55914. parallaxScaleBias: number;
  55915. /**
  55916. * If sets to true, disables all the lights affecting the material.
  55917. */
  55918. disableLighting: boolean;
  55919. /**
  55920. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55921. */
  55922. forceIrradianceInFragment: boolean;
  55923. /**
  55924. * Number of Simultaneous lights allowed on the material.
  55925. */
  55926. maxSimultaneousLights: number;
  55927. /**
  55928. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55929. */
  55930. invertNormalMapX: boolean;
  55931. /**
  55932. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55933. */
  55934. invertNormalMapY: boolean;
  55935. /**
  55936. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55937. */
  55938. twoSidedLighting: boolean;
  55939. /**
  55940. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55941. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55942. */
  55943. useAlphaFresnel: boolean;
  55944. /**
  55945. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55946. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55947. */
  55948. useLinearAlphaFresnel: boolean;
  55949. /**
  55950. * Let user defines the brdf lookup texture used for IBL.
  55951. * A default 8bit version is embedded but you could point at :
  55952. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55953. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55954. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55955. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55956. */
  55957. environmentBRDFTexture: Nullable<BaseTexture>;
  55958. /**
  55959. * Force normal to face away from face.
  55960. */
  55961. forceNormalForward: boolean;
  55962. /**
  55963. * Enables specular anti aliasing in the PBR shader.
  55964. * It will both interacts on the Geometry for analytical and IBL lighting.
  55965. * It also prefilter the roughness map based on the bump values.
  55966. */
  55967. enableSpecularAntiAliasing: boolean;
  55968. /**
  55969. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55970. * makes the reflect vector face the model (under horizon).
  55971. */
  55972. useHorizonOcclusion: boolean;
  55973. /**
  55974. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55975. * too much the area relying on ambient texture to define their ambient occlusion.
  55976. */
  55977. useRadianceOcclusion: boolean;
  55978. /**
  55979. * If set to true, no lighting calculations will be applied.
  55980. */
  55981. unlit: boolean;
  55982. /**
  55983. * Gets the image processing configuration used either in this material.
  55984. */
  55985. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55986. /**
  55987. * Sets the Default image processing configuration used either in the this material.
  55988. *
  55989. * If sets to null, the scene one is in use.
  55990. */
  55991. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55992. /**
  55993. * Gets wether the color curves effect is enabled.
  55994. */
  55995. get cameraColorCurvesEnabled(): boolean;
  55996. /**
  55997. * Sets wether the color curves effect is enabled.
  55998. */
  55999. set cameraColorCurvesEnabled(value: boolean);
  56000. /**
  56001. * Gets wether the color grading effect is enabled.
  56002. */
  56003. get cameraColorGradingEnabled(): boolean;
  56004. /**
  56005. * Gets wether the color grading effect is enabled.
  56006. */
  56007. set cameraColorGradingEnabled(value: boolean);
  56008. /**
  56009. * Gets wether tonemapping is enabled or not.
  56010. */
  56011. get cameraToneMappingEnabled(): boolean;
  56012. /**
  56013. * Sets wether tonemapping is enabled or not
  56014. */
  56015. set cameraToneMappingEnabled(value: boolean);
  56016. /**
  56017. * The camera exposure used on this material.
  56018. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56019. * This corresponds to a photographic exposure.
  56020. */
  56021. get cameraExposure(): number;
  56022. /**
  56023. * The camera exposure used on this material.
  56024. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56025. * This corresponds to a photographic exposure.
  56026. */
  56027. set cameraExposure(value: number);
  56028. /**
  56029. * Gets The camera contrast used on this material.
  56030. */
  56031. get cameraContrast(): number;
  56032. /**
  56033. * Sets The camera contrast used on this material.
  56034. */
  56035. set cameraContrast(value: number);
  56036. /**
  56037. * Gets the Color Grading 2D Lookup Texture.
  56038. */
  56039. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56040. /**
  56041. * Sets the Color Grading 2D Lookup Texture.
  56042. */
  56043. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56044. /**
  56045. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56046. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56047. * 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;
  56048. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56049. */
  56050. get cameraColorCurves(): Nullable<ColorCurves>;
  56051. /**
  56052. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56053. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56054. * 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;
  56055. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56056. */
  56057. set cameraColorCurves(value: Nullable<ColorCurves>);
  56058. /**
  56059. * Instantiates a new PBRMaterial instance.
  56060. *
  56061. * @param name The material name
  56062. * @param scene The scene the material will be use in.
  56063. */
  56064. constructor(name: string, scene: Scene);
  56065. /**
  56066. * Returns the name of this material class.
  56067. */
  56068. getClassName(): string;
  56069. /**
  56070. * Makes a duplicate of the current material.
  56071. * @param name - name to use for the new material.
  56072. */
  56073. clone(name: string): PBRMaterial;
  56074. /**
  56075. * Serializes this PBR Material.
  56076. * @returns - An object with the serialized material.
  56077. */
  56078. serialize(): any;
  56079. /**
  56080. * Parses a PBR Material from a serialized object.
  56081. * @param source - Serialized object.
  56082. * @param scene - BJS scene instance.
  56083. * @param rootUrl - url for the scene object
  56084. * @returns - PBRMaterial
  56085. */
  56086. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56087. }
  56088. }
  56089. declare module BABYLON {
  56090. /**
  56091. * Direct draw surface info
  56092. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56093. */
  56094. export interface DDSInfo {
  56095. /**
  56096. * Width of the texture
  56097. */
  56098. width: number;
  56099. /**
  56100. * Width of the texture
  56101. */
  56102. height: number;
  56103. /**
  56104. * Number of Mipmaps for the texture
  56105. * @see https://en.wikipedia.org/wiki/Mipmap
  56106. */
  56107. mipmapCount: number;
  56108. /**
  56109. * If the textures format is a known fourCC format
  56110. * @see https://www.fourcc.org/
  56111. */
  56112. isFourCC: boolean;
  56113. /**
  56114. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56115. */
  56116. isRGB: boolean;
  56117. /**
  56118. * If the texture is a lumincance format
  56119. */
  56120. isLuminance: boolean;
  56121. /**
  56122. * If this is a cube texture
  56123. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56124. */
  56125. isCube: boolean;
  56126. /**
  56127. * If the texture is a compressed format eg. FOURCC_DXT1
  56128. */
  56129. isCompressed: boolean;
  56130. /**
  56131. * The dxgiFormat of the texture
  56132. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56133. */
  56134. dxgiFormat: number;
  56135. /**
  56136. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56137. */
  56138. textureType: number;
  56139. /**
  56140. * Sphericle polynomial created for the dds texture
  56141. */
  56142. sphericalPolynomial?: SphericalPolynomial;
  56143. }
  56144. /**
  56145. * Class used to provide DDS decompression tools
  56146. */
  56147. export class DDSTools {
  56148. /**
  56149. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56150. */
  56151. static StoreLODInAlphaChannel: boolean;
  56152. /**
  56153. * Gets DDS information from an array buffer
  56154. * @param data defines the array buffer view to read data from
  56155. * @returns the DDS information
  56156. */
  56157. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56158. private static _FloatView;
  56159. private static _Int32View;
  56160. private static _ToHalfFloat;
  56161. private static _FromHalfFloat;
  56162. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56163. private static _GetHalfFloatRGBAArrayBuffer;
  56164. private static _GetFloatRGBAArrayBuffer;
  56165. private static _GetFloatAsUIntRGBAArrayBuffer;
  56166. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56167. private static _GetRGBAArrayBuffer;
  56168. private static _ExtractLongWordOrder;
  56169. private static _GetRGBArrayBuffer;
  56170. private static _GetLuminanceArrayBuffer;
  56171. /**
  56172. * Uploads DDS Levels to a Babylon Texture
  56173. * @hidden
  56174. */
  56175. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56176. }
  56177. interface ThinEngine {
  56178. /**
  56179. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56180. * @param rootUrl defines the url where the file to load is located
  56181. * @param scene defines the current scene
  56182. * @param lodScale defines scale to apply to the mip map selection
  56183. * @param lodOffset defines offset to apply to the mip map selection
  56184. * @param onLoad defines an optional callback raised when the texture is loaded
  56185. * @param onError defines an optional callback raised if there is an issue to load the texture
  56186. * @param format defines the format of the data
  56187. * @param forcedExtension defines the extension to use to pick the right loader
  56188. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56189. * @returns the cube texture as an InternalTexture
  56190. */
  56191. 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;
  56192. }
  56193. }
  56194. declare module BABYLON {
  56195. /**
  56196. * Implementation of the DDS Texture Loader.
  56197. * @hidden
  56198. */
  56199. export class _DDSTextureLoader implements IInternalTextureLoader {
  56200. /**
  56201. * Defines wether the loader supports cascade loading the different faces.
  56202. */
  56203. readonly supportCascades: boolean;
  56204. /**
  56205. * This returns if the loader support the current file information.
  56206. * @param extension defines the file extension of the file being loaded
  56207. * @returns true if the loader can load the specified file
  56208. */
  56209. canLoad(extension: string): boolean;
  56210. /**
  56211. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56212. * @param data contains the texture data
  56213. * @param texture defines the BabylonJS internal texture
  56214. * @param createPolynomials will be true if polynomials have been requested
  56215. * @param onLoad defines the callback to trigger once the texture is ready
  56216. * @param onError defines the callback to trigger in case of error
  56217. */
  56218. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56219. /**
  56220. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56221. * @param data contains the texture data
  56222. * @param texture defines the BabylonJS internal texture
  56223. * @param callback defines the method to call once ready to upload
  56224. */
  56225. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56226. }
  56227. }
  56228. declare module BABYLON {
  56229. /**
  56230. * Implementation of the ENV Texture Loader.
  56231. * @hidden
  56232. */
  56233. export class _ENVTextureLoader implements IInternalTextureLoader {
  56234. /**
  56235. * Defines wether the loader supports cascade loading the different faces.
  56236. */
  56237. readonly supportCascades: boolean;
  56238. /**
  56239. * This returns if the loader support the current file information.
  56240. * @param extension defines the file extension of the file being loaded
  56241. * @returns true if the loader can load the specified file
  56242. */
  56243. canLoad(extension: string): boolean;
  56244. /**
  56245. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56246. * @param data contains the texture data
  56247. * @param texture defines the BabylonJS internal texture
  56248. * @param createPolynomials will be true if polynomials have been requested
  56249. * @param onLoad defines the callback to trigger once the texture is ready
  56250. * @param onError defines the callback to trigger in case of error
  56251. */
  56252. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56253. /**
  56254. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56255. * @param data contains the texture data
  56256. * @param texture defines the BabylonJS internal texture
  56257. * @param callback defines the method to call once ready to upload
  56258. */
  56259. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56260. }
  56261. }
  56262. declare module BABYLON {
  56263. /**
  56264. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56265. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56266. */
  56267. export class KhronosTextureContainer {
  56268. /** contents of the KTX container file */
  56269. data: ArrayBufferView;
  56270. private static HEADER_LEN;
  56271. private static COMPRESSED_2D;
  56272. private static COMPRESSED_3D;
  56273. private static TEX_2D;
  56274. private static TEX_3D;
  56275. /**
  56276. * Gets the openGL type
  56277. */
  56278. glType: number;
  56279. /**
  56280. * Gets the openGL type size
  56281. */
  56282. glTypeSize: number;
  56283. /**
  56284. * Gets the openGL format
  56285. */
  56286. glFormat: number;
  56287. /**
  56288. * Gets the openGL internal format
  56289. */
  56290. glInternalFormat: number;
  56291. /**
  56292. * Gets the base internal format
  56293. */
  56294. glBaseInternalFormat: number;
  56295. /**
  56296. * Gets image width in pixel
  56297. */
  56298. pixelWidth: number;
  56299. /**
  56300. * Gets image height in pixel
  56301. */
  56302. pixelHeight: number;
  56303. /**
  56304. * Gets image depth in pixels
  56305. */
  56306. pixelDepth: number;
  56307. /**
  56308. * Gets the number of array elements
  56309. */
  56310. numberOfArrayElements: number;
  56311. /**
  56312. * Gets the number of faces
  56313. */
  56314. numberOfFaces: number;
  56315. /**
  56316. * Gets the number of mipmap levels
  56317. */
  56318. numberOfMipmapLevels: number;
  56319. /**
  56320. * Gets the bytes of key value data
  56321. */
  56322. bytesOfKeyValueData: number;
  56323. /**
  56324. * Gets the load type
  56325. */
  56326. loadType: number;
  56327. /**
  56328. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56329. */
  56330. isInvalid: boolean;
  56331. /**
  56332. * Creates a new KhronosTextureContainer
  56333. * @param data contents of the KTX container file
  56334. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56335. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56336. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56337. */
  56338. constructor(
  56339. /** contents of the KTX container file */
  56340. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56341. /**
  56342. * Uploads KTX content to a Babylon Texture.
  56343. * It is assumed that the texture has already been created & is currently bound
  56344. * @hidden
  56345. */
  56346. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56347. private _upload2DCompressedLevels;
  56348. /**
  56349. * Checks if the given data starts with a KTX file identifier.
  56350. * @param data the data to check
  56351. * @returns true if the data is a KTX file or false otherwise
  56352. */
  56353. static IsValid(data: ArrayBufferView): boolean;
  56354. }
  56355. }
  56356. declare module BABYLON {
  56357. /**
  56358. * Class for loading KTX2 files
  56359. * !!! Experimental Extension Subject to Changes !!!
  56360. * @hidden
  56361. */
  56362. export class KhronosTextureContainer2 {
  56363. private static _ModulePromise;
  56364. private static _TranscodeFormat;
  56365. constructor(engine: ThinEngine);
  56366. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56367. private _determineTranscodeFormat;
  56368. /**
  56369. * Checks if the given data starts with a KTX2 file identifier.
  56370. * @param data the data to check
  56371. * @returns true if the data is a KTX2 file or false otherwise
  56372. */
  56373. static IsValid(data: ArrayBufferView): boolean;
  56374. }
  56375. }
  56376. declare module BABYLON {
  56377. /**
  56378. * Implementation of the KTX Texture Loader.
  56379. * @hidden
  56380. */
  56381. export class _KTXTextureLoader implements IInternalTextureLoader {
  56382. /**
  56383. * Defines wether the loader supports cascade loading the different faces.
  56384. */
  56385. readonly supportCascades: boolean;
  56386. /**
  56387. * This returns if the loader support the current file information.
  56388. * @param extension defines the file extension of the file being loaded
  56389. * @returns true if the loader can load the specified file
  56390. */
  56391. canLoad(extension: string): boolean;
  56392. /**
  56393. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56394. * @param data contains the texture data
  56395. * @param texture defines the BabylonJS internal texture
  56396. * @param createPolynomials will be true if polynomials have been requested
  56397. * @param onLoad defines the callback to trigger once the texture is ready
  56398. * @param onError defines the callback to trigger in case of error
  56399. */
  56400. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56401. /**
  56402. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56403. * @param data contains the texture data
  56404. * @param texture defines the BabylonJS internal texture
  56405. * @param callback defines the method to call once ready to upload
  56406. */
  56407. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56408. }
  56409. }
  56410. declare module BABYLON {
  56411. /** @hidden */
  56412. export var _forceSceneHelpersToBundle: boolean;
  56413. interface Scene {
  56414. /**
  56415. * Creates a default light for the scene.
  56416. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56417. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56418. */
  56419. createDefaultLight(replace?: boolean): void;
  56420. /**
  56421. * Creates a default camera for the scene.
  56422. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56423. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56424. * @param replace has default false, when true replaces the active camera in the scene
  56425. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56426. */
  56427. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56428. /**
  56429. * Creates a default camera and a default light.
  56430. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56431. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56432. * @param replace has the default false, when true replaces the active camera/light in the scene
  56433. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56434. */
  56435. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56436. /**
  56437. * Creates a new sky box
  56438. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56439. * @param environmentTexture defines the texture to use as environment texture
  56440. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56441. * @param scale defines the overall scale of the skybox
  56442. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56443. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56444. * @returns a new mesh holding the sky box
  56445. */
  56446. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56447. /**
  56448. * Creates a new environment
  56449. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56450. * @param options defines the options you can use to configure the environment
  56451. * @returns the new EnvironmentHelper
  56452. */
  56453. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56454. /**
  56455. * Creates a new VREXperienceHelper
  56456. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56457. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56458. * @returns a new VREXperienceHelper
  56459. */
  56460. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56461. /**
  56462. * Creates a new WebXRDefaultExperience
  56463. * @see http://doc.babylonjs.com/how_to/webxr
  56464. * @param options experience options
  56465. * @returns a promise for a new WebXRDefaultExperience
  56466. */
  56467. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56468. }
  56469. }
  56470. declare module BABYLON {
  56471. /**
  56472. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56473. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56474. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56475. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56476. */
  56477. export class VideoDome extends TransformNode {
  56478. /**
  56479. * Define the video source as a Monoscopic panoramic 360 video.
  56480. */
  56481. static readonly MODE_MONOSCOPIC: number;
  56482. /**
  56483. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56484. */
  56485. static readonly MODE_TOPBOTTOM: number;
  56486. /**
  56487. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56488. */
  56489. static readonly MODE_SIDEBYSIDE: number;
  56490. private _halfDome;
  56491. private _useDirectMapping;
  56492. /**
  56493. * The video texture being displayed on the sphere
  56494. */
  56495. protected _videoTexture: VideoTexture;
  56496. /**
  56497. * Gets the video texture being displayed on the sphere
  56498. */
  56499. get videoTexture(): VideoTexture;
  56500. /**
  56501. * The skybox material
  56502. */
  56503. protected _material: BackgroundMaterial;
  56504. /**
  56505. * The surface used for the skybox
  56506. */
  56507. protected _mesh: Mesh;
  56508. /**
  56509. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56510. */
  56511. private _halfDomeMask;
  56512. /**
  56513. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56514. * Also see the options.resolution property.
  56515. */
  56516. get fovMultiplier(): number;
  56517. set fovMultiplier(value: number);
  56518. private _videoMode;
  56519. /**
  56520. * Gets or set the current video mode for the video. It can be:
  56521. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56522. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56523. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56524. */
  56525. get videoMode(): number;
  56526. set videoMode(value: number);
  56527. /**
  56528. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56529. *
  56530. */
  56531. get halfDome(): boolean;
  56532. /**
  56533. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56534. */
  56535. set halfDome(enabled: boolean);
  56536. /**
  56537. * Oberserver used in Stereoscopic VR Mode.
  56538. */
  56539. private _onBeforeCameraRenderObserver;
  56540. /**
  56541. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56542. * @param name Element's name, child elements will append suffixes for their own names.
  56543. * @param urlsOrVideo defines the url(s) or the video element to use
  56544. * @param options An object containing optional or exposed sub element properties
  56545. */
  56546. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56547. resolution?: number;
  56548. clickToPlay?: boolean;
  56549. autoPlay?: boolean;
  56550. loop?: boolean;
  56551. size?: number;
  56552. poster?: string;
  56553. faceForward?: boolean;
  56554. useDirectMapping?: boolean;
  56555. halfDomeMode?: boolean;
  56556. }, scene: Scene);
  56557. private _changeVideoMode;
  56558. /**
  56559. * Releases resources associated with this node.
  56560. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56561. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56562. */
  56563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56564. }
  56565. }
  56566. declare module BABYLON {
  56567. /**
  56568. * This class can be used to get instrumentation data from a Babylon engine
  56569. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56570. */
  56571. export class EngineInstrumentation implements IDisposable {
  56572. /**
  56573. * Define the instrumented engine.
  56574. */
  56575. engine: Engine;
  56576. private _captureGPUFrameTime;
  56577. private _gpuFrameTimeToken;
  56578. private _gpuFrameTime;
  56579. private _captureShaderCompilationTime;
  56580. private _shaderCompilationTime;
  56581. private _onBeginFrameObserver;
  56582. private _onEndFrameObserver;
  56583. private _onBeforeShaderCompilationObserver;
  56584. private _onAfterShaderCompilationObserver;
  56585. /**
  56586. * Gets the perf counter used for GPU frame time
  56587. */
  56588. get gpuFrameTimeCounter(): PerfCounter;
  56589. /**
  56590. * Gets the GPU frame time capture status
  56591. */
  56592. get captureGPUFrameTime(): boolean;
  56593. /**
  56594. * Enable or disable the GPU frame time capture
  56595. */
  56596. set captureGPUFrameTime(value: boolean);
  56597. /**
  56598. * Gets the perf counter used for shader compilation time
  56599. */
  56600. get shaderCompilationTimeCounter(): PerfCounter;
  56601. /**
  56602. * Gets the shader compilation time capture status
  56603. */
  56604. get captureShaderCompilationTime(): boolean;
  56605. /**
  56606. * Enable or disable the shader compilation time capture
  56607. */
  56608. set captureShaderCompilationTime(value: boolean);
  56609. /**
  56610. * Instantiates a new engine instrumentation.
  56611. * This class can be used to get instrumentation data from a Babylon engine
  56612. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56613. * @param engine Defines the engine to instrument
  56614. */
  56615. constructor(
  56616. /**
  56617. * Define the instrumented engine.
  56618. */
  56619. engine: Engine);
  56620. /**
  56621. * Dispose and release associated resources.
  56622. */
  56623. dispose(): void;
  56624. }
  56625. }
  56626. declare module BABYLON {
  56627. /**
  56628. * This class can be used to get instrumentation data from a Babylon engine
  56629. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56630. */
  56631. export class SceneInstrumentation implements IDisposable {
  56632. /**
  56633. * Defines the scene to instrument
  56634. */
  56635. scene: Scene;
  56636. private _captureActiveMeshesEvaluationTime;
  56637. private _activeMeshesEvaluationTime;
  56638. private _captureRenderTargetsRenderTime;
  56639. private _renderTargetsRenderTime;
  56640. private _captureFrameTime;
  56641. private _frameTime;
  56642. private _captureRenderTime;
  56643. private _renderTime;
  56644. private _captureInterFrameTime;
  56645. private _interFrameTime;
  56646. private _captureParticlesRenderTime;
  56647. private _particlesRenderTime;
  56648. private _captureSpritesRenderTime;
  56649. private _spritesRenderTime;
  56650. private _capturePhysicsTime;
  56651. private _physicsTime;
  56652. private _captureAnimationsTime;
  56653. private _animationsTime;
  56654. private _captureCameraRenderTime;
  56655. private _cameraRenderTime;
  56656. private _onBeforeActiveMeshesEvaluationObserver;
  56657. private _onAfterActiveMeshesEvaluationObserver;
  56658. private _onBeforeRenderTargetsRenderObserver;
  56659. private _onAfterRenderTargetsRenderObserver;
  56660. private _onAfterRenderObserver;
  56661. private _onBeforeDrawPhaseObserver;
  56662. private _onAfterDrawPhaseObserver;
  56663. private _onBeforeAnimationsObserver;
  56664. private _onBeforeParticlesRenderingObserver;
  56665. private _onAfterParticlesRenderingObserver;
  56666. private _onBeforeSpritesRenderingObserver;
  56667. private _onAfterSpritesRenderingObserver;
  56668. private _onBeforePhysicsObserver;
  56669. private _onAfterPhysicsObserver;
  56670. private _onAfterAnimationsObserver;
  56671. private _onBeforeCameraRenderObserver;
  56672. private _onAfterCameraRenderObserver;
  56673. /**
  56674. * Gets the perf counter used for active meshes evaluation time
  56675. */
  56676. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56677. /**
  56678. * Gets the active meshes evaluation time capture status
  56679. */
  56680. get captureActiveMeshesEvaluationTime(): boolean;
  56681. /**
  56682. * Enable or disable the active meshes evaluation time capture
  56683. */
  56684. set captureActiveMeshesEvaluationTime(value: boolean);
  56685. /**
  56686. * Gets the perf counter used for render targets render time
  56687. */
  56688. get renderTargetsRenderTimeCounter(): PerfCounter;
  56689. /**
  56690. * Gets the render targets render time capture status
  56691. */
  56692. get captureRenderTargetsRenderTime(): boolean;
  56693. /**
  56694. * Enable or disable the render targets render time capture
  56695. */
  56696. set captureRenderTargetsRenderTime(value: boolean);
  56697. /**
  56698. * Gets the perf counter used for particles render time
  56699. */
  56700. get particlesRenderTimeCounter(): PerfCounter;
  56701. /**
  56702. * Gets the particles render time capture status
  56703. */
  56704. get captureParticlesRenderTime(): boolean;
  56705. /**
  56706. * Enable or disable the particles render time capture
  56707. */
  56708. set captureParticlesRenderTime(value: boolean);
  56709. /**
  56710. * Gets the perf counter used for sprites render time
  56711. */
  56712. get spritesRenderTimeCounter(): PerfCounter;
  56713. /**
  56714. * Gets the sprites render time capture status
  56715. */
  56716. get captureSpritesRenderTime(): boolean;
  56717. /**
  56718. * Enable or disable the sprites render time capture
  56719. */
  56720. set captureSpritesRenderTime(value: boolean);
  56721. /**
  56722. * Gets the perf counter used for physics time
  56723. */
  56724. get physicsTimeCounter(): PerfCounter;
  56725. /**
  56726. * Gets the physics time capture status
  56727. */
  56728. get capturePhysicsTime(): boolean;
  56729. /**
  56730. * Enable or disable the physics time capture
  56731. */
  56732. set capturePhysicsTime(value: boolean);
  56733. /**
  56734. * Gets the perf counter used for animations time
  56735. */
  56736. get animationsTimeCounter(): PerfCounter;
  56737. /**
  56738. * Gets the animations time capture status
  56739. */
  56740. get captureAnimationsTime(): boolean;
  56741. /**
  56742. * Enable or disable the animations time capture
  56743. */
  56744. set captureAnimationsTime(value: boolean);
  56745. /**
  56746. * Gets the perf counter used for frame time capture
  56747. */
  56748. get frameTimeCounter(): PerfCounter;
  56749. /**
  56750. * Gets the frame time capture status
  56751. */
  56752. get captureFrameTime(): boolean;
  56753. /**
  56754. * Enable or disable the frame time capture
  56755. */
  56756. set captureFrameTime(value: boolean);
  56757. /**
  56758. * Gets the perf counter used for inter-frames time capture
  56759. */
  56760. get interFrameTimeCounter(): PerfCounter;
  56761. /**
  56762. * Gets the inter-frames time capture status
  56763. */
  56764. get captureInterFrameTime(): boolean;
  56765. /**
  56766. * Enable or disable the inter-frames time capture
  56767. */
  56768. set captureInterFrameTime(value: boolean);
  56769. /**
  56770. * Gets the perf counter used for render time capture
  56771. */
  56772. get renderTimeCounter(): PerfCounter;
  56773. /**
  56774. * Gets the render time capture status
  56775. */
  56776. get captureRenderTime(): boolean;
  56777. /**
  56778. * Enable or disable the render time capture
  56779. */
  56780. set captureRenderTime(value: boolean);
  56781. /**
  56782. * Gets the perf counter used for camera render time capture
  56783. */
  56784. get cameraRenderTimeCounter(): PerfCounter;
  56785. /**
  56786. * Gets the camera render time capture status
  56787. */
  56788. get captureCameraRenderTime(): boolean;
  56789. /**
  56790. * Enable or disable the camera render time capture
  56791. */
  56792. set captureCameraRenderTime(value: boolean);
  56793. /**
  56794. * Gets the perf counter used for draw calls
  56795. */
  56796. get drawCallsCounter(): PerfCounter;
  56797. /**
  56798. * Instantiates a new scene instrumentation.
  56799. * This class can be used to get instrumentation data from a Babylon engine
  56800. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56801. * @param scene Defines the scene to instrument
  56802. */
  56803. constructor(
  56804. /**
  56805. * Defines the scene to instrument
  56806. */
  56807. scene: Scene);
  56808. /**
  56809. * Dispose and release associated resources.
  56810. */
  56811. dispose(): void;
  56812. }
  56813. }
  56814. declare module BABYLON {
  56815. /** @hidden */
  56816. export var glowMapGenerationPixelShader: {
  56817. name: string;
  56818. shader: string;
  56819. };
  56820. }
  56821. declare module BABYLON {
  56822. /** @hidden */
  56823. export var glowMapGenerationVertexShader: {
  56824. name: string;
  56825. shader: string;
  56826. };
  56827. }
  56828. declare module BABYLON {
  56829. /**
  56830. * Effect layer options. This helps customizing the behaviour
  56831. * of the effect layer.
  56832. */
  56833. export interface IEffectLayerOptions {
  56834. /**
  56835. * Multiplication factor apply to the canvas size to compute the render target size
  56836. * used to generated the objects (the smaller the faster).
  56837. */
  56838. mainTextureRatio: number;
  56839. /**
  56840. * Enforces a fixed size texture to ensure effect stability across devices.
  56841. */
  56842. mainTextureFixedSize?: number;
  56843. /**
  56844. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56845. */
  56846. alphaBlendingMode: number;
  56847. /**
  56848. * The camera attached to the layer.
  56849. */
  56850. camera: Nullable<Camera>;
  56851. /**
  56852. * The rendering group to draw the layer in.
  56853. */
  56854. renderingGroupId: number;
  56855. }
  56856. /**
  56857. * The effect layer Helps adding post process effect blended with the main pass.
  56858. *
  56859. * This can be for instance use to generate glow or higlight effects on the scene.
  56860. *
  56861. * The effect layer class can not be used directly and is intented to inherited from to be
  56862. * customized per effects.
  56863. */
  56864. export abstract class EffectLayer {
  56865. private _vertexBuffers;
  56866. private _indexBuffer;
  56867. private _cachedDefines;
  56868. private _effectLayerMapGenerationEffect;
  56869. private _effectLayerOptions;
  56870. private _mergeEffect;
  56871. protected _scene: Scene;
  56872. protected _engine: Engine;
  56873. protected _maxSize: number;
  56874. protected _mainTextureDesiredSize: ISize;
  56875. protected _mainTexture: RenderTargetTexture;
  56876. protected _shouldRender: boolean;
  56877. protected _postProcesses: PostProcess[];
  56878. protected _textures: BaseTexture[];
  56879. protected _emissiveTextureAndColor: {
  56880. texture: Nullable<BaseTexture>;
  56881. color: Color4;
  56882. };
  56883. /**
  56884. * The name of the layer
  56885. */
  56886. name: string;
  56887. /**
  56888. * The clear color of the texture used to generate the glow map.
  56889. */
  56890. neutralColor: Color4;
  56891. /**
  56892. * Specifies whether the highlight layer is enabled or not.
  56893. */
  56894. isEnabled: boolean;
  56895. /**
  56896. * Gets the camera attached to the layer.
  56897. */
  56898. get camera(): Nullable<Camera>;
  56899. /**
  56900. * Gets the rendering group id the layer should render in.
  56901. */
  56902. get renderingGroupId(): number;
  56903. set renderingGroupId(renderingGroupId: number);
  56904. /**
  56905. * An event triggered when the effect layer has been disposed.
  56906. */
  56907. onDisposeObservable: Observable<EffectLayer>;
  56908. /**
  56909. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56910. */
  56911. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56912. /**
  56913. * An event triggered when the generated texture is being merged in the scene.
  56914. */
  56915. onBeforeComposeObservable: Observable<EffectLayer>;
  56916. /**
  56917. * An event triggered when the mesh is rendered into the effect render target.
  56918. */
  56919. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56920. /**
  56921. * An event triggered after the mesh has been rendered into the effect render target.
  56922. */
  56923. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56924. /**
  56925. * An event triggered when the generated texture has been merged in the scene.
  56926. */
  56927. onAfterComposeObservable: Observable<EffectLayer>;
  56928. /**
  56929. * An event triggered when the efffect layer changes its size.
  56930. */
  56931. onSizeChangedObservable: Observable<EffectLayer>;
  56932. /** @hidden */
  56933. static _SceneComponentInitialization: (scene: Scene) => void;
  56934. /**
  56935. * Instantiates a new effect Layer and references it in the scene.
  56936. * @param name The name of the layer
  56937. * @param scene The scene to use the layer in
  56938. */
  56939. constructor(
  56940. /** The Friendly of the effect in the scene */
  56941. name: string, scene: Scene);
  56942. /**
  56943. * Get the effect name of the layer.
  56944. * @return The effect name
  56945. */
  56946. abstract getEffectName(): string;
  56947. /**
  56948. * Checks for the readiness of the element composing the layer.
  56949. * @param subMesh the mesh to check for
  56950. * @param useInstances specify whether or not to use instances to render the mesh
  56951. * @return true if ready otherwise, false
  56952. */
  56953. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56954. /**
  56955. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56956. * @returns true if the effect requires stencil during the main canvas render pass.
  56957. */
  56958. abstract needStencil(): boolean;
  56959. /**
  56960. * Create the merge effect. This is the shader use to blit the information back
  56961. * to the main canvas at the end of the scene rendering.
  56962. * @returns The effect containing the shader used to merge the effect on the main canvas
  56963. */
  56964. protected abstract _createMergeEffect(): Effect;
  56965. /**
  56966. * Creates the render target textures and post processes used in the effect layer.
  56967. */
  56968. protected abstract _createTextureAndPostProcesses(): void;
  56969. /**
  56970. * Implementation specific of rendering the generating effect on the main canvas.
  56971. * @param effect The effect used to render through
  56972. */
  56973. protected abstract _internalRender(effect: Effect): void;
  56974. /**
  56975. * Sets the required values for both the emissive texture and and the main color.
  56976. */
  56977. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56978. /**
  56979. * Free any resources and references associated to a mesh.
  56980. * Internal use
  56981. * @param mesh The mesh to free.
  56982. */
  56983. abstract _disposeMesh(mesh: Mesh): void;
  56984. /**
  56985. * Serializes this layer (Glow or Highlight for example)
  56986. * @returns a serialized layer object
  56987. */
  56988. abstract serialize?(): any;
  56989. /**
  56990. * Initializes the effect layer with the required options.
  56991. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56992. */
  56993. protected _init(options: Partial<IEffectLayerOptions>): void;
  56994. /**
  56995. * Generates the index buffer of the full screen quad blending to the main canvas.
  56996. */
  56997. private _generateIndexBuffer;
  56998. /**
  56999. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57000. */
  57001. private _generateVertexBuffer;
  57002. /**
  57003. * Sets the main texture desired size which is the closest power of two
  57004. * of the engine canvas size.
  57005. */
  57006. private _setMainTextureSize;
  57007. /**
  57008. * Creates the main texture for the effect layer.
  57009. */
  57010. protected _createMainTexture(): void;
  57011. /**
  57012. * Adds specific effects defines.
  57013. * @param defines The defines to add specifics to.
  57014. */
  57015. protected _addCustomEffectDefines(defines: string[]): void;
  57016. /**
  57017. * Checks for the readiness of the element composing the layer.
  57018. * @param subMesh the mesh to check for
  57019. * @param useInstances specify whether or not to use instances to render the mesh
  57020. * @param emissiveTexture the associated emissive texture used to generate the glow
  57021. * @return true if ready otherwise, false
  57022. */
  57023. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57024. /**
  57025. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57026. */
  57027. render(): void;
  57028. /**
  57029. * Determine if a given mesh will be used in the current effect.
  57030. * @param mesh mesh to test
  57031. * @returns true if the mesh will be used
  57032. */
  57033. hasMesh(mesh: AbstractMesh): boolean;
  57034. /**
  57035. * Returns true if the layer contains information to display, otherwise false.
  57036. * @returns true if the glow layer should be rendered
  57037. */
  57038. shouldRender(): boolean;
  57039. /**
  57040. * Returns true if the mesh should render, otherwise false.
  57041. * @param mesh The mesh to render
  57042. * @returns true if it should render otherwise false
  57043. */
  57044. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57045. /**
  57046. * Returns true if the mesh can be rendered, otherwise false.
  57047. * @param mesh The mesh to render
  57048. * @param material The material used on the mesh
  57049. * @returns true if it can be rendered otherwise false
  57050. */
  57051. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57052. /**
  57053. * Returns true if the mesh should render, otherwise false.
  57054. * @param mesh The mesh to render
  57055. * @returns true if it should render otherwise false
  57056. */
  57057. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57058. /**
  57059. * Renders the submesh passed in parameter to the generation map.
  57060. */
  57061. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57062. /**
  57063. * Defines whether the current material of the mesh should be use to render the effect.
  57064. * @param mesh defines the current mesh to render
  57065. */
  57066. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57067. /**
  57068. * Rebuild the required buffers.
  57069. * @hidden Internal use only.
  57070. */
  57071. _rebuild(): void;
  57072. /**
  57073. * Dispose only the render target textures and post process.
  57074. */
  57075. private _disposeTextureAndPostProcesses;
  57076. /**
  57077. * Dispose the highlight layer and free resources.
  57078. */
  57079. dispose(): void;
  57080. /**
  57081. * Gets the class name of the effect layer
  57082. * @returns the string with the class name of the effect layer
  57083. */
  57084. getClassName(): string;
  57085. /**
  57086. * Creates an effect layer from parsed effect layer data
  57087. * @param parsedEffectLayer defines effect layer data
  57088. * @param scene defines the current scene
  57089. * @param rootUrl defines the root URL containing the effect layer information
  57090. * @returns a parsed effect Layer
  57091. */
  57092. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57093. }
  57094. }
  57095. declare module BABYLON {
  57096. interface AbstractScene {
  57097. /**
  57098. * The list of effect layers (highlights/glow) added to the scene
  57099. * @see http://doc.babylonjs.com/how_to/highlight_layer
  57100. * @see http://doc.babylonjs.com/how_to/glow_layer
  57101. */
  57102. effectLayers: Array<EffectLayer>;
  57103. /**
  57104. * Removes the given effect layer from this scene.
  57105. * @param toRemove defines the effect layer to remove
  57106. * @returns the index of the removed effect layer
  57107. */
  57108. removeEffectLayer(toRemove: EffectLayer): number;
  57109. /**
  57110. * Adds the given effect layer to this scene
  57111. * @param newEffectLayer defines the effect layer to add
  57112. */
  57113. addEffectLayer(newEffectLayer: EffectLayer): void;
  57114. }
  57115. /**
  57116. * Defines the layer scene component responsible to manage any effect layers
  57117. * in a given scene.
  57118. */
  57119. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57120. /**
  57121. * The component name helpfull to identify the component in the list of scene components.
  57122. */
  57123. readonly name: string;
  57124. /**
  57125. * The scene the component belongs to.
  57126. */
  57127. scene: Scene;
  57128. private _engine;
  57129. private _renderEffects;
  57130. private _needStencil;
  57131. private _previousStencilState;
  57132. /**
  57133. * Creates a new instance of the component for the given scene
  57134. * @param scene Defines the scene to register the component in
  57135. */
  57136. constructor(scene: Scene);
  57137. /**
  57138. * Registers the component in a given scene
  57139. */
  57140. register(): void;
  57141. /**
  57142. * Rebuilds the elements related to this component in case of
  57143. * context lost for instance.
  57144. */
  57145. rebuild(): void;
  57146. /**
  57147. * Serializes the component data to the specified json object
  57148. * @param serializationObject The object to serialize to
  57149. */
  57150. serialize(serializationObject: any): void;
  57151. /**
  57152. * Adds all the elements from the container to the scene
  57153. * @param container the container holding the elements
  57154. */
  57155. addFromContainer(container: AbstractScene): void;
  57156. /**
  57157. * Removes all the elements in the container from the scene
  57158. * @param container contains the elements to remove
  57159. * @param dispose if the removed element should be disposed (default: false)
  57160. */
  57161. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57162. /**
  57163. * Disposes the component and the associated ressources.
  57164. */
  57165. dispose(): void;
  57166. private _isReadyForMesh;
  57167. private _renderMainTexture;
  57168. private _setStencil;
  57169. private _setStencilBack;
  57170. private _draw;
  57171. private _drawCamera;
  57172. private _drawRenderingGroup;
  57173. }
  57174. }
  57175. declare module BABYLON {
  57176. /** @hidden */
  57177. export var glowMapMergePixelShader: {
  57178. name: string;
  57179. shader: string;
  57180. };
  57181. }
  57182. declare module BABYLON {
  57183. /** @hidden */
  57184. export var glowMapMergeVertexShader: {
  57185. name: string;
  57186. shader: string;
  57187. };
  57188. }
  57189. declare module BABYLON {
  57190. interface AbstractScene {
  57191. /**
  57192. * Return a the first highlight layer of the scene with a given name.
  57193. * @param name The name of the highlight layer to look for.
  57194. * @return The highlight layer if found otherwise null.
  57195. */
  57196. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57197. }
  57198. /**
  57199. * Glow layer options. This helps customizing the behaviour
  57200. * of the glow layer.
  57201. */
  57202. export interface IGlowLayerOptions {
  57203. /**
  57204. * Multiplication factor apply to the canvas size to compute the render target size
  57205. * used to generated the glowing objects (the smaller the faster).
  57206. */
  57207. mainTextureRatio: number;
  57208. /**
  57209. * Enforces a fixed size texture to ensure resize independant blur.
  57210. */
  57211. mainTextureFixedSize?: number;
  57212. /**
  57213. * How big is the kernel of the blur texture.
  57214. */
  57215. blurKernelSize: number;
  57216. /**
  57217. * The camera attached to the layer.
  57218. */
  57219. camera: Nullable<Camera>;
  57220. /**
  57221. * Enable MSAA by chosing the number of samples.
  57222. */
  57223. mainTextureSamples?: number;
  57224. /**
  57225. * The rendering group to draw the layer in.
  57226. */
  57227. renderingGroupId: number;
  57228. }
  57229. /**
  57230. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57231. *
  57232. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57233. *
  57234. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57235. */
  57236. export class GlowLayer extends EffectLayer {
  57237. /**
  57238. * Effect Name of the layer.
  57239. */
  57240. static readonly EffectName: string;
  57241. /**
  57242. * The default blur kernel size used for the glow.
  57243. */
  57244. static DefaultBlurKernelSize: number;
  57245. /**
  57246. * The default texture size ratio used for the glow.
  57247. */
  57248. static DefaultTextureRatio: number;
  57249. /**
  57250. * Sets the kernel size of the blur.
  57251. */
  57252. set blurKernelSize(value: number);
  57253. /**
  57254. * Gets the kernel size of the blur.
  57255. */
  57256. get blurKernelSize(): number;
  57257. /**
  57258. * Sets the glow intensity.
  57259. */
  57260. set intensity(value: number);
  57261. /**
  57262. * Gets the glow intensity.
  57263. */
  57264. get intensity(): number;
  57265. private _options;
  57266. private _intensity;
  57267. private _horizontalBlurPostprocess1;
  57268. private _verticalBlurPostprocess1;
  57269. private _horizontalBlurPostprocess2;
  57270. private _verticalBlurPostprocess2;
  57271. private _blurTexture1;
  57272. private _blurTexture2;
  57273. private _postProcesses1;
  57274. private _postProcesses2;
  57275. private _includedOnlyMeshes;
  57276. private _excludedMeshes;
  57277. private _meshesUsingTheirOwnMaterials;
  57278. /**
  57279. * Callback used to let the user override the color selection on a per mesh basis
  57280. */
  57281. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57282. /**
  57283. * Callback used to let the user override the texture selection on a per mesh basis
  57284. */
  57285. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57286. /**
  57287. * Instantiates a new glow Layer and references it to the scene.
  57288. * @param name The name of the layer
  57289. * @param scene The scene to use the layer in
  57290. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57291. */
  57292. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57293. /**
  57294. * Get the effect name of the layer.
  57295. * @return The effect name
  57296. */
  57297. getEffectName(): string;
  57298. /**
  57299. * Create the merge effect. This is the shader use to blit the information back
  57300. * to the main canvas at the end of the scene rendering.
  57301. */
  57302. protected _createMergeEffect(): Effect;
  57303. /**
  57304. * Creates the render target textures and post processes used in the glow layer.
  57305. */
  57306. protected _createTextureAndPostProcesses(): void;
  57307. /**
  57308. * Checks for the readiness of the element composing the layer.
  57309. * @param subMesh the mesh to check for
  57310. * @param useInstances specify wether or not to use instances to render the mesh
  57311. * @param emissiveTexture the associated emissive texture used to generate the glow
  57312. * @return true if ready otherwise, false
  57313. */
  57314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57315. /**
  57316. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57317. */
  57318. needStencil(): boolean;
  57319. /**
  57320. * Returns true if the mesh can be rendered, otherwise false.
  57321. * @param mesh The mesh to render
  57322. * @param material The material used on the mesh
  57323. * @returns true if it can be rendered otherwise false
  57324. */
  57325. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57326. /**
  57327. * Implementation specific of rendering the generating effect on the main canvas.
  57328. * @param effect The effect used to render through
  57329. */
  57330. protected _internalRender(effect: Effect): void;
  57331. /**
  57332. * Sets the required values for both the emissive texture and and the main color.
  57333. */
  57334. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57335. /**
  57336. * Returns true if the mesh should render, otherwise false.
  57337. * @param mesh The mesh to render
  57338. * @returns true if it should render otherwise false
  57339. */
  57340. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57341. /**
  57342. * Adds specific effects defines.
  57343. * @param defines The defines to add specifics to.
  57344. */
  57345. protected _addCustomEffectDefines(defines: string[]): void;
  57346. /**
  57347. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57348. * @param mesh The mesh to exclude from the glow layer
  57349. */
  57350. addExcludedMesh(mesh: Mesh): void;
  57351. /**
  57352. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57353. * @param mesh The mesh to remove
  57354. */
  57355. removeExcludedMesh(mesh: Mesh): void;
  57356. /**
  57357. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57358. * @param mesh The mesh to include in the glow layer
  57359. */
  57360. addIncludedOnlyMesh(mesh: Mesh): void;
  57361. /**
  57362. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57363. * @param mesh The mesh to remove
  57364. */
  57365. removeIncludedOnlyMesh(mesh: Mesh): void;
  57366. /**
  57367. * Determine if a given mesh will be used in the glow layer
  57368. * @param mesh The mesh to test
  57369. * @returns true if the mesh will be highlighted by the current glow layer
  57370. */
  57371. hasMesh(mesh: AbstractMesh): boolean;
  57372. /**
  57373. * Defines whether the current material of the mesh should be use to render the effect.
  57374. * @param mesh defines the current mesh to render
  57375. */
  57376. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57377. /**
  57378. * Add a mesh to be rendered through its own material and not with emissive only.
  57379. * @param mesh The mesh for which we need to use its material
  57380. */
  57381. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57382. /**
  57383. * Remove a mesh from being rendered through its own material and not with emissive only.
  57384. * @param mesh The mesh for which we need to not use its material
  57385. */
  57386. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57387. /**
  57388. * Free any resources and references associated to a mesh.
  57389. * Internal use
  57390. * @param mesh The mesh to free.
  57391. * @hidden
  57392. */
  57393. _disposeMesh(mesh: Mesh): void;
  57394. /**
  57395. * Gets the class name of the effect layer
  57396. * @returns the string with the class name of the effect layer
  57397. */
  57398. getClassName(): string;
  57399. /**
  57400. * Serializes this glow layer
  57401. * @returns a serialized glow layer object
  57402. */
  57403. serialize(): any;
  57404. /**
  57405. * Creates a Glow Layer from parsed glow layer data
  57406. * @param parsedGlowLayer defines glow layer data
  57407. * @param scene defines the current scene
  57408. * @param rootUrl defines the root URL containing the glow layer information
  57409. * @returns a parsed Glow Layer
  57410. */
  57411. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57412. }
  57413. }
  57414. declare module BABYLON {
  57415. /** @hidden */
  57416. export var glowBlurPostProcessPixelShader: {
  57417. name: string;
  57418. shader: string;
  57419. };
  57420. }
  57421. declare module BABYLON {
  57422. interface AbstractScene {
  57423. /**
  57424. * Return a the first highlight layer of the scene with a given name.
  57425. * @param name The name of the highlight layer to look for.
  57426. * @return The highlight layer if found otherwise null.
  57427. */
  57428. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57429. }
  57430. /**
  57431. * Highlight layer options. This helps customizing the behaviour
  57432. * of the highlight layer.
  57433. */
  57434. export interface IHighlightLayerOptions {
  57435. /**
  57436. * Multiplication factor apply to the canvas size to compute the render target size
  57437. * used to generated the glowing objects (the smaller the faster).
  57438. */
  57439. mainTextureRatio: number;
  57440. /**
  57441. * Enforces a fixed size texture to ensure resize independant blur.
  57442. */
  57443. mainTextureFixedSize?: number;
  57444. /**
  57445. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57446. * of the picture to blur (the smaller the faster).
  57447. */
  57448. blurTextureSizeRatio: number;
  57449. /**
  57450. * How big in texel of the blur texture is the vertical blur.
  57451. */
  57452. blurVerticalSize: number;
  57453. /**
  57454. * How big in texel of the blur texture is the horizontal blur.
  57455. */
  57456. blurHorizontalSize: number;
  57457. /**
  57458. * Alpha blending mode used to apply the blur. Default is combine.
  57459. */
  57460. alphaBlendingMode: number;
  57461. /**
  57462. * The camera attached to the layer.
  57463. */
  57464. camera: Nullable<Camera>;
  57465. /**
  57466. * Should we display highlight as a solid stroke?
  57467. */
  57468. isStroke?: boolean;
  57469. /**
  57470. * The rendering group to draw the layer in.
  57471. */
  57472. renderingGroupId: number;
  57473. }
  57474. /**
  57475. * The highlight layer Helps adding a glow effect around a mesh.
  57476. *
  57477. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57478. * glowy meshes to your scene.
  57479. *
  57480. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57481. */
  57482. export class HighlightLayer extends EffectLayer {
  57483. name: string;
  57484. /**
  57485. * Effect Name of the highlight layer.
  57486. */
  57487. static readonly EffectName: string;
  57488. /**
  57489. * The neutral color used during the preparation of the glow effect.
  57490. * This is black by default as the blend operation is a blend operation.
  57491. */
  57492. static NeutralColor: Color4;
  57493. /**
  57494. * Stencil value used for glowing meshes.
  57495. */
  57496. static GlowingMeshStencilReference: number;
  57497. /**
  57498. * Stencil value used for the other meshes in the scene.
  57499. */
  57500. static NormalMeshStencilReference: number;
  57501. /**
  57502. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57503. */
  57504. innerGlow: boolean;
  57505. /**
  57506. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57507. */
  57508. outerGlow: boolean;
  57509. /**
  57510. * Specifies the horizontal size of the blur.
  57511. */
  57512. set blurHorizontalSize(value: number);
  57513. /**
  57514. * Specifies the vertical size of the blur.
  57515. */
  57516. set blurVerticalSize(value: number);
  57517. /**
  57518. * Gets the horizontal size of the blur.
  57519. */
  57520. get blurHorizontalSize(): number;
  57521. /**
  57522. * Gets the vertical size of the blur.
  57523. */
  57524. get blurVerticalSize(): number;
  57525. /**
  57526. * An event triggered when the highlight layer is being blurred.
  57527. */
  57528. onBeforeBlurObservable: Observable<HighlightLayer>;
  57529. /**
  57530. * An event triggered when the highlight layer has been blurred.
  57531. */
  57532. onAfterBlurObservable: Observable<HighlightLayer>;
  57533. private _instanceGlowingMeshStencilReference;
  57534. private _options;
  57535. private _downSamplePostprocess;
  57536. private _horizontalBlurPostprocess;
  57537. private _verticalBlurPostprocess;
  57538. private _blurTexture;
  57539. private _meshes;
  57540. private _excludedMeshes;
  57541. /**
  57542. * Instantiates a new highlight Layer and references it to the scene..
  57543. * @param name The name of the layer
  57544. * @param scene The scene to use the layer in
  57545. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57546. */
  57547. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57548. /**
  57549. * Get the effect name of the layer.
  57550. * @return The effect name
  57551. */
  57552. getEffectName(): string;
  57553. /**
  57554. * Create the merge effect. This is the shader use to blit the information back
  57555. * to the main canvas at the end of the scene rendering.
  57556. */
  57557. protected _createMergeEffect(): Effect;
  57558. /**
  57559. * Creates the render target textures and post processes used in the highlight layer.
  57560. */
  57561. protected _createTextureAndPostProcesses(): void;
  57562. /**
  57563. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57564. */
  57565. needStencil(): boolean;
  57566. /**
  57567. * Checks for the readiness of the element composing the layer.
  57568. * @param subMesh the mesh to check for
  57569. * @param useInstances specify wether or not to use instances to render the mesh
  57570. * @param emissiveTexture the associated emissive texture used to generate the glow
  57571. * @return true if ready otherwise, false
  57572. */
  57573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57574. /**
  57575. * Implementation specific of rendering the generating effect on the main canvas.
  57576. * @param effect The effect used to render through
  57577. */
  57578. protected _internalRender(effect: Effect): void;
  57579. /**
  57580. * Returns true if the layer contains information to display, otherwise false.
  57581. */
  57582. shouldRender(): boolean;
  57583. /**
  57584. * Returns true if the mesh should render, otherwise false.
  57585. * @param mesh The mesh to render
  57586. * @returns true if it should render otherwise false
  57587. */
  57588. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57589. /**
  57590. * Adds specific effects defines.
  57591. * @param defines The defines to add specifics to.
  57592. */
  57593. protected _addCustomEffectDefines(defines: string[]): void;
  57594. /**
  57595. * Sets the required values for both the emissive texture and and the main color.
  57596. */
  57597. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57598. /**
  57599. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57600. * @param mesh The mesh to exclude from the highlight layer
  57601. */
  57602. addExcludedMesh(mesh: Mesh): void;
  57603. /**
  57604. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57605. * @param mesh The mesh to highlight
  57606. */
  57607. removeExcludedMesh(mesh: Mesh): void;
  57608. /**
  57609. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57610. * @param mesh mesh to test
  57611. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57612. */
  57613. hasMesh(mesh: AbstractMesh): boolean;
  57614. /**
  57615. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57616. * @param mesh The mesh to highlight
  57617. * @param color The color of the highlight
  57618. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57619. */
  57620. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57621. /**
  57622. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57623. * @param mesh The mesh to highlight
  57624. */
  57625. removeMesh(mesh: Mesh): void;
  57626. /**
  57627. * Remove all the meshes currently referenced in the highlight layer
  57628. */
  57629. removeAllMeshes(): void;
  57630. /**
  57631. * Force the stencil to the normal expected value for none glowing parts
  57632. */
  57633. private _defaultStencilReference;
  57634. /**
  57635. * Free any resources and references associated to a mesh.
  57636. * Internal use
  57637. * @param mesh The mesh to free.
  57638. * @hidden
  57639. */
  57640. _disposeMesh(mesh: Mesh): void;
  57641. /**
  57642. * Dispose the highlight layer and free resources.
  57643. */
  57644. dispose(): void;
  57645. /**
  57646. * Gets the class name of the effect layer
  57647. * @returns the string with the class name of the effect layer
  57648. */
  57649. getClassName(): string;
  57650. /**
  57651. * Serializes this Highlight layer
  57652. * @returns a serialized Highlight layer object
  57653. */
  57654. serialize(): any;
  57655. /**
  57656. * Creates a Highlight layer from parsed Highlight layer data
  57657. * @param parsedHightlightLayer defines the Highlight layer data
  57658. * @param scene defines the current scene
  57659. * @param rootUrl defines the root URL containing the Highlight layer information
  57660. * @returns a parsed Highlight layer
  57661. */
  57662. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57663. }
  57664. }
  57665. declare module BABYLON {
  57666. interface AbstractScene {
  57667. /**
  57668. * The list of layers (background and foreground) of the scene
  57669. */
  57670. layers: Array<Layer>;
  57671. }
  57672. /**
  57673. * Defines the layer scene component responsible to manage any layers
  57674. * in a given scene.
  57675. */
  57676. export class LayerSceneComponent implements ISceneComponent {
  57677. /**
  57678. * The component name helpfull to identify the component in the list of scene components.
  57679. */
  57680. readonly name: string;
  57681. /**
  57682. * The scene the component belongs to.
  57683. */
  57684. scene: Scene;
  57685. private _engine;
  57686. /**
  57687. * Creates a new instance of the component for the given scene
  57688. * @param scene Defines the scene to register the component in
  57689. */
  57690. constructor(scene: Scene);
  57691. /**
  57692. * Registers the component in a given scene
  57693. */
  57694. register(): void;
  57695. /**
  57696. * Rebuilds the elements related to this component in case of
  57697. * context lost for instance.
  57698. */
  57699. rebuild(): void;
  57700. /**
  57701. * Disposes the component and the associated ressources.
  57702. */
  57703. dispose(): void;
  57704. private _draw;
  57705. private _drawCameraPredicate;
  57706. private _drawCameraBackground;
  57707. private _drawCameraForeground;
  57708. private _drawRenderTargetPredicate;
  57709. private _drawRenderTargetBackground;
  57710. private _drawRenderTargetForeground;
  57711. /**
  57712. * Adds all the elements from the container to the scene
  57713. * @param container the container holding the elements
  57714. */
  57715. addFromContainer(container: AbstractScene): void;
  57716. /**
  57717. * Removes all the elements in the container from the scene
  57718. * @param container contains the elements to remove
  57719. * @param dispose if the removed element should be disposed (default: false)
  57720. */
  57721. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57722. }
  57723. }
  57724. declare module BABYLON {
  57725. /** @hidden */
  57726. export var layerPixelShader: {
  57727. name: string;
  57728. shader: string;
  57729. };
  57730. }
  57731. declare module BABYLON {
  57732. /** @hidden */
  57733. export var layerVertexShader: {
  57734. name: string;
  57735. shader: string;
  57736. };
  57737. }
  57738. declare module BABYLON {
  57739. /**
  57740. * This represents a full screen 2d layer.
  57741. * This can be useful to display a picture in the background of your scene for instance.
  57742. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57743. */
  57744. export class Layer {
  57745. /**
  57746. * Define the name of the layer.
  57747. */
  57748. name: string;
  57749. /**
  57750. * Define the texture the layer should display.
  57751. */
  57752. texture: Nullable<Texture>;
  57753. /**
  57754. * Is the layer in background or foreground.
  57755. */
  57756. isBackground: boolean;
  57757. /**
  57758. * Define the color of the layer (instead of texture).
  57759. */
  57760. color: Color4;
  57761. /**
  57762. * Define the scale of the layer in order to zoom in out of the texture.
  57763. */
  57764. scale: Vector2;
  57765. /**
  57766. * Define an offset for the layer in order to shift the texture.
  57767. */
  57768. offset: Vector2;
  57769. /**
  57770. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57771. */
  57772. alphaBlendingMode: number;
  57773. /**
  57774. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57775. * Alpha test will not mix with the background color in case of transparency.
  57776. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57777. */
  57778. alphaTest: boolean;
  57779. /**
  57780. * Define a mask to restrict the layer to only some of the scene cameras.
  57781. */
  57782. layerMask: number;
  57783. /**
  57784. * Define the list of render target the layer is visible into.
  57785. */
  57786. renderTargetTextures: RenderTargetTexture[];
  57787. /**
  57788. * Define if the layer is only used in renderTarget or if it also
  57789. * renders in the main frame buffer of the canvas.
  57790. */
  57791. renderOnlyInRenderTargetTextures: boolean;
  57792. private _scene;
  57793. private _vertexBuffers;
  57794. private _indexBuffer;
  57795. private _effect;
  57796. private _previousDefines;
  57797. /**
  57798. * An event triggered when the layer is disposed.
  57799. */
  57800. onDisposeObservable: Observable<Layer>;
  57801. private _onDisposeObserver;
  57802. /**
  57803. * Back compatibility with callback before the onDisposeObservable existed.
  57804. * The set callback will be triggered when the layer has been disposed.
  57805. */
  57806. set onDispose(callback: () => void);
  57807. /**
  57808. * An event triggered before rendering the scene
  57809. */
  57810. onBeforeRenderObservable: Observable<Layer>;
  57811. private _onBeforeRenderObserver;
  57812. /**
  57813. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57814. * The set callback will be triggered just before rendering the layer.
  57815. */
  57816. set onBeforeRender(callback: () => void);
  57817. /**
  57818. * An event triggered after rendering the scene
  57819. */
  57820. onAfterRenderObservable: Observable<Layer>;
  57821. private _onAfterRenderObserver;
  57822. /**
  57823. * Back compatibility with callback before the onAfterRenderObservable existed.
  57824. * The set callback will be triggered just after rendering the layer.
  57825. */
  57826. set onAfterRender(callback: () => void);
  57827. /**
  57828. * Instantiates a new layer.
  57829. * This represents a full screen 2d layer.
  57830. * This can be useful to display a picture in the background of your scene for instance.
  57831. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57832. * @param name Define the name of the layer in the scene
  57833. * @param imgUrl Define the url of the texture to display in the layer
  57834. * @param scene Define the scene the layer belongs to
  57835. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57836. * @param color Defines a color for the layer
  57837. */
  57838. constructor(
  57839. /**
  57840. * Define the name of the layer.
  57841. */
  57842. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57843. private _createIndexBuffer;
  57844. /** @hidden */
  57845. _rebuild(): void;
  57846. /**
  57847. * Renders the layer in the scene.
  57848. */
  57849. render(): void;
  57850. /**
  57851. * Disposes and releases the associated ressources.
  57852. */
  57853. dispose(): void;
  57854. }
  57855. }
  57856. declare module BABYLON {
  57857. /** @hidden */
  57858. export var lensFlarePixelShader: {
  57859. name: string;
  57860. shader: string;
  57861. };
  57862. }
  57863. declare module BABYLON {
  57864. /** @hidden */
  57865. export var lensFlareVertexShader: {
  57866. name: string;
  57867. shader: string;
  57868. };
  57869. }
  57870. declare module BABYLON {
  57871. /**
  57872. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57873. * It is usually composed of several `lensFlare`.
  57874. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57875. */
  57876. export class LensFlareSystem {
  57877. /**
  57878. * Define the name of the lens flare system
  57879. */
  57880. name: string;
  57881. /**
  57882. * List of lens flares used in this system.
  57883. */
  57884. lensFlares: LensFlare[];
  57885. /**
  57886. * Define a limit from the border the lens flare can be visible.
  57887. */
  57888. borderLimit: number;
  57889. /**
  57890. * Define a viewport border we do not want to see the lens flare in.
  57891. */
  57892. viewportBorder: number;
  57893. /**
  57894. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57895. */
  57896. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57897. /**
  57898. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57899. */
  57900. layerMask: number;
  57901. /**
  57902. * Define the id of the lens flare system in the scene.
  57903. * (equal to name by default)
  57904. */
  57905. id: string;
  57906. private _scene;
  57907. private _emitter;
  57908. private _vertexBuffers;
  57909. private _indexBuffer;
  57910. private _effect;
  57911. private _positionX;
  57912. private _positionY;
  57913. private _isEnabled;
  57914. /** @hidden */
  57915. static _SceneComponentInitialization: (scene: Scene) => void;
  57916. /**
  57917. * Instantiates a lens flare system.
  57918. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57919. * It is usually composed of several `lensFlare`.
  57920. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57921. * @param name Define the name of the lens flare system in the scene
  57922. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57923. * @param scene Define the scene the lens flare system belongs to
  57924. */
  57925. constructor(
  57926. /**
  57927. * Define the name of the lens flare system
  57928. */
  57929. name: string, emitter: any, scene: Scene);
  57930. /**
  57931. * Define if the lens flare system is enabled.
  57932. */
  57933. get isEnabled(): boolean;
  57934. set isEnabled(value: boolean);
  57935. /**
  57936. * Get the scene the effects belongs to.
  57937. * @returns the scene holding the lens flare system
  57938. */
  57939. getScene(): Scene;
  57940. /**
  57941. * Get the emitter of the lens flare system.
  57942. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57943. * @returns the emitter of the lens flare system
  57944. */
  57945. getEmitter(): any;
  57946. /**
  57947. * Set the emitter of the lens flare system.
  57948. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57949. * @param newEmitter Define the new emitter of the system
  57950. */
  57951. setEmitter(newEmitter: any): void;
  57952. /**
  57953. * Get the lens flare system emitter position.
  57954. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57955. * @returns the position
  57956. */
  57957. getEmitterPosition(): Vector3;
  57958. /**
  57959. * @hidden
  57960. */
  57961. computeEffectivePosition(globalViewport: Viewport): boolean;
  57962. /** @hidden */
  57963. _isVisible(): boolean;
  57964. /**
  57965. * @hidden
  57966. */
  57967. render(): boolean;
  57968. /**
  57969. * Dispose and release the lens flare with its associated resources.
  57970. */
  57971. dispose(): void;
  57972. /**
  57973. * Parse a lens flare system from a JSON repressentation
  57974. * @param parsedLensFlareSystem Define the JSON to parse
  57975. * @param scene Define the scene the parsed system should be instantiated in
  57976. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57977. * @returns the parsed system
  57978. */
  57979. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57980. /**
  57981. * Serialize the current Lens Flare System into a JSON representation.
  57982. * @returns the serialized JSON
  57983. */
  57984. serialize(): any;
  57985. }
  57986. }
  57987. declare module BABYLON {
  57988. /**
  57989. * This represents one of the lens effect in a `lensFlareSystem`.
  57990. * It controls one of the indiviual texture used in the effect.
  57991. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57992. */
  57993. export class LensFlare {
  57994. /**
  57995. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  57996. */
  57997. size: number;
  57998. /**
  57999. * 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.
  58000. */
  58001. position: number;
  58002. /**
  58003. * Define the lens color.
  58004. */
  58005. color: Color3;
  58006. /**
  58007. * Define the lens texture.
  58008. */
  58009. texture: Nullable<Texture>;
  58010. /**
  58011. * Define the alpha mode to render this particular lens.
  58012. */
  58013. alphaMode: number;
  58014. private _system;
  58015. /**
  58016. * Creates a new Lens Flare.
  58017. * This represents one of the lens effect in a `lensFlareSystem`.
  58018. * It controls one of the indiviual texture used in the effect.
  58019. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58020. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58021. * @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.
  58022. * @param color Define the lens color
  58023. * @param imgUrl Define the lens texture url
  58024. * @param system Define the `lensFlareSystem` this flare is part of
  58025. * @returns The newly created Lens Flare
  58026. */
  58027. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58028. /**
  58029. * Instantiates a new Lens Flare.
  58030. * This represents one of the lens effect in a `lensFlareSystem`.
  58031. * It controls one of the indiviual texture used in the effect.
  58032. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58033. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58034. * @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.
  58035. * @param color Define the lens color
  58036. * @param imgUrl Define the lens texture url
  58037. * @param system Define the `lensFlareSystem` this flare is part of
  58038. */
  58039. constructor(
  58040. /**
  58041. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58042. */
  58043. size: number,
  58044. /**
  58045. * 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.
  58046. */
  58047. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58048. /**
  58049. * Dispose and release the lens flare with its associated resources.
  58050. */
  58051. dispose(): void;
  58052. }
  58053. }
  58054. declare module BABYLON {
  58055. interface AbstractScene {
  58056. /**
  58057. * The list of lens flare system added to the scene
  58058. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58059. */
  58060. lensFlareSystems: Array<LensFlareSystem>;
  58061. /**
  58062. * Removes the given lens flare system from this scene.
  58063. * @param toRemove The lens flare system to remove
  58064. * @returns The index of the removed lens flare system
  58065. */
  58066. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58067. /**
  58068. * Adds the given lens flare system to this scene
  58069. * @param newLensFlareSystem The lens flare system to add
  58070. */
  58071. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58072. /**
  58073. * Gets a lens flare system using its name
  58074. * @param name defines the name to look for
  58075. * @returns the lens flare system or null if not found
  58076. */
  58077. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58078. /**
  58079. * Gets a lens flare system using its id
  58080. * @param id defines the id to look for
  58081. * @returns the lens flare system or null if not found
  58082. */
  58083. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58084. }
  58085. /**
  58086. * Defines the lens flare scene component responsible to manage any lens flares
  58087. * in a given scene.
  58088. */
  58089. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58090. /**
  58091. * The component name helpfull to identify the component in the list of scene components.
  58092. */
  58093. readonly name: string;
  58094. /**
  58095. * The scene the component belongs to.
  58096. */
  58097. scene: Scene;
  58098. /**
  58099. * Creates a new instance of the component for the given scene
  58100. * @param scene Defines the scene to register the component in
  58101. */
  58102. constructor(scene: Scene);
  58103. /**
  58104. * Registers the component in a given scene
  58105. */
  58106. register(): void;
  58107. /**
  58108. * Rebuilds the elements related to this component in case of
  58109. * context lost for instance.
  58110. */
  58111. rebuild(): void;
  58112. /**
  58113. * Adds all the elements from the container to the scene
  58114. * @param container the container holding the elements
  58115. */
  58116. addFromContainer(container: AbstractScene): void;
  58117. /**
  58118. * Removes all the elements in the container from the scene
  58119. * @param container contains the elements to remove
  58120. * @param dispose if the removed element should be disposed (default: false)
  58121. */
  58122. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58123. /**
  58124. * Serializes the component data to the specified json object
  58125. * @param serializationObject The object to serialize to
  58126. */
  58127. serialize(serializationObject: any): void;
  58128. /**
  58129. * Disposes the component and the associated ressources.
  58130. */
  58131. dispose(): void;
  58132. private _draw;
  58133. }
  58134. }
  58135. declare module BABYLON {
  58136. /** @hidden */
  58137. export var depthPixelShader: {
  58138. name: string;
  58139. shader: string;
  58140. };
  58141. }
  58142. declare module BABYLON {
  58143. /** @hidden */
  58144. export var depthVertexShader: {
  58145. name: string;
  58146. shader: string;
  58147. };
  58148. }
  58149. declare module BABYLON {
  58150. /**
  58151. * This represents a depth renderer in Babylon.
  58152. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58153. */
  58154. export class DepthRenderer {
  58155. private _scene;
  58156. private _depthMap;
  58157. private _effect;
  58158. private readonly _storeNonLinearDepth;
  58159. private readonly _clearColor;
  58160. /** Get if the depth renderer is using packed depth or not */
  58161. readonly isPacked: boolean;
  58162. private _cachedDefines;
  58163. private _camera;
  58164. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58165. enabled: boolean;
  58166. /**
  58167. * Specifiess that the depth renderer will only be used within
  58168. * the camera it is created for.
  58169. * This can help forcing its rendering during the camera processing.
  58170. */
  58171. useOnlyInActiveCamera: boolean;
  58172. /** @hidden */
  58173. static _SceneComponentInitialization: (scene: Scene) => void;
  58174. /**
  58175. * Instantiates a depth renderer
  58176. * @param scene The scene the renderer belongs to
  58177. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58178. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58179. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58180. */
  58181. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58182. /**
  58183. * Creates the depth rendering effect and checks if the effect is ready.
  58184. * @param subMesh The submesh to be used to render the depth map of
  58185. * @param useInstances If multiple world instances should be used
  58186. * @returns if the depth renderer is ready to render the depth map
  58187. */
  58188. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58189. /**
  58190. * Gets the texture which the depth map will be written to.
  58191. * @returns The depth map texture
  58192. */
  58193. getDepthMap(): RenderTargetTexture;
  58194. /**
  58195. * Disposes of the depth renderer.
  58196. */
  58197. dispose(): void;
  58198. }
  58199. }
  58200. declare module BABYLON {
  58201. /** @hidden */
  58202. export var minmaxReduxPixelShader: {
  58203. name: string;
  58204. shader: string;
  58205. };
  58206. }
  58207. declare module BABYLON {
  58208. /**
  58209. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58210. * and maximum values from all values of the texture.
  58211. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58212. * The source values are read from the red channel of the texture.
  58213. */
  58214. export class MinMaxReducer {
  58215. /**
  58216. * Observable triggered when the computation has been performed
  58217. */
  58218. onAfterReductionPerformed: Observable<{
  58219. min: number;
  58220. max: number;
  58221. }>;
  58222. protected _camera: Camera;
  58223. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58224. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58225. protected _postProcessManager: PostProcessManager;
  58226. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58227. protected _forceFullscreenViewport: boolean;
  58228. /**
  58229. * Creates a min/max reducer
  58230. * @param camera The camera to use for the post processes
  58231. */
  58232. constructor(camera: Camera);
  58233. /**
  58234. * Gets the texture used to read the values from.
  58235. */
  58236. get sourceTexture(): Nullable<RenderTargetTexture>;
  58237. /**
  58238. * Sets the source texture to read the values from.
  58239. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58240. * because in such textures '1' value must not be taken into account to compute the maximum
  58241. * as this value is used to clear the texture.
  58242. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58243. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58244. * @param depthRedux Indicates if the texture is a depth texture or not
  58245. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58246. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58247. */
  58248. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58249. /**
  58250. * Defines the refresh rate of the computation.
  58251. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58252. */
  58253. get refreshRate(): number;
  58254. set refreshRate(value: number);
  58255. protected _activated: boolean;
  58256. /**
  58257. * Gets the activation status of the reducer
  58258. */
  58259. get activated(): boolean;
  58260. /**
  58261. * Activates the reduction computation.
  58262. * When activated, the observers registered in onAfterReductionPerformed are
  58263. * called after the compuation is performed
  58264. */
  58265. activate(): void;
  58266. /**
  58267. * Deactivates the reduction computation.
  58268. */
  58269. deactivate(): void;
  58270. /**
  58271. * Disposes the min/max reducer
  58272. * @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.
  58273. */
  58274. dispose(disposeAll?: boolean): void;
  58275. }
  58276. }
  58277. declare module BABYLON {
  58278. /**
  58279. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58280. */
  58281. export class DepthReducer extends MinMaxReducer {
  58282. private _depthRenderer;
  58283. private _depthRendererId;
  58284. /**
  58285. * Gets the depth renderer used for the computation.
  58286. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58287. */
  58288. get depthRenderer(): Nullable<DepthRenderer>;
  58289. /**
  58290. * Creates a depth reducer
  58291. * @param camera The camera used to render the depth texture
  58292. */
  58293. constructor(camera: Camera);
  58294. /**
  58295. * Sets the depth renderer to use to generate the depth map
  58296. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58297. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58298. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58299. */
  58300. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58301. /** @hidden */
  58302. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58303. /**
  58304. * Activates the reduction computation.
  58305. * When activated, the observers registered in onAfterReductionPerformed are
  58306. * called after the compuation is performed
  58307. */
  58308. activate(): void;
  58309. /**
  58310. * Deactivates the reduction computation.
  58311. */
  58312. deactivate(): void;
  58313. /**
  58314. * Disposes the depth reducer
  58315. * @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.
  58316. */
  58317. dispose(disposeAll?: boolean): void;
  58318. }
  58319. }
  58320. declare module BABYLON {
  58321. /**
  58322. * A CSM implementation allowing casting shadows on large scenes.
  58323. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58324. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58325. */
  58326. export class CascadedShadowGenerator extends ShadowGenerator {
  58327. private static readonly frustumCornersNDCSpace;
  58328. /**
  58329. * Name of the CSM class
  58330. */
  58331. static CLASSNAME: string;
  58332. /**
  58333. * Defines the default number of cascades used by the CSM.
  58334. */
  58335. static readonly DEFAULT_CASCADES_COUNT: number;
  58336. /**
  58337. * Defines the minimum number of cascades used by the CSM.
  58338. */
  58339. static readonly MIN_CASCADES_COUNT: number;
  58340. /**
  58341. * Defines the maximum number of cascades used by the CSM.
  58342. */
  58343. static readonly MAX_CASCADES_COUNT: number;
  58344. protected _validateFilter(filter: number): number;
  58345. /**
  58346. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58347. */
  58348. penumbraDarkness: number;
  58349. private _numCascades;
  58350. /**
  58351. * Gets or set the number of cascades used by the CSM.
  58352. */
  58353. get numCascades(): number;
  58354. set numCascades(value: number);
  58355. /**
  58356. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58357. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58358. */
  58359. stabilizeCascades: boolean;
  58360. private _freezeShadowCastersBoundingInfo;
  58361. private _freezeShadowCastersBoundingInfoObservable;
  58362. /**
  58363. * Enables or disables the shadow casters bounding info computation.
  58364. * If your shadow casters don't move, you can disable this feature.
  58365. * If it is enabled, the bounding box computation is done every frame.
  58366. */
  58367. get freezeShadowCastersBoundingInfo(): boolean;
  58368. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58369. private _scbiMin;
  58370. private _scbiMax;
  58371. protected _computeShadowCastersBoundingInfo(): void;
  58372. protected _shadowCastersBoundingInfo: BoundingInfo;
  58373. /**
  58374. * Gets or sets the shadow casters bounding info.
  58375. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58376. * so that the system won't overwrite the bounds you provide
  58377. */
  58378. get shadowCastersBoundingInfo(): BoundingInfo;
  58379. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58380. protected _breaksAreDirty: boolean;
  58381. protected _minDistance: number;
  58382. protected _maxDistance: number;
  58383. /**
  58384. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58385. *
  58386. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58387. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58388. * @param min minimal distance for the breaks (default to 0.)
  58389. * @param max maximal distance for the breaks (default to 1.)
  58390. */
  58391. setMinMaxDistance(min: number, max: number): void;
  58392. /** Gets the minimal distance used in the cascade break computation */
  58393. get minDistance(): number;
  58394. /** Gets the maximal distance used in the cascade break computation */
  58395. get maxDistance(): number;
  58396. /**
  58397. * Gets the class name of that object
  58398. * @returns "CascadedShadowGenerator"
  58399. */
  58400. getClassName(): string;
  58401. private _cascadeMinExtents;
  58402. private _cascadeMaxExtents;
  58403. /**
  58404. * Gets a cascade minimum extents
  58405. * @param cascadeIndex index of the cascade
  58406. * @returns the minimum cascade extents
  58407. */
  58408. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58409. /**
  58410. * Gets a cascade maximum extents
  58411. * @param cascadeIndex index of the cascade
  58412. * @returns the maximum cascade extents
  58413. */
  58414. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58415. private _cascades;
  58416. private _currentLayer;
  58417. private _viewSpaceFrustumsZ;
  58418. private _viewMatrices;
  58419. private _projectionMatrices;
  58420. private _transformMatrices;
  58421. private _transformMatricesAsArray;
  58422. private _frustumLengths;
  58423. private _lightSizeUVCorrection;
  58424. private _depthCorrection;
  58425. private _frustumCornersWorldSpace;
  58426. private _frustumCenter;
  58427. private _shadowCameraPos;
  58428. private _shadowMaxZ;
  58429. /**
  58430. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58431. * It defaults to camera.maxZ
  58432. */
  58433. get shadowMaxZ(): number;
  58434. /**
  58435. * Sets the shadow max z distance.
  58436. */
  58437. set shadowMaxZ(value: number);
  58438. protected _debug: boolean;
  58439. /**
  58440. * Gets or sets the debug flag.
  58441. * When enabled, the cascades are materialized by different colors on the screen.
  58442. */
  58443. get debug(): boolean;
  58444. set debug(dbg: boolean);
  58445. private _depthClamp;
  58446. /**
  58447. * Gets or sets the depth clamping value.
  58448. *
  58449. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58450. * to account for the shadow casters far away.
  58451. *
  58452. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58453. */
  58454. get depthClamp(): boolean;
  58455. set depthClamp(value: boolean);
  58456. private _cascadeBlendPercentage;
  58457. /**
  58458. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58459. * It defaults to 0.1 (10% blending).
  58460. */
  58461. get cascadeBlendPercentage(): number;
  58462. set cascadeBlendPercentage(value: number);
  58463. private _lambda;
  58464. /**
  58465. * Gets or set the lambda parameter.
  58466. * This parameter is used to split the camera frustum and create the cascades.
  58467. * 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.
  58468. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58469. */
  58470. get lambda(): number;
  58471. set lambda(value: number);
  58472. /**
  58473. * Gets the view matrix corresponding to a given cascade
  58474. * @param cascadeNum cascade to retrieve the view matrix from
  58475. * @returns the cascade view matrix
  58476. */
  58477. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58478. /**
  58479. * Gets the projection matrix corresponding to a given cascade
  58480. * @param cascadeNum cascade to retrieve the projection matrix from
  58481. * @returns the cascade projection matrix
  58482. */
  58483. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58484. /**
  58485. * Gets the transformation matrix corresponding to a given cascade
  58486. * @param cascadeNum cascade to retrieve the transformation matrix from
  58487. * @returns the cascade transformation matrix
  58488. */
  58489. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58490. private _depthRenderer;
  58491. /**
  58492. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58493. *
  58494. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58495. *
  58496. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58497. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58498. * @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
  58499. */
  58500. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58501. private _depthReducer;
  58502. private _autoCalcDepthBounds;
  58503. /**
  58504. * Gets or sets the autoCalcDepthBounds property.
  58505. *
  58506. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58507. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58508. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58509. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58510. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58511. */
  58512. get autoCalcDepthBounds(): boolean;
  58513. set autoCalcDepthBounds(value: boolean);
  58514. /**
  58515. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58516. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58517. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58518. * for setting the refresh rate on the renderer yourself!
  58519. */
  58520. get autoCalcDepthBoundsRefreshRate(): number;
  58521. set autoCalcDepthBoundsRefreshRate(value: number);
  58522. /**
  58523. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58524. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58525. * you change the camera near/far planes!
  58526. */
  58527. splitFrustum(): void;
  58528. private _splitFrustum;
  58529. private _computeMatrices;
  58530. private _computeFrustumInWorldSpace;
  58531. private _computeCascadeFrustum;
  58532. /**
  58533. * Support test.
  58534. */
  58535. static get IsSupported(): boolean;
  58536. /** @hidden */
  58537. static _SceneComponentInitialization: (scene: Scene) => void;
  58538. /**
  58539. * Creates a Cascaded Shadow Generator object.
  58540. * A ShadowGenerator is the required tool to use the shadows.
  58541. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58542. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58543. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58544. * @param light The directional light object generating the shadows.
  58545. * @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.
  58546. */
  58547. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58548. protected _initializeGenerator(): void;
  58549. protected _createTargetRenderTexture(): void;
  58550. protected _initializeShadowMap(): void;
  58551. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58552. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58553. /**
  58554. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58555. * @param defines Defines of the material we want to update
  58556. * @param lightIndex Index of the light in the enabled light list of the material
  58557. */
  58558. prepareDefines(defines: any, lightIndex: number): void;
  58559. /**
  58560. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58561. * defined in the generator but impacting the effect).
  58562. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58563. * @param effect The effect we are binfing the information for
  58564. */
  58565. bindShadowLight(lightIndex: string, effect: Effect): void;
  58566. /**
  58567. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58568. * (eq to view projection * shadow projection matrices)
  58569. * @returns The transform matrix used to create the shadow map
  58570. */
  58571. getTransformMatrix(): Matrix;
  58572. /**
  58573. * Disposes the ShadowGenerator.
  58574. * Returns nothing.
  58575. */
  58576. dispose(): void;
  58577. /**
  58578. * Serializes the shadow generator setup to a json object.
  58579. * @returns The serialized JSON object
  58580. */
  58581. serialize(): any;
  58582. /**
  58583. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58584. * @param parsedShadowGenerator The JSON object to parse
  58585. * @param scene The scene to create the shadow map for
  58586. * @returns The parsed shadow generator
  58587. */
  58588. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58589. }
  58590. }
  58591. declare module BABYLON {
  58592. /**
  58593. * Defines the shadow generator component responsible to manage any shadow generators
  58594. * in a given scene.
  58595. */
  58596. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58597. /**
  58598. * The component name helpfull to identify the component in the list of scene components.
  58599. */
  58600. readonly name: string;
  58601. /**
  58602. * The scene the component belongs to.
  58603. */
  58604. scene: Scene;
  58605. /**
  58606. * Creates a new instance of the component for the given scene
  58607. * @param scene Defines the scene to register the component in
  58608. */
  58609. constructor(scene: Scene);
  58610. /**
  58611. * Registers the component in a given scene
  58612. */
  58613. register(): void;
  58614. /**
  58615. * Rebuilds the elements related to this component in case of
  58616. * context lost for instance.
  58617. */
  58618. rebuild(): void;
  58619. /**
  58620. * Serializes the component data to the specified json object
  58621. * @param serializationObject The object to serialize to
  58622. */
  58623. serialize(serializationObject: any): void;
  58624. /**
  58625. * Adds all the elements from the container to the scene
  58626. * @param container the container holding the elements
  58627. */
  58628. addFromContainer(container: AbstractScene): void;
  58629. /**
  58630. * Removes all the elements in the container from the scene
  58631. * @param container contains the elements to remove
  58632. * @param dispose if the removed element should be disposed (default: false)
  58633. */
  58634. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58635. /**
  58636. * Rebuilds the elements related to this component in case of
  58637. * context lost for instance.
  58638. */
  58639. dispose(): void;
  58640. private _gatherRenderTargets;
  58641. }
  58642. }
  58643. declare module BABYLON {
  58644. /**
  58645. * A point light is a light defined by an unique point in world space.
  58646. * The light is emitted in every direction from this point.
  58647. * A good example of a point light is a standard light bulb.
  58648. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58649. */
  58650. export class PointLight extends ShadowLight {
  58651. private _shadowAngle;
  58652. /**
  58653. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58654. * This specifies what angle the shadow will use to be created.
  58655. *
  58656. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58657. */
  58658. get shadowAngle(): number;
  58659. /**
  58660. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58661. * This specifies what angle the shadow will use to be created.
  58662. *
  58663. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58664. */
  58665. set shadowAngle(value: number);
  58666. /**
  58667. * Gets the direction if it has been set.
  58668. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58669. */
  58670. get direction(): Vector3;
  58671. /**
  58672. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58673. */
  58674. set direction(value: Vector3);
  58675. /**
  58676. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58677. * A PointLight emits the light in every direction.
  58678. * It can cast shadows.
  58679. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58680. * ```javascript
  58681. * var pointLight = new PointLight("pl", camera.position, scene);
  58682. * ```
  58683. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58684. * @param name The light friendly name
  58685. * @param position The position of the point light in the scene
  58686. * @param scene The scene the lights belongs to
  58687. */
  58688. constructor(name: string, position: Vector3, scene: Scene);
  58689. /**
  58690. * Returns the string "PointLight"
  58691. * @returns the class name
  58692. */
  58693. getClassName(): string;
  58694. /**
  58695. * Returns the integer 0.
  58696. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58697. */
  58698. getTypeID(): number;
  58699. /**
  58700. * Specifies wether or not the shadowmap should be a cube texture.
  58701. * @returns true if the shadowmap needs to be a cube texture.
  58702. */
  58703. needCube(): boolean;
  58704. /**
  58705. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58706. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58707. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58708. */
  58709. getShadowDirection(faceIndex?: number): Vector3;
  58710. /**
  58711. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58712. * - fov = PI / 2
  58713. * - aspect ratio : 1.0
  58714. * - z-near and far equal to the active camera minZ and maxZ.
  58715. * Returns the PointLight.
  58716. */
  58717. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58718. protected _buildUniformLayout(): void;
  58719. /**
  58720. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58721. * @param effect The effect to update
  58722. * @param lightIndex The index of the light in the effect to update
  58723. * @returns The point light
  58724. */
  58725. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58726. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58727. /**
  58728. * Prepares the list of defines specific to the light type.
  58729. * @param defines the list of defines
  58730. * @param lightIndex defines the index of the light for the effect
  58731. */
  58732. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58733. }
  58734. }
  58735. declare module BABYLON {
  58736. /**
  58737. * Header information of HDR texture files.
  58738. */
  58739. export interface HDRInfo {
  58740. /**
  58741. * The height of the texture in pixels.
  58742. */
  58743. height: number;
  58744. /**
  58745. * The width of the texture in pixels.
  58746. */
  58747. width: number;
  58748. /**
  58749. * The index of the beginning of the data in the binary file.
  58750. */
  58751. dataPosition: number;
  58752. }
  58753. /**
  58754. * This groups tools to convert HDR texture to native colors array.
  58755. */
  58756. export class HDRTools {
  58757. private static Ldexp;
  58758. private static Rgbe2float;
  58759. private static readStringLine;
  58760. /**
  58761. * Reads header information from an RGBE texture stored in a native array.
  58762. * More information on this format are available here:
  58763. * https://en.wikipedia.org/wiki/RGBE_image_format
  58764. *
  58765. * @param uint8array The binary file stored in native array.
  58766. * @return The header information.
  58767. */
  58768. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58769. /**
  58770. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58771. * This RGBE texture needs to store the information as a panorama.
  58772. *
  58773. * More information on this format are available here:
  58774. * https://en.wikipedia.org/wiki/RGBE_image_format
  58775. *
  58776. * @param buffer The binary file stored in an array buffer.
  58777. * @param size The expected size of the extracted cubemap.
  58778. * @return The Cube Map information.
  58779. */
  58780. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58781. /**
  58782. * Returns the pixels data extracted from an RGBE texture.
  58783. * This pixels will be stored left to right up to down in the R G B order in one array.
  58784. *
  58785. * More information on this format are available here:
  58786. * https://en.wikipedia.org/wiki/RGBE_image_format
  58787. *
  58788. * @param uint8array The binary file stored in an array buffer.
  58789. * @param hdrInfo The header information of the file.
  58790. * @return The pixels data in RGB right to left up to down order.
  58791. */
  58792. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58793. private static RGBE_ReadPixels_RLE;
  58794. }
  58795. }
  58796. declare module BABYLON {
  58797. /**
  58798. * Effect Render Options
  58799. */
  58800. export interface IEffectRendererOptions {
  58801. /**
  58802. * Defines the vertices positions.
  58803. */
  58804. positions?: number[];
  58805. /**
  58806. * Defines the indices.
  58807. */
  58808. indices?: number[];
  58809. }
  58810. /**
  58811. * Helper class to render one or more effects.
  58812. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58813. */
  58814. export class EffectRenderer {
  58815. private engine;
  58816. private static _DefaultOptions;
  58817. private _vertexBuffers;
  58818. private _indexBuffer;
  58819. private _fullscreenViewport;
  58820. /**
  58821. * Creates an effect renderer
  58822. * @param engine the engine to use for rendering
  58823. * @param options defines the options of the effect renderer
  58824. */
  58825. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58826. /**
  58827. * Sets the current viewport in normalized coordinates 0-1
  58828. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58829. */
  58830. setViewport(viewport?: Viewport): void;
  58831. /**
  58832. * Binds the embedded attributes buffer to the effect.
  58833. * @param effect Defines the effect to bind the attributes for
  58834. */
  58835. bindBuffers(effect: Effect): void;
  58836. /**
  58837. * Sets the current effect wrapper to use during draw.
  58838. * The effect needs to be ready before calling this api.
  58839. * This also sets the default full screen position attribute.
  58840. * @param effectWrapper Defines the effect to draw with
  58841. */
  58842. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58843. /**
  58844. * Restores engine states
  58845. */
  58846. restoreStates(): void;
  58847. /**
  58848. * Draws a full screen quad.
  58849. */
  58850. draw(): void;
  58851. private isRenderTargetTexture;
  58852. /**
  58853. * renders one or more effects to a specified texture
  58854. * @param effectWrapper the effect to renderer
  58855. * @param outputTexture texture to draw to, if null it will render to the screen.
  58856. */
  58857. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58858. /**
  58859. * Disposes of the effect renderer
  58860. */
  58861. dispose(): void;
  58862. }
  58863. /**
  58864. * Options to create an EffectWrapper
  58865. */
  58866. interface EffectWrapperCreationOptions {
  58867. /**
  58868. * Engine to use to create the effect
  58869. */
  58870. engine: ThinEngine;
  58871. /**
  58872. * Fragment shader for the effect
  58873. */
  58874. fragmentShader: string;
  58875. /**
  58876. * Use the shader store instead of direct source code
  58877. */
  58878. useShaderStore?: boolean;
  58879. /**
  58880. * Vertex shader for the effect
  58881. */
  58882. vertexShader?: string;
  58883. /**
  58884. * Attributes to use in the shader
  58885. */
  58886. attributeNames?: Array<string>;
  58887. /**
  58888. * Uniforms to use in the shader
  58889. */
  58890. uniformNames?: Array<string>;
  58891. /**
  58892. * Texture sampler names to use in the shader
  58893. */
  58894. samplerNames?: Array<string>;
  58895. /**
  58896. * Defines to use in the shader
  58897. */
  58898. defines?: Array<string>;
  58899. /**
  58900. * Callback when effect is compiled
  58901. */
  58902. onCompiled?: Nullable<(effect: Effect) => void>;
  58903. /**
  58904. * The friendly name of the effect displayed in Spector.
  58905. */
  58906. name?: string;
  58907. }
  58908. /**
  58909. * Wraps an effect to be used for rendering
  58910. */
  58911. export class EffectWrapper {
  58912. /**
  58913. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58914. */
  58915. onApplyObservable: Observable<{}>;
  58916. /**
  58917. * The underlying effect
  58918. */
  58919. effect: Effect;
  58920. /**
  58921. * Creates an effect to be renderer
  58922. * @param creationOptions options to create the effect
  58923. */
  58924. constructor(creationOptions: EffectWrapperCreationOptions);
  58925. /**
  58926. * Disposes of the effect wrapper
  58927. */
  58928. dispose(): void;
  58929. }
  58930. }
  58931. declare module BABYLON {
  58932. /** @hidden */
  58933. export var hdrFilteringVertexShader: {
  58934. name: string;
  58935. shader: string;
  58936. };
  58937. }
  58938. declare module BABYLON {
  58939. /** @hidden */
  58940. export var hdrFilteringPixelShader: {
  58941. name: string;
  58942. shader: string;
  58943. };
  58944. }
  58945. declare module BABYLON {
  58946. /**
  58947. * Options for texture filtering
  58948. */
  58949. interface IHDRFilteringOptions {
  58950. /**
  58951. * Scales pixel intensity for the input HDR map.
  58952. */
  58953. hdrScale?: number;
  58954. /**
  58955. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58956. */
  58957. quality?: number;
  58958. }
  58959. /**
  58960. * Filters HDR maps to get correct renderings of PBR reflections
  58961. */
  58962. export class HDRFiltering {
  58963. private _engine;
  58964. private _effectRenderer;
  58965. private _effectWrapper;
  58966. private _lodGenerationOffset;
  58967. private _lodGenerationScale;
  58968. /**
  58969. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58970. * you care about baking speed.
  58971. */
  58972. quality: number;
  58973. /**
  58974. * Scales pixel intensity for the input HDR map.
  58975. */
  58976. hdrScale: number;
  58977. /**
  58978. * Instantiates HDR filter for reflection maps
  58979. *
  58980. * @param engine Thin engine
  58981. * @param options Options
  58982. */
  58983. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58984. private _createRenderTarget;
  58985. private _prefilterInternal;
  58986. private _createEffect;
  58987. /**
  58988. * Get a value indicating if the filter is ready to be used
  58989. * @param texture Texture to filter
  58990. * @returns true if the filter is ready
  58991. */
  58992. isReady(texture: BaseTexture): boolean;
  58993. /**
  58994. * Prefilters a cube texture to have mipmap levels representing roughness values.
  58995. * Prefiltering will be invoked at the end of next rendering pass.
  58996. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  58997. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  58998. * @param texture Texture to filter
  58999. * @param onFinished Callback when filtering is done
  59000. * @return Promise called when prefiltering is done
  59001. */
  59002. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59003. }
  59004. }
  59005. declare module BABYLON {
  59006. /**
  59007. * This represents a texture coming from an HDR input.
  59008. *
  59009. * The only supported format is currently panorama picture stored in RGBE format.
  59010. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59011. */
  59012. export class HDRCubeTexture extends BaseTexture {
  59013. private static _facesMapping;
  59014. private _generateHarmonics;
  59015. private _noMipmap;
  59016. private _prefilterOnLoad;
  59017. private _textureMatrix;
  59018. private _size;
  59019. private _onLoad;
  59020. private _onError;
  59021. /**
  59022. * The texture URL.
  59023. */
  59024. url: string;
  59025. /**
  59026. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59027. */
  59028. coordinatesMode: number;
  59029. protected _isBlocking: boolean;
  59030. /**
  59031. * Sets wether or not the texture is blocking during loading.
  59032. */
  59033. set isBlocking(value: boolean);
  59034. /**
  59035. * Gets wether or not the texture is blocking during loading.
  59036. */
  59037. get isBlocking(): boolean;
  59038. protected _rotationY: number;
  59039. /**
  59040. * Sets texture matrix rotation angle around Y axis in radians.
  59041. */
  59042. set rotationY(value: number);
  59043. /**
  59044. * Gets texture matrix rotation angle around Y axis radians.
  59045. */
  59046. get rotationY(): number;
  59047. /**
  59048. * Gets or sets the center of the bounding box associated with the cube texture
  59049. * It must define where the camera used to render the texture was set
  59050. */
  59051. boundingBoxPosition: Vector3;
  59052. private _boundingBoxSize;
  59053. /**
  59054. * Gets or sets the size of the bounding box associated with the cube texture
  59055. * When defined, the cubemap will switch to local mode
  59056. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59057. * @example https://www.babylonjs-playground.com/#RNASML
  59058. */
  59059. set boundingBoxSize(value: Vector3);
  59060. get boundingBoxSize(): Vector3;
  59061. /**
  59062. * Instantiates an HDRTexture from the following parameters.
  59063. *
  59064. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59065. * @param sceneOrEngine The scene or engine the texture will be used in
  59066. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59067. * @param noMipmap Forces to not generate the mipmap if true
  59068. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59069. * @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)
  59070. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59071. */
  59072. 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>);
  59073. /**
  59074. * Get the current class name of the texture useful for serialization or dynamic coding.
  59075. * @returns "HDRCubeTexture"
  59076. */
  59077. getClassName(): string;
  59078. /**
  59079. * Occurs when the file is raw .hdr file.
  59080. */
  59081. private loadTexture;
  59082. clone(): HDRCubeTexture;
  59083. delayLoad(): void;
  59084. /**
  59085. * Get the texture reflection matrix used to rotate/transform the reflection.
  59086. * @returns the reflection matrix
  59087. */
  59088. getReflectionTextureMatrix(): Matrix;
  59089. /**
  59090. * Set the texture reflection matrix used to rotate/transform the reflection.
  59091. * @param value Define the reflection matrix to set
  59092. */
  59093. setReflectionTextureMatrix(value: Matrix): void;
  59094. /**
  59095. * Parses a JSON representation of an HDR Texture in order to create the texture
  59096. * @param parsedTexture Define the JSON representation
  59097. * @param scene Define the scene the texture should be created in
  59098. * @param rootUrl Define the root url in case we need to load relative dependencies
  59099. * @returns the newly created texture after parsing
  59100. */
  59101. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59102. serialize(): any;
  59103. }
  59104. }
  59105. declare module BABYLON {
  59106. /**
  59107. * Class used to control physics engine
  59108. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59109. */
  59110. export class PhysicsEngine implements IPhysicsEngine {
  59111. private _physicsPlugin;
  59112. /**
  59113. * Global value used to control the smallest number supported by the simulation
  59114. */
  59115. static Epsilon: number;
  59116. private _impostors;
  59117. private _joints;
  59118. private _subTimeStep;
  59119. /**
  59120. * Gets the gravity vector used by the simulation
  59121. */
  59122. gravity: Vector3;
  59123. /**
  59124. * Factory used to create the default physics plugin.
  59125. * @returns The default physics plugin
  59126. */
  59127. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59128. /**
  59129. * Creates a new Physics Engine
  59130. * @param gravity defines the gravity vector used by the simulation
  59131. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59132. */
  59133. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59134. /**
  59135. * Sets the gravity vector used by the simulation
  59136. * @param gravity defines the gravity vector to use
  59137. */
  59138. setGravity(gravity: Vector3): void;
  59139. /**
  59140. * Set the time step of the physics engine.
  59141. * Default is 1/60.
  59142. * To slow it down, enter 1/600 for example.
  59143. * To speed it up, 1/30
  59144. * @param newTimeStep defines the new timestep to apply to this world.
  59145. */
  59146. setTimeStep(newTimeStep?: number): void;
  59147. /**
  59148. * Get the time step of the physics engine.
  59149. * @returns the current time step
  59150. */
  59151. getTimeStep(): number;
  59152. /**
  59153. * Set the sub time step of the physics engine.
  59154. * Default is 0 meaning there is no sub steps
  59155. * To increase physics resolution precision, set a small value (like 1 ms)
  59156. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59157. */
  59158. setSubTimeStep(subTimeStep?: number): void;
  59159. /**
  59160. * Get the sub time step of the physics engine.
  59161. * @returns the current sub time step
  59162. */
  59163. getSubTimeStep(): number;
  59164. /**
  59165. * Release all resources
  59166. */
  59167. dispose(): void;
  59168. /**
  59169. * Gets the name of the current physics plugin
  59170. * @returns the name of the plugin
  59171. */
  59172. getPhysicsPluginName(): string;
  59173. /**
  59174. * Adding a new impostor for the impostor tracking.
  59175. * This will be done by the impostor itself.
  59176. * @param impostor the impostor to add
  59177. */
  59178. addImpostor(impostor: PhysicsImpostor): void;
  59179. /**
  59180. * Remove an impostor from the engine.
  59181. * This impostor and its mesh will not longer be updated by the physics engine.
  59182. * @param impostor the impostor to remove
  59183. */
  59184. removeImpostor(impostor: PhysicsImpostor): void;
  59185. /**
  59186. * Add a joint to the physics engine
  59187. * @param mainImpostor defines the main impostor to which the joint is added.
  59188. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59189. * @param joint defines the joint that will connect both impostors.
  59190. */
  59191. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59192. /**
  59193. * Removes a joint from the simulation
  59194. * @param mainImpostor defines the impostor used with the joint
  59195. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59196. * @param joint defines the joint to remove
  59197. */
  59198. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59199. /**
  59200. * Called by the scene. No need to call it.
  59201. * @param delta defines the timespam between frames
  59202. */
  59203. _step(delta: number): void;
  59204. /**
  59205. * Gets the current plugin used to run the simulation
  59206. * @returns current plugin
  59207. */
  59208. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59209. /**
  59210. * Gets the list of physic impostors
  59211. * @returns an array of PhysicsImpostor
  59212. */
  59213. getImpostors(): Array<PhysicsImpostor>;
  59214. /**
  59215. * Gets the impostor for a physics enabled object
  59216. * @param object defines the object impersonated by the impostor
  59217. * @returns the PhysicsImpostor or null if not found
  59218. */
  59219. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59220. /**
  59221. * Gets the impostor for a physics body object
  59222. * @param body defines physics body used by the impostor
  59223. * @returns the PhysicsImpostor or null if not found
  59224. */
  59225. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59226. /**
  59227. * Does a raycast in the physics world
  59228. * @param from when should the ray start?
  59229. * @param to when should the ray end?
  59230. * @returns PhysicsRaycastResult
  59231. */
  59232. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59233. }
  59234. }
  59235. declare module BABYLON {
  59236. /** @hidden */
  59237. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59238. private _useDeltaForWorldStep;
  59239. world: any;
  59240. name: string;
  59241. private _physicsMaterials;
  59242. private _fixedTimeStep;
  59243. private _cannonRaycastResult;
  59244. private _raycastResult;
  59245. private _physicsBodysToRemoveAfterStep;
  59246. private _firstFrame;
  59247. BJSCANNON: any;
  59248. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59249. setGravity(gravity: Vector3): void;
  59250. setTimeStep(timeStep: number): void;
  59251. getTimeStep(): number;
  59252. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59253. private _removeMarkedPhysicsBodiesFromWorld;
  59254. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59255. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59256. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59257. private _processChildMeshes;
  59258. removePhysicsBody(impostor: PhysicsImpostor): void;
  59259. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59260. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59261. private _addMaterial;
  59262. private _checkWithEpsilon;
  59263. private _createShape;
  59264. private _createHeightmap;
  59265. private _minus90X;
  59266. private _plus90X;
  59267. private _tmpPosition;
  59268. private _tmpDeltaPosition;
  59269. private _tmpUnityRotation;
  59270. private _updatePhysicsBodyTransformation;
  59271. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59272. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59273. isSupported(): boolean;
  59274. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59275. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59276. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59277. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59278. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59279. getBodyMass(impostor: PhysicsImpostor): number;
  59280. getBodyFriction(impostor: PhysicsImpostor): number;
  59281. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59282. getBodyRestitution(impostor: PhysicsImpostor): number;
  59283. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59284. sleepBody(impostor: PhysicsImpostor): void;
  59285. wakeUpBody(impostor: PhysicsImpostor): void;
  59286. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59287. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59289. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59290. getRadius(impostor: PhysicsImpostor): number;
  59291. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59292. dispose(): void;
  59293. private _extendNamespace;
  59294. /**
  59295. * Does a raycast in the physics world
  59296. * @param from when should the ray start?
  59297. * @param to when should the ray end?
  59298. * @returns PhysicsRaycastResult
  59299. */
  59300. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59301. }
  59302. }
  59303. declare module BABYLON {
  59304. /** @hidden */
  59305. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59306. private _useDeltaForWorldStep;
  59307. world: any;
  59308. name: string;
  59309. BJSOIMO: any;
  59310. private _raycastResult;
  59311. private _fixedTimeStep;
  59312. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59313. setGravity(gravity: Vector3): void;
  59314. setTimeStep(timeStep: number): void;
  59315. getTimeStep(): number;
  59316. private _tmpImpostorsArray;
  59317. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59318. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59319. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59320. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59321. private _tmpPositionVector;
  59322. removePhysicsBody(impostor: PhysicsImpostor): void;
  59323. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59324. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59325. isSupported(): boolean;
  59326. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59327. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59328. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59329. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59330. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59331. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59332. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59333. getBodyMass(impostor: PhysicsImpostor): number;
  59334. getBodyFriction(impostor: PhysicsImpostor): number;
  59335. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59336. getBodyRestitution(impostor: PhysicsImpostor): number;
  59337. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59338. sleepBody(impostor: PhysicsImpostor): void;
  59339. wakeUpBody(impostor: PhysicsImpostor): void;
  59340. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59341. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59342. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59343. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59344. getRadius(impostor: PhysicsImpostor): number;
  59345. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59346. dispose(): void;
  59347. /**
  59348. * Does a raycast in the physics world
  59349. * @param from when should the ray start?
  59350. * @param to when should the ray end?
  59351. * @returns PhysicsRaycastResult
  59352. */
  59353. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59354. }
  59355. }
  59356. declare module BABYLON {
  59357. /**
  59358. * Class containing static functions to help procedurally build meshes
  59359. */
  59360. export class RibbonBuilder {
  59361. /**
  59362. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59363. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59364. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59365. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59366. * * 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
  59367. * * 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
  59368. * * 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
  59369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59370. * * 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
  59371. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59372. * * 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
  59373. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59374. * * 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
  59375. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59377. * @param name defines the name of the mesh
  59378. * @param options defines the options used to create the mesh
  59379. * @param scene defines the hosting scene
  59380. * @returns the ribbon mesh
  59381. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59382. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59383. */
  59384. static CreateRibbon(name: string, options: {
  59385. pathArray: Vector3[][];
  59386. closeArray?: boolean;
  59387. closePath?: boolean;
  59388. offset?: number;
  59389. updatable?: boolean;
  59390. sideOrientation?: number;
  59391. frontUVs?: Vector4;
  59392. backUVs?: Vector4;
  59393. instance?: Mesh;
  59394. invertUV?: boolean;
  59395. uvs?: Vector2[];
  59396. colors?: Color4[];
  59397. }, scene?: Nullable<Scene>): Mesh;
  59398. }
  59399. }
  59400. declare module BABYLON {
  59401. /**
  59402. * Class containing static functions to help procedurally build meshes
  59403. */
  59404. export class ShapeBuilder {
  59405. /**
  59406. * 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.
  59407. * * 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.
  59408. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59409. * * 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.
  59410. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59411. * * 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
  59412. * * 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
  59413. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59415. * * 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
  59416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59418. * @param name defines the name of the mesh
  59419. * @param options defines the options used to create the mesh
  59420. * @param scene defines the hosting scene
  59421. * @returns the extruded shape mesh
  59422. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59424. */
  59425. static ExtrudeShape(name: string, options: {
  59426. shape: Vector3[];
  59427. path: Vector3[];
  59428. scale?: number;
  59429. rotation?: number;
  59430. cap?: number;
  59431. updatable?: boolean;
  59432. sideOrientation?: number;
  59433. frontUVs?: Vector4;
  59434. backUVs?: Vector4;
  59435. instance?: Mesh;
  59436. invertUV?: boolean;
  59437. }, scene?: Nullable<Scene>): Mesh;
  59438. /**
  59439. * Creates an custom extruded shape mesh.
  59440. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59441. * * 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.
  59442. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59443. * * 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
  59444. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59445. * * 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
  59446. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59447. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59448. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59449. * * 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
  59450. * * 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
  59451. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59453. * * 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
  59454. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59456. * @param name defines the name of the mesh
  59457. * @param options defines the options used to create the mesh
  59458. * @param scene defines the hosting scene
  59459. * @returns the custom extruded shape mesh
  59460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59461. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59463. */
  59464. static ExtrudeShapeCustom(name: string, options: {
  59465. shape: Vector3[];
  59466. path: Vector3[];
  59467. scaleFunction?: any;
  59468. rotationFunction?: any;
  59469. ribbonCloseArray?: boolean;
  59470. ribbonClosePath?: boolean;
  59471. cap?: number;
  59472. updatable?: boolean;
  59473. sideOrientation?: number;
  59474. frontUVs?: Vector4;
  59475. backUVs?: Vector4;
  59476. instance?: Mesh;
  59477. invertUV?: boolean;
  59478. }, scene?: Nullable<Scene>): Mesh;
  59479. private static _ExtrudeShapeGeneric;
  59480. }
  59481. }
  59482. declare module BABYLON {
  59483. /**
  59484. * AmmoJS Physics plugin
  59485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59486. * @see https://github.com/kripken/ammo.js/
  59487. */
  59488. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59489. private _useDeltaForWorldStep;
  59490. /**
  59491. * Reference to the Ammo library
  59492. */
  59493. bjsAMMO: any;
  59494. /**
  59495. * Created ammoJS world which physics bodies are added to
  59496. */
  59497. world: any;
  59498. /**
  59499. * Name of the plugin
  59500. */
  59501. name: string;
  59502. private _timeStep;
  59503. private _fixedTimeStep;
  59504. private _maxSteps;
  59505. private _tmpQuaternion;
  59506. private _tmpAmmoTransform;
  59507. private _tmpAmmoQuaternion;
  59508. private _tmpAmmoConcreteContactResultCallback;
  59509. private _collisionConfiguration;
  59510. private _dispatcher;
  59511. private _overlappingPairCache;
  59512. private _solver;
  59513. private _softBodySolver;
  59514. private _tmpAmmoVectorA;
  59515. private _tmpAmmoVectorB;
  59516. private _tmpAmmoVectorC;
  59517. private _tmpAmmoVectorD;
  59518. private _tmpContactCallbackResult;
  59519. private _tmpAmmoVectorRCA;
  59520. private _tmpAmmoVectorRCB;
  59521. private _raycastResult;
  59522. private static readonly DISABLE_COLLISION_FLAG;
  59523. private static readonly KINEMATIC_FLAG;
  59524. private static readonly DISABLE_DEACTIVATION_FLAG;
  59525. /**
  59526. * Initializes the ammoJS plugin
  59527. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59528. * @param ammoInjection can be used to inject your own ammo reference
  59529. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59530. */
  59531. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59532. /**
  59533. * Sets the gravity of the physics world (m/(s^2))
  59534. * @param gravity Gravity to set
  59535. */
  59536. setGravity(gravity: Vector3): void;
  59537. /**
  59538. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59539. * @param timeStep timestep to use in seconds
  59540. */
  59541. setTimeStep(timeStep: number): void;
  59542. /**
  59543. * 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)
  59544. * @param fixedTimeStep fixedTimeStep to use in seconds
  59545. */
  59546. setFixedTimeStep(fixedTimeStep: number): void;
  59547. /**
  59548. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59549. * @param maxSteps the maximum number of steps by the physics engine per frame
  59550. */
  59551. setMaxSteps(maxSteps: number): void;
  59552. /**
  59553. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59554. * @returns the current timestep in seconds
  59555. */
  59556. getTimeStep(): number;
  59557. /**
  59558. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59559. */
  59560. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59561. private _isImpostorInContact;
  59562. private _isImpostorPairInContact;
  59563. private _stepSimulation;
  59564. /**
  59565. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59566. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59567. * After the step the babylon meshes are set to the position of the physics imposters
  59568. * @param delta amount of time to step forward
  59569. * @param impostors array of imposters to update before/after the step
  59570. */
  59571. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59572. /**
  59573. * Update babylon mesh to match physics world object
  59574. * @param impostor imposter to match
  59575. */
  59576. private _afterSoftStep;
  59577. /**
  59578. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59579. * @param impostor imposter to match
  59580. */
  59581. private _ropeStep;
  59582. /**
  59583. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59584. * @param impostor imposter to match
  59585. */
  59586. private _softbodyOrClothStep;
  59587. private _tmpMatrix;
  59588. /**
  59589. * Applies an impulse on the imposter
  59590. * @param impostor imposter to apply impulse to
  59591. * @param force amount of force to be applied to the imposter
  59592. * @param contactPoint the location to apply the impulse on the imposter
  59593. */
  59594. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59595. /**
  59596. * Applies a force on the imposter
  59597. * @param impostor imposter to apply force
  59598. * @param force amount of force to be applied to the imposter
  59599. * @param contactPoint the location to apply the force on the imposter
  59600. */
  59601. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59602. /**
  59603. * Creates a physics body using the plugin
  59604. * @param impostor the imposter to create the physics body on
  59605. */
  59606. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59607. /**
  59608. * Removes the physics body from the imposter and disposes of the body's memory
  59609. * @param impostor imposter to remove the physics body from
  59610. */
  59611. removePhysicsBody(impostor: PhysicsImpostor): void;
  59612. /**
  59613. * Generates a joint
  59614. * @param impostorJoint the imposter joint to create the joint with
  59615. */
  59616. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59617. /**
  59618. * Removes a joint
  59619. * @param impostorJoint the imposter joint to remove the joint from
  59620. */
  59621. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59622. private _addMeshVerts;
  59623. /**
  59624. * Initialise the soft body vertices to match its object's (mesh) vertices
  59625. * Softbody vertices (nodes) are in world space and to match this
  59626. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59627. * @param impostor to create the softbody for
  59628. */
  59629. private _softVertexData;
  59630. /**
  59631. * Create an impostor's soft body
  59632. * @param impostor to create the softbody for
  59633. */
  59634. private _createSoftbody;
  59635. /**
  59636. * Create cloth for an impostor
  59637. * @param impostor to create the softbody for
  59638. */
  59639. private _createCloth;
  59640. /**
  59641. * Create rope for an impostor
  59642. * @param impostor to create the softbody for
  59643. */
  59644. private _createRope;
  59645. /**
  59646. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59647. * @param impostor to create the custom physics shape for
  59648. */
  59649. private _createCustom;
  59650. private _addHullVerts;
  59651. private _createShape;
  59652. /**
  59653. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59654. * @param impostor imposter containing the physics body and babylon object
  59655. */
  59656. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59657. /**
  59658. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59659. * @param impostor imposter containing the physics body and babylon object
  59660. * @param newPosition new position
  59661. * @param newRotation new rotation
  59662. */
  59663. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59664. /**
  59665. * If this plugin is supported
  59666. * @returns true if its supported
  59667. */
  59668. isSupported(): boolean;
  59669. /**
  59670. * Sets the linear velocity of the physics body
  59671. * @param impostor imposter to set the velocity on
  59672. * @param velocity velocity to set
  59673. */
  59674. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59675. /**
  59676. * Sets the angular velocity of the physics body
  59677. * @param impostor imposter to set the velocity on
  59678. * @param velocity velocity to set
  59679. */
  59680. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59681. /**
  59682. * gets the linear velocity
  59683. * @param impostor imposter to get linear velocity from
  59684. * @returns linear velocity
  59685. */
  59686. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59687. /**
  59688. * gets the angular velocity
  59689. * @param impostor imposter to get angular velocity from
  59690. * @returns angular velocity
  59691. */
  59692. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59693. /**
  59694. * Sets the mass of physics body
  59695. * @param impostor imposter to set the mass on
  59696. * @param mass mass to set
  59697. */
  59698. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59699. /**
  59700. * Gets the mass of the physics body
  59701. * @param impostor imposter to get the mass from
  59702. * @returns mass
  59703. */
  59704. getBodyMass(impostor: PhysicsImpostor): number;
  59705. /**
  59706. * Gets friction of the impostor
  59707. * @param impostor impostor to get friction from
  59708. * @returns friction value
  59709. */
  59710. getBodyFriction(impostor: PhysicsImpostor): number;
  59711. /**
  59712. * Sets friction of the impostor
  59713. * @param impostor impostor to set friction on
  59714. * @param friction friction value
  59715. */
  59716. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59717. /**
  59718. * Gets restitution of the impostor
  59719. * @param impostor impostor to get restitution from
  59720. * @returns restitution value
  59721. */
  59722. getBodyRestitution(impostor: PhysicsImpostor): number;
  59723. /**
  59724. * Sets resitution of the impostor
  59725. * @param impostor impostor to set resitution on
  59726. * @param restitution resitution value
  59727. */
  59728. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59729. /**
  59730. * Gets pressure inside the impostor
  59731. * @param impostor impostor to get pressure from
  59732. * @returns pressure value
  59733. */
  59734. getBodyPressure(impostor: PhysicsImpostor): number;
  59735. /**
  59736. * Sets pressure inside a soft body impostor
  59737. * Cloth and rope must remain 0 pressure
  59738. * @param impostor impostor to set pressure on
  59739. * @param pressure pressure value
  59740. */
  59741. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59742. /**
  59743. * Gets stiffness of the impostor
  59744. * @param impostor impostor to get stiffness from
  59745. * @returns pressure value
  59746. */
  59747. getBodyStiffness(impostor: PhysicsImpostor): number;
  59748. /**
  59749. * Sets stiffness of the impostor
  59750. * @param impostor impostor to set stiffness on
  59751. * @param stiffness stiffness value from 0 to 1
  59752. */
  59753. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59754. /**
  59755. * Gets velocityIterations of the impostor
  59756. * @param impostor impostor to get velocity iterations from
  59757. * @returns velocityIterations value
  59758. */
  59759. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59760. /**
  59761. * Sets velocityIterations of the impostor
  59762. * @param impostor impostor to set velocity iterations on
  59763. * @param velocityIterations velocityIterations value
  59764. */
  59765. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59766. /**
  59767. * Gets positionIterations of the impostor
  59768. * @param impostor impostor to get position iterations from
  59769. * @returns positionIterations value
  59770. */
  59771. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59772. /**
  59773. * Sets positionIterations of the impostor
  59774. * @param impostor impostor to set position on
  59775. * @param positionIterations positionIterations value
  59776. */
  59777. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59778. /**
  59779. * Append an anchor to a cloth object
  59780. * @param impostor is the cloth impostor to add anchor to
  59781. * @param otherImpostor is the rigid impostor to anchor to
  59782. * @param width ratio across width from 0 to 1
  59783. * @param height ratio up height from 0 to 1
  59784. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59785. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59786. */
  59787. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59788. /**
  59789. * Append an hook to a rope object
  59790. * @param impostor is the rope impostor to add hook to
  59791. * @param otherImpostor is the rigid impostor to hook to
  59792. * @param length ratio along the rope from 0 to 1
  59793. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59794. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59795. */
  59796. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59797. /**
  59798. * Sleeps the physics body and stops it from being active
  59799. * @param impostor impostor to sleep
  59800. */
  59801. sleepBody(impostor: PhysicsImpostor): void;
  59802. /**
  59803. * Activates the physics body
  59804. * @param impostor impostor to activate
  59805. */
  59806. wakeUpBody(impostor: PhysicsImpostor): void;
  59807. /**
  59808. * Updates the distance parameters of the joint
  59809. * @param joint joint to update
  59810. * @param maxDistance maximum distance of the joint
  59811. * @param minDistance minimum distance of the joint
  59812. */
  59813. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59814. /**
  59815. * Sets a motor on the joint
  59816. * @param joint joint to set motor on
  59817. * @param speed speed of the motor
  59818. * @param maxForce maximum force of the motor
  59819. * @param motorIndex index of the motor
  59820. */
  59821. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59822. /**
  59823. * Sets the motors limit
  59824. * @param joint joint to set limit on
  59825. * @param upperLimit upper limit
  59826. * @param lowerLimit lower limit
  59827. */
  59828. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59829. /**
  59830. * Syncs the position and rotation of a mesh with the impostor
  59831. * @param mesh mesh to sync
  59832. * @param impostor impostor to update the mesh with
  59833. */
  59834. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59835. /**
  59836. * Gets the radius of the impostor
  59837. * @param impostor impostor to get radius from
  59838. * @returns the radius
  59839. */
  59840. getRadius(impostor: PhysicsImpostor): number;
  59841. /**
  59842. * Gets the box size of the impostor
  59843. * @param impostor impostor to get box size from
  59844. * @param result the resulting box size
  59845. */
  59846. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59847. /**
  59848. * Disposes of the impostor
  59849. */
  59850. dispose(): void;
  59851. /**
  59852. * Does a raycast in the physics world
  59853. * @param from when should the ray start?
  59854. * @param to when should the ray end?
  59855. * @returns PhysicsRaycastResult
  59856. */
  59857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59858. }
  59859. }
  59860. declare module BABYLON {
  59861. interface AbstractScene {
  59862. /**
  59863. * The list of reflection probes added to the scene
  59864. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59865. */
  59866. reflectionProbes: Array<ReflectionProbe>;
  59867. /**
  59868. * Removes the given reflection probe from this scene.
  59869. * @param toRemove The reflection probe to remove
  59870. * @returns The index of the removed reflection probe
  59871. */
  59872. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59873. /**
  59874. * Adds the given reflection probe to this scene.
  59875. * @param newReflectionProbe The reflection probe to add
  59876. */
  59877. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59878. }
  59879. /**
  59880. * Class used to generate realtime reflection / refraction cube textures
  59881. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59882. */
  59883. export class ReflectionProbe {
  59884. /** defines the name of the probe */
  59885. name: string;
  59886. private _scene;
  59887. private _renderTargetTexture;
  59888. private _projectionMatrix;
  59889. private _viewMatrix;
  59890. private _target;
  59891. private _add;
  59892. private _attachedMesh;
  59893. private _invertYAxis;
  59894. /** Gets or sets probe position (center of the cube map) */
  59895. position: Vector3;
  59896. /**
  59897. * Creates a new reflection probe
  59898. * @param name defines the name of the probe
  59899. * @param size defines the texture resolution (for each face)
  59900. * @param scene defines the hosting scene
  59901. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59902. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59903. */
  59904. constructor(
  59905. /** defines the name of the probe */
  59906. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59907. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59908. get samples(): number;
  59909. set samples(value: number);
  59910. /** Gets or sets the refresh rate to use (on every frame by default) */
  59911. get refreshRate(): number;
  59912. set refreshRate(value: number);
  59913. /**
  59914. * Gets the hosting scene
  59915. * @returns a Scene
  59916. */
  59917. getScene(): Scene;
  59918. /** Gets the internal CubeTexture used to render to */
  59919. get cubeTexture(): RenderTargetTexture;
  59920. /** Gets the list of meshes to render */
  59921. get renderList(): Nullable<AbstractMesh[]>;
  59922. /**
  59923. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59924. * @param mesh defines the mesh to attach to
  59925. */
  59926. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59927. /**
  59928. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59929. * @param renderingGroupId The rendering group id corresponding to its index
  59930. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59931. */
  59932. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59933. /**
  59934. * Clean all associated resources
  59935. */
  59936. dispose(): void;
  59937. /**
  59938. * Converts the reflection probe information to a readable string for debug purpose.
  59939. * @param fullDetails Supports for multiple levels of logging within scene loading
  59940. * @returns the human readable reflection probe info
  59941. */
  59942. toString(fullDetails?: boolean): string;
  59943. /**
  59944. * Get the class name of the relfection probe.
  59945. * @returns "ReflectionProbe"
  59946. */
  59947. getClassName(): string;
  59948. /**
  59949. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59950. * @returns The JSON representation of the texture
  59951. */
  59952. serialize(): any;
  59953. /**
  59954. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59955. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59956. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59957. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59958. * @returns The parsed reflection probe if successful
  59959. */
  59960. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59961. }
  59962. }
  59963. declare module BABYLON {
  59964. /** @hidden */
  59965. export var _BabylonLoaderRegistered: boolean;
  59966. /**
  59967. * Helps setting up some configuration for the babylon file loader.
  59968. */
  59969. export class BabylonFileLoaderConfiguration {
  59970. /**
  59971. * The loader does not allow injecting custom physix engine into the plugins.
  59972. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59973. * So you could set this variable to your engine import to make it work.
  59974. */
  59975. static LoaderInjectedPhysicsEngine: any;
  59976. }
  59977. }
  59978. declare module BABYLON {
  59979. /**
  59980. * The Physically based simple base material of BJS.
  59981. *
  59982. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59983. * It is used as the base class for both the specGloss and metalRough conventions.
  59984. */
  59985. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59986. /**
  59987. * Number of Simultaneous lights allowed on the material.
  59988. */
  59989. maxSimultaneousLights: number;
  59990. /**
  59991. * If sets to true, disables all the lights affecting the material.
  59992. */
  59993. disableLighting: boolean;
  59994. /**
  59995. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  59996. */
  59997. environmentTexture: BaseTexture;
  59998. /**
  59999. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60000. */
  60001. invertNormalMapX: boolean;
  60002. /**
  60003. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60004. */
  60005. invertNormalMapY: boolean;
  60006. /**
  60007. * Normal map used in the model.
  60008. */
  60009. normalTexture: BaseTexture;
  60010. /**
  60011. * Emissivie color used to self-illuminate the model.
  60012. */
  60013. emissiveColor: Color3;
  60014. /**
  60015. * Emissivie texture used to self-illuminate the model.
  60016. */
  60017. emissiveTexture: BaseTexture;
  60018. /**
  60019. * Occlusion Channel Strenght.
  60020. */
  60021. occlusionStrength: number;
  60022. /**
  60023. * Occlusion Texture of the material (adding extra occlusion effects).
  60024. */
  60025. occlusionTexture: BaseTexture;
  60026. /**
  60027. * Defines the alpha limits in alpha test mode.
  60028. */
  60029. alphaCutOff: number;
  60030. /**
  60031. * Gets the current double sided mode.
  60032. */
  60033. get doubleSided(): boolean;
  60034. /**
  60035. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60036. */
  60037. set doubleSided(value: boolean);
  60038. /**
  60039. * Stores the pre-calculated light information of a mesh in a texture.
  60040. */
  60041. lightmapTexture: BaseTexture;
  60042. /**
  60043. * If true, the light map contains occlusion information instead of lighting info.
  60044. */
  60045. useLightmapAsShadowmap: boolean;
  60046. /**
  60047. * Instantiates a new PBRMaterial instance.
  60048. *
  60049. * @param name The material name
  60050. * @param scene The scene the material will be use in.
  60051. */
  60052. constructor(name: string, scene: Scene);
  60053. getClassName(): string;
  60054. }
  60055. }
  60056. declare module BABYLON {
  60057. /**
  60058. * The PBR material of BJS following the metal roughness convention.
  60059. *
  60060. * This fits to the PBR convention in the GLTF definition:
  60061. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60062. */
  60063. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60064. /**
  60065. * The base color has two different interpretations depending on the value of metalness.
  60066. * When the material is a metal, the base color is the specific measured reflectance value
  60067. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60068. * of the material.
  60069. */
  60070. baseColor: Color3;
  60071. /**
  60072. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60073. * well as opacity information in the alpha channel.
  60074. */
  60075. baseTexture: BaseTexture;
  60076. /**
  60077. * Specifies the metallic scalar value of the material.
  60078. * Can also be used to scale the metalness values of the metallic texture.
  60079. */
  60080. metallic: number;
  60081. /**
  60082. * Specifies the roughness scalar value of the material.
  60083. * Can also be used to scale the roughness values of the metallic texture.
  60084. */
  60085. roughness: number;
  60086. /**
  60087. * Texture containing both the metallic value in the B channel and the
  60088. * roughness value in the G channel to keep better precision.
  60089. */
  60090. metallicRoughnessTexture: BaseTexture;
  60091. /**
  60092. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60093. *
  60094. * @param name The material name
  60095. * @param scene The scene the material will be use in.
  60096. */
  60097. constructor(name: string, scene: Scene);
  60098. /**
  60099. * Return the currrent class name of the material.
  60100. */
  60101. getClassName(): string;
  60102. /**
  60103. * Makes a duplicate of the current material.
  60104. * @param name - name to use for the new material.
  60105. */
  60106. clone(name: string): PBRMetallicRoughnessMaterial;
  60107. /**
  60108. * Serialize the material to a parsable JSON object.
  60109. */
  60110. serialize(): any;
  60111. /**
  60112. * Parses a JSON object correponding to the serialize function.
  60113. */
  60114. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60115. }
  60116. }
  60117. declare module BABYLON {
  60118. /**
  60119. * The PBR material of BJS following the specular glossiness convention.
  60120. *
  60121. * This fits to the PBR convention in the GLTF definition:
  60122. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60123. */
  60124. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60125. /**
  60126. * Specifies the diffuse color of the material.
  60127. */
  60128. diffuseColor: Color3;
  60129. /**
  60130. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60131. * channel.
  60132. */
  60133. diffuseTexture: BaseTexture;
  60134. /**
  60135. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60136. */
  60137. specularColor: Color3;
  60138. /**
  60139. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60140. */
  60141. glossiness: number;
  60142. /**
  60143. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60144. */
  60145. specularGlossinessTexture: BaseTexture;
  60146. /**
  60147. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60148. *
  60149. * @param name The material name
  60150. * @param scene The scene the material will be use in.
  60151. */
  60152. constructor(name: string, scene: Scene);
  60153. /**
  60154. * Return the currrent class name of the material.
  60155. */
  60156. getClassName(): string;
  60157. /**
  60158. * Makes a duplicate of the current material.
  60159. * @param name - name to use for the new material.
  60160. */
  60161. clone(name: string): PBRSpecularGlossinessMaterial;
  60162. /**
  60163. * Serialize the material to a parsable JSON object.
  60164. */
  60165. serialize(): any;
  60166. /**
  60167. * Parses a JSON object correponding to the serialize function.
  60168. */
  60169. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60170. }
  60171. }
  60172. declare module BABYLON {
  60173. /**
  60174. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60175. * It can help converting any input color in a desired output one. This can then be used to create effects
  60176. * from sepia, black and white to sixties or futuristic rendering...
  60177. *
  60178. * The only supported format is currently 3dl.
  60179. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60180. */
  60181. export class ColorGradingTexture extends BaseTexture {
  60182. /**
  60183. * The texture URL.
  60184. */
  60185. url: string;
  60186. /**
  60187. * Empty line regex stored for GC.
  60188. */
  60189. private static _noneEmptyLineRegex;
  60190. private _textureMatrix;
  60191. private _onLoad;
  60192. /**
  60193. * Instantiates a ColorGradingTexture from the following parameters.
  60194. *
  60195. * @param url The location of the color gradind data (currently only supporting 3dl)
  60196. * @param sceneOrEngine The scene or engine the texture will be used in
  60197. * @param onLoad defines a callback triggered when the texture has been loaded
  60198. */
  60199. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60200. /**
  60201. * Fires the onload event from the constructor if requested.
  60202. */
  60203. private _triggerOnLoad;
  60204. /**
  60205. * Returns the texture matrix used in most of the material.
  60206. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60207. */
  60208. getTextureMatrix(): Matrix;
  60209. /**
  60210. * Occurs when the file being loaded is a .3dl LUT file.
  60211. */
  60212. private load3dlTexture;
  60213. /**
  60214. * Starts the loading process of the texture.
  60215. */
  60216. private loadTexture;
  60217. /**
  60218. * Clones the color gradind texture.
  60219. */
  60220. clone(): ColorGradingTexture;
  60221. /**
  60222. * Called during delayed load for textures.
  60223. */
  60224. delayLoad(): void;
  60225. /**
  60226. * Parses a color grading texture serialized by Babylon.
  60227. * @param parsedTexture The texture information being parsedTexture
  60228. * @param scene The scene to load the texture in
  60229. * @param rootUrl The root url of the data assets to load
  60230. * @return A color gradind texture
  60231. */
  60232. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60233. /**
  60234. * Serializes the LUT texture to json format.
  60235. */
  60236. serialize(): any;
  60237. }
  60238. }
  60239. declare module BABYLON {
  60240. /**
  60241. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60242. */
  60243. export class EquiRectangularCubeTexture extends BaseTexture {
  60244. /** The six faces of the cube. */
  60245. private static _FacesMapping;
  60246. private _noMipmap;
  60247. private _onLoad;
  60248. private _onError;
  60249. /** The size of the cubemap. */
  60250. private _size;
  60251. /** The buffer of the image. */
  60252. private _buffer;
  60253. /** The width of the input image. */
  60254. private _width;
  60255. /** The height of the input image. */
  60256. private _height;
  60257. /** The URL to the image. */
  60258. url: string;
  60259. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60260. coordinatesMode: number;
  60261. /**
  60262. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60263. * @param url The location of the image
  60264. * @param scene The scene the texture will be used in
  60265. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60266. * @param noMipmap Forces to not generate the mipmap if true
  60267. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60268. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60269. * @param onLoad — defines a callback called when texture is loaded
  60270. * @param onError — defines a callback called if there is an error
  60271. */
  60272. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60273. /**
  60274. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60275. */
  60276. private loadImage;
  60277. /**
  60278. * Convert the image buffer into a cubemap and create a CubeTexture.
  60279. */
  60280. private loadTexture;
  60281. /**
  60282. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60283. * @param buffer The ArrayBuffer that should be converted.
  60284. * @returns The buffer as Float32Array.
  60285. */
  60286. private getFloat32ArrayFromArrayBuffer;
  60287. /**
  60288. * Get the current class name of the texture useful for serialization or dynamic coding.
  60289. * @returns "EquiRectangularCubeTexture"
  60290. */
  60291. getClassName(): string;
  60292. /**
  60293. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60294. * @returns A clone of the current EquiRectangularCubeTexture.
  60295. */
  60296. clone(): EquiRectangularCubeTexture;
  60297. }
  60298. }
  60299. declare module BABYLON {
  60300. /**
  60301. * Defines the options related to the creation of an HtmlElementTexture
  60302. */
  60303. export interface IHtmlElementTextureOptions {
  60304. /**
  60305. * Defines wether mip maps should be created or not.
  60306. */
  60307. generateMipMaps?: boolean;
  60308. /**
  60309. * Defines the sampling mode of the texture.
  60310. */
  60311. samplingMode?: number;
  60312. /**
  60313. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60314. */
  60315. engine: Nullable<ThinEngine>;
  60316. /**
  60317. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60318. */
  60319. scene: Nullable<Scene>;
  60320. }
  60321. /**
  60322. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60323. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60324. * is automatically managed.
  60325. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60326. * in your application.
  60327. *
  60328. * As the update is not automatic, you need to call them manually.
  60329. */
  60330. export class HtmlElementTexture extends BaseTexture {
  60331. /**
  60332. * The texture URL.
  60333. */
  60334. element: HTMLVideoElement | HTMLCanvasElement;
  60335. private static readonly DefaultOptions;
  60336. private _textureMatrix;
  60337. private _isVideo;
  60338. private _generateMipMaps;
  60339. private _samplingMode;
  60340. /**
  60341. * Instantiates a HtmlElementTexture from the following parameters.
  60342. *
  60343. * @param name Defines the name of the texture
  60344. * @param element Defines the video or canvas the texture is filled with
  60345. * @param options Defines the other none mandatory texture creation options
  60346. */
  60347. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60348. private _createInternalTexture;
  60349. /**
  60350. * Returns the texture matrix used in most of the material.
  60351. */
  60352. getTextureMatrix(): Matrix;
  60353. /**
  60354. * Updates the content of the texture.
  60355. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60356. */
  60357. update(invertY?: Nullable<boolean>): void;
  60358. }
  60359. }
  60360. declare module BABYLON {
  60361. /**
  60362. * Based on jsTGALoader - Javascript loader for TGA file
  60363. * By Vincent Thibault
  60364. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60365. */
  60366. export class TGATools {
  60367. private static _TYPE_INDEXED;
  60368. private static _TYPE_RGB;
  60369. private static _TYPE_GREY;
  60370. private static _TYPE_RLE_INDEXED;
  60371. private static _TYPE_RLE_RGB;
  60372. private static _TYPE_RLE_GREY;
  60373. private static _ORIGIN_MASK;
  60374. private static _ORIGIN_SHIFT;
  60375. private static _ORIGIN_BL;
  60376. private static _ORIGIN_BR;
  60377. private static _ORIGIN_UL;
  60378. private static _ORIGIN_UR;
  60379. /**
  60380. * Gets the header of a TGA file
  60381. * @param data defines the TGA data
  60382. * @returns the header
  60383. */
  60384. static GetTGAHeader(data: Uint8Array): any;
  60385. /**
  60386. * Uploads TGA content to a Babylon Texture
  60387. * @hidden
  60388. */
  60389. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60390. /** @hidden */
  60391. 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;
  60392. /** @hidden */
  60393. 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;
  60394. /** @hidden */
  60395. 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;
  60396. /** @hidden */
  60397. 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;
  60398. /** @hidden */
  60399. 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;
  60400. /** @hidden */
  60401. 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;
  60402. }
  60403. }
  60404. declare module BABYLON {
  60405. /**
  60406. * Implementation of the TGA Texture Loader.
  60407. * @hidden
  60408. */
  60409. export class _TGATextureLoader implements IInternalTextureLoader {
  60410. /**
  60411. * Defines wether the loader supports cascade loading the different faces.
  60412. */
  60413. readonly supportCascades: boolean;
  60414. /**
  60415. * This returns if the loader support the current file information.
  60416. * @param extension defines the file extension of the file being loaded
  60417. * @returns true if the loader can load the specified file
  60418. */
  60419. canLoad(extension: string): boolean;
  60420. /**
  60421. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60422. * @param data contains the texture data
  60423. * @param texture defines the BabylonJS internal texture
  60424. * @param createPolynomials will be true if polynomials have been requested
  60425. * @param onLoad defines the callback to trigger once the texture is ready
  60426. * @param onError defines the callback to trigger in case of error
  60427. */
  60428. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60429. /**
  60430. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60431. * @param data contains the texture data
  60432. * @param texture defines the BabylonJS internal texture
  60433. * @param callback defines the method to call once ready to upload
  60434. */
  60435. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60436. }
  60437. }
  60438. declare module BABYLON {
  60439. /**
  60440. * Info about the .basis files
  60441. */
  60442. class BasisFileInfo {
  60443. /**
  60444. * If the file has alpha
  60445. */
  60446. hasAlpha: boolean;
  60447. /**
  60448. * Info about each image of the basis file
  60449. */
  60450. images: Array<{
  60451. levels: Array<{
  60452. width: number;
  60453. height: number;
  60454. transcodedPixels: ArrayBufferView;
  60455. }>;
  60456. }>;
  60457. }
  60458. /**
  60459. * Result of transcoding a basis file
  60460. */
  60461. class TranscodeResult {
  60462. /**
  60463. * Info about the .basis file
  60464. */
  60465. fileInfo: BasisFileInfo;
  60466. /**
  60467. * Format to use when loading the file
  60468. */
  60469. format: number;
  60470. }
  60471. /**
  60472. * Configuration options for the Basis transcoder
  60473. */
  60474. export class BasisTranscodeConfiguration {
  60475. /**
  60476. * Supported compression formats used to determine the supported output format of the transcoder
  60477. */
  60478. supportedCompressionFormats?: {
  60479. /**
  60480. * etc1 compression format
  60481. */
  60482. etc1?: boolean;
  60483. /**
  60484. * s3tc compression format
  60485. */
  60486. s3tc?: boolean;
  60487. /**
  60488. * pvrtc compression format
  60489. */
  60490. pvrtc?: boolean;
  60491. /**
  60492. * etc2 compression format
  60493. */
  60494. etc2?: boolean;
  60495. };
  60496. /**
  60497. * If mipmap levels should be loaded for transcoded images (Default: true)
  60498. */
  60499. loadMipmapLevels?: boolean;
  60500. /**
  60501. * Index of a single image to load (Default: all images)
  60502. */
  60503. loadSingleImage?: number;
  60504. }
  60505. /**
  60506. * Used to load .Basis files
  60507. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60508. */
  60509. export class BasisTools {
  60510. private static _IgnoreSupportedFormats;
  60511. /**
  60512. * URL to use when loading the basis transcoder
  60513. */
  60514. static JSModuleURL: string;
  60515. /**
  60516. * URL to use when loading the wasm module for the transcoder
  60517. */
  60518. static WasmModuleURL: string;
  60519. /**
  60520. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60521. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60522. * @returns internal format corresponding to the Basis format
  60523. */
  60524. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60525. private static _WorkerPromise;
  60526. private static _Worker;
  60527. private static _actionId;
  60528. private static _CreateWorkerAsync;
  60529. /**
  60530. * Transcodes a loaded image file to compressed pixel data
  60531. * @param data image data to transcode
  60532. * @param config configuration options for the transcoding
  60533. * @returns a promise resulting in the transcoded image
  60534. */
  60535. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60536. /**
  60537. * Loads a texture from the transcode result
  60538. * @param texture texture load to
  60539. * @param transcodeResult the result of transcoding the basis file to load from
  60540. */
  60541. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60542. }
  60543. }
  60544. declare module BABYLON {
  60545. /**
  60546. * Loader for .basis file format
  60547. */
  60548. export class _BasisTextureLoader implements IInternalTextureLoader {
  60549. /**
  60550. * Defines whether the loader supports cascade loading the different faces.
  60551. */
  60552. readonly supportCascades: boolean;
  60553. /**
  60554. * This returns if the loader support the current file information.
  60555. * @param extension defines the file extension of the file being loaded
  60556. * @returns true if the loader can load the specified file
  60557. */
  60558. canLoad(extension: string): boolean;
  60559. /**
  60560. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60561. * @param data contains the texture data
  60562. * @param texture defines the BabylonJS internal texture
  60563. * @param createPolynomials will be true if polynomials have been requested
  60564. * @param onLoad defines the callback to trigger once the texture is ready
  60565. * @param onError defines the callback to trigger in case of error
  60566. */
  60567. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60568. /**
  60569. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60570. * @param data contains the texture data
  60571. * @param texture defines the BabylonJS internal texture
  60572. * @param callback defines the method to call once ready to upload
  60573. */
  60574. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60575. }
  60576. }
  60577. declare module BABYLON {
  60578. /**
  60579. * Defines the basic options interface of a TexturePacker Frame
  60580. */
  60581. export interface ITexturePackerFrame {
  60582. /**
  60583. * The frame ID
  60584. */
  60585. id: number;
  60586. /**
  60587. * The frames Scale
  60588. */
  60589. scale: Vector2;
  60590. /**
  60591. * The Frames offset
  60592. */
  60593. offset: Vector2;
  60594. }
  60595. /**
  60596. * This is a support class for frame Data on texture packer sets.
  60597. */
  60598. export class TexturePackerFrame implements ITexturePackerFrame {
  60599. /**
  60600. * The frame ID
  60601. */
  60602. id: number;
  60603. /**
  60604. * The frames Scale
  60605. */
  60606. scale: Vector2;
  60607. /**
  60608. * The Frames offset
  60609. */
  60610. offset: Vector2;
  60611. /**
  60612. * Initializes a texture package frame.
  60613. * @param id The numerical frame identifier
  60614. * @param scale Scalar Vector2 for UV frame
  60615. * @param offset Vector2 for the frame position in UV units.
  60616. * @returns TexturePackerFrame
  60617. */
  60618. constructor(id: number, scale: Vector2, offset: Vector2);
  60619. }
  60620. }
  60621. declare module BABYLON {
  60622. /**
  60623. * Defines the basic options interface of a TexturePacker
  60624. */
  60625. export interface ITexturePackerOptions {
  60626. /**
  60627. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60628. */
  60629. map?: string[];
  60630. /**
  60631. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60632. */
  60633. uvsIn?: string;
  60634. /**
  60635. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60636. */
  60637. uvsOut?: string;
  60638. /**
  60639. * number representing the layout style. Defaults to LAYOUT_STRIP
  60640. */
  60641. layout?: number;
  60642. /**
  60643. * number of columns if using custom column count layout(2). This defaults to 4.
  60644. */
  60645. colnum?: number;
  60646. /**
  60647. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60648. */
  60649. updateInputMeshes?: boolean;
  60650. /**
  60651. * boolean flag to dispose all the source textures. Defaults to true.
  60652. */
  60653. disposeSources?: boolean;
  60654. /**
  60655. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60656. */
  60657. fillBlanks?: boolean;
  60658. /**
  60659. * string value representing the context fill style color. Defaults to 'black'.
  60660. */
  60661. customFillColor?: string;
  60662. /**
  60663. * Width and Height Value of each Frame in the TexturePacker Sets
  60664. */
  60665. frameSize?: number;
  60666. /**
  60667. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60668. */
  60669. paddingRatio?: number;
  60670. /**
  60671. * Number that declares the fill method for the padding gutter.
  60672. */
  60673. paddingMode?: number;
  60674. /**
  60675. * If in SUBUV_COLOR padding mode what color to use.
  60676. */
  60677. paddingColor?: Color3 | Color4;
  60678. }
  60679. /**
  60680. * Defines the basic interface of a TexturePacker JSON File
  60681. */
  60682. export interface ITexturePackerJSON {
  60683. /**
  60684. * The frame ID
  60685. */
  60686. name: string;
  60687. /**
  60688. * The base64 channel data
  60689. */
  60690. sets: any;
  60691. /**
  60692. * The options of the Packer
  60693. */
  60694. options: ITexturePackerOptions;
  60695. /**
  60696. * The frame data of the Packer
  60697. */
  60698. frames: Array<number>;
  60699. }
  60700. /**
  60701. * This is a support class that generates a series of packed texture sets.
  60702. * @see https://doc.babylonjs.com/babylon101/materials
  60703. */
  60704. export class TexturePacker {
  60705. /** Packer Layout Constant 0 */
  60706. static readonly LAYOUT_STRIP: number;
  60707. /** Packer Layout Constant 1 */
  60708. static readonly LAYOUT_POWER2: number;
  60709. /** Packer Layout Constant 2 */
  60710. static readonly LAYOUT_COLNUM: number;
  60711. /** Packer Layout Constant 0 */
  60712. static readonly SUBUV_WRAP: number;
  60713. /** Packer Layout Constant 1 */
  60714. static readonly SUBUV_EXTEND: number;
  60715. /** Packer Layout Constant 2 */
  60716. static readonly SUBUV_COLOR: number;
  60717. /** The Name of the Texture Package */
  60718. name: string;
  60719. /** The scene scope of the TexturePacker */
  60720. scene: Scene;
  60721. /** The Meshes to target */
  60722. meshes: AbstractMesh[];
  60723. /** Arguments passed with the Constructor */
  60724. options: ITexturePackerOptions;
  60725. /** The promise that is started upon initialization */
  60726. promise: Nullable<Promise<TexturePacker | string>>;
  60727. /** The Container object for the channel sets that are generated */
  60728. sets: object;
  60729. /** The Container array for the frames that are generated */
  60730. frames: TexturePackerFrame[];
  60731. /** The expected number of textures the system is parsing. */
  60732. private _expecting;
  60733. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60734. private _paddingValue;
  60735. /**
  60736. * Initializes a texture package series from an array of meshes or a single mesh.
  60737. * @param name The name of the package
  60738. * @param meshes The target meshes to compose the package from
  60739. * @param options The arguments that texture packer should follow while building.
  60740. * @param scene The scene which the textures are scoped to.
  60741. * @returns TexturePacker
  60742. */
  60743. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60744. /**
  60745. * Starts the package process
  60746. * @param resolve The promises resolution function
  60747. * @returns TexturePacker
  60748. */
  60749. private _createFrames;
  60750. /**
  60751. * Calculates the Size of the Channel Sets
  60752. * @returns Vector2
  60753. */
  60754. private _calculateSize;
  60755. /**
  60756. * Calculates the UV data for the frames.
  60757. * @param baseSize the base frameSize
  60758. * @param padding the base frame padding
  60759. * @param dtSize size of the Dynamic Texture for that channel
  60760. * @param dtUnits is 1/dtSize
  60761. * @param update flag to update the input meshes
  60762. */
  60763. private _calculateMeshUVFrames;
  60764. /**
  60765. * Calculates the frames Offset.
  60766. * @param index of the frame
  60767. * @returns Vector2
  60768. */
  60769. private _getFrameOffset;
  60770. /**
  60771. * Updates a Mesh to the frame data
  60772. * @param mesh that is the target
  60773. * @param frameID or the frame index
  60774. */
  60775. private _updateMeshUV;
  60776. /**
  60777. * Updates a Meshes materials to use the texture packer channels
  60778. * @param m is the mesh to target
  60779. * @param force all channels on the packer to be set.
  60780. */
  60781. private _updateTextureReferences;
  60782. /**
  60783. * Public method to set a Mesh to a frame
  60784. * @param m that is the target
  60785. * @param frameID or the frame index
  60786. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60787. */
  60788. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60789. /**
  60790. * Starts the async promise to compile the texture packer.
  60791. * @returns Promise<void>
  60792. */
  60793. processAsync(): Promise<void>;
  60794. /**
  60795. * Disposes all textures associated with this packer
  60796. */
  60797. dispose(): void;
  60798. /**
  60799. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60800. * @param imageType is the image type to use.
  60801. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60802. */
  60803. download(imageType?: string, quality?: number): void;
  60804. /**
  60805. * Public method to load a texturePacker JSON file.
  60806. * @param data of the JSON file in string format.
  60807. */
  60808. updateFromJSON(data: string): void;
  60809. }
  60810. }
  60811. declare module BABYLON {
  60812. /**
  60813. * 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.
  60814. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60815. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60816. */
  60817. export class CustomProceduralTexture extends ProceduralTexture {
  60818. private _animate;
  60819. private _time;
  60820. private _config;
  60821. private _texturePath;
  60822. /**
  60823. * Instantiates a new Custom Procedural Texture.
  60824. * 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.
  60825. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60826. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60827. * @param name Define the name of the texture
  60828. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60829. * @param size Define the size of the texture to create
  60830. * @param scene Define the scene the texture belongs to
  60831. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60832. * @param generateMipMaps Define if the texture should creates mip maps or not
  60833. */
  60834. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60835. private _loadJson;
  60836. /**
  60837. * Is the texture ready to be used ? (rendered at least once)
  60838. * @returns true if ready, otherwise, false.
  60839. */
  60840. isReady(): boolean;
  60841. /**
  60842. * Render the texture to its associated render target.
  60843. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60844. */
  60845. render(useCameraPostProcess?: boolean): void;
  60846. /**
  60847. * Update the list of dependant textures samplers in the shader.
  60848. */
  60849. updateTextures(): void;
  60850. /**
  60851. * Update the uniform values of the procedural texture in the shader.
  60852. */
  60853. updateShaderUniforms(): void;
  60854. /**
  60855. * Define if the texture animates or not.
  60856. */
  60857. get animate(): boolean;
  60858. set animate(value: boolean);
  60859. }
  60860. }
  60861. declare module BABYLON {
  60862. /** @hidden */
  60863. export var noisePixelShader: {
  60864. name: string;
  60865. shader: string;
  60866. };
  60867. }
  60868. declare module BABYLON {
  60869. /**
  60870. * Class used to generate noise procedural textures
  60871. */
  60872. export class NoiseProceduralTexture extends ProceduralTexture {
  60873. private _time;
  60874. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60875. brightness: number;
  60876. /** Defines the number of octaves to process */
  60877. octaves: number;
  60878. /** Defines the level of persistence (0.8 by default) */
  60879. persistence: number;
  60880. /** Gets or sets animation speed factor (default is 1) */
  60881. animationSpeedFactor: number;
  60882. /**
  60883. * Creates a new NoiseProceduralTexture
  60884. * @param name defines the name fo the texture
  60885. * @param size defines the size of the texture (default is 256)
  60886. * @param scene defines the hosting scene
  60887. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60888. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60889. */
  60890. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60891. private _updateShaderUniforms;
  60892. protected _getDefines(): string;
  60893. /** Generate the current state of the procedural texture */
  60894. render(useCameraPostProcess?: boolean): void;
  60895. /**
  60896. * Serializes this noise procedural texture
  60897. * @returns a serialized noise procedural texture object
  60898. */
  60899. serialize(): any;
  60900. /**
  60901. * Clone the texture.
  60902. * @returns the cloned texture
  60903. */
  60904. clone(): NoiseProceduralTexture;
  60905. /**
  60906. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60907. * @param parsedTexture defines parsed texture data
  60908. * @param scene defines the current scene
  60909. * @param rootUrl defines the root URL containing noise procedural texture information
  60910. * @returns a parsed NoiseProceduralTexture
  60911. */
  60912. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60913. }
  60914. }
  60915. declare module BABYLON {
  60916. /**
  60917. * Raw cube texture where the raw buffers are passed in
  60918. */
  60919. export class RawCubeTexture extends CubeTexture {
  60920. /**
  60921. * Creates a cube texture where the raw buffers are passed in.
  60922. * @param scene defines the scene the texture is attached to
  60923. * @param data defines the array of data to use to create each face
  60924. * @param size defines the size of the textures
  60925. * @param format defines the format of the data
  60926. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60927. * @param generateMipMaps defines if the engine should generate the mip levels
  60928. * @param invertY defines if data must be stored with Y axis inverted
  60929. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60930. * @param compression defines the compression used (null by default)
  60931. */
  60932. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60933. /**
  60934. * Updates the raw cube texture.
  60935. * @param data defines the data to store
  60936. * @param format defines the data format
  60937. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60938. * @param invertY defines if data must be stored with Y axis inverted
  60939. * @param compression defines the compression used (null by default)
  60940. * @param level defines which level of the texture to update
  60941. */
  60942. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60943. /**
  60944. * Updates a raw cube texture with RGBD encoded data.
  60945. * @param data defines the array of data [mipmap][face] to use to create each face
  60946. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60947. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60948. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60949. * @returns a promsie that resolves when the operation is complete
  60950. */
  60951. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60952. /**
  60953. * Clones the raw cube texture.
  60954. * @return a new cube texture
  60955. */
  60956. clone(): CubeTexture;
  60957. /** @hidden */
  60958. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60959. }
  60960. }
  60961. declare module BABYLON {
  60962. /**
  60963. * Class used to store 2D array textures containing user data
  60964. */
  60965. export class RawTexture2DArray extends Texture {
  60966. /** Gets or sets the texture format to use */
  60967. format: number;
  60968. /**
  60969. * Create a new RawTexture2DArray
  60970. * @param data defines the data of the texture
  60971. * @param width defines the width of the texture
  60972. * @param height defines the height of the texture
  60973. * @param depth defines the number of layers of the texture
  60974. * @param format defines the texture format to use
  60975. * @param scene defines the hosting scene
  60976. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60977. * @param invertY defines if texture must be stored with Y axis inverted
  60978. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60979. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60980. */
  60981. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60982. /** Gets or sets the texture format to use */
  60983. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60984. /**
  60985. * Update the texture with new data
  60986. * @param data defines the data to store in the texture
  60987. */
  60988. update(data: ArrayBufferView): void;
  60989. }
  60990. }
  60991. declare module BABYLON {
  60992. /**
  60993. * Class used to store 3D textures containing user data
  60994. */
  60995. export class RawTexture3D extends Texture {
  60996. /** Gets or sets the texture format to use */
  60997. format: number;
  60998. /**
  60999. * Create a new RawTexture3D
  61000. * @param data defines the data of the texture
  61001. * @param width defines the width of the texture
  61002. * @param height defines the height of the texture
  61003. * @param depth defines the depth of the texture
  61004. * @param format defines the texture format to use
  61005. * @param scene defines the hosting scene
  61006. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61007. * @param invertY defines if texture must be stored with Y axis inverted
  61008. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61009. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61010. */
  61011. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61012. /** Gets or sets the texture format to use */
  61013. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61014. /**
  61015. * Update the texture with new data
  61016. * @param data defines the data to store in the texture
  61017. */
  61018. update(data: ArrayBufferView): void;
  61019. }
  61020. }
  61021. declare module BABYLON {
  61022. /**
  61023. * Creates a refraction texture used by refraction channel of the standard material.
  61024. * It is like a mirror but to see through a material.
  61025. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61026. */
  61027. export class RefractionTexture extends RenderTargetTexture {
  61028. /**
  61029. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61030. * 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.
  61031. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61032. */
  61033. refractionPlane: Plane;
  61034. /**
  61035. * Define how deep under the surface we should see.
  61036. */
  61037. depth: number;
  61038. /**
  61039. * Creates a refraction texture used by refraction channel of the standard material.
  61040. * It is like a mirror but to see through a material.
  61041. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61042. * @param name Define the texture name
  61043. * @param size Define the size of the underlying texture
  61044. * @param scene Define the scene the refraction belongs to
  61045. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61046. */
  61047. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61048. /**
  61049. * Clone the refraction texture.
  61050. * @returns the cloned texture
  61051. */
  61052. clone(): RefractionTexture;
  61053. /**
  61054. * Serialize the texture to a JSON representation you could use in Parse later on
  61055. * @returns the serialized JSON representation
  61056. */
  61057. serialize(): any;
  61058. }
  61059. }
  61060. declare module BABYLON {
  61061. /**
  61062. * Block used to add support for vertex skinning (bones)
  61063. */
  61064. export class BonesBlock extends NodeMaterialBlock {
  61065. /**
  61066. * Creates a new BonesBlock
  61067. * @param name defines the block name
  61068. */
  61069. constructor(name: string);
  61070. /**
  61071. * Initialize the block and prepare the context for build
  61072. * @param state defines the state that will be used for the build
  61073. */
  61074. initialize(state: NodeMaterialBuildState): void;
  61075. /**
  61076. * Gets the current class name
  61077. * @returns the class name
  61078. */
  61079. getClassName(): string;
  61080. /**
  61081. * Gets the matrix indices input component
  61082. */
  61083. get matricesIndices(): NodeMaterialConnectionPoint;
  61084. /**
  61085. * Gets the matrix weights input component
  61086. */
  61087. get matricesWeights(): NodeMaterialConnectionPoint;
  61088. /**
  61089. * Gets the extra matrix indices input component
  61090. */
  61091. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61092. /**
  61093. * Gets the extra matrix weights input component
  61094. */
  61095. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61096. /**
  61097. * Gets the world input component
  61098. */
  61099. get world(): NodeMaterialConnectionPoint;
  61100. /**
  61101. * Gets the output component
  61102. */
  61103. get output(): NodeMaterialConnectionPoint;
  61104. autoConfigure(material: NodeMaterial): void;
  61105. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61106. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61107. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61108. protected _buildBlock(state: NodeMaterialBuildState): this;
  61109. }
  61110. }
  61111. declare module BABYLON {
  61112. /**
  61113. * Block used to add support for instances
  61114. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61115. */
  61116. export class InstancesBlock extends NodeMaterialBlock {
  61117. /**
  61118. * Creates a new InstancesBlock
  61119. * @param name defines the block name
  61120. */
  61121. constructor(name: string);
  61122. /**
  61123. * Gets the current class name
  61124. * @returns the class name
  61125. */
  61126. getClassName(): string;
  61127. /**
  61128. * Gets the first world row input component
  61129. */
  61130. get world0(): NodeMaterialConnectionPoint;
  61131. /**
  61132. * Gets the second world row input component
  61133. */
  61134. get world1(): NodeMaterialConnectionPoint;
  61135. /**
  61136. * Gets the third world row input component
  61137. */
  61138. get world2(): NodeMaterialConnectionPoint;
  61139. /**
  61140. * Gets the forth world row input component
  61141. */
  61142. get world3(): NodeMaterialConnectionPoint;
  61143. /**
  61144. * Gets the world input component
  61145. */
  61146. get world(): NodeMaterialConnectionPoint;
  61147. /**
  61148. * Gets the output component
  61149. */
  61150. get output(): NodeMaterialConnectionPoint;
  61151. /**
  61152. * Gets the isntanceID component
  61153. */
  61154. get instanceID(): NodeMaterialConnectionPoint;
  61155. autoConfigure(material: NodeMaterial): void;
  61156. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61157. protected _buildBlock(state: NodeMaterialBuildState): this;
  61158. }
  61159. }
  61160. declare module BABYLON {
  61161. /**
  61162. * Block used to add morph targets support to vertex shader
  61163. */
  61164. export class MorphTargetsBlock extends NodeMaterialBlock {
  61165. private _repeatableContentAnchor;
  61166. /**
  61167. * Create a new MorphTargetsBlock
  61168. * @param name defines the block name
  61169. */
  61170. constructor(name: string);
  61171. /**
  61172. * Gets the current class name
  61173. * @returns the class name
  61174. */
  61175. getClassName(): string;
  61176. /**
  61177. * Gets the position input component
  61178. */
  61179. get position(): NodeMaterialConnectionPoint;
  61180. /**
  61181. * Gets the normal input component
  61182. */
  61183. get normal(): NodeMaterialConnectionPoint;
  61184. /**
  61185. * Gets the tangent input component
  61186. */
  61187. get tangent(): NodeMaterialConnectionPoint;
  61188. /**
  61189. * Gets the tangent input component
  61190. */
  61191. get uv(): NodeMaterialConnectionPoint;
  61192. /**
  61193. * Gets the position output component
  61194. */
  61195. get positionOutput(): NodeMaterialConnectionPoint;
  61196. /**
  61197. * Gets the normal output component
  61198. */
  61199. get normalOutput(): NodeMaterialConnectionPoint;
  61200. /**
  61201. * Gets the tangent output component
  61202. */
  61203. get tangentOutput(): NodeMaterialConnectionPoint;
  61204. /**
  61205. * Gets the tangent output component
  61206. */
  61207. get uvOutput(): NodeMaterialConnectionPoint;
  61208. initialize(state: NodeMaterialBuildState): void;
  61209. autoConfigure(material: NodeMaterial): void;
  61210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61212. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61213. protected _buildBlock(state: NodeMaterialBuildState): this;
  61214. }
  61215. }
  61216. declare module BABYLON {
  61217. /**
  61218. * Block used to get data information from a light
  61219. */
  61220. export class LightInformationBlock extends NodeMaterialBlock {
  61221. private _lightDataUniformName;
  61222. private _lightColorUniformName;
  61223. private _lightTypeDefineName;
  61224. /**
  61225. * Gets or sets the light associated with this block
  61226. */
  61227. light: Nullable<Light>;
  61228. /**
  61229. * Creates a new LightInformationBlock
  61230. * @param name defines the block name
  61231. */
  61232. constructor(name: string);
  61233. /**
  61234. * Gets the current class name
  61235. * @returns the class name
  61236. */
  61237. getClassName(): string;
  61238. /**
  61239. * Gets the world position input component
  61240. */
  61241. get worldPosition(): NodeMaterialConnectionPoint;
  61242. /**
  61243. * Gets the direction output component
  61244. */
  61245. get direction(): NodeMaterialConnectionPoint;
  61246. /**
  61247. * Gets the direction output component
  61248. */
  61249. get color(): NodeMaterialConnectionPoint;
  61250. /**
  61251. * Gets the direction output component
  61252. */
  61253. get intensity(): NodeMaterialConnectionPoint;
  61254. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61256. protected _buildBlock(state: NodeMaterialBuildState): this;
  61257. serialize(): any;
  61258. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61259. }
  61260. }
  61261. declare module BABYLON {
  61262. /**
  61263. * Block used to add image processing support to fragment shader
  61264. */
  61265. export class ImageProcessingBlock extends NodeMaterialBlock {
  61266. /**
  61267. * Create a new ImageProcessingBlock
  61268. * @param name defines the block name
  61269. */
  61270. constructor(name: string);
  61271. /**
  61272. * Gets the current class name
  61273. * @returns the class name
  61274. */
  61275. getClassName(): string;
  61276. /**
  61277. * Gets the color input component
  61278. */
  61279. get color(): NodeMaterialConnectionPoint;
  61280. /**
  61281. * Gets the output component
  61282. */
  61283. get output(): NodeMaterialConnectionPoint;
  61284. /**
  61285. * Initialize the block and prepare the context for build
  61286. * @param state defines the state that will be used for the build
  61287. */
  61288. initialize(state: NodeMaterialBuildState): void;
  61289. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61291. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61292. protected _buildBlock(state: NodeMaterialBuildState): this;
  61293. }
  61294. }
  61295. declare module BABYLON {
  61296. /**
  61297. * Block used to pertub normals based on a normal map
  61298. */
  61299. export class PerturbNormalBlock extends NodeMaterialBlock {
  61300. private _tangentSpaceParameterName;
  61301. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61302. invertX: boolean;
  61303. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61304. invertY: boolean;
  61305. /**
  61306. * Create a new PerturbNormalBlock
  61307. * @param name defines the block name
  61308. */
  61309. constructor(name: string);
  61310. /**
  61311. * Gets the current class name
  61312. * @returns the class name
  61313. */
  61314. getClassName(): string;
  61315. /**
  61316. * Gets the world position input component
  61317. */
  61318. get worldPosition(): NodeMaterialConnectionPoint;
  61319. /**
  61320. * Gets the world normal input component
  61321. */
  61322. get worldNormal(): NodeMaterialConnectionPoint;
  61323. /**
  61324. * Gets the world tangent input component
  61325. */
  61326. get worldTangent(): NodeMaterialConnectionPoint;
  61327. /**
  61328. * Gets the uv input component
  61329. */
  61330. get uv(): NodeMaterialConnectionPoint;
  61331. /**
  61332. * Gets the normal map color input component
  61333. */
  61334. get normalMapColor(): NodeMaterialConnectionPoint;
  61335. /**
  61336. * Gets the strength input component
  61337. */
  61338. get strength(): NodeMaterialConnectionPoint;
  61339. /**
  61340. * Gets the output component
  61341. */
  61342. get output(): NodeMaterialConnectionPoint;
  61343. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61344. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61345. autoConfigure(material: NodeMaterial): void;
  61346. protected _buildBlock(state: NodeMaterialBuildState): this;
  61347. protected _dumpPropertiesCode(): string;
  61348. serialize(): any;
  61349. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61350. }
  61351. }
  61352. declare module BABYLON {
  61353. /**
  61354. * Block used to discard a pixel if a value is smaller than a cutoff
  61355. */
  61356. export class DiscardBlock extends NodeMaterialBlock {
  61357. /**
  61358. * Create a new DiscardBlock
  61359. * @param name defines the block name
  61360. */
  61361. constructor(name: string);
  61362. /**
  61363. * Gets the current class name
  61364. * @returns the class name
  61365. */
  61366. getClassName(): string;
  61367. /**
  61368. * Gets the color input component
  61369. */
  61370. get value(): NodeMaterialConnectionPoint;
  61371. /**
  61372. * Gets the cutoff input component
  61373. */
  61374. get cutoff(): NodeMaterialConnectionPoint;
  61375. protected _buildBlock(state: NodeMaterialBuildState): this;
  61376. }
  61377. }
  61378. declare module BABYLON {
  61379. /**
  61380. * Block used to test if the fragment shader is front facing
  61381. */
  61382. export class FrontFacingBlock extends NodeMaterialBlock {
  61383. /**
  61384. * Creates a new FrontFacingBlock
  61385. * @param name defines the block name
  61386. */
  61387. constructor(name: string);
  61388. /**
  61389. * Gets the current class name
  61390. * @returns the class name
  61391. */
  61392. getClassName(): string;
  61393. /**
  61394. * Gets the output component
  61395. */
  61396. get output(): NodeMaterialConnectionPoint;
  61397. protected _buildBlock(state: NodeMaterialBuildState): this;
  61398. }
  61399. }
  61400. declare module BABYLON {
  61401. /**
  61402. * Block used to get the derivative value on x and y of a given input
  61403. */
  61404. export class DerivativeBlock extends NodeMaterialBlock {
  61405. /**
  61406. * Create a new DerivativeBlock
  61407. * @param name defines the block name
  61408. */
  61409. constructor(name: string);
  61410. /**
  61411. * Gets the current class name
  61412. * @returns the class name
  61413. */
  61414. getClassName(): string;
  61415. /**
  61416. * Gets the input component
  61417. */
  61418. get input(): NodeMaterialConnectionPoint;
  61419. /**
  61420. * Gets the derivative output on x
  61421. */
  61422. get dx(): NodeMaterialConnectionPoint;
  61423. /**
  61424. * Gets the derivative output on y
  61425. */
  61426. get dy(): NodeMaterialConnectionPoint;
  61427. protected _buildBlock(state: NodeMaterialBuildState): this;
  61428. }
  61429. }
  61430. declare module BABYLON {
  61431. /**
  61432. * Block used to make gl_FragCoord available
  61433. */
  61434. export class FragCoordBlock extends NodeMaterialBlock {
  61435. /**
  61436. * Creates a new FragCoordBlock
  61437. * @param name defines the block name
  61438. */
  61439. constructor(name: string);
  61440. /**
  61441. * Gets the current class name
  61442. * @returns the class name
  61443. */
  61444. getClassName(): string;
  61445. /**
  61446. * Gets the xy component
  61447. */
  61448. get xy(): NodeMaterialConnectionPoint;
  61449. /**
  61450. * Gets the xyz component
  61451. */
  61452. get xyz(): NodeMaterialConnectionPoint;
  61453. /**
  61454. * Gets the xyzw component
  61455. */
  61456. get xyzw(): NodeMaterialConnectionPoint;
  61457. /**
  61458. * Gets the x component
  61459. */
  61460. get x(): NodeMaterialConnectionPoint;
  61461. /**
  61462. * Gets the y component
  61463. */
  61464. get y(): NodeMaterialConnectionPoint;
  61465. /**
  61466. * Gets the z component
  61467. */
  61468. get z(): NodeMaterialConnectionPoint;
  61469. /**
  61470. * Gets the w component
  61471. */
  61472. get output(): NodeMaterialConnectionPoint;
  61473. protected writeOutputs(state: NodeMaterialBuildState): string;
  61474. protected _buildBlock(state: NodeMaterialBuildState): this;
  61475. }
  61476. }
  61477. declare module BABYLON {
  61478. /**
  61479. * Block used to get the screen sizes
  61480. */
  61481. export class ScreenSizeBlock extends NodeMaterialBlock {
  61482. private _varName;
  61483. private _scene;
  61484. /**
  61485. * Creates a new ScreenSizeBlock
  61486. * @param name defines the block name
  61487. */
  61488. constructor(name: string);
  61489. /**
  61490. * Gets the current class name
  61491. * @returns the class name
  61492. */
  61493. getClassName(): string;
  61494. /**
  61495. * Gets the xy component
  61496. */
  61497. get xy(): NodeMaterialConnectionPoint;
  61498. /**
  61499. * Gets the x component
  61500. */
  61501. get x(): NodeMaterialConnectionPoint;
  61502. /**
  61503. * Gets the y component
  61504. */
  61505. get y(): NodeMaterialConnectionPoint;
  61506. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61507. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61508. protected _buildBlock(state: NodeMaterialBuildState): this;
  61509. }
  61510. }
  61511. declare module BABYLON {
  61512. /**
  61513. * Block used to add support for scene fog
  61514. */
  61515. export class FogBlock extends NodeMaterialBlock {
  61516. private _fogDistanceName;
  61517. private _fogParameters;
  61518. /**
  61519. * Create a new FogBlock
  61520. * @param name defines the block name
  61521. */
  61522. constructor(name: string);
  61523. /**
  61524. * Gets the current class name
  61525. * @returns the class name
  61526. */
  61527. getClassName(): string;
  61528. /**
  61529. * Gets the world position input component
  61530. */
  61531. get worldPosition(): NodeMaterialConnectionPoint;
  61532. /**
  61533. * Gets the view input component
  61534. */
  61535. get view(): NodeMaterialConnectionPoint;
  61536. /**
  61537. * Gets the color input component
  61538. */
  61539. get input(): NodeMaterialConnectionPoint;
  61540. /**
  61541. * Gets the fog color input component
  61542. */
  61543. get fogColor(): NodeMaterialConnectionPoint;
  61544. /**
  61545. * Gets the output component
  61546. */
  61547. get output(): NodeMaterialConnectionPoint;
  61548. autoConfigure(material: NodeMaterial): void;
  61549. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61550. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61551. protected _buildBlock(state: NodeMaterialBuildState): this;
  61552. }
  61553. }
  61554. declare module BABYLON {
  61555. /**
  61556. * Block used to add light in the fragment shader
  61557. */
  61558. export class LightBlock extends NodeMaterialBlock {
  61559. private _lightId;
  61560. /**
  61561. * Gets or sets the light associated with this block
  61562. */
  61563. light: Nullable<Light>;
  61564. /**
  61565. * Create a new LightBlock
  61566. * @param name defines the block name
  61567. */
  61568. constructor(name: string);
  61569. /**
  61570. * Gets the current class name
  61571. * @returns the class name
  61572. */
  61573. getClassName(): string;
  61574. /**
  61575. * Gets the world position input component
  61576. */
  61577. get worldPosition(): NodeMaterialConnectionPoint;
  61578. /**
  61579. * Gets the world normal input component
  61580. */
  61581. get worldNormal(): NodeMaterialConnectionPoint;
  61582. /**
  61583. * Gets the camera (or eye) position component
  61584. */
  61585. get cameraPosition(): NodeMaterialConnectionPoint;
  61586. /**
  61587. * Gets the glossiness component
  61588. */
  61589. get glossiness(): NodeMaterialConnectionPoint;
  61590. /**
  61591. * Gets the glossinness power component
  61592. */
  61593. get glossPower(): NodeMaterialConnectionPoint;
  61594. /**
  61595. * Gets the diffuse color component
  61596. */
  61597. get diffuseColor(): NodeMaterialConnectionPoint;
  61598. /**
  61599. * Gets the specular color component
  61600. */
  61601. get specularColor(): NodeMaterialConnectionPoint;
  61602. /**
  61603. * Gets the diffuse output component
  61604. */
  61605. get diffuseOutput(): NodeMaterialConnectionPoint;
  61606. /**
  61607. * Gets the specular output component
  61608. */
  61609. get specularOutput(): NodeMaterialConnectionPoint;
  61610. /**
  61611. * Gets the shadow output component
  61612. */
  61613. get shadow(): NodeMaterialConnectionPoint;
  61614. autoConfigure(material: NodeMaterial): void;
  61615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61616. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61617. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61618. private _injectVertexCode;
  61619. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61620. serialize(): any;
  61621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61622. }
  61623. }
  61624. declare module BABYLON {
  61625. /**
  61626. * Block used to read a reflection texture from a sampler
  61627. */
  61628. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61629. /**
  61630. * Create a new ReflectionTextureBlock
  61631. * @param name defines the block name
  61632. */
  61633. constructor(name: string);
  61634. /**
  61635. * Gets the current class name
  61636. * @returns the class name
  61637. */
  61638. getClassName(): string;
  61639. /**
  61640. * Gets the world position input component
  61641. */
  61642. get position(): NodeMaterialConnectionPoint;
  61643. /**
  61644. * Gets the world position input component
  61645. */
  61646. get worldPosition(): NodeMaterialConnectionPoint;
  61647. /**
  61648. * Gets the world normal input component
  61649. */
  61650. get worldNormal(): NodeMaterialConnectionPoint;
  61651. /**
  61652. * Gets the world input component
  61653. */
  61654. get world(): NodeMaterialConnectionPoint;
  61655. /**
  61656. * Gets the camera (or eye) position component
  61657. */
  61658. get cameraPosition(): NodeMaterialConnectionPoint;
  61659. /**
  61660. * Gets the view input component
  61661. */
  61662. get view(): NodeMaterialConnectionPoint;
  61663. /**
  61664. * Gets the rgb output component
  61665. */
  61666. get rgb(): NodeMaterialConnectionPoint;
  61667. /**
  61668. * Gets the r output component
  61669. */
  61670. get r(): NodeMaterialConnectionPoint;
  61671. /**
  61672. * Gets the g output component
  61673. */
  61674. get g(): NodeMaterialConnectionPoint;
  61675. /**
  61676. * Gets the b output component
  61677. */
  61678. get b(): NodeMaterialConnectionPoint;
  61679. autoConfigure(material: NodeMaterial): void;
  61680. protected _buildBlock(state: NodeMaterialBuildState): this;
  61681. }
  61682. }
  61683. declare module BABYLON {
  61684. /**
  61685. * Block used to add 2 vectors
  61686. */
  61687. export class AddBlock extends NodeMaterialBlock {
  61688. /**
  61689. * Creates a new AddBlock
  61690. * @param name defines the block name
  61691. */
  61692. constructor(name: string);
  61693. /**
  61694. * Gets the current class name
  61695. * @returns the class name
  61696. */
  61697. getClassName(): string;
  61698. /**
  61699. * Gets the left operand input component
  61700. */
  61701. get left(): NodeMaterialConnectionPoint;
  61702. /**
  61703. * Gets the right operand input component
  61704. */
  61705. get right(): NodeMaterialConnectionPoint;
  61706. /**
  61707. * Gets the output component
  61708. */
  61709. get output(): NodeMaterialConnectionPoint;
  61710. protected _buildBlock(state: NodeMaterialBuildState): this;
  61711. }
  61712. }
  61713. declare module BABYLON {
  61714. /**
  61715. * Block used to scale a vector by a float
  61716. */
  61717. export class ScaleBlock extends NodeMaterialBlock {
  61718. /**
  61719. * Creates a new ScaleBlock
  61720. * @param name defines the block name
  61721. */
  61722. constructor(name: string);
  61723. /**
  61724. * Gets the current class name
  61725. * @returns the class name
  61726. */
  61727. getClassName(): string;
  61728. /**
  61729. * Gets the input component
  61730. */
  61731. get input(): NodeMaterialConnectionPoint;
  61732. /**
  61733. * Gets the factor input component
  61734. */
  61735. get factor(): NodeMaterialConnectionPoint;
  61736. /**
  61737. * Gets the output component
  61738. */
  61739. get output(): NodeMaterialConnectionPoint;
  61740. protected _buildBlock(state: NodeMaterialBuildState): this;
  61741. }
  61742. }
  61743. declare module BABYLON {
  61744. /**
  61745. * Block used to clamp a float
  61746. */
  61747. export class ClampBlock extends NodeMaterialBlock {
  61748. /** Gets or sets the minimum range */
  61749. minimum: number;
  61750. /** Gets or sets the maximum range */
  61751. maximum: number;
  61752. /**
  61753. * Creates a new ClampBlock
  61754. * @param name defines the block name
  61755. */
  61756. constructor(name: string);
  61757. /**
  61758. * Gets the current class name
  61759. * @returns the class name
  61760. */
  61761. getClassName(): string;
  61762. /**
  61763. * Gets the value input component
  61764. */
  61765. get value(): NodeMaterialConnectionPoint;
  61766. /**
  61767. * Gets the output component
  61768. */
  61769. get output(): NodeMaterialConnectionPoint;
  61770. protected _buildBlock(state: NodeMaterialBuildState): this;
  61771. protected _dumpPropertiesCode(): string;
  61772. serialize(): any;
  61773. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61774. }
  61775. }
  61776. declare module BABYLON {
  61777. /**
  61778. * Block used to apply a cross product between 2 vectors
  61779. */
  61780. export class CrossBlock extends NodeMaterialBlock {
  61781. /**
  61782. * Creates a new CrossBlock
  61783. * @param name defines the block name
  61784. */
  61785. constructor(name: string);
  61786. /**
  61787. * Gets the current class name
  61788. * @returns the class name
  61789. */
  61790. getClassName(): string;
  61791. /**
  61792. * Gets the left operand input component
  61793. */
  61794. get left(): NodeMaterialConnectionPoint;
  61795. /**
  61796. * Gets the right operand input component
  61797. */
  61798. get right(): NodeMaterialConnectionPoint;
  61799. /**
  61800. * Gets the output component
  61801. */
  61802. get output(): NodeMaterialConnectionPoint;
  61803. protected _buildBlock(state: NodeMaterialBuildState): this;
  61804. }
  61805. }
  61806. declare module BABYLON {
  61807. /**
  61808. * Block used to apply a dot product between 2 vectors
  61809. */
  61810. export class DotBlock extends NodeMaterialBlock {
  61811. /**
  61812. * Creates a new DotBlock
  61813. * @param name defines the block name
  61814. */
  61815. constructor(name: string);
  61816. /**
  61817. * Gets the current class name
  61818. * @returns the class name
  61819. */
  61820. getClassName(): string;
  61821. /**
  61822. * Gets the left operand input component
  61823. */
  61824. get left(): NodeMaterialConnectionPoint;
  61825. /**
  61826. * Gets the right operand input component
  61827. */
  61828. get right(): NodeMaterialConnectionPoint;
  61829. /**
  61830. * Gets the output component
  61831. */
  61832. get output(): NodeMaterialConnectionPoint;
  61833. protected _buildBlock(state: NodeMaterialBuildState): this;
  61834. }
  61835. }
  61836. declare module BABYLON {
  61837. /**
  61838. * Block used to normalize a vector
  61839. */
  61840. export class NormalizeBlock extends NodeMaterialBlock {
  61841. /**
  61842. * Creates a new NormalizeBlock
  61843. * @param name defines the block name
  61844. */
  61845. constructor(name: string);
  61846. /**
  61847. * Gets the current class name
  61848. * @returns the class name
  61849. */
  61850. getClassName(): string;
  61851. /**
  61852. * Gets the input component
  61853. */
  61854. get input(): NodeMaterialConnectionPoint;
  61855. /**
  61856. * Gets the output component
  61857. */
  61858. get output(): NodeMaterialConnectionPoint;
  61859. protected _buildBlock(state: NodeMaterialBuildState): this;
  61860. }
  61861. }
  61862. declare module BABYLON {
  61863. /**
  61864. * Operations supported by the Trigonometry block
  61865. */
  61866. export enum TrigonometryBlockOperations {
  61867. /** Cos */
  61868. Cos = 0,
  61869. /** Sin */
  61870. Sin = 1,
  61871. /** Abs */
  61872. Abs = 2,
  61873. /** Exp */
  61874. Exp = 3,
  61875. /** Exp2 */
  61876. Exp2 = 4,
  61877. /** Round */
  61878. Round = 5,
  61879. /** Floor */
  61880. Floor = 6,
  61881. /** Ceiling */
  61882. Ceiling = 7,
  61883. /** Square root */
  61884. Sqrt = 8,
  61885. /** Log */
  61886. Log = 9,
  61887. /** Tangent */
  61888. Tan = 10,
  61889. /** Arc tangent */
  61890. ArcTan = 11,
  61891. /** Arc cosinus */
  61892. ArcCos = 12,
  61893. /** Arc sinus */
  61894. ArcSin = 13,
  61895. /** Fraction */
  61896. Fract = 14,
  61897. /** Sign */
  61898. Sign = 15,
  61899. /** To radians (from degrees) */
  61900. Radians = 16,
  61901. /** To degrees (from radians) */
  61902. Degrees = 17
  61903. }
  61904. /**
  61905. * Block used to apply trigonometry operation to floats
  61906. */
  61907. export class TrigonometryBlock extends NodeMaterialBlock {
  61908. /**
  61909. * Gets or sets the operation applied by the block
  61910. */
  61911. operation: TrigonometryBlockOperations;
  61912. /**
  61913. * Creates a new TrigonometryBlock
  61914. * @param name defines the block name
  61915. */
  61916. constructor(name: string);
  61917. /**
  61918. * Gets the current class name
  61919. * @returns the class name
  61920. */
  61921. getClassName(): string;
  61922. /**
  61923. * Gets the input component
  61924. */
  61925. get input(): NodeMaterialConnectionPoint;
  61926. /**
  61927. * Gets the output component
  61928. */
  61929. get output(): NodeMaterialConnectionPoint;
  61930. protected _buildBlock(state: NodeMaterialBuildState): this;
  61931. serialize(): any;
  61932. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61933. protected _dumpPropertiesCode(): string;
  61934. }
  61935. }
  61936. declare module BABYLON {
  61937. /**
  61938. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61939. */
  61940. export class ColorMergerBlock extends NodeMaterialBlock {
  61941. /**
  61942. * Create a new ColorMergerBlock
  61943. * @param name defines the block name
  61944. */
  61945. constructor(name: string);
  61946. /**
  61947. * Gets the current class name
  61948. * @returns the class name
  61949. */
  61950. getClassName(): string;
  61951. /**
  61952. * Gets the rgb component (input)
  61953. */
  61954. get rgbIn(): NodeMaterialConnectionPoint;
  61955. /**
  61956. * Gets the r component (input)
  61957. */
  61958. get r(): NodeMaterialConnectionPoint;
  61959. /**
  61960. * Gets the g component (input)
  61961. */
  61962. get g(): NodeMaterialConnectionPoint;
  61963. /**
  61964. * Gets the b component (input)
  61965. */
  61966. get b(): NodeMaterialConnectionPoint;
  61967. /**
  61968. * Gets the a component (input)
  61969. */
  61970. get a(): NodeMaterialConnectionPoint;
  61971. /**
  61972. * Gets the rgba component (output)
  61973. */
  61974. get rgba(): NodeMaterialConnectionPoint;
  61975. /**
  61976. * Gets the rgb component (output)
  61977. */
  61978. get rgbOut(): NodeMaterialConnectionPoint;
  61979. /**
  61980. * Gets the rgb component (output)
  61981. * @deprecated Please use rgbOut instead.
  61982. */
  61983. get rgb(): NodeMaterialConnectionPoint;
  61984. protected _buildBlock(state: NodeMaterialBuildState): this;
  61985. }
  61986. }
  61987. declare module BABYLON {
  61988. /**
  61989. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61990. */
  61991. export class VectorSplitterBlock extends NodeMaterialBlock {
  61992. /**
  61993. * Create a new VectorSplitterBlock
  61994. * @param name defines the block name
  61995. */
  61996. constructor(name: string);
  61997. /**
  61998. * Gets the current class name
  61999. * @returns the class name
  62000. */
  62001. getClassName(): string;
  62002. /**
  62003. * Gets the xyzw component (input)
  62004. */
  62005. get xyzw(): NodeMaterialConnectionPoint;
  62006. /**
  62007. * Gets the xyz component (input)
  62008. */
  62009. get xyzIn(): NodeMaterialConnectionPoint;
  62010. /**
  62011. * Gets the xy component (input)
  62012. */
  62013. get xyIn(): NodeMaterialConnectionPoint;
  62014. /**
  62015. * Gets the xyz component (output)
  62016. */
  62017. get xyzOut(): NodeMaterialConnectionPoint;
  62018. /**
  62019. * Gets the xy component (output)
  62020. */
  62021. get xyOut(): NodeMaterialConnectionPoint;
  62022. /**
  62023. * Gets the x component (output)
  62024. */
  62025. get x(): NodeMaterialConnectionPoint;
  62026. /**
  62027. * Gets the y component (output)
  62028. */
  62029. get y(): NodeMaterialConnectionPoint;
  62030. /**
  62031. * Gets the z component (output)
  62032. */
  62033. get z(): NodeMaterialConnectionPoint;
  62034. /**
  62035. * Gets the w component (output)
  62036. */
  62037. get w(): NodeMaterialConnectionPoint;
  62038. protected _inputRename(name: string): string;
  62039. protected _outputRename(name: string): string;
  62040. protected _buildBlock(state: NodeMaterialBuildState): this;
  62041. }
  62042. }
  62043. declare module BABYLON {
  62044. /**
  62045. * Block used to lerp between 2 values
  62046. */
  62047. export class LerpBlock extends NodeMaterialBlock {
  62048. /**
  62049. * Creates a new LerpBlock
  62050. * @param name defines the block name
  62051. */
  62052. constructor(name: string);
  62053. /**
  62054. * Gets the current class name
  62055. * @returns the class name
  62056. */
  62057. getClassName(): string;
  62058. /**
  62059. * Gets the left operand input component
  62060. */
  62061. get left(): NodeMaterialConnectionPoint;
  62062. /**
  62063. * Gets the right operand input component
  62064. */
  62065. get right(): NodeMaterialConnectionPoint;
  62066. /**
  62067. * Gets the gradient operand input component
  62068. */
  62069. get gradient(): NodeMaterialConnectionPoint;
  62070. /**
  62071. * Gets the output component
  62072. */
  62073. get output(): NodeMaterialConnectionPoint;
  62074. protected _buildBlock(state: NodeMaterialBuildState): this;
  62075. }
  62076. }
  62077. declare module BABYLON {
  62078. /**
  62079. * Block used to divide 2 vectors
  62080. */
  62081. export class DivideBlock extends NodeMaterialBlock {
  62082. /**
  62083. * Creates a new DivideBlock
  62084. * @param name defines the block name
  62085. */
  62086. constructor(name: string);
  62087. /**
  62088. * Gets the current class name
  62089. * @returns the class name
  62090. */
  62091. getClassName(): string;
  62092. /**
  62093. * Gets the left operand input component
  62094. */
  62095. get left(): NodeMaterialConnectionPoint;
  62096. /**
  62097. * Gets the right operand input component
  62098. */
  62099. get right(): NodeMaterialConnectionPoint;
  62100. /**
  62101. * Gets the output component
  62102. */
  62103. get output(): NodeMaterialConnectionPoint;
  62104. protected _buildBlock(state: NodeMaterialBuildState): this;
  62105. }
  62106. }
  62107. declare module BABYLON {
  62108. /**
  62109. * Block used to subtract 2 vectors
  62110. */
  62111. export class SubtractBlock extends NodeMaterialBlock {
  62112. /**
  62113. * Creates a new SubtractBlock
  62114. * @param name defines the block name
  62115. */
  62116. constructor(name: string);
  62117. /**
  62118. * Gets the current class name
  62119. * @returns the class name
  62120. */
  62121. getClassName(): string;
  62122. /**
  62123. * Gets the left operand input component
  62124. */
  62125. get left(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the right operand input component
  62128. */
  62129. get right(): NodeMaterialConnectionPoint;
  62130. /**
  62131. * Gets the output component
  62132. */
  62133. get output(): NodeMaterialConnectionPoint;
  62134. protected _buildBlock(state: NodeMaterialBuildState): this;
  62135. }
  62136. }
  62137. declare module BABYLON {
  62138. /**
  62139. * Block used to step a value
  62140. */
  62141. export class StepBlock extends NodeMaterialBlock {
  62142. /**
  62143. * Creates a new StepBlock
  62144. * @param name defines the block name
  62145. */
  62146. constructor(name: string);
  62147. /**
  62148. * Gets the current class name
  62149. * @returns the class name
  62150. */
  62151. getClassName(): string;
  62152. /**
  62153. * Gets the value operand input component
  62154. */
  62155. get value(): NodeMaterialConnectionPoint;
  62156. /**
  62157. * Gets the edge operand input component
  62158. */
  62159. get edge(): NodeMaterialConnectionPoint;
  62160. /**
  62161. * Gets the output component
  62162. */
  62163. get output(): NodeMaterialConnectionPoint;
  62164. protected _buildBlock(state: NodeMaterialBuildState): this;
  62165. }
  62166. }
  62167. declare module BABYLON {
  62168. /**
  62169. * Block used to get the opposite (1 - x) of a value
  62170. */
  62171. export class OneMinusBlock extends NodeMaterialBlock {
  62172. /**
  62173. * Creates a new OneMinusBlock
  62174. * @param name defines the block name
  62175. */
  62176. constructor(name: string);
  62177. /**
  62178. * Gets the current class name
  62179. * @returns the class name
  62180. */
  62181. getClassName(): string;
  62182. /**
  62183. * Gets the input component
  62184. */
  62185. get input(): NodeMaterialConnectionPoint;
  62186. /**
  62187. * Gets the output component
  62188. */
  62189. get output(): NodeMaterialConnectionPoint;
  62190. protected _buildBlock(state: NodeMaterialBuildState): this;
  62191. }
  62192. }
  62193. declare module BABYLON {
  62194. /**
  62195. * Block used to get the view direction
  62196. */
  62197. export class ViewDirectionBlock extends NodeMaterialBlock {
  62198. /**
  62199. * Creates a new ViewDirectionBlock
  62200. * @param name defines the block name
  62201. */
  62202. constructor(name: string);
  62203. /**
  62204. * Gets the current class name
  62205. * @returns the class name
  62206. */
  62207. getClassName(): string;
  62208. /**
  62209. * Gets the world position component
  62210. */
  62211. get worldPosition(): NodeMaterialConnectionPoint;
  62212. /**
  62213. * Gets the camera position component
  62214. */
  62215. get cameraPosition(): NodeMaterialConnectionPoint;
  62216. /**
  62217. * Gets the output component
  62218. */
  62219. get output(): NodeMaterialConnectionPoint;
  62220. autoConfigure(material: NodeMaterial): void;
  62221. protected _buildBlock(state: NodeMaterialBuildState): this;
  62222. }
  62223. }
  62224. declare module BABYLON {
  62225. /**
  62226. * Block used to compute fresnel value
  62227. */
  62228. export class FresnelBlock extends NodeMaterialBlock {
  62229. /**
  62230. * Create a new FresnelBlock
  62231. * @param name defines the block name
  62232. */
  62233. constructor(name: string);
  62234. /**
  62235. * Gets the current class name
  62236. * @returns the class name
  62237. */
  62238. getClassName(): string;
  62239. /**
  62240. * Gets the world normal input component
  62241. */
  62242. get worldNormal(): NodeMaterialConnectionPoint;
  62243. /**
  62244. * Gets the view direction input component
  62245. */
  62246. get viewDirection(): NodeMaterialConnectionPoint;
  62247. /**
  62248. * Gets the bias input component
  62249. */
  62250. get bias(): NodeMaterialConnectionPoint;
  62251. /**
  62252. * Gets the camera (or eye) position component
  62253. */
  62254. get power(): NodeMaterialConnectionPoint;
  62255. /**
  62256. * Gets the fresnel output component
  62257. */
  62258. get fresnel(): NodeMaterialConnectionPoint;
  62259. autoConfigure(material: NodeMaterial): void;
  62260. protected _buildBlock(state: NodeMaterialBuildState): this;
  62261. }
  62262. }
  62263. declare module BABYLON {
  62264. /**
  62265. * Block used to get the max of 2 values
  62266. */
  62267. export class MaxBlock extends NodeMaterialBlock {
  62268. /**
  62269. * Creates a new MaxBlock
  62270. * @param name defines the block name
  62271. */
  62272. constructor(name: string);
  62273. /**
  62274. * Gets the current class name
  62275. * @returns the class name
  62276. */
  62277. getClassName(): string;
  62278. /**
  62279. * Gets the left operand input component
  62280. */
  62281. get left(): NodeMaterialConnectionPoint;
  62282. /**
  62283. * Gets the right operand input component
  62284. */
  62285. get right(): NodeMaterialConnectionPoint;
  62286. /**
  62287. * Gets the output component
  62288. */
  62289. get output(): NodeMaterialConnectionPoint;
  62290. protected _buildBlock(state: NodeMaterialBuildState): this;
  62291. }
  62292. }
  62293. declare module BABYLON {
  62294. /**
  62295. * Block used to get the min of 2 values
  62296. */
  62297. export class MinBlock extends NodeMaterialBlock {
  62298. /**
  62299. * Creates a new MinBlock
  62300. * @param name defines the block name
  62301. */
  62302. constructor(name: string);
  62303. /**
  62304. * Gets the current class name
  62305. * @returns the class name
  62306. */
  62307. getClassName(): string;
  62308. /**
  62309. * Gets the left operand input component
  62310. */
  62311. get left(): NodeMaterialConnectionPoint;
  62312. /**
  62313. * Gets the right operand input component
  62314. */
  62315. get right(): NodeMaterialConnectionPoint;
  62316. /**
  62317. * Gets the output component
  62318. */
  62319. get output(): NodeMaterialConnectionPoint;
  62320. protected _buildBlock(state: NodeMaterialBuildState): this;
  62321. }
  62322. }
  62323. declare module BABYLON {
  62324. /**
  62325. * Block used to get the distance between 2 values
  62326. */
  62327. export class DistanceBlock extends NodeMaterialBlock {
  62328. /**
  62329. * Creates a new DistanceBlock
  62330. * @param name defines the block name
  62331. */
  62332. constructor(name: string);
  62333. /**
  62334. * Gets the current class name
  62335. * @returns the class name
  62336. */
  62337. getClassName(): string;
  62338. /**
  62339. * Gets the left operand input component
  62340. */
  62341. get left(): NodeMaterialConnectionPoint;
  62342. /**
  62343. * Gets the right operand input component
  62344. */
  62345. get right(): NodeMaterialConnectionPoint;
  62346. /**
  62347. * Gets the output component
  62348. */
  62349. get output(): NodeMaterialConnectionPoint;
  62350. protected _buildBlock(state: NodeMaterialBuildState): this;
  62351. }
  62352. }
  62353. declare module BABYLON {
  62354. /**
  62355. * Block used to get the length of a vector
  62356. */
  62357. export class LengthBlock extends NodeMaterialBlock {
  62358. /**
  62359. * Creates a new LengthBlock
  62360. * @param name defines the block name
  62361. */
  62362. constructor(name: string);
  62363. /**
  62364. * Gets the current class name
  62365. * @returns the class name
  62366. */
  62367. getClassName(): string;
  62368. /**
  62369. * Gets the value input component
  62370. */
  62371. get value(): NodeMaterialConnectionPoint;
  62372. /**
  62373. * Gets the output component
  62374. */
  62375. get output(): NodeMaterialConnectionPoint;
  62376. protected _buildBlock(state: NodeMaterialBuildState): this;
  62377. }
  62378. }
  62379. declare module BABYLON {
  62380. /**
  62381. * Block used to get negative version of a value (i.e. x * -1)
  62382. */
  62383. export class NegateBlock extends NodeMaterialBlock {
  62384. /**
  62385. * Creates a new NegateBlock
  62386. * @param name defines the block name
  62387. */
  62388. constructor(name: string);
  62389. /**
  62390. * Gets the current class name
  62391. * @returns the class name
  62392. */
  62393. getClassName(): string;
  62394. /**
  62395. * Gets the value input component
  62396. */
  62397. get value(): NodeMaterialConnectionPoint;
  62398. /**
  62399. * Gets the output component
  62400. */
  62401. get output(): NodeMaterialConnectionPoint;
  62402. protected _buildBlock(state: NodeMaterialBuildState): this;
  62403. }
  62404. }
  62405. declare module BABYLON {
  62406. /**
  62407. * Block used to get the value of the first parameter raised to the power of the second
  62408. */
  62409. export class PowBlock extends NodeMaterialBlock {
  62410. /**
  62411. * Creates a new PowBlock
  62412. * @param name defines the block name
  62413. */
  62414. constructor(name: string);
  62415. /**
  62416. * Gets the current class name
  62417. * @returns the class name
  62418. */
  62419. getClassName(): string;
  62420. /**
  62421. * Gets the value operand input component
  62422. */
  62423. get value(): NodeMaterialConnectionPoint;
  62424. /**
  62425. * Gets the power operand input component
  62426. */
  62427. get power(): NodeMaterialConnectionPoint;
  62428. /**
  62429. * Gets the output component
  62430. */
  62431. get output(): NodeMaterialConnectionPoint;
  62432. protected _buildBlock(state: NodeMaterialBuildState): this;
  62433. }
  62434. }
  62435. declare module BABYLON {
  62436. /**
  62437. * Block used to get a random number
  62438. */
  62439. export class RandomNumberBlock extends NodeMaterialBlock {
  62440. /**
  62441. * Creates a new RandomNumberBlock
  62442. * @param name defines the block name
  62443. */
  62444. constructor(name: string);
  62445. /**
  62446. * Gets the current class name
  62447. * @returns the class name
  62448. */
  62449. getClassName(): string;
  62450. /**
  62451. * Gets the seed input component
  62452. */
  62453. get seed(): NodeMaterialConnectionPoint;
  62454. /**
  62455. * Gets the output component
  62456. */
  62457. get output(): NodeMaterialConnectionPoint;
  62458. protected _buildBlock(state: NodeMaterialBuildState): this;
  62459. }
  62460. }
  62461. declare module BABYLON {
  62462. /**
  62463. * Block used to compute arc tangent of 2 values
  62464. */
  62465. export class ArcTan2Block extends NodeMaterialBlock {
  62466. /**
  62467. * Creates a new ArcTan2Block
  62468. * @param name defines the block name
  62469. */
  62470. constructor(name: string);
  62471. /**
  62472. * Gets the current class name
  62473. * @returns the class name
  62474. */
  62475. getClassName(): string;
  62476. /**
  62477. * Gets the x operand input component
  62478. */
  62479. get x(): NodeMaterialConnectionPoint;
  62480. /**
  62481. * Gets the y operand input component
  62482. */
  62483. get y(): NodeMaterialConnectionPoint;
  62484. /**
  62485. * Gets the output component
  62486. */
  62487. get output(): NodeMaterialConnectionPoint;
  62488. protected _buildBlock(state: NodeMaterialBuildState): this;
  62489. }
  62490. }
  62491. declare module BABYLON {
  62492. /**
  62493. * Block used to smooth step a value
  62494. */
  62495. export class SmoothStepBlock extends NodeMaterialBlock {
  62496. /**
  62497. * Creates a new SmoothStepBlock
  62498. * @param name defines the block name
  62499. */
  62500. constructor(name: string);
  62501. /**
  62502. * Gets the current class name
  62503. * @returns the class name
  62504. */
  62505. getClassName(): string;
  62506. /**
  62507. * Gets the value operand input component
  62508. */
  62509. get value(): NodeMaterialConnectionPoint;
  62510. /**
  62511. * Gets the first edge operand input component
  62512. */
  62513. get edge0(): NodeMaterialConnectionPoint;
  62514. /**
  62515. * Gets the second edge operand input component
  62516. */
  62517. get edge1(): NodeMaterialConnectionPoint;
  62518. /**
  62519. * Gets the output component
  62520. */
  62521. get output(): NodeMaterialConnectionPoint;
  62522. protected _buildBlock(state: NodeMaterialBuildState): this;
  62523. }
  62524. }
  62525. declare module BABYLON {
  62526. /**
  62527. * Block used to get the reciprocal (1 / x) of a value
  62528. */
  62529. export class ReciprocalBlock extends NodeMaterialBlock {
  62530. /**
  62531. * Creates a new ReciprocalBlock
  62532. * @param name defines the block name
  62533. */
  62534. constructor(name: string);
  62535. /**
  62536. * Gets the current class name
  62537. * @returns the class name
  62538. */
  62539. getClassName(): string;
  62540. /**
  62541. * Gets the input component
  62542. */
  62543. get input(): NodeMaterialConnectionPoint;
  62544. /**
  62545. * Gets the output component
  62546. */
  62547. get output(): NodeMaterialConnectionPoint;
  62548. protected _buildBlock(state: NodeMaterialBuildState): this;
  62549. }
  62550. }
  62551. declare module BABYLON {
  62552. /**
  62553. * Block used to replace a color by another one
  62554. */
  62555. export class ReplaceColorBlock extends NodeMaterialBlock {
  62556. /**
  62557. * Creates a new ReplaceColorBlock
  62558. * @param name defines the block name
  62559. */
  62560. constructor(name: string);
  62561. /**
  62562. * Gets the current class name
  62563. * @returns the class name
  62564. */
  62565. getClassName(): string;
  62566. /**
  62567. * Gets the value input component
  62568. */
  62569. get value(): NodeMaterialConnectionPoint;
  62570. /**
  62571. * Gets the reference input component
  62572. */
  62573. get reference(): NodeMaterialConnectionPoint;
  62574. /**
  62575. * Gets the distance input component
  62576. */
  62577. get distance(): NodeMaterialConnectionPoint;
  62578. /**
  62579. * Gets the replacement input component
  62580. */
  62581. get replacement(): NodeMaterialConnectionPoint;
  62582. /**
  62583. * Gets the output component
  62584. */
  62585. get output(): NodeMaterialConnectionPoint;
  62586. protected _buildBlock(state: NodeMaterialBuildState): this;
  62587. }
  62588. }
  62589. declare module BABYLON {
  62590. /**
  62591. * Block used to posterize a value
  62592. * @see https://en.wikipedia.org/wiki/Posterization
  62593. */
  62594. export class PosterizeBlock extends NodeMaterialBlock {
  62595. /**
  62596. * Creates a new PosterizeBlock
  62597. * @param name defines the block name
  62598. */
  62599. constructor(name: string);
  62600. /**
  62601. * Gets the current class name
  62602. * @returns the class name
  62603. */
  62604. getClassName(): string;
  62605. /**
  62606. * Gets the value input component
  62607. */
  62608. get value(): NodeMaterialConnectionPoint;
  62609. /**
  62610. * Gets the steps input component
  62611. */
  62612. get steps(): NodeMaterialConnectionPoint;
  62613. /**
  62614. * Gets the output component
  62615. */
  62616. get output(): NodeMaterialConnectionPoint;
  62617. protected _buildBlock(state: NodeMaterialBuildState): this;
  62618. }
  62619. }
  62620. declare module BABYLON {
  62621. /**
  62622. * Operations supported by the Wave block
  62623. */
  62624. export enum WaveBlockKind {
  62625. /** SawTooth */
  62626. SawTooth = 0,
  62627. /** Square */
  62628. Square = 1,
  62629. /** Triangle */
  62630. Triangle = 2
  62631. }
  62632. /**
  62633. * Block used to apply wave operation to floats
  62634. */
  62635. export class WaveBlock extends NodeMaterialBlock {
  62636. /**
  62637. * Gets or sets the kibnd of wave to be applied by the block
  62638. */
  62639. kind: WaveBlockKind;
  62640. /**
  62641. * Creates a new WaveBlock
  62642. * @param name defines the block name
  62643. */
  62644. constructor(name: string);
  62645. /**
  62646. * Gets the current class name
  62647. * @returns the class name
  62648. */
  62649. getClassName(): string;
  62650. /**
  62651. * Gets the input component
  62652. */
  62653. get input(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the output component
  62656. */
  62657. get output(): NodeMaterialConnectionPoint;
  62658. protected _buildBlock(state: NodeMaterialBuildState): this;
  62659. serialize(): any;
  62660. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62661. }
  62662. }
  62663. declare module BABYLON {
  62664. /**
  62665. * Class used to store a color step for the GradientBlock
  62666. */
  62667. export class GradientBlockColorStep {
  62668. /**
  62669. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62670. */
  62671. step: number;
  62672. /**
  62673. * Gets or sets the color associated with this step
  62674. */
  62675. color: Color3;
  62676. /**
  62677. * Creates a new GradientBlockColorStep
  62678. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62679. * @param color defines the color associated with this step
  62680. */
  62681. constructor(
  62682. /**
  62683. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62684. */
  62685. step: number,
  62686. /**
  62687. * Gets or sets the color associated with this step
  62688. */
  62689. color: Color3);
  62690. }
  62691. /**
  62692. * Block used to return a color from a gradient based on an input value between 0 and 1
  62693. */
  62694. export class GradientBlock extends NodeMaterialBlock {
  62695. /**
  62696. * Gets or sets the list of color steps
  62697. */
  62698. colorSteps: GradientBlockColorStep[];
  62699. /**
  62700. * Creates a new GradientBlock
  62701. * @param name defines the block name
  62702. */
  62703. constructor(name: string);
  62704. /**
  62705. * Gets the current class name
  62706. * @returns the class name
  62707. */
  62708. getClassName(): string;
  62709. /**
  62710. * Gets the gradient input component
  62711. */
  62712. get gradient(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the output component
  62715. */
  62716. get output(): NodeMaterialConnectionPoint;
  62717. private _writeColorConstant;
  62718. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62719. serialize(): any;
  62720. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62721. protected _dumpPropertiesCode(): string;
  62722. }
  62723. }
  62724. declare module BABYLON {
  62725. /**
  62726. * Block used to normalize lerp between 2 values
  62727. */
  62728. export class NLerpBlock extends NodeMaterialBlock {
  62729. /**
  62730. * Creates a new NLerpBlock
  62731. * @param name defines the block name
  62732. */
  62733. constructor(name: string);
  62734. /**
  62735. * Gets the current class name
  62736. * @returns the class name
  62737. */
  62738. getClassName(): string;
  62739. /**
  62740. * Gets the left operand input component
  62741. */
  62742. get left(): NodeMaterialConnectionPoint;
  62743. /**
  62744. * Gets the right operand input component
  62745. */
  62746. get right(): NodeMaterialConnectionPoint;
  62747. /**
  62748. * Gets the gradient operand input component
  62749. */
  62750. get gradient(): NodeMaterialConnectionPoint;
  62751. /**
  62752. * Gets the output component
  62753. */
  62754. get output(): NodeMaterialConnectionPoint;
  62755. protected _buildBlock(state: NodeMaterialBuildState): this;
  62756. }
  62757. }
  62758. declare module BABYLON {
  62759. /**
  62760. * block used to Generate a Worley Noise 3D Noise Pattern
  62761. */
  62762. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62763. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62764. manhattanDistance: boolean;
  62765. /**
  62766. * Creates a new WorleyNoise3DBlock
  62767. * @param name defines the block name
  62768. */
  62769. constructor(name: string);
  62770. /**
  62771. * Gets the current class name
  62772. * @returns the class name
  62773. */
  62774. getClassName(): string;
  62775. /**
  62776. * Gets the seed input component
  62777. */
  62778. get seed(): NodeMaterialConnectionPoint;
  62779. /**
  62780. * Gets the jitter input component
  62781. */
  62782. get jitter(): NodeMaterialConnectionPoint;
  62783. /**
  62784. * Gets the output component
  62785. */
  62786. get output(): NodeMaterialConnectionPoint;
  62787. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62788. /**
  62789. * Exposes the properties to the UI?
  62790. */
  62791. protected _dumpPropertiesCode(): string;
  62792. /**
  62793. * Exposes the properties to the Seralize?
  62794. */
  62795. serialize(): any;
  62796. /**
  62797. * Exposes the properties to the deseralize?
  62798. */
  62799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62800. }
  62801. }
  62802. declare module BABYLON {
  62803. /**
  62804. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62805. */
  62806. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62807. /**
  62808. * Creates a new SimplexPerlin3DBlock
  62809. * @param name defines the block name
  62810. */
  62811. constructor(name: string);
  62812. /**
  62813. * Gets the current class name
  62814. * @returns the class name
  62815. */
  62816. getClassName(): string;
  62817. /**
  62818. * Gets the seed operand input component
  62819. */
  62820. get seed(): NodeMaterialConnectionPoint;
  62821. /**
  62822. * Gets the output component
  62823. */
  62824. get output(): NodeMaterialConnectionPoint;
  62825. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62826. }
  62827. }
  62828. declare module BABYLON {
  62829. /**
  62830. * Block used to blend normals
  62831. */
  62832. export class NormalBlendBlock extends NodeMaterialBlock {
  62833. /**
  62834. * Creates a new NormalBlendBlock
  62835. * @param name defines the block name
  62836. */
  62837. constructor(name: string);
  62838. /**
  62839. * Gets the current class name
  62840. * @returns the class name
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * Gets the first input component
  62845. */
  62846. get normalMap0(): NodeMaterialConnectionPoint;
  62847. /**
  62848. * Gets the second input component
  62849. */
  62850. get normalMap1(): NodeMaterialConnectionPoint;
  62851. /**
  62852. * Gets the output component
  62853. */
  62854. get output(): NodeMaterialConnectionPoint;
  62855. protected _buildBlock(state: NodeMaterialBuildState): this;
  62856. }
  62857. }
  62858. declare module BABYLON {
  62859. /**
  62860. * Block used to rotate a 2d vector by a given angle
  62861. */
  62862. export class Rotate2dBlock extends NodeMaterialBlock {
  62863. /**
  62864. * Creates a new Rotate2dBlock
  62865. * @param name defines the block name
  62866. */
  62867. constructor(name: string);
  62868. /**
  62869. * Gets the current class name
  62870. * @returns the class name
  62871. */
  62872. getClassName(): string;
  62873. /**
  62874. * Gets the input vector
  62875. */
  62876. get input(): NodeMaterialConnectionPoint;
  62877. /**
  62878. * Gets the input angle
  62879. */
  62880. get angle(): NodeMaterialConnectionPoint;
  62881. /**
  62882. * Gets the output component
  62883. */
  62884. get output(): NodeMaterialConnectionPoint;
  62885. autoConfigure(material: NodeMaterial): void;
  62886. protected _buildBlock(state: NodeMaterialBuildState): this;
  62887. }
  62888. }
  62889. declare module BABYLON {
  62890. /**
  62891. * Block used to get the reflected vector from a direction and a normal
  62892. */
  62893. export class ReflectBlock extends NodeMaterialBlock {
  62894. /**
  62895. * Creates a new ReflectBlock
  62896. * @param name defines the block name
  62897. */
  62898. constructor(name: string);
  62899. /**
  62900. * Gets the current class name
  62901. * @returns the class name
  62902. */
  62903. getClassName(): string;
  62904. /**
  62905. * Gets the incident component
  62906. */
  62907. get incident(): NodeMaterialConnectionPoint;
  62908. /**
  62909. * Gets the normal component
  62910. */
  62911. get normal(): NodeMaterialConnectionPoint;
  62912. /**
  62913. * Gets the output component
  62914. */
  62915. get output(): NodeMaterialConnectionPoint;
  62916. protected _buildBlock(state: NodeMaterialBuildState): this;
  62917. }
  62918. }
  62919. declare module BABYLON {
  62920. /**
  62921. * Block used to get the refracted vector from a direction and a normal
  62922. */
  62923. export class RefractBlock extends NodeMaterialBlock {
  62924. /**
  62925. * Creates a new RefractBlock
  62926. * @param name defines the block name
  62927. */
  62928. constructor(name: string);
  62929. /**
  62930. * Gets the current class name
  62931. * @returns the class name
  62932. */
  62933. getClassName(): string;
  62934. /**
  62935. * Gets the incident component
  62936. */
  62937. get incident(): NodeMaterialConnectionPoint;
  62938. /**
  62939. * Gets the normal component
  62940. */
  62941. get normal(): NodeMaterialConnectionPoint;
  62942. /**
  62943. * Gets the index of refraction component
  62944. */
  62945. get ior(): NodeMaterialConnectionPoint;
  62946. /**
  62947. * Gets the output component
  62948. */
  62949. get output(): NodeMaterialConnectionPoint;
  62950. protected _buildBlock(state: NodeMaterialBuildState): this;
  62951. }
  62952. }
  62953. declare module BABYLON {
  62954. /**
  62955. * Block used to desaturate a color
  62956. */
  62957. export class DesaturateBlock extends NodeMaterialBlock {
  62958. /**
  62959. * Creates a new DesaturateBlock
  62960. * @param name defines the block name
  62961. */
  62962. constructor(name: string);
  62963. /**
  62964. * Gets the current class name
  62965. * @returns the class name
  62966. */
  62967. getClassName(): string;
  62968. /**
  62969. * Gets the color operand input component
  62970. */
  62971. get color(): NodeMaterialConnectionPoint;
  62972. /**
  62973. * Gets the level operand input component
  62974. */
  62975. get level(): NodeMaterialConnectionPoint;
  62976. /**
  62977. * Gets the output component
  62978. */
  62979. get output(): NodeMaterialConnectionPoint;
  62980. protected _buildBlock(state: NodeMaterialBuildState): this;
  62981. }
  62982. }
  62983. declare module BABYLON {
  62984. /**
  62985. * Block used to implement the ambient occlusion module of the PBR material
  62986. */
  62987. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62988. /**
  62989. * Create a new AmbientOcclusionBlock
  62990. * @param name defines the block name
  62991. */
  62992. constructor(name: string);
  62993. /**
  62994. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  62995. */
  62996. useAmbientInGrayScale: boolean;
  62997. /**
  62998. * Initialize the block and prepare the context for build
  62999. * @param state defines the state that will be used for the build
  63000. */
  63001. initialize(state: NodeMaterialBuildState): void;
  63002. /**
  63003. * Gets the current class name
  63004. * @returns the class name
  63005. */
  63006. getClassName(): string;
  63007. /**
  63008. * Gets the texture input component
  63009. */
  63010. get texture(): NodeMaterialConnectionPoint;
  63011. /**
  63012. * Gets the texture intensity component
  63013. */
  63014. get intensity(): NodeMaterialConnectionPoint;
  63015. /**
  63016. * Gets the direct light intensity input component
  63017. */
  63018. get directLightIntensity(): NodeMaterialConnectionPoint;
  63019. /**
  63020. * Gets the ambient occlusion object output component
  63021. */
  63022. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63023. /**
  63024. * Gets the main code of the block (fragment side)
  63025. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63026. * @returns the shader code
  63027. */
  63028. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63030. protected _buildBlock(state: NodeMaterialBuildState): this;
  63031. protected _dumpPropertiesCode(): string;
  63032. serialize(): any;
  63033. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63034. }
  63035. }
  63036. declare module BABYLON {
  63037. /**
  63038. * Block used to implement the reflection module of the PBR material
  63039. */
  63040. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63041. /** @hidden */
  63042. _defineLODReflectionAlpha: string;
  63043. /** @hidden */
  63044. _defineLinearSpecularReflection: string;
  63045. private _vEnvironmentIrradianceName;
  63046. /** @hidden */
  63047. _vReflectionMicrosurfaceInfosName: string;
  63048. /** @hidden */
  63049. _vReflectionInfosName: string;
  63050. /** @hidden */
  63051. _vReflectionFilteringInfoName: string;
  63052. private _scene;
  63053. /**
  63054. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63055. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63056. * It's less burden on the user side in the editor part.
  63057. */
  63058. /** @hidden */
  63059. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63060. /** @hidden */
  63061. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63062. /** @hidden */
  63063. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63064. /**
  63065. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63066. * diffuse part of the IBL.
  63067. */
  63068. useSphericalHarmonics: boolean;
  63069. /**
  63070. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63071. */
  63072. forceIrradianceInFragment: boolean;
  63073. /**
  63074. * Create a new ReflectionBlock
  63075. * @param name defines the block name
  63076. */
  63077. constructor(name: string);
  63078. /**
  63079. * Gets the current class name
  63080. * @returns the class name
  63081. */
  63082. getClassName(): string;
  63083. /**
  63084. * Gets the position input component
  63085. */
  63086. get position(): NodeMaterialConnectionPoint;
  63087. /**
  63088. * Gets the world position input component
  63089. */
  63090. get worldPosition(): NodeMaterialConnectionPoint;
  63091. /**
  63092. * Gets the world normal input component
  63093. */
  63094. get worldNormal(): NodeMaterialConnectionPoint;
  63095. /**
  63096. * Gets the world input component
  63097. */
  63098. get world(): NodeMaterialConnectionPoint;
  63099. /**
  63100. * Gets the camera (or eye) position component
  63101. */
  63102. get cameraPosition(): NodeMaterialConnectionPoint;
  63103. /**
  63104. * Gets the view input component
  63105. */
  63106. get view(): NodeMaterialConnectionPoint;
  63107. /**
  63108. * Gets the color input component
  63109. */
  63110. get color(): NodeMaterialConnectionPoint;
  63111. /**
  63112. * Gets the reflection object output component
  63113. */
  63114. get reflection(): NodeMaterialConnectionPoint;
  63115. /**
  63116. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63117. */
  63118. get hasTexture(): boolean;
  63119. /**
  63120. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63121. */
  63122. get reflectionColor(): string;
  63123. protected _getTexture(): Nullable<BaseTexture>;
  63124. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63125. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63126. /**
  63127. * Gets the code to inject in the vertex shader
  63128. * @param state current state of the node material building
  63129. * @returns the shader code
  63130. */
  63131. handleVertexSide(state: NodeMaterialBuildState): string;
  63132. /**
  63133. * Gets the main code of the block (fragment side)
  63134. * @param state current state of the node material building
  63135. * @param normalVarName name of the existing variable corresponding to the normal
  63136. * @returns the shader code
  63137. */
  63138. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63139. protected _buildBlock(state: NodeMaterialBuildState): this;
  63140. protected _dumpPropertiesCode(): string;
  63141. serialize(): any;
  63142. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63143. }
  63144. }
  63145. declare module BABYLON {
  63146. /**
  63147. * Block used to implement the sheen module of the PBR material
  63148. */
  63149. export class SheenBlock extends NodeMaterialBlock {
  63150. /**
  63151. * Create a new SheenBlock
  63152. * @param name defines the block name
  63153. */
  63154. constructor(name: string);
  63155. /**
  63156. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63157. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63158. * making it easier to setup and tweak the effect
  63159. */
  63160. albedoScaling: boolean;
  63161. /**
  63162. * Defines if the sheen is linked to the sheen color.
  63163. */
  63164. linkSheenWithAlbedo: boolean;
  63165. /**
  63166. * Initialize the block and prepare the context for build
  63167. * @param state defines the state that will be used for the build
  63168. */
  63169. initialize(state: NodeMaterialBuildState): void;
  63170. /**
  63171. * Gets the current class name
  63172. * @returns the class name
  63173. */
  63174. getClassName(): string;
  63175. /**
  63176. * Gets the intensity input component
  63177. */
  63178. get intensity(): NodeMaterialConnectionPoint;
  63179. /**
  63180. * Gets the color input component
  63181. */
  63182. get color(): NodeMaterialConnectionPoint;
  63183. /**
  63184. * Gets the roughness input component
  63185. */
  63186. get roughness(): NodeMaterialConnectionPoint;
  63187. /**
  63188. * Gets the sheen object output component
  63189. */
  63190. get sheen(): NodeMaterialConnectionPoint;
  63191. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63192. /**
  63193. * Gets the main code of the block (fragment side)
  63194. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63195. * @returns the shader code
  63196. */
  63197. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63198. protected _buildBlock(state: NodeMaterialBuildState): this;
  63199. protected _dumpPropertiesCode(): string;
  63200. serialize(): any;
  63201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63202. }
  63203. }
  63204. declare module BABYLON {
  63205. /**
  63206. * Block used to implement the reflectivity module of the PBR material
  63207. */
  63208. export class ReflectivityBlock extends NodeMaterialBlock {
  63209. private _metallicReflectanceColor;
  63210. private _metallicF0Factor;
  63211. /** @hidden */
  63212. _vMetallicReflectanceFactorsName: string;
  63213. /**
  63214. * The property below is set by the main PBR block prior to calling methods of this class.
  63215. */
  63216. /** @hidden */
  63217. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63218. /**
  63219. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63220. */
  63221. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63222. /**
  63223. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63224. */
  63225. useMetallnessFromMetallicTextureBlue: boolean;
  63226. /**
  63227. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63228. */
  63229. useRoughnessFromMetallicTextureAlpha: boolean;
  63230. /**
  63231. * Specifies if the metallic texture contains the roughness information in its green channel.
  63232. */
  63233. useRoughnessFromMetallicTextureGreen: boolean;
  63234. /**
  63235. * Create a new ReflectivityBlock
  63236. * @param name defines the block name
  63237. */
  63238. constructor(name: string);
  63239. /**
  63240. * Initialize the block and prepare the context for build
  63241. * @param state defines the state that will be used for the build
  63242. */
  63243. initialize(state: NodeMaterialBuildState): void;
  63244. /**
  63245. * Gets the current class name
  63246. * @returns the class name
  63247. */
  63248. getClassName(): string;
  63249. /**
  63250. * Gets the metallic input component
  63251. */
  63252. get metallic(): NodeMaterialConnectionPoint;
  63253. /**
  63254. * Gets the roughness input component
  63255. */
  63256. get roughness(): NodeMaterialConnectionPoint;
  63257. /**
  63258. * Gets the texture input component
  63259. */
  63260. get texture(): NodeMaterialConnectionPoint;
  63261. /**
  63262. * Gets the reflectivity object output component
  63263. */
  63264. get reflectivity(): NodeMaterialConnectionPoint;
  63265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63266. /**
  63267. * Gets the main code of the block (fragment side)
  63268. * @param state current state of the node material building
  63269. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63270. * @returns the shader code
  63271. */
  63272. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63273. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63274. protected _buildBlock(state: NodeMaterialBuildState): this;
  63275. protected _dumpPropertiesCode(): string;
  63276. serialize(): any;
  63277. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63278. }
  63279. }
  63280. declare module BABYLON {
  63281. /**
  63282. * Block used to implement the anisotropy module of the PBR material
  63283. */
  63284. export class AnisotropyBlock extends NodeMaterialBlock {
  63285. /**
  63286. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63287. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63288. * It's less burden on the user side in the editor part.
  63289. */
  63290. /** @hidden */
  63291. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63292. /** @hidden */
  63293. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63294. /**
  63295. * Create a new AnisotropyBlock
  63296. * @param name defines the block name
  63297. */
  63298. constructor(name: string);
  63299. /**
  63300. * Initialize the block and prepare the context for build
  63301. * @param state defines the state that will be used for the build
  63302. */
  63303. initialize(state: NodeMaterialBuildState): void;
  63304. /**
  63305. * Gets the current class name
  63306. * @returns the class name
  63307. */
  63308. getClassName(): string;
  63309. /**
  63310. * Gets the intensity input component
  63311. */
  63312. get intensity(): NodeMaterialConnectionPoint;
  63313. /**
  63314. * Gets the direction input component
  63315. */
  63316. get direction(): NodeMaterialConnectionPoint;
  63317. /**
  63318. * Gets the texture input component
  63319. */
  63320. get texture(): NodeMaterialConnectionPoint;
  63321. /**
  63322. * Gets the uv input component
  63323. */
  63324. get uv(): NodeMaterialConnectionPoint;
  63325. /**
  63326. * Gets the worldTangent input component
  63327. */
  63328. get worldTangent(): NodeMaterialConnectionPoint;
  63329. /**
  63330. * Gets the anisotropy object output component
  63331. */
  63332. get anisotropy(): NodeMaterialConnectionPoint;
  63333. private _generateTBNSpace;
  63334. /**
  63335. * Gets the main code of the block (fragment side)
  63336. * @param state current state of the node material building
  63337. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63338. * @returns the shader code
  63339. */
  63340. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63342. protected _buildBlock(state: NodeMaterialBuildState): this;
  63343. }
  63344. }
  63345. declare module BABYLON {
  63346. /**
  63347. * Block used to implement the clear coat module of the PBR material
  63348. */
  63349. export class ClearCoatBlock extends NodeMaterialBlock {
  63350. private _scene;
  63351. /**
  63352. * Create a new ClearCoatBlock
  63353. * @param name defines the block name
  63354. */
  63355. constructor(name: string);
  63356. /**
  63357. * Initialize the block and prepare the context for build
  63358. * @param state defines the state that will be used for the build
  63359. */
  63360. initialize(state: NodeMaterialBuildState): void;
  63361. /**
  63362. * Gets the current class name
  63363. * @returns the class name
  63364. */
  63365. getClassName(): string;
  63366. /**
  63367. * Gets the intensity input component
  63368. */
  63369. get intensity(): NodeMaterialConnectionPoint;
  63370. /**
  63371. * Gets the roughness input component
  63372. */
  63373. get roughness(): NodeMaterialConnectionPoint;
  63374. /**
  63375. * Gets the ior input component
  63376. */
  63377. get ior(): NodeMaterialConnectionPoint;
  63378. /**
  63379. * Gets the texture input component
  63380. */
  63381. get texture(): NodeMaterialConnectionPoint;
  63382. /**
  63383. * Gets the bump texture input component
  63384. */
  63385. get bumpTexture(): NodeMaterialConnectionPoint;
  63386. /**
  63387. * Gets the uv input component
  63388. */
  63389. get uv(): NodeMaterialConnectionPoint;
  63390. /**
  63391. * Gets the tint color input component
  63392. */
  63393. get tintColor(): NodeMaterialConnectionPoint;
  63394. /**
  63395. * Gets the tint "at distance" input component
  63396. */
  63397. get tintAtDistance(): NodeMaterialConnectionPoint;
  63398. /**
  63399. * Gets the tint thickness input component
  63400. */
  63401. get tintThickness(): NodeMaterialConnectionPoint;
  63402. /**
  63403. * Gets the world tangent input component
  63404. */
  63405. get worldTangent(): NodeMaterialConnectionPoint;
  63406. /**
  63407. * Gets the clear coat object output component
  63408. */
  63409. get clearcoat(): NodeMaterialConnectionPoint;
  63410. autoConfigure(material: NodeMaterial): void;
  63411. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63412. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63413. private _generateTBNSpace;
  63414. /**
  63415. * Gets the main code of the block (fragment side)
  63416. * @param state current state of the node material building
  63417. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63418. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63419. * @param worldPosVarName name of the variable holding the world position
  63420. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63421. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63422. * @param worldNormalVarName name of the variable holding the world normal
  63423. * @returns the shader code
  63424. */
  63425. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63426. protected _buildBlock(state: NodeMaterialBuildState): this;
  63427. }
  63428. }
  63429. declare module BABYLON {
  63430. /**
  63431. * Block used to implement the sub surface module of the PBR material
  63432. */
  63433. export class SubSurfaceBlock extends NodeMaterialBlock {
  63434. /**
  63435. * Create a new SubSurfaceBlock
  63436. * @param name defines the block name
  63437. */
  63438. constructor(name: string);
  63439. /**
  63440. * Stores the intensity of the different subsurface effects in the thickness texture.
  63441. * * the green channel is the translucency intensity.
  63442. * * the blue channel is the scattering intensity.
  63443. * * the alpha channel is the refraction intensity.
  63444. */
  63445. useMaskFromThicknessTexture: boolean;
  63446. /**
  63447. * Initialize the block and prepare the context for build
  63448. * @param state defines the state that will be used for the build
  63449. */
  63450. initialize(state: NodeMaterialBuildState): void;
  63451. /**
  63452. * Gets the current class name
  63453. * @returns the class name
  63454. */
  63455. getClassName(): string;
  63456. /**
  63457. * Gets the min thickness input component
  63458. */
  63459. get minThickness(): NodeMaterialConnectionPoint;
  63460. /**
  63461. * Gets the max thickness input component
  63462. */
  63463. get maxThickness(): NodeMaterialConnectionPoint;
  63464. /**
  63465. * Gets the thickness texture component
  63466. */
  63467. get thicknessTexture(): NodeMaterialConnectionPoint;
  63468. /**
  63469. * Gets the tint color input component
  63470. */
  63471. get tintColor(): NodeMaterialConnectionPoint;
  63472. /**
  63473. * Gets the translucency intensity input component
  63474. */
  63475. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63476. /**
  63477. * Gets the translucency diffusion distance input component
  63478. */
  63479. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63480. /**
  63481. * Gets the refraction object parameters
  63482. */
  63483. get refraction(): NodeMaterialConnectionPoint;
  63484. /**
  63485. * Gets the sub surface object output component
  63486. */
  63487. get subsurface(): NodeMaterialConnectionPoint;
  63488. autoConfigure(material: NodeMaterial): void;
  63489. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63490. /**
  63491. * Gets the main code of the block (fragment side)
  63492. * @param state current state of the node material building
  63493. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63494. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63495. * @param worldPosVarName name of the variable holding the world position
  63496. * @returns the shader code
  63497. */
  63498. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63499. protected _buildBlock(state: NodeMaterialBuildState): this;
  63500. }
  63501. }
  63502. declare module BABYLON {
  63503. /**
  63504. * Block used to implement the PBR metallic/roughness model
  63505. */
  63506. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63507. /**
  63508. * Gets or sets the light associated with this block
  63509. */
  63510. light: Nullable<Light>;
  63511. private _lightId;
  63512. private _scene;
  63513. private _environmentBRDFTexture;
  63514. private _environmentBrdfSamplerName;
  63515. private _vNormalWName;
  63516. private _invertNormalName;
  63517. /**
  63518. * Create a new ReflectionBlock
  63519. * @param name defines the block name
  63520. */
  63521. constructor(name: string);
  63522. /**
  63523. * Intensity of the direct lights e.g. the four lights available in your scene.
  63524. * This impacts both the direct diffuse and specular highlights.
  63525. */
  63526. directIntensity: number;
  63527. /**
  63528. * Intensity of the environment e.g. how much the environment will light the object
  63529. * either through harmonics for rough material or through the refelction for shiny ones.
  63530. */
  63531. environmentIntensity: number;
  63532. /**
  63533. * This is a special control allowing the reduction of the specular highlights coming from the
  63534. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63535. */
  63536. specularIntensity: number;
  63537. /**
  63538. * Defines the falloff type used in this material.
  63539. * It by default is Physical.
  63540. */
  63541. lightFalloff: number;
  63542. /**
  63543. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63544. */
  63545. useAlphaFromAlbedoTexture: boolean;
  63546. /**
  63547. * Specifies that alpha test should be used
  63548. */
  63549. useAlphaTest: boolean;
  63550. /**
  63551. * Defines the alpha limits in alpha test mode.
  63552. */
  63553. alphaTestCutoff: number;
  63554. /**
  63555. * Specifies that alpha blending should be used
  63556. */
  63557. useAlphaBlending: boolean;
  63558. /**
  63559. * Defines if the alpha value should be determined via the rgb values.
  63560. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63561. */
  63562. opacityRGB: boolean;
  63563. /**
  63564. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63565. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63566. */
  63567. useRadianceOverAlpha: boolean;
  63568. /**
  63569. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63570. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63571. */
  63572. useSpecularOverAlpha: boolean;
  63573. /**
  63574. * Enables specular anti aliasing in the PBR shader.
  63575. * It will both interacts on the Geometry for analytical and IBL lighting.
  63576. * It also prefilter the roughness map based on the bump values.
  63577. */
  63578. enableSpecularAntiAliasing: boolean;
  63579. /**
  63580. * Enables realtime filtering on the texture.
  63581. */
  63582. realTimeFiltering: boolean;
  63583. /**
  63584. * Quality switch for realtime filtering
  63585. */
  63586. realTimeFilteringQuality: number;
  63587. /**
  63588. * Defines if the material uses energy conservation.
  63589. */
  63590. useEnergyConservation: boolean;
  63591. /**
  63592. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63593. * too much the area relying on ambient texture to define their ambient occlusion.
  63594. */
  63595. useRadianceOcclusion: boolean;
  63596. /**
  63597. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63598. * makes the reflect vector face the model (under horizon).
  63599. */
  63600. useHorizonOcclusion: boolean;
  63601. /**
  63602. * If set to true, no lighting calculations will be applied.
  63603. */
  63604. unlit: boolean;
  63605. /**
  63606. * Force normal to face away from face.
  63607. */
  63608. forceNormalForward: boolean;
  63609. /**
  63610. * Defines the material debug mode.
  63611. * It helps seeing only some components of the material while troubleshooting.
  63612. */
  63613. debugMode: number;
  63614. /**
  63615. * Specify from where on screen the debug mode should start.
  63616. * The value goes from -1 (full screen) to 1 (not visible)
  63617. * It helps with side by side comparison against the final render
  63618. * This defaults to 0
  63619. */
  63620. debugLimit: number;
  63621. /**
  63622. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63623. * You can use the factor to better multiply the final value.
  63624. */
  63625. debugFactor: number;
  63626. /**
  63627. * Initialize the block and prepare the context for build
  63628. * @param state defines the state that will be used for the build
  63629. */
  63630. initialize(state: NodeMaterialBuildState): void;
  63631. /**
  63632. * Gets the current class name
  63633. * @returns the class name
  63634. */
  63635. getClassName(): string;
  63636. /**
  63637. * Gets the world position input component
  63638. */
  63639. get worldPosition(): NodeMaterialConnectionPoint;
  63640. /**
  63641. * Gets the world normal input component
  63642. */
  63643. get worldNormal(): NodeMaterialConnectionPoint;
  63644. /**
  63645. * Gets the perturbed normal input component
  63646. */
  63647. get perturbedNormal(): NodeMaterialConnectionPoint;
  63648. /**
  63649. * Gets the camera position input component
  63650. */
  63651. get cameraPosition(): NodeMaterialConnectionPoint;
  63652. /**
  63653. * Gets the base color input component
  63654. */
  63655. get baseColor(): NodeMaterialConnectionPoint;
  63656. /**
  63657. * Gets the opacity texture input component
  63658. */
  63659. get opacityTexture(): NodeMaterialConnectionPoint;
  63660. /**
  63661. * Gets the ambient color input component
  63662. */
  63663. get ambientColor(): NodeMaterialConnectionPoint;
  63664. /**
  63665. * Gets the reflectivity object parameters
  63666. */
  63667. get reflectivity(): NodeMaterialConnectionPoint;
  63668. /**
  63669. * Gets the ambient occlusion object parameters
  63670. */
  63671. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63672. /**
  63673. * Gets the reflection object parameters
  63674. */
  63675. get reflection(): NodeMaterialConnectionPoint;
  63676. /**
  63677. * Gets the sheen object parameters
  63678. */
  63679. get sheen(): NodeMaterialConnectionPoint;
  63680. /**
  63681. * Gets the clear coat object parameters
  63682. */
  63683. get clearcoat(): NodeMaterialConnectionPoint;
  63684. /**
  63685. * Gets the sub surface object parameters
  63686. */
  63687. get subsurface(): NodeMaterialConnectionPoint;
  63688. /**
  63689. * Gets the anisotropy object parameters
  63690. */
  63691. get anisotropy(): NodeMaterialConnectionPoint;
  63692. /**
  63693. * Gets the ambient output component
  63694. */
  63695. get ambient(): NodeMaterialConnectionPoint;
  63696. /**
  63697. * Gets the diffuse output component
  63698. */
  63699. get diffuse(): NodeMaterialConnectionPoint;
  63700. /**
  63701. * Gets the specular output component
  63702. */
  63703. get specular(): NodeMaterialConnectionPoint;
  63704. /**
  63705. * Gets the sheen output component
  63706. */
  63707. get sheenDir(): NodeMaterialConnectionPoint;
  63708. /**
  63709. * Gets the clear coat output component
  63710. */
  63711. get clearcoatDir(): NodeMaterialConnectionPoint;
  63712. /**
  63713. * Gets the indirect diffuse output component
  63714. */
  63715. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63716. /**
  63717. * Gets the indirect specular output component
  63718. */
  63719. get specularIndirect(): NodeMaterialConnectionPoint;
  63720. /**
  63721. * Gets the indirect sheen output component
  63722. */
  63723. get sheenIndirect(): NodeMaterialConnectionPoint;
  63724. /**
  63725. * Gets the indirect clear coat output component
  63726. */
  63727. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63728. /**
  63729. * Gets the refraction output component
  63730. */
  63731. get refraction(): NodeMaterialConnectionPoint;
  63732. /**
  63733. * Gets the global lighting output component
  63734. */
  63735. get lighting(): NodeMaterialConnectionPoint;
  63736. /**
  63737. * Gets the shadow output component
  63738. */
  63739. get shadow(): NodeMaterialConnectionPoint;
  63740. /**
  63741. * Gets the alpha output component
  63742. */
  63743. get alpha(): NodeMaterialConnectionPoint;
  63744. autoConfigure(material: NodeMaterial): void;
  63745. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63746. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63747. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63748. private _injectVertexCode;
  63749. /**
  63750. * Gets the code corresponding to the albedo/opacity module
  63751. * @returns the shader code
  63752. */
  63753. getAlbedoOpacityCode(): string;
  63754. protected _buildBlock(state: NodeMaterialBuildState): this;
  63755. protected _dumpPropertiesCode(): string;
  63756. serialize(): any;
  63757. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63758. }
  63759. }
  63760. declare module BABYLON {
  63761. /**
  63762. * Block used to compute value of one parameter modulo another
  63763. */
  63764. export class ModBlock extends NodeMaterialBlock {
  63765. /**
  63766. * Creates a new ModBlock
  63767. * @param name defines the block name
  63768. */
  63769. constructor(name: string);
  63770. /**
  63771. * Gets the current class name
  63772. * @returns the class name
  63773. */
  63774. getClassName(): string;
  63775. /**
  63776. * Gets the left operand input component
  63777. */
  63778. get left(): NodeMaterialConnectionPoint;
  63779. /**
  63780. * Gets the right operand input component
  63781. */
  63782. get right(): NodeMaterialConnectionPoint;
  63783. /**
  63784. * Gets the output component
  63785. */
  63786. get output(): NodeMaterialConnectionPoint;
  63787. protected _buildBlock(state: NodeMaterialBuildState): this;
  63788. }
  63789. }
  63790. declare module BABYLON {
  63791. /**
  63792. * Helper class to push actions to a pool of workers.
  63793. */
  63794. export class WorkerPool implements IDisposable {
  63795. private _workerInfos;
  63796. private _pendingActions;
  63797. /**
  63798. * Constructor
  63799. * @param workers Array of workers to use for actions
  63800. */
  63801. constructor(workers: Array<Worker>);
  63802. /**
  63803. * Terminates all workers and clears any pending actions.
  63804. */
  63805. dispose(): void;
  63806. /**
  63807. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63808. * pended until a worker has completed its action.
  63809. * @param action The action to perform. Call onComplete when the action is complete.
  63810. */
  63811. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63812. private _execute;
  63813. }
  63814. }
  63815. declare module BABYLON {
  63816. /**
  63817. * Configuration for Draco compression
  63818. */
  63819. export interface IDracoCompressionConfiguration {
  63820. /**
  63821. * Configuration for the decoder.
  63822. */
  63823. decoder: {
  63824. /**
  63825. * The url to the WebAssembly module.
  63826. */
  63827. wasmUrl?: string;
  63828. /**
  63829. * The url to the WebAssembly binary.
  63830. */
  63831. wasmBinaryUrl?: string;
  63832. /**
  63833. * The url to the fallback JavaScript module.
  63834. */
  63835. fallbackUrl?: string;
  63836. };
  63837. }
  63838. /**
  63839. * Draco compression (https://google.github.io/draco/)
  63840. *
  63841. * This class wraps the Draco module.
  63842. *
  63843. * **Encoder**
  63844. *
  63845. * The encoder is not currently implemented.
  63846. *
  63847. * **Decoder**
  63848. *
  63849. * 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.
  63850. *
  63851. * To update the configuration, use the following code:
  63852. * ```javascript
  63853. * DracoCompression.Configuration = {
  63854. * decoder: {
  63855. * wasmUrl: "<url to the WebAssembly library>",
  63856. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63857. * fallbackUrl: "<url to the fallback JavaScript library>",
  63858. * }
  63859. * };
  63860. * ```
  63861. *
  63862. * 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.
  63863. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63864. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63865. *
  63866. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63867. * ```javascript
  63868. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63869. * ```
  63870. *
  63871. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63872. */
  63873. export class DracoCompression implements IDisposable {
  63874. private _workerPoolPromise?;
  63875. private _decoderModulePromise?;
  63876. /**
  63877. * The configuration. Defaults to the following urls:
  63878. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63879. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63880. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63881. */
  63882. static Configuration: IDracoCompressionConfiguration;
  63883. /**
  63884. * Returns true if the decoder configuration is available.
  63885. */
  63886. static get DecoderAvailable(): boolean;
  63887. /**
  63888. * Default number of workers to create when creating the draco compression object.
  63889. */
  63890. static DefaultNumWorkers: number;
  63891. private static GetDefaultNumWorkers;
  63892. private static _Default;
  63893. /**
  63894. * Default instance for the draco compression object.
  63895. */
  63896. static get Default(): DracoCompression;
  63897. /**
  63898. * Constructor
  63899. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63900. */
  63901. constructor(numWorkers?: number);
  63902. /**
  63903. * Stop all async operations and release resources.
  63904. */
  63905. dispose(): void;
  63906. /**
  63907. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63908. * @returns a promise that resolves when ready
  63909. */
  63910. whenReadyAsync(): Promise<void>;
  63911. /**
  63912. * Decode Draco compressed mesh data to vertex data.
  63913. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63914. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63915. * @returns A promise that resolves with the decoded vertex data
  63916. */
  63917. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63918. [kind: string]: number;
  63919. }): Promise<VertexData>;
  63920. }
  63921. }
  63922. declare module BABYLON {
  63923. /**
  63924. * Class for building Constructive Solid Geometry
  63925. */
  63926. export class CSG {
  63927. private polygons;
  63928. /**
  63929. * The world matrix
  63930. */
  63931. matrix: Matrix;
  63932. /**
  63933. * Stores the position
  63934. */
  63935. position: Vector3;
  63936. /**
  63937. * Stores the rotation
  63938. */
  63939. rotation: Vector3;
  63940. /**
  63941. * Stores the rotation quaternion
  63942. */
  63943. rotationQuaternion: Nullable<Quaternion>;
  63944. /**
  63945. * Stores the scaling vector
  63946. */
  63947. scaling: Vector3;
  63948. /**
  63949. * Convert the Mesh to CSG
  63950. * @param mesh The Mesh to convert to CSG
  63951. * @returns A new CSG from the Mesh
  63952. */
  63953. static FromMesh(mesh: Mesh): CSG;
  63954. /**
  63955. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63956. * @param polygons Polygons used to construct a CSG solid
  63957. */
  63958. private static FromPolygons;
  63959. /**
  63960. * Clones, or makes a deep copy, of the CSG
  63961. * @returns A new CSG
  63962. */
  63963. clone(): CSG;
  63964. /**
  63965. * Unions this CSG with another CSG
  63966. * @param csg The CSG to union against this CSG
  63967. * @returns The unioned CSG
  63968. */
  63969. union(csg: CSG): CSG;
  63970. /**
  63971. * Unions this CSG with another CSG in place
  63972. * @param csg The CSG to union against this CSG
  63973. */
  63974. unionInPlace(csg: CSG): void;
  63975. /**
  63976. * Subtracts this CSG with another CSG
  63977. * @param csg The CSG to subtract against this CSG
  63978. * @returns A new CSG
  63979. */
  63980. subtract(csg: CSG): CSG;
  63981. /**
  63982. * Subtracts this CSG with another CSG in place
  63983. * @param csg The CSG to subtact against this CSG
  63984. */
  63985. subtractInPlace(csg: CSG): void;
  63986. /**
  63987. * Intersect this CSG with another CSG
  63988. * @param csg The CSG to intersect against this CSG
  63989. * @returns A new CSG
  63990. */
  63991. intersect(csg: CSG): CSG;
  63992. /**
  63993. * Intersects this CSG with another CSG in place
  63994. * @param csg The CSG to intersect against this CSG
  63995. */
  63996. intersectInPlace(csg: CSG): void;
  63997. /**
  63998. * Return a new CSG solid with solid and empty space switched. This solid is
  63999. * not modified.
  64000. * @returns A new CSG solid with solid and empty space switched
  64001. */
  64002. inverse(): CSG;
  64003. /**
  64004. * Inverses the CSG in place
  64005. */
  64006. inverseInPlace(): void;
  64007. /**
  64008. * This is used to keep meshes transformations so they can be restored
  64009. * when we build back a Babylon Mesh
  64010. * NB : All CSG operations are performed in world coordinates
  64011. * @param csg The CSG to copy the transform attributes from
  64012. * @returns This CSG
  64013. */
  64014. copyTransformAttributes(csg: CSG): CSG;
  64015. /**
  64016. * Build Raw mesh from CSG
  64017. * Coordinates here are in world space
  64018. * @param name The name of the mesh geometry
  64019. * @param scene The Scene
  64020. * @param keepSubMeshes Specifies if the submeshes should be kept
  64021. * @returns A new Mesh
  64022. */
  64023. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64024. /**
  64025. * Build Mesh from CSG taking material and transforms into account
  64026. * @param name The name of the Mesh
  64027. * @param material The material of the Mesh
  64028. * @param scene The Scene
  64029. * @param keepSubMeshes Specifies if submeshes should be kept
  64030. * @returns The new Mesh
  64031. */
  64032. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64033. }
  64034. }
  64035. declare module BABYLON {
  64036. /**
  64037. * Class used to create a trail following a mesh
  64038. */
  64039. export class TrailMesh extends Mesh {
  64040. private _generator;
  64041. private _autoStart;
  64042. private _running;
  64043. private _diameter;
  64044. private _length;
  64045. private _sectionPolygonPointsCount;
  64046. private _sectionVectors;
  64047. private _sectionNormalVectors;
  64048. private _beforeRenderObserver;
  64049. /**
  64050. * @constructor
  64051. * @param name The value used by scene.getMeshByName() to do a lookup.
  64052. * @param generator The mesh or transform node to generate a trail.
  64053. * @param scene The scene to add this mesh to.
  64054. * @param diameter Diameter of trailing mesh. Default is 1.
  64055. * @param length Length of trailing mesh. Default is 60.
  64056. * @param autoStart Automatically start trailing mesh. Default true.
  64057. */
  64058. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64059. /**
  64060. * "TrailMesh"
  64061. * @returns "TrailMesh"
  64062. */
  64063. getClassName(): string;
  64064. private _createMesh;
  64065. /**
  64066. * Start trailing mesh.
  64067. */
  64068. start(): void;
  64069. /**
  64070. * Stop trailing mesh.
  64071. */
  64072. stop(): void;
  64073. /**
  64074. * Update trailing mesh geometry.
  64075. */
  64076. update(): void;
  64077. /**
  64078. * Returns a new TrailMesh object.
  64079. * @param name is a string, the name given to the new mesh
  64080. * @param newGenerator use new generator object for cloned trail mesh
  64081. * @returns a new mesh
  64082. */
  64083. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64084. /**
  64085. * Serializes this trail mesh
  64086. * @param serializationObject object to write serialization to
  64087. */
  64088. serialize(serializationObject: any): void;
  64089. /**
  64090. * Parses a serialized trail mesh
  64091. * @param parsedMesh the serialized mesh
  64092. * @param scene the scene to create the trail mesh in
  64093. * @returns the created trail mesh
  64094. */
  64095. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64096. }
  64097. }
  64098. declare module BABYLON {
  64099. /**
  64100. * Class containing static functions to help procedurally build meshes
  64101. */
  64102. export class TiledBoxBuilder {
  64103. /**
  64104. * Creates a box mesh
  64105. * 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)
  64106. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64108. * * 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
  64109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64110. * @param name defines the name of the mesh
  64111. * @param options defines the options used to create the mesh
  64112. * @param scene defines the hosting scene
  64113. * @returns the box mesh
  64114. */
  64115. static CreateTiledBox(name: string, options: {
  64116. pattern?: number;
  64117. width?: number;
  64118. height?: number;
  64119. depth?: number;
  64120. tileSize?: number;
  64121. tileWidth?: number;
  64122. tileHeight?: number;
  64123. alignHorizontal?: number;
  64124. alignVertical?: number;
  64125. faceUV?: Vector4[];
  64126. faceColors?: Color4[];
  64127. sideOrientation?: number;
  64128. updatable?: boolean;
  64129. }, scene?: Nullable<Scene>): Mesh;
  64130. }
  64131. }
  64132. declare module BABYLON {
  64133. /**
  64134. * Class containing static functions to help procedurally build meshes
  64135. */
  64136. export class TorusKnotBuilder {
  64137. /**
  64138. * Creates a torus knot mesh
  64139. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64140. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64141. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64142. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64144. * * 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
  64145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64146. * @param name defines the name of the mesh
  64147. * @param options defines the options used to create the mesh
  64148. * @param scene defines the hosting scene
  64149. * @returns the torus knot mesh
  64150. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64151. */
  64152. static CreateTorusKnot(name: string, options: {
  64153. radius?: number;
  64154. tube?: number;
  64155. radialSegments?: number;
  64156. tubularSegments?: number;
  64157. p?: number;
  64158. q?: number;
  64159. updatable?: boolean;
  64160. sideOrientation?: number;
  64161. frontUVs?: Vector4;
  64162. backUVs?: Vector4;
  64163. }, scene: any): Mesh;
  64164. }
  64165. }
  64166. declare module BABYLON {
  64167. /**
  64168. * Polygon
  64169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64170. */
  64171. export class Polygon {
  64172. /**
  64173. * Creates a rectangle
  64174. * @param xmin bottom X coord
  64175. * @param ymin bottom Y coord
  64176. * @param xmax top X coord
  64177. * @param ymax top Y coord
  64178. * @returns points that make the resulting rectation
  64179. */
  64180. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64181. /**
  64182. * Creates a circle
  64183. * @param radius radius of circle
  64184. * @param cx scale in x
  64185. * @param cy scale in y
  64186. * @param numberOfSides number of sides that make up the circle
  64187. * @returns points that make the resulting circle
  64188. */
  64189. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64190. /**
  64191. * Creates a polygon from input string
  64192. * @param input Input polygon data
  64193. * @returns the parsed points
  64194. */
  64195. static Parse(input: string): Vector2[];
  64196. /**
  64197. * Starts building a polygon from x and y coordinates
  64198. * @param x x coordinate
  64199. * @param y y coordinate
  64200. * @returns the started path2
  64201. */
  64202. static StartingAt(x: number, y: number): Path2;
  64203. }
  64204. /**
  64205. * Builds a polygon
  64206. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64207. */
  64208. export class PolygonMeshBuilder {
  64209. private _points;
  64210. private _outlinepoints;
  64211. private _holes;
  64212. private _name;
  64213. private _scene;
  64214. private _epoints;
  64215. private _eholes;
  64216. private _addToepoint;
  64217. /**
  64218. * Babylon reference to the earcut plugin.
  64219. */
  64220. bjsEarcut: any;
  64221. /**
  64222. * Creates a PolygonMeshBuilder
  64223. * @param name name of the builder
  64224. * @param contours Path of the polygon
  64225. * @param scene scene to add to when creating the mesh
  64226. * @param earcutInjection can be used to inject your own earcut reference
  64227. */
  64228. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64229. /**
  64230. * Adds a whole within the polygon
  64231. * @param hole Array of points defining the hole
  64232. * @returns this
  64233. */
  64234. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64235. /**
  64236. * Creates the polygon
  64237. * @param updatable If the mesh should be updatable
  64238. * @param depth The depth of the mesh created
  64239. * @returns the created mesh
  64240. */
  64241. build(updatable?: boolean, depth?: number): Mesh;
  64242. /**
  64243. * Creates the polygon
  64244. * @param depth The depth of the mesh created
  64245. * @returns the created VertexData
  64246. */
  64247. buildVertexData(depth?: number): VertexData;
  64248. /**
  64249. * Adds a side to the polygon
  64250. * @param positions points that make the polygon
  64251. * @param normals normals of the polygon
  64252. * @param uvs uvs of the polygon
  64253. * @param indices indices of the polygon
  64254. * @param bounds bounds of the polygon
  64255. * @param points points of the polygon
  64256. * @param depth depth of the polygon
  64257. * @param flip flip of the polygon
  64258. */
  64259. private addSide;
  64260. }
  64261. }
  64262. declare module BABYLON {
  64263. /**
  64264. * Class containing static functions to help procedurally build meshes
  64265. */
  64266. export class PolygonBuilder {
  64267. /**
  64268. * Creates a polygon mesh
  64269. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64270. * * 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
  64271. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64273. * * 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)
  64274. * * Remember you can only change the shape positions, not their number when updating a polygon
  64275. * @param name defines the name of the mesh
  64276. * @param options defines the options used to create the mesh
  64277. * @param scene defines the hosting scene
  64278. * @param earcutInjection can be used to inject your own earcut reference
  64279. * @returns the polygon mesh
  64280. */
  64281. static CreatePolygon(name: string, options: {
  64282. shape: Vector3[];
  64283. holes?: Vector3[][];
  64284. depth?: number;
  64285. faceUV?: Vector4[];
  64286. faceColors?: Color4[];
  64287. updatable?: boolean;
  64288. sideOrientation?: number;
  64289. frontUVs?: Vector4;
  64290. backUVs?: Vector4;
  64291. wrap?: boolean;
  64292. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64293. /**
  64294. * Creates an extruded polygon mesh, with depth in the Y direction.
  64295. * * 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)
  64296. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64297. * @param name defines the name of the mesh
  64298. * @param options defines the options used to create the mesh
  64299. * @param scene defines the hosting scene
  64300. * @param earcutInjection can be used to inject your own earcut reference
  64301. * @returns the polygon mesh
  64302. */
  64303. static ExtrudePolygon(name: string, options: {
  64304. shape: Vector3[];
  64305. holes?: Vector3[][];
  64306. depth?: number;
  64307. faceUV?: Vector4[];
  64308. faceColors?: Color4[];
  64309. updatable?: boolean;
  64310. sideOrientation?: number;
  64311. frontUVs?: Vector4;
  64312. backUVs?: Vector4;
  64313. wrap?: boolean;
  64314. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64315. }
  64316. }
  64317. declare module BABYLON {
  64318. /**
  64319. * Class containing static functions to help procedurally build meshes
  64320. */
  64321. export class LatheBuilder {
  64322. /**
  64323. * Creates lathe mesh.
  64324. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64325. * * 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
  64326. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64327. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64328. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64329. * * 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
  64330. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64331. * * 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
  64332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64333. * * 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
  64334. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64336. * @param name defines the name of the mesh
  64337. * @param options defines the options used to create the mesh
  64338. * @param scene defines the hosting scene
  64339. * @returns the lathe mesh
  64340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64341. */
  64342. static CreateLathe(name: string, options: {
  64343. shape: Vector3[];
  64344. radius?: number;
  64345. tessellation?: number;
  64346. clip?: number;
  64347. arc?: number;
  64348. closed?: boolean;
  64349. updatable?: boolean;
  64350. sideOrientation?: number;
  64351. frontUVs?: Vector4;
  64352. backUVs?: Vector4;
  64353. cap?: number;
  64354. invertUV?: boolean;
  64355. }, scene?: Nullable<Scene>): Mesh;
  64356. }
  64357. }
  64358. declare module BABYLON {
  64359. /**
  64360. * Class containing static functions to help procedurally build meshes
  64361. */
  64362. export class TiledPlaneBuilder {
  64363. /**
  64364. * Creates a tiled plane mesh
  64365. * * The parameter `pattern` will, depending on value, do nothing or
  64366. * * * flip (reflect about central vertical) alternate tiles across and up
  64367. * * * flip every tile on alternate rows
  64368. * * * rotate (180 degs) alternate tiles across and up
  64369. * * * rotate every tile on alternate rows
  64370. * * * flip and rotate alternate tiles across and up
  64371. * * * flip and rotate every tile on alternate rows
  64372. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64373. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64374. * * 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
  64375. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64376. * * 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)
  64377. * * 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)
  64378. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64379. * @param name defines the name of the mesh
  64380. * @param options defines the options used to create the mesh
  64381. * @param scene defines the hosting scene
  64382. * @returns the box mesh
  64383. */
  64384. static CreateTiledPlane(name: string, options: {
  64385. pattern?: number;
  64386. tileSize?: number;
  64387. tileWidth?: number;
  64388. tileHeight?: number;
  64389. size?: number;
  64390. width?: number;
  64391. height?: number;
  64392. alignHorizontal?: number;
  64393. alignVertical?: number;
  64394. sideOrientation?: number;
  64395. frontUVs?: Vector4;
  64396. backUVs?: Vector4;
  64397. updatable?: boolean;
  64398. }, scene?: Nullable<Scene>): Mesh;
  64399. }
  64400. }
  64401. declare module BABYLON {
  64402. /**
  64403. * Class containing static functions to help procedurally build meshes
  64404. */
  64405. export class TubeBuilder {
  64406. /**
  64407. * Creates a tube mesh.
  64408. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64409. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64410. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64411. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64412. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64413. * * 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)
  64414. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64415. * * 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
  64416. * * 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
  64417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64418. * * 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
  64419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64421. * @param name defines the name of the mesh
  64422. * @param options defines the options used to create the mesh
  64423. * @param scene defines the hosting scene
  64424. * @returns the tube mesh
  64425. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64426. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64427. */
  64428. static CreateTube(name: string, options: {
  64429. path: Vector3[];
  64430. radius?: number;
  64431. tessellation?: number;
  64432. radiusFunction?: {
  64433. (i: number, distance: number): number;
  64434. };
  64435. cap?: number;
  64436. arc?: number;
  64437. updatable?: boolean;
  64438. sideOrientation?: number;
  64439. frontUVs?: Vector4;
  64440. backUVs?: Vector4;
  64441. instance?: Mesh;
  64442. invertUV?: boolean;
  64443. }, scene?: Nullable<Scene>): Mesh;
  64444. }
  64445. }
  64446. declare module BABYLON {
  64447. /**
  64448. * Class containing static functions to help procedurally build meshes
  64449. */
  64450. export class IcoSphereBuilder {
  64451. /**
  64452. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64453. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64454. * * 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`)
  64455. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64456. * * 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
  64457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64458. * * 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
  64459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64460. * @param name defines the name of the mesh
  64461. * @param options defines the options used to create the mesh
  64462. * @param scene defines the hosting scene
  64463. * @returns the icosahedron mesh
  64464. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64465. */
  64466. static CreateIcoSphere(name: string, options: {
  64467. radius?: number;
  64468. radiusX?: number;
  64469. radiusY?: number;
  64470. radiusZ?: number;
  64471. flat?: boolean;
  64472. subdivisions?: number;
  64473. sideOrientation?: number;
  64474. frontUVs?: Vector4;
  64475. backUVs?: Vector4;
  64476. updatable?: boolean;
  64477. }, scene?: Nullable<Scene>): Mesh;
  64478. }
  64479. }
  64480. declare module BABYLON {
  64481. /**
  64482. * Class containing static functions to help procedurally build meshes
  64483. */
  64484. export class DecalBuilder {
  64485. /**
  64486. * Creates a decal mesh.
  64487. * 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
  64488. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64489. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64490. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64491. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64492. * @param name defines the name of the mesh
  64493. * @param sourceMesh defines the mesh where the decal must be applied
  64494. * @param options defines the options used to create the mesh
  64495. * @param scene defines the hosting scene
  64496. * @returns the decal mesh
  64497. * @see https://doc.babylonjs.com/how_to/decals
  64498. */
  64499. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64500. position?: Vector3;
  64501. normal?: Vector3;
  64502. size?: Vector3;
  64503. angle?: number;
  64504. }): Mesh;
  64505. }
  64506. }
  64507. declare module BABYLON {
  64508. /**
  64509. * Class containing static functions to help procedurally build meshes
  64510. */
  64511. export class MeshBuilder {
  64512. /**
  64513. * Creates a box mesh
  64514. * * The parameter `size` sets the size (float) of each box side (default 1)
  64515. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64516. * * 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)
  64517. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64519. * * 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
  64520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64521. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64522. * @param name defines the name of the mesh
  64523. * @param options defines the options used to create the mesh
  64524. * @param scene defines the hosting scene
  64525. * @returns the box mesh
  64526. */
  64527. static CreateBox(name: string, options: {
  64528. size?: number;
  64529. width?: number;
  64530. height?: number;
  64531. depth?: number;
  64532. faceUV?: Vector4[];
  64533. faceColors?: Color4[];
  64534. sideOrientation?: number;
  64535. frontUVs?: Vector4;
  64536. backUVs?: Vector4;
  64537. wrap?: boolean;
  64538. topBaseAt?: number;
  64539. bottomBaseAt?: number;
  64540. updatable?: boolean;
  64541. }, scene?: Nullable<Scene>): Mesh;
  64542. /**
  64543. * Creates a tiled box mesh
  64544. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64546. * @param name defines the name of the mesh
  64547. * @param options defines the options used to create the mesh
  64548. * @param scene defines the hosting scene
  64549. * @returns the tiled box mesh
  64550. */
  64551. static CreateTiledBox(name: string, options: {
  64552. pattern?: number;
  64553. size?: number;
  64554. width?: number;
  64555. height?: number;
  64556. depth: number;
  64557. tileSize?: number;
  64558. tileWidth?: number;
  64559. tileHeight?: number;
  64560. faceUV?: Vector4[];
  64561. faceColors?: Color4[];
  64562. alignHorizontal?: number;
  64563. alignVertical?: number;
  64564. sideOrientation?: number;
  64565. updatable?: boolean;
  64566. }, scene?: Nullable<Scene>): Mesh;
  64567. /**
  64568. * Creates a sphere mesh
  64569. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64570. * * 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`)
  64571. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64572. * * 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
  64573. * * 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)
  64574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64575. * * 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
  64576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64577. * @param name defines the name of the mesh
  64578. * @param options defines the options used to create the mesh
  64579. * @param scene defines the hosting scene
  64580. * @returns the sphere mesh
  64581. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64582. */
  64583. static CreateSphere(name: string, options: {
  64584. segments?: number;
  64585. diameter?: number;
  64586. diameterX?: number;
  64587. diameterY?: number;
  64588. diameterZ?: number;
  64589. arc?: number;
  64590. slice?: number;
  64591. sideOrientation?: number;
  64592. frontUVs?: Vector4;
  64593. backUVs?: Vector4;
  64594. updatable?: boolean;
  64595. }, scene?: Nullable<Scene>): Mesh;
  64596. /**
  64597. * Creates a plane polygonal mesh. By default, this is a disc
  64598. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64599. * * 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
  64600. * * 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
  64601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64602. * * 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
  64603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64604. * @param name defines the name of the mesh
  64605. * @param options defines the options used to create the mesh
  64606. * @param scene defines the hosting scene
  64607. * @returns the plane polygonal mesh
  64608. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64609. */
  64610. static CreateDisc(name: string, options: {
  64611. radius?: number;
  64612. tessellation?: number;
  64613. arc?: number;
  64614. updatable?: boolean;
  64615. sideOrientation?: number;
  64616. frontUVs?: Vector4;
  64617. backUVs?: Vector4;
  64618. }, scene?: Nullable<Scene>): Mesh;
  64619. /**
  64620. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64621. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64622. * * 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`)
  64623. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64624. * * 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
  64625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64626. * * 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
  64627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64628. * @param name defines the name of the mesh
  64629. * @param options defines the options used to create the mesh
  64630. * @param scene defines the hosting scene
  64631. * @returns the icosahedron mesh
  64632. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64633. */
  64634. static CreateIcoSphere(name: string, options: {
  64635. radius?: number;
  64636. radiusX?: number;
  64637. radiusY?: number;
  64638. radiusZ?: number;
  64639. flat?: boolean;
  64640. subdivisions?: number;
  64641. sideOrientation?: number;
  64642. frontUVs?: Vector4;
  64643. backUVs?: Vector4;
  64644. updatable?: boolean;
  64645. }, scene?: Nullable<Scene>): Mesh;
  64646. /**
  64647. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64648. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64649. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64650. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64651. * * 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
  64652. * * 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
  64653. * * 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
  64654. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64655. * * 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
  64656. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64657. * * 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
  64658. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64659. * * 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
  64660. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64662. * @param name defines the name of the mesh
  64663. * @param options defines the options used to create the mesh
  64664. * @param scene defines the hosting scene
  64665. * @returns the ribbon mesh
  64666. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64667. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64668. */
  64669. static CreateRibbon(name: string, options: {
  64670. pathArray: Vector3[][];
  64671. closeArray?: boolean;
  64672. closePath?: boolean;
  64673. offset?: number;
  64674. updatable?: boolean;
  64675. sideOrientation?: number;
  64676. frontUVs?: Vector4;
  64677. backUVs?: Vector4;
  64678. instance?: Mesh;
  64679. invertUV?: boolean;
  64680. uvs?: Vector2[];
  64681. colors?: Color4[];
  64682. }, scene?: Nullable<Scene>): Mesh;
  64683. /**
  64684. * Creates a cylinder or a cone mesh
  64685. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64686. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64687. * * 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.
  64688. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64689. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64690. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64691. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64692. * * 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).
  64693. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64694. * * 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).
  64695. * * 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
  64696. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64697. * * 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
  64698. * * 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.
  64699. * * If `enclose` is false, a ring surface is one element.
  64700. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64701. * * 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
  64702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64703. * * 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
  64704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64705. * @param name defines the name of the mesh
  64706. * @param options defines the options used to create the mesh
  64707. * @param scene defines the hosting scene
  64708. * @returns the cylinder mesh
  64709. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64710. */
  64711. static CreateCylinder(name: string, options: {
  64712. height?: number;
  64713. diameterTop?: number;
  64714. diameterBottom?: number;
  64715. diameter?: number;
  64716. tessellation?: number;
  64717. subdivisions?: number;
  64718. arc?: number;
  64719. faceColors?: Color4[];
  64720. faceUV?: Vector4[];
  64721. updatable?: boolean;
  64722. hasRings?: boolean;
  64723. enclose?: boolean;
  64724. cap?: number;
  64725. sideOrientation?: number;
  64726. frontUVs?: Vector4;
  64727. backUVs?: Vector4;
  64728. }, scene?: Nullable<Scene>): Mesh;
  64729. /**
  64730. * Creates a torus mesh
  64731. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64732. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64733. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64735. * * 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
  64736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64737. * @param name defines the name of the mesh
  64738. * @param options defines the options used to create the mesh
  64739. * @param scene defines the hosting scene
  64740. * @returns the torus mesh
  64741. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64742. */
  64743. static CreateTorus(name: string, options: {
  64744. diameter?: number;
  64745. thickness?: number;
  64746. tessellation?: number;
  64747. updatable?: boolean;
  64748. sideOrientation?: number;
  64749. frontUVs?: Vector4;
  64750. backUVs?: Vector4;
  64751. }, scene?: Nullable<Scene>): Mesh;
  64752. /**
  64753. * Creates a torus knot mesh
  64754. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64755. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64756. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64757. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64759. * * 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
  64760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64761. * @param name defines the name of the mesh
  64762. * @param options defines the options used to create the mesh
  64763. * @param scene defines the hosting scene
  64764. * @returns the torus knot mesh
  64765. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64766. */
  64767. static CreateTorusKnot(name: string, options: {
  64768. radius?: number;
  64769. tube?: number;
  64770. radialSegments?: number;
  64771. tubularSegments?: number;
  64772. p?: number;
  64773. q?: number;
  64774. updatable?: boolean;
  64775. sideOrientation?: number;
  64776. frontUVs?: Vector4;
  64777. backUVs?: Vector4;
  64778. }, scene?: Nullable<Scene>): Mesh;
  64779. /**
  64780. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64781. * * 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
  64782. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64783. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64784. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64785. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64786. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64787. * * 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
  64788. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64791. * @param name defines the name of the new line system
  64792. * @param options defines the options used to create the line system
  64793. * @param scene defines the hosting scene
  64794. * @returns a new line system mesh
  64795. */
  64796. static CreateLineSystem(name: string, options: {
  64797. lines: Vector3[][];
  64798. updatable?: boolean;
  64799. instance?: Nullable<LinesMesh>;
  64800. colors?: Nullable<Color4[][]>;
  64801. useVertexAlpha?: boolean;
  64802. }, scene: Nullable<Scene>): LinesMesh;
  64803. /**
  64804. * Creates a line mesh
  64805. * 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
  64806. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64807. * * The parameter `points` is an array successive Vector3
  64808. * * 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
  64809. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64810. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64811. * * When updating an instance, remember that only point positions can change, not the number of points
  64812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64813. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64814. * @param name defines the name of the new line system
  64815. * @param options defines the options used to create the line system
  64816. * @param scene defines the hosting scene
  64817. * @returns a new line mesh
  64818. */
  64819. static CreateLines(name: string, options: {
  64820. points: Vector3[];
  64821. updatable?: boolean;
  64822. instance?: Nullable<LinesMesh>;
  64823. colors?: Color4[];
  64824. useVertexAlpha?: boolean;
  64825. }, scene?: Nullable<Scene>): LinesMesh;
  64826. /**
  64827. * Creates a dashed line mesh
  64828. * * 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
  64829. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64830. * * The parameter `points` is an array successive Vector3
  64831. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64832. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64833. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64834. * * 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
  64835. * * When updating an instance, remember that only point positions can change, not the number of points
  64836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64837. * @param name defines the name of the mesh
  64838. * @param options defines the options used to create the mesh
  64839. * @param scene defines the hosting scene
  64840. * @returns the dashed line mesh
  64841. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64842. */
  64843. static CreateDashedLines(name: string, options: {
  64844. points: Vector3[];
  64845. dashSize?: number;
  64846. gapSize?: number;
  64847. dashNb?: number;
  64848. updatable?: boolean;
  64849. instance?: LinesMesh;
  64850. }, scene?: Nullable<Scene>): LinesMesh;
  64851. /**
  64852. * 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.
  64853. * * 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.
  64854. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64855. * * 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.
  64856. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64857. * * 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
  64858. * * 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
  64859. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64861. * * 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
  64862. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64864. * @param name defines the name of the mesh
  64865. * @param options defines the options used to create the mesh
  64866. * @param scene defines the hosting scene
  64867. * @returns the extruded shape mesh
  64868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64870. */
  64871. static ExtrudeShape(name: string, options: {
  64872. shape: Vector3[];
  64873. path: Vector3[];
  64874. scale?: number;
  64875. rotation?: number;
  64876. cap?: number;
  64877. updatable?: boolean;
  64878. sideOrientation?: number;
  64879. frontUVs?: Vector4;
  64880. backUVs?: Vector4;
  64881. instance?: Mesh;
  64882. invertUV?: boolean;
  64883. }, scene?: Nullable<Scene>): Mesh;
  64884. /**
  64885. * Creates an custom extruded shape mesh.
  64886. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64887. * * 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.
  64888. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64889. * * 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
  64890. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64891. * * 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
  64892. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64893. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64894. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64895. * * 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
  64896. * * 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
  64897. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64899. * * 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
  64900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64902. * @param name defines the name of the mesh
  64903. * @param options defines the options used to create the mesh
  64904. * @param scene defines the hosting scene
  64905. * @returns the custom extruded shape mesh
  64906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64907. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64909. */
  64910. static ExtrudeShapeCustom(name: string, options: {
  64911. shape: Vector3[];
  64912. path: Vector3[];
  64913. scaleFunction?: any;
  64914. rotationFunction?: any;
  64915. ribbonCloseArray?: boolean;
  64916. ribbonClosePath?: boolean;
  64917. cap?: number;
  64918. updatable?: boolean;
  64919. sideOrientation?: number;
  64920. frontUVs?: Vector4;
  64921. backUVs?: Vector4;
  64922. instance?: Mesh;
  64923. invertUV?: boolean;
  64924. }, scene?: Nullable<Scene>): Mesh;
  64925. /**
  64926. * Creates lathe mesh.
  64927. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64928. * * 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
  64929. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64930. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64931. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64932. * * 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
  64933. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64934. * * 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
  64935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64936. * * 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
  64937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64939. * @param name defines the name of the mesh
  64940. * @param options defines the options used to create the mesh
  64941. * @param scene defines the hosting scene
  64942. * @returns the lathe mesh
  64943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64944. */
  64945. static CreateLathe(name: string, options: {
  64946. shape: Vector3[];
  64947. radius?: number;
  64948. tessellation?: number;
  64949. clip?: number;
  64950. arc?: number;
  64951. closed?: boolean;
  64952. updatable?: boolean;
  64953. sideOrientation?: number;
  64954. frontUVs?: Vector4;
  64955. backUVs?: Vector4;
  64956. cap?: number;
  64957. invertUV?: boolean;
  64958. }, scene?: Nullable<Scene>): Mesh;
  64959. /**
  64960. * Creates a tiled plane mesh
  64961. * * You can set a limited pattern arrangement with the tiles
  64962. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64963. * * 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
  64964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64965. * @param name defines the name of the mesh
  64966. * @param options defines the options used to create the mesh
  64967. * @param scene defines the hosting scene
  64968. * @returns the plane mesh
  64969. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64970. */
  64971. static CreateTiledPlane(name: string, options: {
  64972. pattern?: number;
  64973. tileSize?: number;
  64974. tileWidth?: number;
  64975. tileHeight?: number;
  64976. size?: number;
  64977. width?: number;
  64978. height?: number;
  64979. alignHorizontal?: number;
  64980. alignVertical?: number;
  64981. sideOrientation?: number;
  64982. frontUVs?: Vector4;
  64983. backUVs?: Vector4;
  64984. updatable?: boolean;
  64985. }, scene?: Nullable<Scene>): Mesh;
  64986. /**
  64987. * Creates a plane mesh
  64988. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64989. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64990. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64992. * * 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
  64993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64994. * @param name defines the name of the mesh
  64995. * @param options defines the options used to create the mesh
  64996. * @param scene defines the hosting scene
  64997. * @returns the plane mesh
  64998. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64999. */
  65000. static CreatePlane(name: string, options: {
  65001. size?: number;
  65002. width?: number;
  65003. height?: number;
  65004. sideOrientation?: number;
  65005. frontUVs?: Vector4;
  65006. backUVs?: Vector4;
  65007. updatable?: boolean;
  65008. sourcePlane?: Plane;
  65009. }, scene?: Nullable<Scene>): Mesh;
  65010. /**
  65011. * Creates a ground mesh
  65012. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65013. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65015. * @param name defines the name of the mesh
  65016. * @param options defines the options used to create the mesh
  65017. * @param scene defines the hosting scene
  65018. * @returns the ground mesh
  65019. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65020. */
  65021. static CreateGround(name: string, options: {
  65022. width?: number;
  65023. height?: number;
  65024. subdivisions?: number;
  65025. subdivisionsX?: number;
  65026. subdivisionsY?: number;
  65027. updatable?: boolean;
  65028. }, scene?: Nullable<Scene>): Mesh;
  65029. /**
  65030. * Creates a tiled ground mesh
  65031. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65032. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65033. * * 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
  65034. * * 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
  65035. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65036. * @param name defines the name of the mesh
  65037. * @param options defines the options used to create the mesh
  65038. * @param scene defines the hosting scene
  65039. * @returns the tiled ground mesh
  65040. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65041. */
  65042. static CreateTiledGround(name: string, options: {
  65043. xmin: number;
  65044. zmin: number;
  65045. xmax: number;
  65046. zmax: number;
  65047. subdivisions?: {
  65048. w: number;
  65049. h: number;
  65050. };
  65051. precision?: {
  65052. w: number;
  65053. h: number;
  65054. };
  65055. updatable?: boolean;
  65056. }, scene?: Nullable<Scene>): Mesh;
  65057. /**
  65058. * Creates a ground mesh from a height map
  65059. * * The parameter `url` sets the URL of the height map image resource.
  65060. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65061. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65062. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65063. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65064. * * 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.
  65065. * * 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).
  65066. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65068. * @param name defines the name of the mesh
  65069. * @param url defines the url to the height map
  65070. * @param options defines the options used to create the mesh
  65071. * @param scene defines the hosting scene
  65072. * @returns the ground mesh
  65073. * @see https://doc.babylonjs.com/babylon101/height_map
  65074. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65075. */
  65076. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65077. width?: number;
  65078. height?: number;
  65079. subdivisions?: number;
  65080. minHeight?: number;
  65081. maxHeight?: number;
  65082. colorFilter?: Color3;
  65083. alphaFilter?: number;
  65084. updatable?: boolean;
  65085. onReady?: (mesh: GroundMesh) => void;
  65086. }, scene?: Nullable<Scene>): GroundMesh;
  65087. /**
  65088. * Creates a polygon mesh
  65089. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65090. * * 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
  65091. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65093. * * 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)
  65094. * * Remember you can only change the shape positions, not their number when updating a polygon
  65095. * @param name defines the name of the mesh
  65096. * @param options defines the options used to create the mesh
  65097. * @param scene defines the hosting scene
  65098. * @param earcutInjection can be used to inject your own earcut reference
  65099. * @returns the polygon mesh
  65100. */
  65101. static CreatePolygon(name: string, options: {
  65102. shape: Vector3[];
  65103. holes?: Vector3[][];
  65104. depth?: number;
  65105. faceUV?: Vector4[];
  65106. faceColors?: Color4[];
  65107. updatable?: boolean;
  65108. sideOrientation?: number;
  65109. frontUVs?: Vector4;
  65110. backUVs?: Vector4;
  65111. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65112. /**
  65113. * Creates an extruded polygon mesh, with depth in the Y direction.
  65114. * * 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)
  65115. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65116. * @param name defines the name of the mesh
  65117. * @param options defines the options used to create the mesh
  65118. * @param scene defines the hosting scene
  65119. * @param earcutInjection can be used to inject your own earcut reference
  65120. * @returns the polygon mesh
  65121. */
  65122. static ExtrudePolygon(name: string, options: {
  65123. shape: Vector3[];
  65124. holes?: Vector3[][];
  65125. depth?: number;
  65126. faceUV?: Vector4[];
  65127. faceColors?: Color4[];
  65128. updatable?: boolean;
  65129. sideOrientation?: number;
  65130. frontUVs?: Vector4;
  65131. backUVs?: Vector4;
  65132. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65133. /**
  65134. * Creates a tube mesh.
  65135. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65136. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65137. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65138. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65139. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65140. * * 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)
  65141. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65142. * * 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
  65143. * * 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
  65144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65145. * * 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
  65146. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65148. * @param name defines the name of the mesh
  65149. * @param options defines the options used to create the mesh
  65150. * @param scene defines the hosting scene
  65151. * @returns the tube mesh
  65152. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65153. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65154. */
  65155. static CreateTube(name: string, options: {
  65156. path: Vector3[];
  65157. radius?: number;
  65158. tessellation?: number;
  65159. radiusFunction?: {
  65160. (i: number, distance: number): number;
  65161. };
  65162. cap?: number;
  65163. arc?: number;
  65164. updatable?: boolean;
  65165. sideOrientation?: number;
  65166. frontUVs?: Vector4;
  65167. backUVs?: Vector4;
  65168. instance?: Mesh;
  65169. invertUV?: boolean;
  65170. }, scene?: Nullable<Scene>): Mesh;
  65171. /**
  65172. * Creates a polyhedron mesh
  65173. * * 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
  65174. * * The parameter `size` (positive float, default 1) sets the polygon size
  65175. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65176. * * 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`
  65177. * * 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
  65178. * * 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)`)
  65179. * * 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
  65180. * * 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
  65181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65182. * * 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
  65183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65184. * @param name defines the name of the mesh
  65185. * @param options defines the options used to create the mesh
  65186. * @param scene defines the hosting scene
  65187. * @returns the polyhedron mesh
  65188. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65189. */
  65190. static CreatePolyhedron(name: string, options: {
  65191. type?: number;
  65192. size?: number;
  65193. sizeX?: number;
  65194. sizeY?: number;
  65195. sizeZ?: number;
  65196. custom?: any;
  65197. faceUV?: Vector4[];
  65198. faceColors?: Color4[];
  65199. flat?: boolean;
  65200. updatable?: boolean;
  65201. sideOrientation?: number;
  65202. frontUVs?: Vector4;
  65203. backUVs?: Vector4;
  65204. }, scene?: Nullable<Scene>): Mesh;
  65205. /**
  65206. * Creates a decal mesh.
  65207. * 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
  65208. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65209. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65210. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65211. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65212. * @param name defines the name of the mesh
  65213. * @param sourceMesh defines the mesh where the decal must be applied
  65214. * @param options defines the options used to create the mesh
  65215. * @param scene defines the hosting scene
  65216. * @returns the decal mesh
  65217. * @see https://doc.babylonjs.com/how_to/decals
  65218. */
  65219. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65220. position?: Vector3;
  65221. normal?: Vector3;
  65222. size?: Vector3;
  65223. angle?: number;
  65224. }): Mesh;
  65225. }
  65226. }
  65227. declare module BABYLON {
  65228. /**
  65229. * A simplifier interface for future simplification implementations
  65230. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65231. */
  65232. export interface ISimplifier {
  65233. /**
  65234. * Simplification of a given mesh according to the given settings.
  65235. * Since this requires computation, it is assumed that the function runs async.
  65236. * @param settings The settings of the simplification, including quality and distance
  65237. * @param successCallback A callback that will be called after the mesh was simplified.
  65238. * @param errorCallback in case of an error, this callback will be called. optional.
  65239. */
  65240. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65241. }
  65242. /**
  65243. * Expected simplification settings.
  65244. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65245. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65246. */
  65247. export interface ISimplificationSettings {
  65248. /**
  65249. * Gets or sets the expected quality
  65250. */
  65251. quality: number;
  65252. /**
  65253. * Gets or sets the distance when this optimized version should be used
  65254. */
  65255. distance: number;
  65256. /**
  65257. * Gets an already optimized mesh
  65258. */
  65259. optimizeMesh?: boolean;
  65260. }
  65261. /**
  65262. * Class used to specify simplification options
  65263. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65264. */
  65265. export class SimplificationSettings implements ISimplificationSettings {
  65266. /** expected quality */
  65267. quality: number;
  65268. /** distance when this optimized version should be used */
  65269. distance: number;
  65270. /** already optimized mesh */
  65271. optimizeMesh?: boolean | undefined;
  65272. /**
  65273. * Creates a SimplificationSettings
  65274. * @param quality expected quality
  65275. * @param distance distance when this optimized version should be used
  65276. * @param optimizeMesh already optimized mesh
  65277. */
  65278. constructor(
  65279. /** expected quality */
  65280. quality: number,
  65281. /** distance when this optimized version should be used */
  65282. distance: number,
  65283. /** already optimized mesh */
  65284. optimizeMesh?: boolean | undefined);
  65285. }
  65286. /**
  65287. * Interface used to define a simplification task
  65288. */
  65289. export interface ISimplificationTask {
  65290. /**
  65291. * Array of settings
  65292. */
  65293. settings: Array<ISimplificationSettings>;
  65294. /**
  65295. * Simplification type
  65296. */
  65297. simplificationType: SimplificationType;
  65298. /**
  65299. * Mesh to simplify
  65300. */
  65301. mesh: Mesh;
  65302. /**
  65303. * Callback called on success
  65304. */
  65305. successCallback?: () => void;
  65306. /**
  65307. * Defines if parallel processing can be used
  65308. */
  65309. parallelProcessing: boolean;
  65310. }
  65311. /**
  65312. * Queue used to order the simplification tasks
  65313. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65314. */
  65315. export class SimplificationQueue {
  65316. private _simplificationArray;
  65317. /**
  65318. * Gets a boolean indicating that the process is still running
  65319. */
  65320. running: boolean;
  65321. /**
  65322. * Creates a new queue
  65323. */
  65324. constructor();
  65325. /**
  65326. * Adds a new simplification task
  65327. * @param task defines a task to add
  65328. */
  65329. addTask(task: ISimplificationTask): void;
  65330. /**
  65331. * Execute next task
  65332. */
  65333. executeNext(): void;
  65334. /**
  65335. * Execute a simplification task
  65336. * @param task defines the task to run
  65337. */
  65338. runSimplification(task: ISimplificationTask): void;
  65339. private getSimplifier;
  65340. }
  65341. /**
  65342. * The implemented types of simplification
  65343. * At the moment only Quadratic Error Decimation is implemented
  65344. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65345. */
  65346. export enum SimplificationType {
  65347. /** Quadratic error decimation */
  65348. QUADRATIC = 0
  65349. }
  65350. /**
  65351. * An implementation of the Quadratic Error simplification algorithm.
  65352. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65353. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65354. * @author RaananW
  65355. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65356. */
  65357. export class QuadraticErrorSimplification implements ISimplifier {
  65358. private _mesh;
  65359. private triangles;
  65360. private vertices;
  65361. private references;
  65362. private _reconstructedMesh;
  65363. /** Gets or sets the number pf sync interations */
  65364. syncIterations: number;
  65365. /** Gets or sets the aggressiveness of the simplifier */
  65366. aggressiveness: number;
  65367. /** Gets or sets the number of allowed iterations for decimation */
  65368. decimationIterations: number;
  65369. /** Gets or sets the espilon to use for bounding box computation */
  65370. boundingBoxEpsilon: number;
  65371. /**
  65372. * Creates a new QuadraticErrorSimplification
  65373. * @param _mesh defines the target mesh
  65374. */
  65375. constructor(_mesh: Mesh);
  65376. /**
  65377. * Simplification of a given mesh according to the given settings.
  65378. * Since this requires computation, it is assumed that the function runs async.
  65379. * @param settings The settings of the simplification, including quality and distance
  65380. * @param successCallback A callback that will be called after the mesh was simplified.
  65381. */
  65382. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65383. private runDecimation;
  65384. private initWithMesh;
  65385. private init;
  65386. private reconstructMesh;
  65387. private initDecimatedMesh;
  65388. private isFlipped;
  65389. private updateTriangles;
  65390. private identifyBorder;
  65391. private updateMesh;
  65392. private vertexError;
  65393. private calculateError;
  65394. }
  65395. }
  65396. declare module BABYLON {
  65397. interface Scene {
  65398. /** @hidden (Backing field) */
  65399. _simplificationQueue: SimplificationQueue;
  65400. /**
  65401. * Gets or sets the simplification queue attached to the scene
  65402. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65403. */
  65404. simplificationQueue: SimplificationQueue;
  65405. }
  65406. interface Mesh {
  65407. /**
  65408. * Simplify the mesh according to the given array of settings.
  65409. * Function will return immediately and will simplify async
  65410. * @param settings a collection of simplification settings
  65411. * @param parallelProcessing should all levels calculate parallel or one after the other
  65412. * @param simplificationType the type of simplification to run
  65413. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65414. * @returns the current mesh
  65415. */
  65416. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65417. }
  65418. /**
  65419. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65420. * created in a scene
  65421. */
  65422. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65423. /**
  65424. * The component name helpfull to identify the component in the list of scene components.
  65425. */
  65426. readonly name: string;
  65427. /**
  65428. * The scene the component belongs to.
  65429. */
  65430. scene: Scene;
  65431. /**
  65432. * Creates a new instance of the component for the given scene
  65433. * @param scene Defines the scene to register the component in
  65434. */
  65435. constructor(scene: Scene);
  65436. /**
  65437. * Registers the component in a given scene
  65438. */
  65439. register(): void;
  65440. /**
  65441. * Rebuilds the elements related to this component in case of
  65442. * context lost for instance.
  65443. */
  65444. rebuild(): void;
  65445. /**
  65446. * Disposes the component and the associated ressources
  65447. */
  65448. dispose(): void;
  65449. private _beforeCameraUpdate;
  65450. }
  65451. }
  65452. declare module BABYLON {
  65453. interface Mesh {
  65454. /**
  65455. * Creates a new thin instance
  65456. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65457. * @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
  65458. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65459. */
  65460. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65461. /**
  65462. * Adds the transformation (matrix) of the current mesh as a thin instance
  65463. * @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
  65464. * @returns the thin instance index number
  65465. */
  65466. thinInstanceAddSelf(refresh: boolean): number;
  65467. /**
  65468. * Registers a custom attribute to be used with thin instances
  65469. * @param kind name of the attribute
  65470. * @param stride size in floats of the attribute
  65471. */
  65472. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65473. /**
  65474. * Sets the matrix of a thin instance
  65475. * @param index index of the thin instance
  65476. * @param matrix matrix to set
  65477. * @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
  65478. */
  65479. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65480. /**
  65481. * Sets the value of a custom attribute for a thin instance
  65482. * @param kind name of the attribute
  65483. * @param index index of the thin instance
  65484. * @param value value to set
  65485. * @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
  65486. */
  65487. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65488. /**
  65489. * 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.
  65490. */
  65491. thinInstanceCount: number;
  65492. /**
  65493. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65494. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65495. * @param buffer buffer to set
  65496. * @param stride size in floats of each value of the buffer
  65497. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65498. */
  65499. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65500. /**
  65501. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65502. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65503. */
  65504. thinInstanceBufferUpdated(kind: string): void;
  65505. /**
  65506. * Refreshes the bounding info, taking into account all the thin instances defined
  65507. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65508. */
  65509. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65510. /** @hidden */
  65511. _thinInstanceInitializeUserStorage(): void;
  65512. /** @hidden */
  65513. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65514. /** @hidden */
  65515. _userThinInstanceBuffersStorage: {
  65516. data: {
  65517. [key: string]: Float32Array;
  65518. };
  65519. sizes: {
  65520. [key: string]: number;
  65521. };
  65522. vertexBuffers: {
  65523. [key: string]: Nullable<VertexBuffer>;
  65524. };
  65525. strides: {
  65526. [key: string]: number;
  65527. };
  65528. };
  65529. }
  65530. }
  65531. declare module BABYLON {
  65532. /**
  65533. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65534. */
  65535. export interface INavigationEnginePlugin {
  65536. /**
  65537. * plugin name
  65538. */
  65539. name: string;
  65540. /**
  65541. * Creates a navigation mesh
  65542. * @param meshes array of all the geometry used to compute the navigatio mesh
  65543. * @param parameters bunch of parameters used to filter geometry
  65544. */
  65545. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65546. /**
  65547. * Create a navigation mesh debug mesh
  65548. * @param scene is where the mesh will be added
  65549. * @returns debug display mesh
  65550. */
  65551. createDebugNavMesh(scene: Scene): Mesh;
  65552. /**
  65553. * Get a navigation mesh constrained position, closest to the parameter position
  65554. * @param position world position
  65555. * @returns the closest point to position constrained by the navigation mesh
  65556. */
  65557. getClosestPoint(position: Vector3): Vector3;
  65558. /**
  65559. * Get a navigation mesh constrained position, closest to the parameter position
  65560. * @param position world position
  65561. * @param result output the closest point to position constrained by the navigation mesh
  65562. */
  65563. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65564. /**
  65565. * Get a navigation mesh constrained position, within a particular radius
  65566. * @param position world position
  65567. * @param maxRadius the maximum distance to the constrained world position
  65568. * @returns the closest point to position constrained by the navigation mesh
  65569. */
  65570. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65571. /**
  65572. * Get a navigation mesh constrained position, within a particular radius
  65573. * @param position world position
  65574. * @param maxRadius the maximum distance to the constrained world position
  65575. * @param result output the closest point to position constrained by the navigation mesh
  65576. */
  65577. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65578. /**
  65579. * Compute the final position from a segment made of destination-position
  65580. * @param position world position
  65581. * @param destination world position
  65582. * @returns the resulting point along the navmesh
  65583. */
  65584. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65585. /**
  65586. * Compute the final position from a segment made of destination-position
  65587. * @param position world position
  65588. * @param destination world position
  65589. * @param result output the resulting point along the navmesh
  65590. */
  65591. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65592. /**
  65593. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65594. * @param start world position
  65595. * @param end world position
  65596. * @returns array containing world position composing the path
  65597. */
  65598. computePath(start: Vector3, end: Vector3): Vector3[];
  65599. /**
  65600. * If this plugin is supported
  65601. * @returns true if plugin is supported
  65602. */
  65603. isSupported(): boolean;
  65604. /**
  65605. * Create a new Crowd so you can add agents
  65606. * @param maxAgents the maximum agent count in the crowd
  65607. * @param maxAgentRadius the maximum radius an agent can have
  65608. * @param scene to attach the crowd to
  65609. * @returns the crowd you can add agents to
  65610. */
  65611. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65612. /**
  65613. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65614. * The queries will try to find a solution within those bounds
  65615. * default is (1,1,1)
  65616. * @param extent x,y,z value that define the extent around the queries point of reference
  65617. */
  65618. setDefaultQueryExtent(extent: Vector3): void;
  65619. /**
  65620. * Get the Bounding box extent specified by setDefaultQueryExtent
  65621. * @returns the box extent values
  65622. */
  65623. getDefaultQueryExtent(): Vector3;
  65624. /**
  65625. * build the navmesh from a previously saved state using getNavmeshData
  65626. * @param data the Uint8Array returned by getNavmeshData
  65627. */
  65628. buildFromNavmeshData(data: Uint8Array): void;
  65629. /**
  65630. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65631. * @returns data the Uint8Array that can be saved and reused
  65632. */
  65633. getNavmeshData(): Uint8Array;
  65634. /**
  65635. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65636. * @param result output the box extent values
  65637. */
  65638. getDefaultQueryExtentToRef(result: Vector3): void;
  65639. /**
  65640. * Release all resources
  65641. */
  65642. dispose(): void;
  65643. }
  65644. /**
  65645. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65646. */
  65647. export interface ICrowd {
  65648. /**
  65649. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65650. * You can attach anything to that node. The node position is updated in the scene update tick.
  65651. * @param pos world position that will be constrained by the navigation mesh
  65652. * @param parameters agent parameters
  65653. * @param transform hooked to the agent that will be update by the scene
  65654. * @returns agent index
  65655. */
  65656. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65657. /**
  65658. * Returns the agent position in world space
  65659. * @param index agent index returned by addAgent
  65660. * @returns world space position
  65661. */
  65662. getAgentPosition(index: number): Vector3;
  65663. /**
  65664. * Gets the agent position result in world space
  65665. * @param index agent index returned by addAgent
  65666. * @param result output world space position
  65667. */
  65668. getAgentPositionToRef(index: number, result: Vector3): void;
  65669. /**
  65670. * Gets the agent velocity in world space
  65671. * @param index agent index returned by addAgent
  65672. * @returns world space velocity
  65673. */
  65674. getAgentVelocity(index: number): Vector3;
  65675. /**
  65676. * Gets the agent velocity result in world space
  65677. * @param index agent index returned by addAgent
  65678. * @param result output world space velocity
  65679. */
  65680. getAgentVelocityToRef(index: number, result: Vector3): void;
  65681. /**
  65682. * remove a particular agent previously created
  65683. * @param index agent index returned by addAgent
  65684. */
  65685. removeAgent(index: number): void;
  65686. /**
  65687. * get the list of all agents attached to this crowd
  65688. * @returns list of agent indices
  65689. */
  65690. getAgents(): number[];
  65691. /**
  65692. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65693. * @param deltaTime in seconds
  65694. */
  65695. update(deltaTime: number): void;
  65696. /**
  65697. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65698. * @param index agent index returned by addAgent
  65699. * @param destination targeted world position
  65700. */
  65701. agentGoto(index: number, destination: Vector3): void;
  65702. /**
  65703. * Teleport the agent to a new position
  65704. * @param index agent index returned by addAgent
  65705. * @param destination targeted world position
  65706. */
  65707. agentTeleport(index: number, destination: Vector3): void;
  65708. /**
  65709. * Update agent parameters
  65710. * @param index agent index returned by addAgent
  65711. * @param parameters agent parameters
  65712. */
  65713. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65714. /**
  65715. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65716. * The queries will try to find a solution within those bounds
  65717. * default is (1,1,1)
  65718. * @param extent x,y,z value that define the extent around the queries point of reference
  65719. */
  65720. setDefaultQueryExtent(extent: Vector3): void;
  65721. /**
  65722. * Get the Bounding box extent specified by setDefaultQueryExtent
  65723. * @returns the box extent values
  65724. */
  65725. getDefaultQueryExtent(): Vector3;
  65726. /**
  65727. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65728. * @param result output the box extent values
  65729. */
  65730. getDefaultQueryExtentToRef(result: Vector3): void;
  65731. /**
  65732. * Release all resources
  65733. */
  65734. dispose(): void;
  65735. }
  65736. /**
  65737. * Configures an agent
  65738. */
  65739. export interface IAgentParameters {
  65740. /**
  65741. * Agent radius. [Limit: >= 0]
  65742. */
  65743. radius: number;
  65744. /**
  65745. * Agent height. [Limit: > 0]
  65746. */
  65747. height: number;
  65748. /**
  65749. * Maximum allowed acceleration. [Limit: >= 0]
  65750. */
  65751. maxAcceleration: number;
  65752. /**
  65753. * Maximum allowed speed. [Limit: >= 0]
  65754. */
  65755. maxSpeed: number;
  65756. /**
  65757. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65758. */
  65759. collisionQueryRange: number;
  65760. /**
  65761. * The path visibility optimization range. [Limit: > 0]
  65762. */
  65763. pathOptimizationRange: number;
  65764. /**
  65765. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65766. */
  65767. separationWeight: number;
  65768. }
  65769. /**
  65770. * Configures the navigation mesh creation
  65771. */
  65772. export interface INavMeshParameters {
  65773. /**
  65774. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65775. */
  65776. cs: number;
  65777. /**
  65778. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65779. */
  65780. ch: number;
  65781. /**
  65782. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65783. */
  65784. walkableSlopeAngle: number;
  65785. /**
  65786. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65787. * be considered walkable. [Limit: >= 3] [Units: vx]
  65788. */
  65789. walkableHeight: number;
  65790. /**
  65791. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65792. */
  65793. walkableClimb: number;
  65794. /**
  65795. * The distance to erode/shrink the walkable area of the heightfield away from
  65796. * obstructions. [Limit: >=0] [Units: vx]
  65797. */
  65798. walkableRadius: number;
  65799. /**
  65800. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65801. */
  65802. maxEdgeLen: number;
  65803. /**
  65804. * The maximum distance a simplfied contour's border edges should deviate
  65805. * the original raw contour. [Limit: >=0] [Units: vx]
  65806. */
  65807. maxSimplificationError: number;
  65808. /**
  65809. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65810. */
  65811. minRegionArea: number;
  65812. /**
  65813. * Any regions with a span count smaller than this value will, if possible,
  65814. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65815. */
  65816. mergeRegionArea: number;
  65817. /**
  65818. * The maximum number of vertices allowed for polygons generated during the
  65819. * contour to polygon conversion process. [Limit: >= 3]
  65820. */
  65821. maxVertsPerPoly: number;
  65822. /**
  65823. * Sets the sampling distance to use when generating the detail mesh.
  65824. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65825. */
  65826. detailSampleDist: number;
  65827. /**
  65828. * The maximum distance the detail mesh surface should deviate from heightfield
  65829. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65830. */
  65831. detailSampleMaxError: number;
  65832. }
  65833. }
  65834. declare module BABYLON {
  65835. /**
  65836. * RecastJS navigation plugin
  65837. */
  65838. export class RecastJSPlugin implements INavigationEnginePlugin {
  65839. /**
  65840. * Reference to the Recast library
  65841. */
  65842. bjsRECAST: any;
  65843. /**
  65844. * plugin name
  65845. */
  65846. name: string;
  65847. /**
  65848. * the first navmesh created. We might extend this to support multiple navmeshes
  65849. */
  65850. navMesh: any;
  65851. /**
  65852. * Initializes the recastJS plugin
  65853. * @param recastInjection can be used to inject your own recast reference
  65854. */
  65855. constructor(recastInjection?: any);
  65856. /**
  65857. * Creates a navigation mesh
  65858. * @param meshes array of all the geometry used to compute the navigatio mesh
  65859. * @param parameters bunch of parameters used to filter geometry
  65860. */
  65861. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65862. /**
  65863. * Create a navigation mesh debug mesh
  65864. * @param scene is where the mesh will be added
  65865. * @returns debug display mesh
  65866. */
  65867. createDebugNavMesh(scene: Scene): Mesh;
  65868. /**
  65869. * Get a navigation mesh constrained position, closest to the parameter position
  65870. * @param position world position
  65871. * @returns the closest point to position constrained by the navigation mesh
  65872. */
  65873. getClosestPoint(position: Vector3): Vector3;
  65874. /**
  65875. * Get a navigation mesh constrained position, closest to the parameter position
  65876. * @param position world position
  65877. * @param result output the closest point to position constrained by the navigation mesh
  65878. */
  65879. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65880. /**
  65881. * Get a navigation mesh constrained position, within a particular radius
  65882. * @param position world position
  65883. * @param maxRadius the maximum distance to the constrained world position
  65884. * @returns the closest point to position constrained by the navigation mesh
  65885. */
  65886. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65887. /**
  65888. * Get a navigation mesh constrained position, within a particular radius
  65889. * @param position world position
  65890. * @param maxRadius the maximum distance to the constrained world position
  65891. * @param result output the closest point to position constrained by the navigation mesh
  65892. */
  65893. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65894. /**
  65895. * Compute the final position from a segment made of destination-position
  65896. * @param position world position
  65897. * @param destination world position
  65898. * @returns the resulting point along the navmesh
  65899. */
  65900. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65901. /**
  65902. * Compute the final position from a segment made of destination-position
  65903. * @param position world position
  65904. * @param destination world position
  65905. * @param result output the resulting point along the navmesh
  65906. */
  65907. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65908. /**
  65909. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65910. * @param start world position
  65911. * @param end world position
  65912. * @returns array containing world position composing the path
  65913. */
  65914. computePath(start: Vector3, end: Vector3): Vector3[];
  65915. /**
  65916. * Create a new Crowd so you can add agents
  65917. * @param maxAgents the maximum agent count in the crowd
  65918. * @param maxAgentRadius the maximum radius an agent can have
  65919. * @param scene to attach the crowd to
  65920. * @returns the crowd you can add agents to
  65921. */
  65922. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65923. /**
  65924. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65925. * The queries will try to find a solution within those bounds
  65926. * default is (1,1,1)
  65927. * @param extent x,y,z value that define the extent around the queries point of reference
  65928. */
  65929. setDefaultQueryExtent(extent: Vector3): void;
  65930. /**
  65931. * Get the Bounding box extent specified by setDefaultQueryExtent
  65932. * @returns the box extent values
  65933. */
  65934. getDefaultQueryExtent(): Vector3;
  65935. /**
  65936. * build the navmesh from a previously saved state using getNavmeshData
  65937. * @param data the Uint8Array returned by getNavmeshData
  65938. */
  65939. buildFromNavmeshData(data: Uint8Array): void;
  65940. /**
  65941. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65942. * @returns data the Uint8Array that can be saved and reused
  65943. */
  65944. getNavmeshData(): Uint8Array;
  65945. /**
  65946. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65947. * @param result output the box extent values
  65948. */
  65949. getDefaultQueryExtentToRef(result: Vector3): void;
  65950. /**
  65951. * Disposes
  65952. */
  65953. dispose(): void;
  65954. /**
  65955. * If this plugin is supported
  65956. * @returns true if plugin is supported
  65957. */
  65958. isSupported(): boolean;
  65959. }
  65960. /**
  65961. * Recast detour crowd implementation
  65962. */
  65963. export class RecastJSCrowd implements ICrowd {
  65964. /**
  65965. * Recast/detour plugin
  65966. */
  65967. bjsRECASTPlugin: RecastJSPlugin;
  65968. /**
  65969. * Link to the detour crowd
  65970. */
  65971. recastCrowd: any;
  65972. /**
  65973. * One transform per agent
  65974. */
  65975. transforms: TransformNode[];
  65976. /**
  65977. * All agents created
  65978. */
  65979. agents: number[];
  65980. /**
  65981. * Link to the scene is kept to unregister the crowd from the scene
  65982. */
  65983. private _scene;
  65984. /**
  65985. * Observer for crowd updates
  65986. */
  65987. private _onBeforeAnimationsObserver;
  65988. /**
  65989. * Constructor
  65990. * @param plugin recastJS plugin
  65991. * @param maxAgents the maximum agent count in the crowd
  65992. * @param maxAgentRadius the maximum radius an agent can have
  65993. * @param scene to attach the crowd to
  65994. * @returns the crowd you can add agents to
  65995. */
  65996. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65997. /**
  65998. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65999. * You can attach anything to that node. The node position is updated in the scene update tick.
  66000. * @param pos world position that will be constrained by the navigation mesh
  66001. * @param parameters agent parameters
  66002. * @param transform hooked to the agent that will be update by the scene
  66003. * @returns agent index
  66004. */
  66005. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66006. /**
  66007. * Returns the agent position in world space
  66008. * @param index agent index returned by addAgent
  66009. * @returns world space position
  66010. */
  66011. getAgentPosition(index: number): Vector3;
  66012. /**
  66013. * Returns the agent position result in world space
  66014. * @param index agent index returned by addAgent
  66015. * @param result output world space position
  66016. */
  66017. getAgentPositionToRef(index: number, result: Vector3): void;
  66018. /**
  66019. * Returns the agent velocity in world space
  66020. * @param index agent index returned by addAgent
  66021. * @returns world space velocity
  66022. */
  66023. getAgentVelocity(index: number): Vector3;
  66024. /**
  66025. * Returns the agent velocity result in world space
  66026. * @param index agent index returned by addAgent
  66027. * @param result output world space velocity
  66028. */
  66029. getAgentVelocityToRef(index: number, result: Vector3): void;
  66030. /**
  66031. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66032. * @param index agent index returned by addAgent
  66033. * @param destination targeted world position
  66034. */
  66035. agentGoto(index: number, destination: Vector3): void;
  66036. /**
  66037. * Teleport the agent to a new position
  66038. * @param index agent index returned by addAgent
  66039. * @param destination targeted world position
  66040. */
  66041. agentTeleport(index: number, destination: Vector3): void;
  66042. /**
  66043. * Update agent parameters
  66044. * @param index agent index returned by addAgent
  66045. * @param parameters agent parameters
  66046. */
  66047. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66048. /**
  66049. * remove a particular agent previously created
  66050. * @param index agent index returned by addAgent
  66051. */
  66052. removeAgent(index: number): void;
  66053. /**
  66054. * get the list of all agents attached to this crowd
  66055. * @returns list of agent indices
  66056. */
  66057. getAgents(): number[];
  66058. /**
  66059. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66060. * @param deltaTime in seconds
  66061. */
  66062. update(deltaTime: number): void;
  66063. /**
  66064. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66065. * The queries will try to find a solution within those bounds
  66066. * default is (1,1,1)
  66067. * @param extent x,y,z value that define the extent around the queries point of reference
  66068. */
  66069. setDefaultQueryExtent(extent: Vector3): void;
  66070. /**
  66071. * Get the Bounding box extent specified by setDefaultQueryExtent
  66072. * @returns the box extent values
  66073. */
  66074. getDefaultQueryExtent(): Vector3;
  66075. /**
  66076. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66077. * @param result output the box extent values
  66078. */
  66079. getDefaultQueryExtentToRef(result: Vector3): void;
  66080. /**
  66081. * Release all resources
  66082. */
  66083. dispose(): void;
  66084. }
  66085. }
  66086. declare module BABYLON {
  66087. /**
  66088. * Class used to enable access to IndexedDB
  66089. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66090. */
  66091. export class Database implements IOfflineProvider {
  66092. private _callbackManifestChecked;
  66093. private _currentSceneUrl;
  66094. private _db;
  66095. private _enableSceneOffline;
  66096. private _enableTexturesOffline;
  66097. private _manifestVersionFound;
  66098. private _mustUpdateRessources;
  66099. private _hasReachedQuota;
  66100. private _isSupported;
  66101. private _idbFactory;
  66102. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66103. private static IsUASupportingBlobStorage;
  66104. /**
  66105. * Gets a boolean indicating if Database storate is enabled (off by default)
  66106. */
  66107. static IDBStorageEnabled: boolean;
  66108. /**
  66109. * Gets a boolean indicating if scene must be saved in the database
  66110. */
  66111. get enableSceneOffline(): boolean;
  66112. /**
  66113. * Gets a boolean indicating if textures must be saved in the database
  66114. */
  66115. get enableTexturesOffline(): boolean;
  66116. /**
  66117. * Creates a new Database
  66118. * @param urlToScene defines the url to load the scene
  66119. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66120. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66121. */
  66122. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66123. private static _ParseURL;
  66124. private static _ReturnFullUrlLocation;
  66125. private _checkManifestFile;
  66126. /**
  66127. * Open the database and make it available
  66128. * @param successCallback defines the callback to call on success
  66129. * @param errorCallback defines the callback to call on error
  66130. */
  66131. open(successCallback: () => void, errorCallback: () => void): void;
  66132. /**
  66133. * Loads an image from the database
  66134. * @param url defines the url to load from
  66135. * @param image defines the target DOM image
  66136. */
  66137. loadImage(url: string, image: HTMLImageElement): void;
  66138. private _loadImageFromDBAsync;
  66139. private _saveImageIntoDBAsync;
  66140. private _checkVersionFromDB;
  66141. private _loadVersionFromDBAsync;
  66142. private _saveVersionIntoDBAsync;
  66143. /**
  66144. * Loads a file from database
  66145. * @param url defines the URL to load from
  66146. * @param sceneLoaded defines a callback to call on success
  66147. * @param progressCallBack defines a callback to call when progress changed
  66148. * @param errorCallback defines a callback to call on error
  66149. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66150. */
  66151. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66152. private _loadFileAsync;
  66153. private _saveFileAsync;
  66154. /**
  66155. * Validates if xhr data is correct
  66156. * @param xhr defines the request to validate
  66157. * @param dataType defines the expected data type
  66158. * @returns true if data is correct
  66159. */
  66160. private static _ValidateXHRData;
  66161. }
  66162. }
  66163. declare module BABYLON {
  66164. /** @hidden */
  66165. export var gpuUpdateParticlesPixelShader: {
  66166. name: string;
  66167. shader: string;
  66168. };
  66169. }
  66170. declare module BABYLON {
  66171. /** @hidden */
  66172. export var gpuUpdateParticlesVertexShader: {
  66173. name: string;
  66174. shader: string;
  66175. };
  66176. }
  66177. declare module BABYLON {
  66178. /** @hidden */
  66179. export var clipPlaneFragmentDeclaration2: {
  66180. name: string;
  66181. shader: string;
  66182. };
  66183. }
  66184. declare module BABYLON {
  66185. /** @hidden */
  66186. export var gpuRenderParticlesPixelShader: {
  66187. name: string;
  66188. shader: string;
  66189. };
  66190. }
  66191. declare module BABYLON {
  66192. /** @hidden */
  66193. export var clipPlaneVertexDeclaration2: {
  66194. name: string;
  66195. shader: string;
  66196. };
  66197. }
  66198. declare module BABYLON {
  66199. /** @hidden */
  66200. export var gpuRenderParticlesVertexShader: {
  66201. name: string;
  66202. shader: string;
  66203. };
  66204. }
  66205. declare module BABYLON {
  66206. /**
  66207. * This represents a GPU particle system in Babylon
  66208. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66209. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66210. */
  66211. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66212. /**
  66213. * The layer mask we are rendering the particles through.
  66214. */
  66215. layerMask: number;
  66216. private _capacity;
  66217. private _activeCount;
  66218. private _currentActiveCount;
  66219. private _accumulatedCount;
  66220. private _renderEffect;
  66221. private _updateEffect;
  66222. private _buffer0;
  66223. private _buffer1;
  66224. private _spriteBuffer;
  66225. private _updateVAO;
  66226. private _renderVAO;
  66227. private _targetIndex;
  66228. private _sourceBuffer;
  66229. private _targetBuffer;
  66230. private _engine;
  66231. private _currentRenderId;
  66232. private _started;
  66233. private _stopped;
  66234. private _timeDelta;
  66235. private _randomTexture;
  66236. private _randomTexture2;
  66237. private _attributesStrideSize;
  66238. private _updateEffectOptions;
  66239. private _randomTextureSize;
  66240. private _actualFrame;
  66241. private _customEffect;
  66242. private readonly _rawTextureWidth;
  66243. /**
  66244. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66245. */
  66246. static get IsSupported(): boolean;
  66247. /**
  66248. * An event triggered when the system is disposed.
  66249. */
  66250. onDisposeObservable: Observable<IParticleSystem>;
  66251. /**
  66252. * Gets the maximum number of particles active at the same time.
  66253. * @returns The max number of active particles.
  66254. */
  66255. getCapacity(): number;
  66256. /**
  66257. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66258. * to override the particles.
  66259. */
  66260. forceDepthWrite: boolean;
  66261. /**
  66262. * Gets or set the number of active particles
  66263. */
  66264. get activeParticleCount(): number;
  66265. set activeParticleCount(value: number);
  66266. private _preWarmDone;
  66267. /**
  66268. * Specifies if the particles are updated in emitter local space or world space.
  66269. */
  66270. isLocal: boolean;
  66271. /**
  66272. * Is this system ready to be used/rendered
  66273. * @return true if the system is ready
  66274. */
  66275. isReady(): boolean;
  66276. /**
  66277. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66278. * @returns True if it has been started, otherwise false.
  66279. */
  66280. isStarted(): boolean;
  66281. /**
  66282. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66283. * @returns True if it has been stopped, otherwise false.
  66284. */
  66285. isStopped(): boolean;
  66286. /**
  66287. * Gets a boolean indicating that the system is stopping
  66288. * @returns true if the system is currently stopping
  66289. */
  66290. isStopping(): boolean;
  66291. /**
  66292. * Gets the number of particles active at the same time.
  66293. * @returns The number of active particles.
  66294. */
  66295. getActiveCount(): number;
  66296. /**
  66297. * Starts the particle system and begins to emit
  66298. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66299. */
  66300. start(delay?: number): void;
  66301. /**
  66302. * Stops the particle system.
  66303. */
  66304. stop(): void;
  66305. /**
  66306. * Remove all active particles
  66307. */
  66308. reset(): void;
  66309. /**
  66310. * Returns the string "GPUParticleSystem"
  66311. * @returns a string containing the class name
  66312. */
  66313. getClassName(): string;
  66314. /**
  66315. * Gets the custom effect used to render the particles
  66316. * @param blendMode Blend mode for which the effect should be retrieved
  66317. * @returns The effect
  66318. */
  66319. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66320. /**
  66321. * Sets the custom effect used to render the particles
  66322. * @param effect The effect to set
  66323. * @param blendMode Blend mode for which the effect should be set
  66324. */
  66325. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66326. /** @hidden */
  66327. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66328. /**
  66329. * Observable that will be called just before the particles are drawn
  66330. */
  66331. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66332. /**
  66333. * Gets the name of the particle vertex shader
  66334. */
  66335. get vertexShaderName(): string;
  66336. private _colorGradientsTexture;
  66337. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66338. /**
  66339. * Adds a new color gradient
  66340. * @param gradient defines the gradient to use (between 0 and 1)
  66341. * @param color1 defines the color to affect to the specified gradient
  66342. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66343. * @returns the current particle system
  66344. */
  66345. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66346. private _refreshColorGradient;
  66347. /** Force the system to rebuild all gradients that need to be resync */
  66348. forceRefreshGradients(): void;
  66349. /**
  66350. * Remove a specific color gradient
  66351. * @param gradient defines the gradient to remove
  66352. * @returns the current particle system
  66353. */
  66354. removeColorGradient(gradient: number): GPUParticleSystem;
  66355. private _angularSpeedGradientsTexture;
  66356. private _sizeGradientsTexture;
  66357. private _velocityGradientsTexture;
  66358. private _limitVelocityGradientsTexture;
  66359. private _dragGradientsTexture;
  66360. private _addFactorGradient;
  66361. /**
  66362. * Adds a new size gradient
  66363. * @param gradient defines the gradient to use (between 0 and 1)
  66364. * @param factor defines the size factor to affect to the specified gradient
  66365. * @returns the current particle system
  66366. */
  66367. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66368. /**
  66369. * Remove a specific size gradient
  66370. * @param gradient defines the gradient to remove
  66371. * @returns the current particle system
  66372. */
  66373. removeSizeGradient(gradient: number): GPUParticleSystem;
  66374. private _refreshFactorGradient;
  66375. /**
  66376. * Adds a new angular speed gradient
  66377. * @param gradient defines the gradient to use (between 0 and 1)
  66378. * @param factor defines the angular speed to affect to the specified gradient
  66379. * @returns the current particle system
  66380. */
  66381. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66382. /**
  66383. * Remove a specific angular speed gradient
  66384. * @param gradient defines the gradient to remove
  66385. * @returns the current particle system
  66386. */
  66387. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66388. /**
  66389. * Adds a new velocity gradient
  66390. * @param gradient defines the gradient to use (between 0 and 1)
  66391. * @param factor defines the velocity to affect to the specified gradient
  66392. * @returns the current particle system
  66393. */
  66394. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66395. /**
  66396. * Remove a specific velocity gradient
  66397. * @param gradient defines the gradient to remove
  66398. * @returns the current particle system
  66399. */
  66400. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66401. /**
  66402. * Adds a new limit velocity gradient
  66403. * @param gradient defines the gradient to use (between 0 and 1)
  66404. * @param factor defines the limit velocity value to affect to the specified gradient
  66405. * @returns the current particle system
  66406. */
  66407. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66408. /**
  66409. * Remove a specific limit velocity gradient
  66410. * @param gradient defines the gradient to remove
  66411. * @returns the current particle system
  66412. */
  66413. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66414. /**
  66415. * Adds a new drag gradient
  66416. * @param gradient defines the gradient to use (between 0 and 1)
  66417. * @param factor defines the drag value to affect to the specified gradient
  66418. * @returns the current particle system
  66419. */
  66420. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66421. /**
  66422. * Remove a specific drag gradient
  66423. * @param gradient defines the gradient to remove
  66424. * @returns the current particle system
  66425. */
  66426. removeDragGradient(gradient: number): GPUParticleSystem;
  66427. /**
  66428. * Not supported by GPUParticleSystem
  66429. * @param gradient defines the gradient to use (between 0 and 1)
  66430. * @param factor defines the emit rate value to affect to the specified gradient
  66431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66432. * @returns the current particle system
  66433. */
  66434. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66435. /**
  66436. * Not supported by GPUParticleSystem
  66437. * @param gradient defines the gradient to remove
  66438. * @returns the current particle system
  66439. */
  66440. removeEmitRateGradient(gradient: number): IParticleSystem;
  66441. /**
  66442. * Not supported by GPUParticleSystem
  66443. * @param gradient defines the gradient to use (between 0 and 1)
  66444. * @param factor defines the start size value to affect to the specified gradient
  66445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66446. * @returns the current particle system
  66447. */
  66448. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66449. /**
  66450. * Not supported by GPUParticleSystem
  66451. * @param gradient defines the gradient to remove
  66452. * @returns the current particle system
  66453. */
  66454. removeStartSizeGradient(gradient: number): IParticleSystem;
  66455. /**
  66456. * Not supported by GPUParticleSystem
  66457. * @param gradient defines the gradient to use (between 0 and 1)
  66458. * @param min defines the color remap minimal range
  66459. * @param max defines the color remap maximal range
  66460. * @returns the current particle system
  66461. */
  66462. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66463. /**
  66464. * Not supported by GPUParticleSystem
  66465. * @param gradient defines the gradient to remove
  66466. * @returns the current particle system
  66467. */
  66468. removeColorRemapGradient(): IParticleSystem;
  66469. /**
  66470. * Not supported by GPUParticleSystem
  66471. * @param gradient defines the gradient to use (between 0 and 1)
  66472. * @param min defines the alpha remap minimal range
  66473. * @param max defines the alpha remap maximal range
  66474. * @returns the current particle system
  66475. */
  66476. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66477. /**
  66478. * Not supported by GPUParticleSystem
  66479. * @param gradient defines the gradient to remove
  66480. * @returns the current particle system
  66481. */
  66482. removeAlphaRemapGradient(): IParticleSystem;
  66483. /**
  66484. * Not supported by GPUParticleSystem
  66485. * @param gradient defines the gradient to use (between 0 and 1)
  66486. * @param color defines the color to affect to the specified gradient
  66487. * @returns the current particle system
  66488. */
  66489. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66490. /**
  66491. * Not supported by GPUParticleSystem
  66492. * @param gradient defines the gradient to remove
  66493. * @returns the current particle system
  66494. */
  66495. removeRampGradient(): IParticleSystem;
  66496. /**
  66497. * Not supported by GPUParticleSystem
  66498. * @returns the list of ramp gradients
  66499. */
  66500. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66501. /**
  66502. * Not supported by GPUParticleSystem
  66503. * Gets or sets a boolean indicating that ramp gradients must be used
  66504. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66505. */
  66506. get useRampGradients(): boolean;
  66507. set useRampGradients(value: boolean);
  66508. /**
  66509. * Not supported by GPUParticleSystem
  66510. * @param gradient defines the gradient to use (between 0 and 1)
  66511. * @param factor defines the life time factor to affect to the specified gradient
  66512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66513. * @returns the current particle system
  66514. */
  66515. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66516. /**
  66517. * Not supported by GPUParticleSystem
  66518. * @param gradient defines the gradient to remove
  66519. * @returns the current particle system
  66520. */
  66521. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66522. /**
  66523. * Instantiates a GPU particle system.
  66524. * 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.
  66525. * @param name The name of the particle system
  66526. * @param options The options used to create the system
  66527. * @param scene The scene the particle system belongs to
  66528. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66529. * @param customEffect a custom effect used to change the way particles are rendered by default
  66530. */
  66531. constructor(name: string, options: Partial<{
  66532. capacity: number;
  66533. randomTextureSize: number;
  66534. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66535. protected _reset(): void;
  66536. private _createUpdateVAO;
  66537. private _createRenderVAO;
  66538. private _initialize;
  66539. /** @hidden */
  66540. _recreateUpdateEffect(): void;
  66541. private _getEffect;
  66542. /**
  66543. * Fill the defines array according to the current settings of the particle system
  66544. * @param defines Array to be updated
  66545. * @param blendMode blend mode to take into account when updating the array
  66546. */
  66547. fillDefines(defines: Array<string>, blendMode?: number): void;
  66548. /**
  66549. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66550. * @param uniforms Uniforms array to fill
  66551. * @param attributes Attributes array to fill
  66552. * @param samplers Samplers array to fill
  66553. */
  66554. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66555. /** @hidden */
  66556. _recreateRenderEffect(): Effect;
  66557. /**
  66558. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66559. * @param preWarm defines if we are in the pre-warmimg phase
  66560. */
  66561. animate(preWarm?: boolean): void;
  66562. private _createFactorGradientTexture;
  66563. private _createSizeGradientTexture;
  66564. private _createAngularSpeedGradientTexture;
  66565. private _createVelocityGradientTexture;
  66566. private _createLimitVelocityGradientTexture;
  66567. private _createDragGradientTexture;
  66568. private _createColorGradientTexture;
  66569. /**
  66570. * Renders the particle system in its current state
  66571. * @param preWarm defines if the system should only update the particles but not render them
  66572. * @returns the current number of particles
  66573. */
  66574. render(preWarm?: boolean): number;
  66575. /**
  66576. * Rebuilds the particle system
  66577. */
  66578. rebuild(): void;
  66579. private _releaseBuffers;
  66580. private _releaseVAOs;
  66581. /**
  66582. * Disposes the particle system and free the associated resources
  66583. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66584. */
  66585. dispose(disposeTexture?: boolean): void;
  66586. /**
  66587. * Clones the particle system.
  66588. * @param name The name of the cloned object
  66589. * @param newEmitter The new emitter to use
  66590. * @returns the cloned particle system
  66591. */
  66592. clone(name: string, newEmitter: any): GPUParticleSystem;
  66593. /**
  66594. * Serializes the particle system to a JSON object
  66595. * @param serializeTexture defines if the texture must be serialized as well
  66596. * @returns the JSON object
  66597. */
  66598. serialize(serializeTexture?: boolean): any;
  66599. /**
  66600. * Parses a JSON object to create a GPU particle system.
  66601. * @param parsedParticleSystem The JSON object to parse
  66602. * @param scene The scene to create the particle system in
  66603. * @param rootUrl The root url to use to load external dependencies like texture
  66604. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66605. * @returns the parsed GPU particle system
  66606. */
  66607. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66608. }
  66609. }
  66610. declare module BABYLON {
  66611. /**
  66612. * Represents a set of particle systems working together to create a specific effect
  66613. */
  66614. export class ParticleSystemSet implements IDisposable {
  66615. /**
  66616. * Gets or sets base Assets URL
  66617. */
  66618. static BaseAssetsUrl: string;
  66619. private _emitterCreationOptions;
  66620. private _emitterNode;
  66621. /**
  66622. * Gets the particle system list
  66623. */
  66624. systems: IParticleSystem[];
  66625. /**
  66626. * Gets the emitter node used with this set
  66627. */
  66628. get emitterNode(): Nullable<TransformNode>;
  66629. /**
  66630. * Creates a new emitter mesh as a sphere
  66631. * @param options defines the options used to create the sphere
  66632. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66633. * @param scene defines the hosting scene
  66634. */
  66635. setEmitterAsSphere(options: {
  66636. diameter: number;
  66637. segments: number;
  66638. color: Color3;
  66639. }, renderingGroupId: number, scene: Scene): void;
  66640. /**
  66641. * Starts all particle systems of the set
  66642. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66643. */
  66644. start(emitter?: AbstractMesh): void;
  66645. /**
  66646. * Release all associated resources
  66647. */
  66648. dispose(): void;
  66649. /**
  66650. * Serialize the set into a JSON compatible object
  66651. * @param serializeTexture defines if the texture must be serialized as well
  66652. * @returns a JSON compatible representation of the set
  66653. */
  66654. serialize(serializeTexture?: boolean): any;
  66655. /**
  66656. * Parse a new ParticleSystemSet from a serialized source
  66657. * @param data defines a JSON compatible representation of the set
  66658. * @param scene defines the hosting scene
  66659. * @param gpu defines if we want GPU particles or CPU particles
  66660. * @returns a new ParticleSystemSet
  66661. */
  66662. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66663. }
  66664. }
  66665. declare module BABYLON {
  66666. /**
  66667. * This class is made for on one-liner static method to help creating particle system set.
  66668. */
  66669. export class ParticleHelper {
  66670. /**
  66671. * Gets or sets base Assets URL
  66672. */
  66673. static BaseAssetsUrl: string;
  66674. /** Define the Url to load snippets */
  66675. static SnippetUrl: string;
  66676. /**
  66677. * Create a default particle system that you can tweak
  66678. * @param emitter defines the emitter to use
  66679. * @param capacity defines the system capacity (default is 500 particles)
  66680. * @param scene defines the hosting scene
  66681. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66682. * @returns the new Particle system
  66683. */
  66684. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66685. /**
  66686. * This is the main static method (one-liner) of this helper to create different particle systems
  66687. * @param type This string represents the type to the particle system to create
  66688. * @param scene The scene where the particle system should live
  66689. * @param gpu If the system will use gpu
  66690. * @returns the ParticleSystemSet created
  66691. */
  66692. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66693. /**
  66694. * Static function used to export a particle system to a ParticleSystemSet variable.
  66695. * Please note that the emitter shape is not exported
  66696. * @param systems defines the particle systems to export
  66697. * @returns the created particle system set
  66698. */
  66699. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66700. /**
  66701. * Creates a particle system from a snippet saved in a remote file
  66702. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66703. * @param url defines the url to load from
  66704. * @param scene defines the hosting scene
  66705. * @param gpu If the system will use gpu
  66706. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66707. * @returns a promise that will resolve to the new particle system
  66708. */
  66709. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66710. /**
  66711. * Creates a particle system from a snippet saved by the particle system editor
  66712. * @param snippetId defines the snippet to load
  66713. * @param scene defines the hosting scene
  66714. * @param gpu If the system will use gpu
  66715. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66716. * @returns a promise that will resolve to the new particle system
  66717. */
  66718. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66719. }
  66720. }
  66721. declare module BABYLON {
  66722. interface Engine {
  66723. /**
  66724. * Create an effect to use with particle systems.
  66725. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66726. * the particle system for which you want to create a custom effect in the last parameter
  66727. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66728. * @param uniformsNames defines a list of attribute names
  66729. * @param samplers defines an array of string used to represent textures
  66730. * @param defines defines the string containing the defines to use to compile the shaders
  66731. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66732. * @param onCompiled defines a function to call when the effect creation is successful
  66733. * @param onError defines a function to call when the effect creation has failed
  66734. * @param particleSystem the particle system you want to create the effect for
  66735. * @returns the new Effect
  66736. */
  66737. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66738. }
  66739. interface Mesh {
  66740. /**
  66741. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66742. * @returns an array of IParticleSystem
  66743. */
  66744. getEmittedParticleSystems(): IParticleSystem[];
  66745. /**
  66746. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66747. * @returns an array of IParticleSystem
  66748. */
  66749. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66750. }
  66751. }
  66752. declare module BABYLON {
  66753. /** Defines the 4 color options */
  66754. export enum PointColor {
  66755. /** color value */
  66756. Color = 2,
  66757. /** uv value */
  66758. UV = 1,
  66759. /** random value */
  66760. Random = 0,
  66761. /** stated value */
  66762. Stated = 3
  66763. }
  66764. /**
  66765. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66766. * 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.
  66767. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66768. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66769. *
  66770. * Full documentation here : TO BE ENTERED
  66771. */
  66772. export class PointsCloudSystem implements IDisposable {
  66773. /**
  66774. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66775. * Example : var p = SPS.particles[i];
  66776. */
  66777. particles: CloudPoint[];
  66778. /**
  66779. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66780. */
  66781. nbParticles: number;
  66782. /**
  66783. * This a counter for your own usage. It's not set by any SPS functions.
  66784. */
  66785. counter: number;
  66786. /**
  66787. * The PCS name. This name is also given to the underlying mesh.
  66788. */
  66789. name: string;
  66790. /**
  66791. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66792. */
  66793. mesh: Mesh;
  66794. /**
  66795. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66796. * Please read :
  66797. */
  66798. vars: any;
  66799. /**
  66800. * @hidden
  66801. */
  66802. _size: number;
  66803. private _scene;
  66804. private _promises;
  66805. private _positions;
  66806. private _indices;
  66807. private _normals;
  66808. private _colors;
  66809. private _uvs;
  66810. private _indices32;
  66811. private _positions32;
  66812. private _colors32;
  66813. private _uvs32;
  66814. private _updatable;
  66815. private _isVisibilityBoxLocked;
  66816. private _alwaysVisible;
  66817. private _groups;
  66818. private _groupCounter;
  66819. private _computeParticleColor;
  66820. private _computeParticleTexture;
  66821. private _computeParticleRotation;
  66822. private _computeBoundingBox;
  66823. private _isReady;
  66824. /**
  66825. * Creates a PCS (Points Cloud System) object
  66826. * @param name (String) is the PCS name, this will be the underlying mesh name
  66827. * @param pointSize (number) is the size for each point
  66828. * @param scene (Scene) is the scene in which the PCS is added
  66829. * @param options defines the options of the PCS e.g.
  66830. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66831. */
  66832. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66833. updatable?: boolean;
  66834. });
  66835. /**
  66836. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66837. * If no points were added to the PCS, the returned mesh is just a single point.
  66838. * @returns a promise for the created mesh
  66839. */
  66840. buildMeshAsync(): Promise<Mesh>;
  66841. /**
  66842. * @hidden
  66843. */
  66844. private _buildMesh;
  66845. private _addParticle;
  66846. private _randomUnitVector;
  66847. private _getColorIndicesForCoord;
  66848. private _setPointsColorOrUV;
  66849. private _colorFromTexture;
  66850. private _calculateDensity;
  66851. /**
  66852. * Adds points to the PCS in random positions within a unit sphere
  66853. * @param nb (positive integer) the number of particles to be created from this model
  66854. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66855. * @returns the number of groups in the system
  66856. */
  66857. addPoints(nb: number, pointFunction?: any): number;
  66858. /**
  66859. * Adds points to the PCS from the surface of the model shape
  66860. * @param mesh is any Mesh object that will be used as a surface model for the points
  66861. * @param nb (positive integer) the number of particles to be created from this model
  66862. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66863. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66864. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66865. * @returns the number of groups in the system
  66866. */
  66867. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66868. /**
  66869. * Adds points to the PCS inside the model shape
  66870. * @param mesh is any Mesh object that will be used as a surface model for the points
  66871. * @param nb (positive integer) the number of particles to be created from this model
  66872. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66873. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66874. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66875. * @returns the number of groups in the system
  66876. */
  66877. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66878. /**
  66879. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66880. * This method calls `updateParticle()` for each particle of the SPS.
  66881. * For an animated SPS, it is usually called within the render loop.
  66882. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66883. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66884. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66885. * @returns the PCS.
  66886. */
  66887. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66888. /**
  66889. * Disposes the PCS.
  66890. */
  66891. dispose(): void;
  66892. /**
  66893. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66894. * doc :
  66895. * @returns the PCS.
  66896. */
  66897. refreshVisibleSize(): PointsCloudSystem;
  66898. /**
  66899. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66900. * @param size the size (float) of the visibility box
  66901. * note : this doesn't lock the PCS mesh bounding box.
  66902. * doc :
  66903. */
  66904. setVisibilityBox(size: number): void;
  66905. /**
  66906. * Gets whether the PCS is always visible or not
  66907. * doc :
  66908. */
  66909. get isAlwaysVisible(): boolean;
  66910. /**
  66911. * Sets the PCS as always visible or not
  66912. * doc :
  66913. */
  66914. set isAlwaysVisible(val: boolean);
  66915. /**
  66916. * Tells to `setParticles()` to compute the particle rotations or not
  66917. * Default value : false. The PCS is faster when it's set to false
  66918. * Note : particle rotations are only applied to parent particles
  66919. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66920. */
  66921. set computeParticleRotation(val: boolean);
  66922. /**
  66923. * Tells to `setParticles()` to compute the particle colors or not.
  66924. * Default value : true. The PCS is faster when it's set to false.
  66925. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66926. */
  66927. set computeParticleColor(val: boolean);
  66928. set computeParticleTexture(val: boolean);
  66929. /**
  66930. * Gets if `setParticles()` computes the particle colors or not.
  66931. * Default value : false. The PCS is faster when it's set to false.
  66932. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66933. */
  66934. get computeParticleColor(): boolean;
  66935. /**
  66936. * Gets if `setParticles()` computes the particle textures or not.
  66937. * Default value : false. The PCS is faster when it's set to false.
  66938. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66939. */
  66940. get computeParticleTexture(): boolean;
  66941. /**
  66942. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66943. */
  66944. set computeBoundingBox(val: boolean);
  66945. /**
  66946. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66947. */
  66948. get computeBoundingBox(): boolean;
  66949. /**
  66950. * This function does nothing. It may be overwritten to set all the particle first values.
  66951. * The PCS doesn't call this function, you may have to call it by your own.
  66952. * doc :
  66953. */
  66954. initParticles(): void;
  66955. /**
  66956. * This function does nothing. It may be overwritten to recycle a particle
  66957. * The PCS doesn't call this function, you can to call it
  66958. * doc :
  66959. * @param particle The particle to recycle
  66960. * @returns the recycled particle
  66961. */
  66962. recycleParticle(particle: CloudPoint): CloudPoint;
  66963. /**
  66964. * Updates a particle : this function should be overwritten by the user.
  66965. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66966. * doc :
  66967. * @example : just set a particle position or velocity and recycle conditions
  66968. * @param particle The particle to update
  66969. * @returns the updated particle
  66970. */
  66971. updateParticle(particle: CloudPoint): CloudPoint;
  66972. /**
  66973. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66974. * This does nothing and may be overwritten by the user.
  66975. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66976. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66977. * @param update the boolean update value actually passed to setParticles()
  66978. */
  66979. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66980. /**
  66981. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66982. * This will be passed three parameters.
  66983. * This does nothing and may be overwritten by the user.
  66984. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66985. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66986. * @param update the boolean update value actually passed to setParticles()
  66987. */
  66988. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66989. }
  66990. }
  66991. declare module BABYLON {
  66992. /**
  66993. * Represents one particle of a points cloud system.
  66994. */
  66995. export class CloudPoint {
  66996. /**
  66997. * particle global index
  66998. */
  66999. idx: number;
  67000. /**
  67001. * The color of the particle
  67002. */
  67003. color: Nullable<Color4>;
  67004. /**
  67005. * The world space position of the particle.
  67006. */
  67007. position: Vector3;
  67008. /**
  67009. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67010. */
  67011. rotation: Vector3;
  67012. /**
  67013. * The world space rotation quaternion of the particle.
  67014. */
  67015. rotationQuaternion: Nullable<Quaternion>;
  67016. /**
  67017. * The uv of the particle.
  67018. */
  67019. uv: Nullable<Vector2>;
  67020. /**
  67021. * The current speed of the particle.
  67022. */
  67023. velocity: Vector3;
  67024. /**
  67025. * The pivot point in the particle local space.
  67026. */
  67027. pivot: Vector3;
  67028. /**
  67029. * Must the particle be translated from its pivot point in its local space ?
  67030. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67031. * Default : false
  67032. */
  67033. translateFromPivot: boolean;
  67034. /**
  67035. * Index of this particle in the global "positions" array (Internal use)
  67036. * @hidden
  67037. */
  67038. _pos: number;
  67039. /**
  67040. * @hidden Index of this particle in the global "indices" array (Internal use)
  67041. */
  67042. _ind: number;
  67043. /**
  67044. * Group this particle belongs to
  67045. */
  67046. _group: PointsGroup;
  67047. /**
  67048. * Group id of this particle
  67049. */
  67050. groupId: number;
  67051. /**
  67052. * Index of the particle in its group id (Internal use)
  67053. */
  67054. idxInGroup: number;
  67055. /**
  67056. * @hidden Particle BoundingInfo object (Internal use)
  67057. */
  67058. _boundingInfo: BoundingInfo;
  67059. /**
  67060. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67061. */
  67062. _pcs: PointsCloudSystem;
  67063. /**
  67064. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67065. */
  67066. _stillInvisible: boolean;
  67067. /**
  67068. * @hidden Last computed particle rotation matrix
  67069. */
  67070. _rotationMatrix: number[];
  67071. /**
  67072. * Parent particle Id, if any.
  67073. * Default null.
  67074. */
  67075. parentId: Nullable<number>;
  67076. /**
  67077. * @hidden Internal global position in the PCS.
  67078. */
  67079. _globalPosition: Vector3;
  67080. /**
  67081. * Creates a Point Cloud object.
  67082. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67083. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67084. * @param group (PointsGroup) is the group the particle belongs to
  67085. * @param groupId (integer) is the group identifier in the PCS.
  67086. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67087. * @param pcs defines the PCS it is associated to
  67088. */
  67089. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67090. /**
  67091. * get point size
  67092. */
  67093. get size(): Vector3;
  67094. /**
  67095. * Set point size
  67096. */
  67097. set size(scale: Vector3);
  67098. /**
  67099. * Legacy support, changed quaternion to rotationQuaternion
  67100. */
  67101. get quaternion(): Nullable<Quaternion>;
  67102. /**
  67103. * Legacy support, changed quaternion to rotationQuaternion
  67104. */
  67105. set quaternion(q: Nullable<Quaternion>);
  67106. /**
  67107. * Returns a boolean. True if the particle intersects a mesh, else false
  67108. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67109. * @param target is the object (point or mesh) what the intersection is computed against
  67110. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67111. * @returns true if it intersects
  67112. */
  67113. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67114. /**
  67115. * get the rotation matrix of the particle
  67116. * @hidden
  67117. */
  67118. getRotationMatrix(m: Matrix): void;
  67119. }
  67120. /**
  67121. * Represents a group of points in a points cloud system
  67122. * * PCS internal tool, don't use it manually.
  67123. */
  67124. export class PointsGroup {
  67125. /**
  67126. * The group id
  67127. * @hidden
  67128. */
  67129. groupID: number;
  67130. /**
  67131. * image data for group (internal use)
  67132. * @hidden
  67133. */
  67134. _groupImageData: Nullable<ArrayBufferView>;
  67135. /**
  67136. * Image Width (internal use)
  67137. * @hidden
  67138. */
  67139. _groupImgWidth: number;
  67140. /**
  67141. * Image Height (internal use)
  67142. * @hidden
  67143. */
  67144. _groupImgHeight: number;
  67145. /**
  67146. * Custom position function (internal use)
  67147. * @hidden
  67148. */
  67149. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67150. /**
  67151. * density per facet for surface points
  67152. * @hidden
  67153. */
  67154. _groupDensity: number[];
  67155. /**
  67156. * Only when points are colored by texture carries pointer to texture list array
  67157. * @hidden
  67158. */
  67159. _textureNb: number;
  67160. /**
  67161. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67162. * PCS internal tool, don't use it manually.
  67163. * @hidden
  67164. */
  67165. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67166. }
  67167. }
  67168. declare module BABYLON {
  67169. interface Scene {
  67170. /** @hidden (Backing field) */
  67171. _physicsEngine: Nullable<IPhysicsEngine>;
  67172. /** @hidden */
  67173. _physicsTimeAccumulator: number;
  67174. /**
  67175. * Gets the current physics engine
  67176. * @returns a IPhysicsEngine or null if none attached
  67177. */
  67178. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67179. /**
  67180. * Enables physics to the current scene
  67181. * @param gravity defines the scene's gravity for the physics engine
  67182. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67183. * @return a boolean indicating if the physics engine was initialized
  67184. */
  67185. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67186. /**
  67187. * Disables and disposes the physics engine associated with the scene
  67188. */
  67189. disablePhysicsEngine(): void;
  67190. /**
  67191. * Gets a boolean indicating if there is an active physics engine
  67192. * @returns a boolean indicating if there is an active physics engine
  67193. */
  67194. isPhysicsEnabled(): boolean;
  67195. /**
  67196. * Deletes a physics compound impostor
  67197. * @param compound defines the compound to delete
  67198. */
  67199. deleteCompoundImpostor(compound: any): void;
  67200. /**
  67201. * An event triggered when physic simulation is about to be run
  67202. */
  67203. onBeforePhysicsObservable: Observable<Scene>;
  67204. /**
  67205. * An event triggered when physic simulation has been done
  67206. */
  67207. onAfterPhysicsObservable: Observable<Scene>;
  67208. }
  67209. interface AbstractMesh {
  67210. /** @hidden */
  67211. _physicsImpostor: Nullable<PhysicsImpostor>;
  67212. /**
  67213. * Gets or sets impostor used for physic simulation
  67214. * @see http://doc.babylonjs.com/features/physics_engine
  67215. */
  67216. physicsImpostor: Nullable<PhysicsImpostor>;
  67217. /**
  67218. * Gets the current physics impostor
  67219. * @see http://doc.babylonjs.com/features/physics_engine
  67220. * @returns a physics impostor or null
  67221. */
  67222. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67223. /** Apply a physic impulse to the mesh
  67224. * @param force defines the force to apply
  67225. * @param contactPoint defines where to apply the force
  67226. * @returns the current mesh
  67227. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67228. */
  67229. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67230. /**
  67231. * Creates a physic joint between two meshes
  67232. * @param otherMesh defines the other mesh to use
  67233. * @param pivot1 defines the pivot to use on this mesh
  67234. * @param pivot2 defines the pivot to use on the other mesh
  67235. * @param options defines additional options (can be plugin dependent)
  67236. * @returns the current mesh
  67237. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67238. */
  67239. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67240. /** @hidden */
  67241. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67242. }
  67243. /**
  67244. * Defines the physics engine scene component responsible to manage a physics engine
  67245. */
  67246. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67247. /**
  67248. * The component name helpful to identify the component in the list of scene components.
  67249. */
  67250. readonly name: string;
  67251. /**
  67252. * The scene the component belongs to.
  67253. */
  67254. scene: Scene;
  67255. /**
  67256. * Creates a new instance of the component for the given scene
  67257. * @param scene Defines the scene to register the component in
  67258. */
  67259. constructor(scene: Scene);
  67260. /**
  67261. * Registers the component in a given scene
  67262. */
  67263. register(): void;
  67264. /**
  67265. * Rebuilds the elements related to this component in case of
  67266. * context lost for instance.
  67267. */
  67268. rebuild(): void;
  67269. /**
  67270. * Disposes the component and the associated ressources
  67271. */
  67272. dispose(): void;
  67273. }
  67274. }
  67275. declare module BABYLON {
  67276. /**
  67277. * A helper for physics simulations
  67278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67279. */
  67280. export class PhysicsHelper {
  67281. private _scene;
  67282. private _physicsEngine;
  67283. /**
  67284. * Initializes the Physics helper
  67285. * @param scene Babylon.js scene
  67286. */
  67287. constructor(scene: Scene);
  67288. /**
  67289. * Applies a radial explosion impulse
  67290. * @param origin the origin of the explosion
  67291. * @param radiusOrEventOptions the radius or the options of radial explosion
  67292. * @param strength the explosion strength
  67293. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67294. * @returns A physics radial explosion event, or null
  67295. */
  67296. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67297. /**
  67298. * Applies a radial explosion force
  67299. * @param origin the origin of the explosion
  67300. * @param radiusOrEventOptions the radius or the options of radial explosion
  67301. * @param strength the explosion strength
  67302. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67303. * @returns A physics radial explosion event, or null
  67304. */
  67305. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67306. /**
  67307. * Creates a gravitational field
  67308. * @param origin the origin of the explosion
  67309. * @param radiusOrEventOptions the radius or the options of radial explosion
  67310. * @param strength the explosion strength
  67311. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67312. * @returns A physics gravitational field event, or null
  67313. */
  67314. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67315. /**
  67316. * Creates a physics updraft event
  67317. * @param origin the origin of the updraft
  67318. * @param radiusOrEventOptions the radius or the options of the updraft
  67319. * @param strength the strength of the updraft
  67320. * @param height the height of the updraft
  67321. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67322. * @returns A physics updraft event, or null
  67323. */
  67324. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67325. /**
  67326. * Creates a physics vortex event
  67327. * @param origin the of the vortex
  67328. * @param radiusOrEventOptions the radius or the options of the vortex
  67329. * @param strength the strength of the vortex
  67330. * @param height the height of the vortex
  67331. * @returns a Physics vortex event, or null
  67332. * A physics vortex event or null
  67333. */
  67334. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67335. }
  67336. /**
  67337. * Represents a physics radial explosion event
  67338. */
  67339. class PhysicsRadialExplosionEvent {
  67340. private _scene;
  67341. private _options;
  67342. private _sphere;
  67343. private _dataFetched;
  67344. /**
  67345. * Initializes a radial explosioin event
  67346. * @param _scene BabylonJS scene
  67347. * @param _options The options for the vortex event
  67348. */
  67349. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67350. /**
  67351. * Returns the data related to the radial explosion event (sphere).
  67352. * @returns The radial explosion event data
  67353. */
  67354. getData(): PhysicsRadialExplosionEventData;
  67355. /**
  67356. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67357. * @param impostor A physics imposter
  67358. * @param origin the origin of the explosion
  67359. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67360. */
  67361. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67362. /**
  67363. * Triggers affecterd impostors callbacks
  67364. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67365. */
  67366. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67367. /**
  67368. * Disposes the sphere.
  67369. * @param force Specifies if the sphere should be disposed by force
  67370. */
  67371. dispose(force?: boolean): void;
  67372. /*** Helpers ***/
  67373. private _prepareSphere;
  67374. private _intersectsWithSphere;
  67375. }
  67376. /**
  67377. * Represents a gravitational field event
  67378. */
  67379. class PhysicsGravitationalFieldEvent {
  67380. private _physicsHelper;
  67381. private _scene;
  67382. private _origin;
  67383. private _options;
  67384. private _tickCallback;
  67385. private _sphere;
  67386. private _dataFetched;
  67387. /**
  67388. * Initializes the physics gravitational field event
  67389. * @param _physicsHelper A physics helper
  67390. * @param _scene BabylonJS scene
  67391. * @param _origin The origin position of the gravitational field event
  67392. * @param _options The options for the vortex event
  67393. */
  67394. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67395. /**
  67396. * Returns the data related to the gravitational field event (sphere).
  67397. * @returns A gravitational field event
  67398. */
  67399. getData(): PhysicsGravitationalFieldEventData;
  67400. /**
  67401. * Enables the gravitational field.
  67402. */
  67403. enable(): void;
  67404. /**
  67405. * Disables the gravitational field.
  67406. */
  67407. disable(): void;
  67408. /**
  67409. * Disposes the sphere.
  67410. * @param force The force to dispose from the gravitational field event
  67411. */
  67412. dispose(force?: boolean): void;
  67413. private _tick;
  67414. }
  67415. /**
  67416. * Represents a physics updraft event
  67417. */
  67418. class PhysicsUpdraftEvent {
  67419. private _scene;
  67420. private _origin;
  67421. private _options;
  67422. private _physicsEngine;
  67423. private _originTop;
  67424. private _originDirection;
  67425. private _tickCallback;
  67426. private _cylinder;
  67427. private _cylinderPosition;
  67428. private _dataFetched;
  67429. /**
  67430. * Initializes the physics updraft event
  67431. * @param _scene BabylonJS scene
  67432. * @param _origin The origin position of the updraft
  67433. * @param _options The options for the updraft event
  67434. */
  67435. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67436. /**
  67437. * Returns the data related to the updraft event (cylinder).
  67438. * @returns A physics updraft event
  67439. */
  67440. getData(): PhysicsUpdraftEventData;
  67441. /**
  67442. * Enables the updraft.
  67443. */
  67444. enable(): void;
  67445. /**
  67446. * Disables the updraft.
  67447. */
  67448. disable(): void;
  67449. /**
  67450. * Disposes the cylinder.
  67451. * @param force Specifies if the updraft should be disposed by force
  67452. */
  67453. dispose(force?: boolean): void;
  67454. private getImpostorHitData;
  67455. private _tick;
  67456. /*** Helpers ***/
  67457. private _prepareCylinder;
  67458. private _intersectsWithCylinder;
  67459. }
  67460. /**
  67461. * Represents a physics vortex event
  67462. */
  67463. class PhysicsVortexEvent {
  67464. private _scene;
  67465. private _origin;
  67466. private _options;
  67467. private _physicsEngine;
  67468. private _originTop;
  67469. private _tickCallback;
  67470. private _cylinder;
  67471. private _cylinderPosition;
  67472. private _dataFetched;
  67473. /**
  67474. * Initializes the physics vortex event
  67475. * @param _scene The BabylonJS scene
  67476. * @param _origin The origin position of the vortex
  67477. * @param _options The options for the vortex event
  67478. */
  67479. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67480. /**
  67481. * Returns the data related to the vortex event (cylinder).
  67482. * @returns The physics vortex event data
  67483. */
  67484. getData(): PhysicsVortexEventData;
  67485. /**
  67486. * Enables the vortex.
  67487. */
  67488. enable(): void;
  67489. /**
  67490. * Disables the cortex.
  67491. */
  67492. disable(): void;
  67493. /**
  67494. * Disposes the sphere.
  67495. * @param force
  67496. */
  67497. dispose(force?: boolean): void;
  67498. private getImpostorHitData;
  67499. private _tick;
  67500. /*** Helpers ***/
  67501. private _prepareCylinder;
  67502. private _intersectsWithCylinder;
  67503. }
  67504. /**
  67505. * Options fot the radial explosion event
  67506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67507. */
  67508. export class PhysicsRadialExplosionEventOptions {
  67509. /**
  67510. * The radius of the sphere for the radial explosion.
  67511. */
  67512. radius: number;
  67513. /**
  67514. * The strenth of the explosion.
  67515. */
  67516. strength: number;
  67517. /**
  67518. * The strenght of the force in correspondence to the distance of the affected object
  67519. */
  67520. falloff: PhysicsRadialImpulseFalloff;
  67521. /**
  67522. * Sphere options for the radial explosion.
  67523. */
  67524. sphere: {
  67525. segments: number;
  67526. diameter: number;
  67527. };
  67528. /**
  67529. * Sphere options for the radial explosion.
  67530. */
  67531. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67532. }
  67533. /**
  67534. * Options fot the updraft event
  67535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67536. */
  67537. export class PhysicsUpdraftEventOptions {
  67538. /**
  67539. * The radius of the cylinder for the vortex
  67540. */
  67541. radius: number;
  67542. /**
  67543. * The strenth of the updraft.
  67544. */
  67545. strength: number;
  67546. /**
  67547. * The height of the cylinder for the updraft.
  67548. */
  67549. height: number;
  67550. /**
  67551. * The mode for the the updraft.
  67552. */
  67553. updraftMode: PhysicsUpdraftMode;
  67554. }
  67555. /**
  67556. * Options fot the vortex event
  67557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67558. */
  67559. export class PhysicsVortexEventOptions {
  67560. /**
  67561. * The radius of the cylinder for the vortex
  67562. */
  67563. radius: number;
  67564. /**
  67565. * The strenth of the vortex.
  67566. */
  67567. strength: number;
  67568. /**
  67569. * The height of the cylinder for the vortex.
  67570. */
  67571. height: number;
  67572. /**
  67573. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67574. */
  67575. centripetalForceThreshold: number;
  67576. /**
  67577. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67578. */
  67579. centripetalForceMultiplier: number;
  67580. /**
  67581. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67582. */
  67583. centrifugalForceMultiplier: number;
  67584. /**
  67585. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67586. */
  67587. updraftForceMultiplier: number;
  67588. }
  67589. /**
  67590. * The strenght of the force in correspondence to the distance of the affected object
  67591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67592. */
  67593. export enum PhysicsRadialImpulseFalloff {
  67594. /** Defines that impulse is constant in strength across it's whole radius */
  67595. Constant = 0,
  67596. /** Defines that impulse gets weaker if it's further from the origin */
  67597. Linear = 1
  67598. }
  67599. /**
  67600. * The strength of the force in correspondence to the distance of the affected object
  67601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67602. */
  67603. export enum PhysicsUpdraftMode {
  67604. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67605. Center = 0,
  67606. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67607. Perpendicular = 1
  67608. }
  67609. /**
  67610. * Interface for a physics hit data
  67611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67612. */
  67613. export interface PhysicsHitData {
  67614. /**
  67615. * The force applied at the contact point
  67616. */
  67617. force: Vector3;
  67618. /**
  67619. * The contact point
  67620. */
  67621. contactPoint: Vector3;
  67622. /**
  67623. * The distance from the origin to the contact point
  67624. */
  67625. distanceFromOrigin: number;
  67626. }
  67627. /**
  67628. * Interface for radial explosion event data
  67629. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67630. */
  67631. export interface PhysicsRadialExplosionEventData {
  67632. /**
  67633. * A sphere used for the radial explosion event
  67634. */
  67635. sphere: Mesh;
  67636. }
  67637. /**
  67638. * Interface for gravitational field event data
  67639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67640. */
  67641. export interface PhysicsGravitationalFieldEventData {
  67642. /**
  67643. * A sphere mesh used for the gravitational field event
  67644. */
  67645. sphere: Mesh;
  67646. }
  67647. /**
  67648. * Interface for updraft event data
  67649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67650. */
  67651. export interface PhysicsUpdraftEventData {
  67652. /**
  67653. * A cylinder used for the updraft event
  67654. */
  67655. cylinder: Mesh;
  67656. }
  67657. /**
  67658. * Interface for vortex event data
  67659. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67660. */
  67661. export interface PhysicsVortexEventData {
  67662. /**
  67663. * A cylinder used for the vortex event
  67664. */
  67665. cylinder: Mesh;
  67666. }
  67667. /**
  67668. * Interface for an affected physics impostor
  67669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67670. */
  67671. export interface PhysicsAffectedImpostorWithData {
  67672. /**
  67673. * The impostor affected by the effect
  67674. */
  67675. impostor: PhysicsImpostor;
  67676. /**
  67677. * The data about the hit/horce from the explosion
  67678. */
  67679. hitData: PhysicsHitData;
  67680. }
  67681. }
  67682. declare module BABYLON {
  67683. /** @hidden */
  67684. export var blackAndWhitePixelShader: {
  67685. name: string;
  67686. shader: string;
  67687. };
  67688. }
  67689. declare module BABYLON {
  67690. /**
  67691. * Post process used to render in black and white
  67692. */
  67693. export class BlackAndWhitePostProcess extends PostProcess {
  67694. /**
  67695. * Linear about to convert he result to black and white (default: 1)
  67696. */
  67697. degree: number;
  67698. /**
  67699. * Creates a black and white post process
  67700. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67701. * @param name The name of the effect.
  67702. * @param options The required width/height ratio to downsize to before computing the render pass.
  67703. * @param camera The camera to apply the render pass to.
  67704. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67705. * @param engine The engine which the post process will be applied. (default: current engine)
  67706. * @param reusable If the post process can be reused on the same frame. (default: false)
  67707. */
  67708. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67709. }
  67710. }
  67711. declare module BABYLON {
  67712. /**
  67713. * This represents a set of one or more post processes in Babylon.
  67714. * A post process can be used to apply a shader to a texture after it is rendered.
  67715. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67716. */
  67717. export class PostProcessRenderEffect {
  67718. private _postProcesses;
  67719. private _getPostProcesses;
  67720. private _singleInstance;
  67721. private _cameras;
  67722. private _indicesForCamera;
  67723. /**
  67724. * Name of the effect
  67725. * @hidden
  67726. */
  67727. _name: string;
  67728. /**
  67729. * Instantiates a post process render effect.
  67730. * A post process can be used to apply a shader to a texture after it is rendered.
  67731. * @param engine The engine the effect is tied to
  67732. * @param name The name of the effect
  67733. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67734. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67735. */
  67736. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67737. /**
  67738. * Checks if all the post processes in the effect are supported.
  67739. */
  67740. get isSupported(): boolean;
  67741. /**
  67742. * Updates the current state of the effect
  67743. * @hidden
  67744. */
  67745. _update(): void;
  67746. /**
  67747. * Attaches the effect on cameras
  67748. * @param cameras The camera to attach to.
  67749. * @hidden
  67750. */
  67751. _attachCameras(cameras: Camera): void;
  67752. /**
  67753. * Attaches the effect on cameras
  67754. * @param cameras The camera to attach to.
  67755. * @hidden
  67756. */
  67757. _attachCameras(cameras: Camera[]): void;
  67758. /**
  67759. * Detaches the effect on cameras
  67760. * @param cameras The camera to detatch from.
  67761. * @hidden
  67762. */
  67763. _detachCameras(cameras: Camera): void;
  67764. /**
  67765. * Detatches the effect on cameras
  67766. * @param cameras The camera to detatch from.
  67767. * @hidden
  67768. */
  67769. _detachCameras(cameras: Camera[]): void;
  67770. /**
  67771. * Enables the effect on given cameras
  67772. * @param cameras The camera to enable.
  67773. * @hidden
  67774. */
  67775. _enable(cameras: Camera): void;
  67776. /**
  67777. * Enables the effect on given cameras
  67778. * @param cameras The camera to enable.
  67779. * @hidden
  67780. */
  67781. _enable(cameras: Nullable<Camera[]>): void;
  67782. /**
  67783. * Disables the effect on the given cameras
  67784. * @param cameras The camera to disable.
  67785. * @hidden
  67786. */
  67787. _disable(cameras: Camera): void;
  67788. /**
  67789. * Disables the effect on the given cameras
  67790. * @param cameras The camera to disable.
  67791. * @hidden
  67792. */
  67793. _disable(cameras: Nullable<Camera[]>): void;
  67794. /**
  67795. * Gets a list of the post processes contained in the effect.
  67796. * @param camera The camera to get the post processes on.
  67797. * @returns The list of the post processes in the effect.
  67798. */
  67799. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67800. }
  67801. }
  67802. declare module BABYLON {
  67803. /** @hidden */
  67804. export var extractHighlightsPixelShader: {
  67805. name: string;
  67806. shader: string;
  67807. };
  67808. }
  67809. declare module BABYLON {
  67810. /**
  67811. * 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.
  67812. */
  67813. export class ExtractHighlightsPostProcess extends PostProcess {
  67814. /**
  67815. * The luminance threshold, pixels below this value will be set to black.
  67816. */
  67817. threshold: number;
  67818. /** @hidden */
  67819. _exposure: number;
  67820. /**
  67821. * Post process which has the input texture to be used when performing highlight extraction
  67822. * @hidden
  67823. */
  67824. _inputPostProcess: Nullable<PostProcess>;
  67825. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67826. }
  67827. }
  67828. declare module BABYLON {
  67829. /** @hidden */
  67830. export var bloomMergePixelShader: {
  67831. name: string;
  67832. shader: string;
  67833. };
  67834. }
  67835. declare module BABYLON {
  67836. /**
  67837. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67838. */
  67839. export class BloomMergePostProcess extends PostProcess {
  67840. /** Weight of the bloom to be added to the original input. */
  67841. weight: number;
  67842. /**
  67843. * Creates a new instance of @see BloomMergePostProcess
  67844. * @param name The name of the effect.
  67845. * @param originalFromInput Post process which's input will be used for the merge.
  67846. * @param blurred Blurred highlights post process which's output will be used.
  67847. * @param weight Weight of the bloom to be added to the original input.
  67848. * @param options The required width/height ratio to downsize to before computing the render pass.
  67849. * @param camera The camera to apply the render pass to.
  67850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67851. * @param engine The engine which the post process will be applied. (default: current engine)
  67852. * @param reusable If the post process can be reused on the same frame. (default: false)
  67853. * @param textureType Type of textures used when performing the post process. (default: 0)
  67854. * @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)
  67855. */
  67856. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67857. /** Weight of the bloom to be added to the original input. */
  67858. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67859. }
  67860. }
  67861. declare module BABYLON {
  67862. /**
  67863. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67864. */
  67865. export class BloomEffect extends PostProcessRenderEffect {
  67866. private bloomScale;
  67867. /**
  67868. * @hidden Internal
  67869. */
  67870. _effects: Array<PostProcess>;
  67871. /**
  67872. * @hidden Internal
  67873. */
  67874. _downscale: ExtractHighlightsPostProcess;
  67875. private _blurX;
  67876. private _blurY;
  67877. private _merge;
  67878. /**
  67879. * The luminance threshold to find bright areas of the image to bloom.
  67880. */
  67881. get threshold(): number;
  67882. set threshold(value: number);
  67883. /**
  67884. * The strength of the bloom.
  67885. */
  67886. get weight(): number;
  67887. set weight(value: number);
  67888. /**
  67889. * Specifies the size of the bloom blur kernel, relative to the final output size
  67890. */
  67891. get kernel(): number;
  67892. set kernel(value: number);
  67893. /**
  67894. * Creates a new instance of @see BloomEffect
  67895. * @param scene The scene the effect belongs to.
  67896. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67897. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67898. * @param bloomWeight The the strength of bloom.
  67899. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67900. * @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)
  67901. */
  67902. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67903. /**
  67904. * Disposes each of the internal effects for a given camera.
  67905. * @param camera The camera to dispose the effect on.
  67906. */
  67907. disposeEffects(camera: Camera): void;
  67908. /**
  67909. * @hidden Internal
  67910. */
  67911. _updateEffects(): void;
  67912. /**
  67913. * Internal
  67914. * @returns if all the contained post processes are ready.
  67915. * @hidden
  67916. */
  67917. _isReady(): boolean;
  67918. }
  67919. }
  67920. declare module BABYLON {
  67921. /** @hidden */
  67922. export var chromaticAberrationPixelShader: {
  67923. name: string;
  67924. shader: string;
  67925. };
  67926. }
  67927. declare module BABYLON {
  67928. /**
  67929. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67930. */
  67931. export class ChromaticAberrationPostProcess extends PostProcess {
  67932. /**
  67933. * The amount of seperation of rgb channels (default: 30)
  67934. */
  67935. aberrationAmount: number;
  67936. /**
  67937. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67938. */
  67939. radialIntensity: number;
  67940. /**
  67941. * 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))
  67942. */
  67943. direction: Vector2;
  67944. /**
  67945. * 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))
  67946. */
  67947. centerPosition: Vector2;
  67948. /**
  67949. * Creates a new instance ChromaticAberrationPostProcess
  67950. * @param name The name of the effect.
  67951. * @param screenWidth The width of the screen to apply the effect on.
  67952. * @param screenHeight The height of the screen to apply the effect on.
  67953. * @param options The required width/height ratio to downsize to before computing the render pass.
  67954. * @param camera The camera to apply the render pass to.
  67955. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67956. * @param engine The engine which the post process will be applied. (default: current engine)
  67957. * @param reusable If the post process can be reused on the same frame. (default: false)
  67958. * @param textureType Type of textures used when performing the post process. (default: 0)
  67959. * @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)
  67960. */
  67961. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67962. }
  67963. }
  67964. declare module BABYLON {
  67965. /** @hidden */
  67966. export var circleOfConfusionPixelShader: {
  67967. name: string;
  67968. shader: string;
  67969. };
  67970. }
  67971. declare module BABYLON {
  67972. /**
  67973. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67974. */
  67975. export class CircleOfConfusionPostProcess extends PostProcess {
  67976. /**
  67977. * 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.
  67978. */
  67979. lensSize: number;
  67980. /**
  67981. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67982. */
  67983. fStop: number;
  67984. /**
  67985. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67986. */
  67987. focusDistance: number;
  67988. /**
  67989. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67990. */
  67991. focalLength: number;
  67992. private _depthTexture;
  67993. /**
  67994. * Creates a new instance CircleOfConfusionPostProcess
  67995. * @param name The name of the effect.
  67996. * @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.
  67997. * @param options The required width/height ratio to downsize to before computing the render pass.
  67998. * @param camera The camera to apply the render pass to.
  67999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68000. * @param engine The engine which the post process will be applied. (default: current engine)
  68001. * @param reusable If the post process can be reused on the same frame. (default: false)
  68002. * @param textureType Type of textures used when performing the post process. (default: 0)
  68003. * @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)
  68004. */
  68005. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68006. /**
  68007. * 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.
  68008. */
  68009. set depthTexture(value: RenderTargetTexture);
  68010. }
  68011. }
  68012. declare module BABYLON {
  68013. /** @hidden */
  68014. export var colorCorrectionPixelShader: {
  68015. name: string;
  68016. shader: string;
  68017. };
  68018. }
  68019. declare module BABYLON {
  68020. /**
  68021. *
  68022. * This post-process allows the modification of rendered colors by using
  68023. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68024. *
  68025. * The object needs to be provided an url to a texture containing the color
  68026. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68027. * Use an image editing software to tweak the LUT to match your needs.
  68028. *
  68029. * For an example of a color LUT, see here:
  68030. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68031. * For explanations on color grading, see here:
  68032. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68033. *
  68034. */
  68035. export class ColorCorrectionPostProcess extends PostProcess {
  68036. private _colorTableTexture;
  68037. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68038. }
  68039. }
  68040. declare module BABYLON {
  68041. /** @hidden */
  68042. export var convolutionPixelShader: {
  68043. name: string;
  68044. shader: string;
  68045. };
  68046. }
  68047. declare module BABYLON {
  68048. /**
  68049. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68050. * input texture to perform effects such as edge detection or sharpening
  68051. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68052. */
  68053. export class ConvolutionPostProcess extends PostProcess {
  68054. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68055. kernel: number[];
  68056. /**
  68057. * Creates a new instance ConvolutionPostProcess
  68058. * @param name The name of the effect.
  68059. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68060. * @param options The required width/height ratio to downsize to before computing the render pass.
  68061. * @param camera The camera to apply the render pass to.
  68062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68063. * @param engine The engine which the post process will be applied. (default: current engine)
  68064. * @param reusable If the post process can be reused on the same frame. (default: false)
  68065. * @param textureType Type of textures used when performing the post process. (default: 0)
  68066. */
  68067. constructor(name: string,
  68068. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68069. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68070. /**
  68071. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68072. */
  68073. static EdgeDetect0Kernel: number[];
  68074. /**
  68075. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68076. */
  68077. static EdgeDetect1Kernel: number[];
  68078. /**
  68079. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68080. */
  68081. static EdgeDetect2Kernel: number[];
  68082. /**
  68083. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68084. */
  68085. static SharpenKernel: number[];
  68086. /**
  68087. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68088. */
  68089. static EmbossKernel: number[];
  68090. /**
  68091. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68092. */
  68093. static GaussianKernel: number[];
  68094. }
  68095. }
  68096. declare module BABYLON {
  68097. /**
  68098. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68099. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68100. * based on samples that have a large difference in distance than the center pixel.
  68101. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68102. */
  68103. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68104. direction: Vector2;
  68105. /**
  68106. * Creates a new instance CircleOfConfusionPostProcess
  68107. * @param name The name of the effect.
  68108. * @param scene The scene the effect belongs to.
  68109. * @param direction The direction the blur should be applied.
  68110. * @param kernel The size of the kernel used to blur.
  68111. * @param options The required width/height ratio to downsize to before computing the render pass.
  68112. * @param camera The camera to apply the render pass to.
  68113. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68114. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68115. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68116. * @param engine The engine which the post process will be applied. (default: current engine)
  68117. * @param reusable If the post process can be reused on the same frame. (default: false)
  68118. * @param textureType Type of textures used when performing the post process. (default: 0)
  68119. * @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)
  68120. */
  68121. 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);
  68122. }
  68123. }
  68124. declare module BABYLON {
  68125. /** @hidden */
  68126. export var depthOfFieldMergePixelShader: {
  68127. name: string;
  68128. shader: string;
  68129. };
  68130. }
  68131. declare module BABYLON {
  68132. /**
  68133. * Options to be set when merging outputs from the default pipeline.
  68134. */
  68135. export class DepthOfFieldMergePostProcessOptions {
  68136. /**
  68137. * The original image to merge on top of
  68138. */
  68139. originalFromInput: PostProcess;
  68140. /**
  68141. * Parameters to perform the merge of the depth of field effect
  68142. */
  68143. depthOfField?: {
  68144. circleOfConfusion: PostProcess;
  68145. blurSteps: Array<PostProcess>;
  68146. };
  68147. /**
  68148. * Parameters to perform the merge of bloom effect
  68149. */
  68150. bloom?: {
  68151. blurred: PostProcess;
  68152. weight: number;
  68153. };
  68154. }
  68155. /**
  68156. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68157. */
  68158. export class DepthOfFieldMergePostProcess extends PostProcess {
  68159. private blurSteps;
  68160. /**
  68161. * Creates a new instance of DepthOfFieldMergePostProcess
  68162. * @param name The name of the effect.
  68163. * @param originalFromInput Post process which's input will be used for the merge.
  68164. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68165. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68166. * @param options The required width/height ratio to downsize to before computing the render pass.
  68167. * @param camera The camera to apply the render pass to.
  68168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68169. * @param engine The engine which the post process will be applied. (default: current engine)
  68170. * @param reusable If the post process can be reused on the same frame. (default: false)
  68171. * @param textureType Type of textures used when performing the post process. (default: 0)
  68172. * @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)
  68173. */
  68174. 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);
  68175. /**
  68176. * Updates the effect with the current post process compile time values and recompiles the shader.
  68177. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68178. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68179. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68180. * @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
  68181. * @param onCompiled Called when the shader has been compiled.
  68182. * @param onError Called if there is an error when compiling a shader.
  68183. */
  68184. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68185. }
  68186. }
  68187. declare module BABYLON {
  68188. /**
  68189. * Specifies the level of max blur that should be applied when using the depth of field effect
  68190. */
  68191. export enum DepthOfFieldEffectBlurLevel {
  68192. /**
  68193. * Subtle blur
  68194. */
  68195. Low = 0,
  68196. /**
  68197. * Medium blur
  68198. */
  68199. Medium = 1,
  68200. /**
  68201. * Large blur
  68202. */
  68203. High = 2
  68204. }
  68205. /**
  68206. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68207. */
  68208. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68209. private _circleOfConfusion;
  68210. /**
  68211. * @hidden Internal, blurs from high to low
  68212. */
  68213. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68214. private _depthOfFieldBlurY;
  68215. private _dofMerge;
  68216. /**
  68217. * @hidden Internal post processes in depth of field effect
  68218. */
  68219. _effects: Array<PostProcess>;
  68220. /**
  68221. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68222. */
  68223. set focalLength(value: number);
  68224. get focalLength(): number;
  68225. /**
  68226. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68227. */
  68228. set fStop(value: number);
  68229. get fStop(): number;
  68230. /**
  68231. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68232. */
  68233. set focusDistance(value: number);
  68234. get focusDistance(): number;
  68235. /**
  68236. * 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.
  68237. */
  68238. set lensSize(value: number);
  68239. get lensSize(): number;
  68240. /**
  68241. * Creates a new instance DepthOfFieldEffect
  68242. * @param scene The scene the effect belongs to.
  68243. * @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.
  68244. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68245. * @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)
  68246. */
  68247. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68248. /**
  68249. * Get the current class name of the current effet
  68250. * @returns "DepthOfFieldEffect"
  68251. */
  68252. getClassName(): string;
  68253. /**
  68254. * 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.
  68255. */
  68256. set depthTexture(value: RenderTargetTexture);
  68257. /**
  68258. * Disposes each of the internal effects for a given camera.
  68259. * @param camera The camera to dispose the effect on.
  68260. */
  68261. disposeEffects(camera: Camera): void;
  68262. /**
  68263. * @hidden Internal
  68264. */
  68265. _updateEffects(): void;
  68266. /**
  68267. * Internal
  68268. * @returns if all the contained post processes are ready.
  68269. * @hidden
  68270. */
  68271. _isReady(): boolean;
  68272. }
  68273. }
  68274. declare module BABYLON {
  68275. /** @hidden */
  68276. export var displayPassPixelShader: {
  68277. name: string;
  68278. shader: string;
  68279. };
  68280. }
  68281. declare module BABYLON {
  68282. /**
  68283. * DisplayPassPostProcess which produces an output the same as it's input
  68284. */
  68285. export class DisplayPassPostProcess extends PostProcess {
  68286. /**
  68287. * Creates the DisplayPassPostProcess
  68288. * @param name The name of the effect.
  68289. * @param options The required width/height ratio to downsize to before computing the render pass.
  68290. * @param camera The camera to apply the render pass to.
  68291. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68292. * @param engine The engine which the post process will be applied. (default: current engine)
  68293. * @param reusable If the post process can be reused on the same frame. (default: false)
  68294. */
  68295. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68296. }
  68297. }
  68298. declare module BABYLON {
  68299. /** @hidden */
  68300. export var filterPixelShader: {
  68301. name: string;
  68302. shader: string;
  68303. };
  68304. }
  68305. declare module BABYLON {
  68306. /**
  68307. * Applies a kernel filter to the image
  68308. */
  68309. export class FilterPostProcess extends PostProcess {
  68310. /** The matrix to be applied to the image */
  68311. kernelMatrix: Matrix;
  68312. /**
  68313. *
  68314. * @param name The name of the effect.
  68315. * @param kernelMatrix The matrix to be applied to the image
  68316. * @param options The required width/height ratio to downsize to before computing the render pass.
  68317. * @param camera The camera to apply the render pass to.
  68318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68319. * @param engine The engine which the post process will be applied. (default: current engine)
  68320. * @param reusable If the post process can be reused on the same frame. (default: false)
  68321. */
  68322. constructor(name: string,
  68323. /** The matrix to be applied to the image */
  68324. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68325. }
  68326. }
  68327. declare module BABYLON {
  68328. /** @hidden */
  68329. export var fxaaPixelShader: {
  68330. name: string;
  68331. shader: string;
  68332. };
  68333. }
  68334. declare module BABYLON {
  68335. /** @hidden */
  68336. export var fxaaVertexShader: {
  68337. name: string;
  68338. shader: string;
  68339. };
  68340. }
  68341. declare module BABYLON {
  68342. /**
  68343. * Fxaa post process
  68344. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68345. */
  68346. export class FxaaPostProcess extends PostProcess {
  68347. /** @hidden */
  68348. texelWidth: number;
  68349. /** @hidden */
  68350. texelHeight: number;
  68351. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68352. private _getDefines;
  68353. }
  68354. }
  68355. declare module BABYLON {
  68356. /** @hidden */
  68357. export var grainPixelShader: {
  68358. name: string;
  68359. shader: string;
  68360. };
  68361. }
  68362. declare module BABYLON {
  68363. /**
  68364. * The GrainPostProcess adds noise to the image at mid luminance levels
  68365. */
  68366. export class GrainPostProcess extends PostProcess {
  68367. /**
  68368. * The intensity of the grain added (default: 30)
  68369. */
  68370. intensity: number;
  68371. /**
  68372. * If the grain should be randomized on every frame
  68373. */
  68374. animated: boolean;
  68375. /**
  68376. * Creates a new instance of @see GrainPostProcess
  68377. * @param name The name of the effect.
  68378. * @param options The required width/height ratio to downsize to before computing the render pass.
  68379. * @param camera The camera to apply the render pass to.
  68380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68381. * @param engine The engine which the post process will be applied. (default: current engine)
  68382. * @param reusable If the post process can be reused on the same frame. (default: false)
  68383. * @param textureType Type of textures used when performing the post process. (default: 0)
  68384. * @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)
  68385. */
  68386. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68387. }
  68388. }
  68389. declare module BABYLON {
  68390. /** @hidden */
  68391. export var highlightsPixelShader: {
  68392. name: string;
  68393. shader: string;
  68394. };
  68395. }
  68396. declare module BABYLON {
  68397. /**
  68398. * Extracts highlights from the image
  68399. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68400. */
  68401. export class HighlightsPostProcess extends PostProcess {
  68402. /**
  68403. * Extracts highlights from the image
  68404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68405. * @param name The name of the effect.
  68406. * @param options The required width/height ratio to downsize to before computing the render pass.
  68407. * @param camera The camera to apply the render pass to.
  68408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68409. * @param engine The engine which the post process will be applied. (default: current engine)
  68410. * @param reusable If the post process can be reused on the same frame. (default: false)
  68411. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68412. */
  68413. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68414. }
  68415. }
  68416. declare module BABYLON {
  68417. /** @hidden */
  68418. export var mrtFragmentDeclaration: {
  68419. name: string;
  68420. shader: string;
  68421. };
  68422. }
  68423. declare module BABYLON {
  68424. /** @hidden */
  68425. export var geometryPixelShader: {
  68426. name: string;
  68427. shader: string;
  68428. };
  68429. }
  68430. declare module BABYLON {
  68431. /** @hidden */
  68432. export var geometryVertexShader: {
  68433. name: string;
  68434. shader: string;
  68435. };
  68436. }
  68437. declare module BABYLON {
  68438. /** @hidden */
  68439. interface ISavedTransformationMatrix {
  68440. world: Matrix;
  68441. viewProjection: Matrix;
  68442. }
  68443. /**
  68444. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68445. */
  68446. export class GeometryBufferRenderer {
  68447. /**
  68448. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68449. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68450. */
  68451. static readonly POSITION_TEXTURE_TYPE: number;
  68452. /**
  68453. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68454. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68455. */
  68456. static readonly VELOCITY_TEXTURE_TYPE: number;
  68457. /**
  68458. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68459. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68460. */
  68461. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68462. /**
  68463. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68464. * in order to compute objects velocities when enableVelocity is set to "true"
  68465. * @hidden
  68466. */
  68467. _previousTransformationMatrices: {
  68468. [index: number]: ISavedTransformationMatrix;
  68469. };
  68470. /**
  68471. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68472. * in order to compute objects velocities when enableVelocity is set to "true"
  68473. * @hidden
  68474. */
  68475. _previousBonesTransformationMatrices: {
  68476. [index: number]: Float32Array;
  68477. };
  68478. /**
  68479. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68480. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68481. */
  68482. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68483. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68484. renderTransparentMeshes: boolean;
  68485. private _scene;
  68486. private _multiRenderTarget;
  68487. private _ratio;
  68488. private _enablePosition;
  68489. private _enableVelocity;
  68490. private _enableReflectivity;
  68491. private _positionIndex;
  68492. private _velocityIndex;
  68493. private _reflectivityIndex;
  68494. protected _effect: Effect;
  68495. protected _cachedDefines: string;
  68496. /**
  68497. * Set the render list (meshes to be rendered) used in the G buffer.
  68498. */
  68499. set renderList(meshes: Mesh[]);
  68500. /**
  68501. * Gets wether or not G buffer are supported by the running hardware.
  68502. * This requires draw buffer supports
  68503. */
  68504. get isSupported(): boolean;
  68505. /**
  68506. * Returns the index of the given texture type in the G-Buffer textures array
  68507. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68508. * @returns the index of the given texture type in the G-Buffer textures array
  68509. */
  68510. getTextureIndex(textureType: number): number;
  68511. /**
  68512. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68513. */
  68514. get enablePosition(): boolean;
  68515. /**
  68516. * Sets whether or not objects positions are enabled for the G buffer.
  68517. */
  68518. set enablePosition(enable: boolean);
  68519. /**
  68520. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68521. */
  68522. get enableVelocity(): boolean;
  68523. /**
  68524. * Sets wether or not objects velocities are enabled for the G buffer.
  68525. */
  68526. set enableVelocity(enable: boolean);
  68527. /**
  68528. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68529. */
  68530. get enableReflectivity(): boolean;
  68531. /**
  68532. * Sets wether or not objects roughness are enabled for the G buffer.
  68533. */
  68534. set enableReflectivity(enable: boolean);
  68535. /**
  68536. * Gets the scene associated with the buffer.
  68537. */
  68538. get scene(): Scene;
  68539. /**
  68540. * Gets the ratio used by the buffer during its creation.
  68541. * How big is the buffer related to the main canvas.
  68542. */
  68543. get ratio(): number;
  68544. /** @hidden */
  68545. static _SceneComponentInitialization: (scene: Scene) => void;
  68546. /**
  68547. * Creates a new G Buffer for the scene
  68548. * @param scene The scene the buffer belongs to
  68549. * @param ratio How big is the buffer related to the main canvas.
  68550. */
  68551. constructor(scene: Scene, ratio?: number);
  68552. /**
  68553. * Checks wether everything is ready to render a submesh to the G buffer.
  68554. * @param subMesh the submesh to check readiness for
  68555. * @param useInstances is the mesh drawn using instance or not
  68556. * @returns true if ready otherwise false
  68557. */
  68558. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68559. /**
  68560. * Gets the current underlying G Buffer.
  68561. * @returns the buffer
  68562. */
  68563. getGBuffer(): MultiRenderTarget;
  68564. /**
  68565. * Gets the number of samples used to render the buffer (anti aliasing).
  68566. */
  68567. get samples(): number;
  68568. /**
  68569. * Sets the number of samples used to render the buffer (anti aliasing).
  68570. */
  68571. set samples(value: number);
  68572. /**
  68573. * Disposes the renderer and frees up associated resources.
  68574. */
  68575. dispose(): void;
  68576. protected _createRenderTargets(): void;
  68577. private _copyBonesTransformationMatrices;
  68578. }
  68579. }
  68580. declare module BABYLON {
  68581. interface Scene {
  68582. /** @hidden (Backing field) */
  68583. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68584. /**
  68585. * Gets or Sets the current geometry buffer associated to the scene.
  68586. */
  68587. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68588. /**
  68589. * Enables a GeometryBufferRender and associates it with the scene
  68590. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68591. * @returns the GeometryBufferRenderer
  68592. */
  68593. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68594. /**
  68595. * Disables the GeometryBufferRender associated with the scene
  68596. */
  68597. disableGeometryBufferRenderer(): void;
  68598. }
  68599. /**
  68600. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68601. * in several rendering techniques.
  68602. */
  68603. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68604. /**
  68605. * The component name helpful to identify the component in the list of scene components.
  68606. */
  68607. readonly name: string;
  68608. /**
  68609. * The scene the component belongs to.
  68610. */
  68611. scene: Scene;
  68612. /**
  68613. * Creates a new instance of the component for the given scene
  68614. * @param scene Defines the scene to register the component in
  68615. */
  68616. constructor(scene: Scene);
  68617. /**
  68618. * Registers the component in a given scene
  68619. */
  68620. register(): void;
  68621. /**
  68622. * Rebuilds the elements related to this component in case of
  68623. * context lost for instance.
  68624. */
  68625. rebuild(): void;
  68626. /**
  68627. * Disposes the component and the associated ressources
  68628. */
  68629. dispose(): void;
  68630. private _gatherRenderTargets;
  68631. }
  68632. }
  68633. declare module BABYLON {
  68634. /** @hidden */
  68635. export var motionBlurPixelShader: {
  68636. name: string;
  68637. shader: string;
  68638. };
  68639. }
  68640. declare module BABYLON {
  68641. /**
  68642. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68643. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68644. * As an example, all you have to do is to create the post-process:
  68645. * var mb = new BABYLON.MotionBlurPostProcess(
  68646. * 'mb', // The name of the effect.
  68647. * scene, // The scene containing the objects to blur according to their velocity.
  68648. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68649. * camera // The camera to apply the render pass to.
  68650. * );
  68651. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68652. */
  68653. export class MotionBlurPostProcess extends PostProcess {
  68654. /**
  68655. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68656. */
  68657. motionStrength: number;
  68658. /**
  68659. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68660. */
  68661. get motionBlurSamples(): number;
  68662. /**
  68663. * Sets the number of iterations to be used for motion blur quality
  68664. */
  68665. set motionBlurSamples(samples: number);
  68666. private _motionBlurSamples;
  68667. private _geometryBufferRenderer;
  68668. /**
  68669. * Creates a new instance MotionBlurPostProcess
  68670. * @param name The name of the effect.
  68671. * @param scene The scene containing the objects to blur according to their velocity.
  68672. * @param options The required width/height ratio to downsize to before computing the render pass.
  68673. * @param camera The camera to apply the render pass to.
  68674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68675. * @param engine The engine which the post process will be applied. (default: current engine)
  68676. * @param reusable If the post process can be reused on the same frame. (default: false)
  68677. * @param textureType Type of textures used when performing the post process. (default: 0)
  68678. * @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)
  68679. */
  68680. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68681. /**
  68682. * Excludes the given skinned mesh from computing bones velocities.
  68683. * 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.
  68684. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68685. */
  68686. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68687. /**
  68688. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68689. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68690. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68691. */
  68692. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68693. /**
  68694. * Disposes the post process.
  68695. * @param camera The camera to dispose the post process on.
  68696. */
  68697. dispose(camera?: Camera): void;
  68698. }
  68699. }
  68700. declare module BABYLON {
  68701. /** @hidden */
  68702. export var refractionPixelShader: {
  68703. name: string;
  68704. shader: string;
  68705. };
  68706. }
  68707. declare module BABYLON {
  68708. /**
  68709. * Post process which applies a refractin texture
  68710. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68711. */
  68712. export class RefractionPostProcess extends PostProcess {
  68713. /** the base color of the refraction (used to taint the rendering) */
  68714. color: Color3;
  68715. /** simulated refraction depth */
  68716. depth: number;
  68717. /** the coefficient of the base color (0 to remove base color tainting) */
  68718. colorLevel: number;
  68719. private _refTexture;
  68720. private _ownRefractionTexture;
  68721. /**
  68722. * Gets or sets the refraction texture
  68723. * Please note that you are responsible for disposing the texture if you set it manually
  68724. */
  68725. get refractionTexture(): Texture;
  68726. set refractionTexture(value: Texture);
  68727. /**
  68728. * Initializes the RefractionPostProcess
  68729. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68730. * @param name The name of the effect.
  68731. * @param refractionTextureUrl Url of the refraction texture to use
  68732. * @param color the base color of the refraction (used to taint the rendering)
  68733. * @param depth simulated refraction depth
  68734. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68735. * @param camera The camera to apply the render pass to.
  68736. * @param options The required width/height ratio to downsize to before computing the render pass.
  68737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68738. * @param engine The engine which the post process will be applied. (default: current engine)
  68739. * @param reusable If the post process can be reused on the same frame. (default: false)
  68740. */
  68741. constructor(name: string, refractionTextureUrl: string,
  68742. /** the base color of the refraction (used to taint the rendering) */
  68743. color: Color3,
  68744. /** simulated refraction depth */
  68745. depth: number,
  68746. /** the coefficient of the base color (0 to remove base color tainting) */
  68747. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68748. /**
  68749. * Disposes of the post process
  68750. * @param camera Camera to dispose post process on
  68751. */
  68752. dispose(camera: Camera): void;
  68753. }
  68754. }
  68755. declare module BABYLON {
  68756. /** @hidden */
  68757. export var sharpenPixelShader: {
  68758. name: string;
  68759. shader: string;
  68760. };
  68761. }
  68762. declare module BABYLON {
  68763. /**
  68764. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68765. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68766. */
  68767. export class SharpenPostProcess extends PostProcess {
  68768. /**
  68769. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68770. */
  68771. colorAmount: number;
  68772. /**
  68773. * How much sharpness should be applied (default: 0.3)
  68774. */
  68775. edgeAmount: number;
  68776. /**
  68777. * Creates a new instance ConvolutionPostProcess
  68778. * @param name The name of the effect.
  68779. * @param options The required width/height ratio to downsize to before computing the render pass.
  68780. * @param camera The camera to apply the render pass to.
  68781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68782. * @param engine The engine which the post process will be applied. (default: current engine)
  68783. * @param reusable If the post process can be reused on the same frame. (default: false)
  68784. * @param textureType Type of textures used when performing the post process. (default: 0)
  68785. * @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)
  68786. */
  68787. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68788. }
  68789. }
  68790. declare module BABYLON {
  68791. /**
  68792. * PostProcessRenderPipeline
  68793. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68794. */
  68795. export class PostProcessRenderPipeline {
  68796. private engine;
  68797. private _renderEffects;
  68798. private _renderEffectsForIsolatedPass;
  68799. /**
  68800. * List of inspectable custom properties (used by the Inspector)
  68801. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68802. */
  68803. inspectableCustomProperties: IInspectable[];
  68804. /**
  68805. * @hidden
  68806. */
  68807. protected _cameras: Camera[];
  68808. /** @hidden */
  68809. _name: string;
  68810. /**
  68811. * Gets pipeline name
  68812. */
  68813. get name(): string;
  68814. /** Gets the list of attached cameras */
  68815. get cameras(): Camera[];
  68816. /**
  68817. * Initializes a PostProcessRenderPipeline
  68818. * @param engine engine to add the pipeline to
  68819. * @param name name of the pipeline
  68820. */
  68821. constructor(engine: Engine, name: string);
  68822. /**
  68823. * Gets the class name
  68824. * @returns "PostProcessRenderPipeline"
  68825. */
  68826. getClassName(): string;
  68827. /**
  68828. * If all the render effects in the pipeline are supported
  68829. */
  68830. get isSupported(): boolean;
  68831. /**
  68832. * Adds an effect to the pipeline
  68833. * @param renderEffect the effect to add
  68834. */
  68835. addEffect(renderEffect: PostProcessRenderEffect): void;
  68836. /** @hidden */
  68837. _rebuild(): void;
  68838. /** @hidden */
  68839. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68840. /** @hidden */
  68841. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68842. /** @hidden */
  68843. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68844. /** @hidden */
  68845. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68846. /** @hidden */
  68847. _attachCameras(cameras: Camera, unique: boolean): void;
  68848. /** @hidden */
  68849. _attachCameras(cameras: Camera[], unique: boolean): void;
  68850. /** @hidden */
  68851. _detachCameras(cameras: Camera): void;
  68852. /** @hidden */
  68853. _detachCameras(cameras: Nullable<Camera[]>): void;
  68854. /** @hidden */
  68855. _update(): void;
  68856. /** @hidden */
  68857. _reset(): void;
  68858. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68859. /**
  68860. * Disposes of the pipeline
  68861. */
  68862. dispose(): void;
  68863. }
  68864. }
  68865. declare module BABYLON {
  68866. /**
  68867. * PostProcessRenderPipelineManager class
  68868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68869. */
  68870. export class PostProcessRenderPipelineManager {
  68871. private _renderPipelines;
  68872. /**
  68873. * Initializes a PostProcessRenderPipelineManager
  68874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68875. */
  68876. constructor();
  68877. /**
  68878. * Gets the list of supported render pipelines
  68879. */
  68880. get supportedPipelines(): PostProcessRenderPipeline[];
  68881. /**
  68882. * Adds a pipeline to the manager
  68883. * @param renderPipeline The pipeline to add
  68884. */
  68885. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68886. /**
  68887. * Attaches a camera to the pipeline
  68888. * @param renderPipelineName The name of the pipeline to attach to
  68889. * @param cameras the camera to attach
  68890. * @param unique if the camera can be attached multiple times to the pipeline
  68891. */
  68892. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68893. /**
  68894. * Detaches a camera from the pipeline
  68895. * @param renderPipelineName The name of the pipeline to detach from
  68896. * @param cameras the camera to detach
  68897. */
  68898. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68899. /**
  68900. * Enables an effect by name on a pipeline
  68901. * @param renderPipelineName the name of the pipeline to enable the effect in
  68902. * @param renderEffectName the name of the effect to enable
  68903. * @param cameras the cameras that the effect should be enabled on
  68904. */
  68905. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68906. /**
  68907. * Disables an effect by name on a pipeline
  68908. * @param renderPipelineName the name of the pipeline to disable the effect in
  68909. * @param renderEffectName the name of the effect to disable
  68910. * @param cameras the cameras that the effect should be disabled on
  68911. */
  68912. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68913. /**
  68914. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68915. */
  68916. update(): void;
  68917. /** @hidden */
  68918. _rebuild(): void;
  68919. /**
  68920. * Disposes of the manager and pipelines
  68921. */
  68922. dispose(): void;
  68923. }
  68924. }
  68925. declare module BABYLON {
  68926. interface Scene {
  68927. /** @hidden (Backing field) */
  68928. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68929. /**
  68930. * Gets the postprocess render pipeline manager
  68931. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68932. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68933. */
  68934. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68935. }
  68936. /**
  68937. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68938. */
  68939. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68940. /**
  68941. * The component name helpfull to identify the component in the list of scene components.
  68942. */
  68943. readonly name: string;
  68944. /**
  68945. * The scene the component belongs to.
  68946. */
  68947. scene: Scene;
  68948. /**
  68949. * Creates a new instance of the component for the given scene
  68950. * @param scene Defines the scene to register the component in
  68951. */
  68952. constructor(scene: Scene);
  68953. /**
  68954. * Registers the component in a given scene
  68955. */
  68956. register(): void;
  68957. /**
  68958. * Rebuilds the elements related to this component in case of
  68959. * context lost for instance.
  68960. */
  68961. rebuild(): void;
  68962. /**
  68963. * Disposes the component and the associated ressources
  68964. */
  68965. dispose(): void;
  68966. private _gatherRenderTargets;
  68967. }
  68968. }
  68969. declare module BABYLON {
  68970. /**
  68971. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68972. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68973. */
  68974. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68975. private _scene;
  68976. private _camerasToBeAttached;
  68977. /**
  68978. * ID of the sharpen post process,
  68979. */
  68980. private readonly SharpenPostProcessId;
  68981. /**
  68982. * @ignore
  68983. * ID of the image processing post process;
  68984. */
  68985. readonly ImageProcessingPostProcessId: string;
  68986. /**
  68987. * @ignore
  68988. * ID of the Fast Approximate Anti-Aliasing post process;
  68989. */
  68990. readonly FxaaPostProcessId: string;
  68991. /**
  68992. * ID of the chromatic aberration post process,
  68993. */
  68994. private readonly ChromaticAberrationPostProcessId;
  68995. /**
  68996. * ID of the grain post process
  68997. */
  68998. private readonly GrainPostProcessId;
  68999. /**
  69000. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69001. */
  69002. sharpen: SharpenPostProcess;
  69003. private _sharpenEffect;
  69004. private bloom;
  69005. /**
  69006. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69007. */
  69008. depthOfField: DepthOfFieldEffect;
  69009. /**
  69010. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69011. */
  69012. fxaa: FxaaPostProcess;
  69013. /**
  69014. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69015. */
  69016. imageProcessing: ImageProcessingPostProcess;
  69017. /**
  69018. * Chromatic aberration post process which will shift rgb colors in the image
  69019. */
  69020. chromaticAberration: ChromaticAberrationPostProcess;
  69021. private _chromaticAberrationEffect;
  69022. /**
  69023. * Grain post process which add noise to the image
  69024. */
  69025. grain: GrainPostProcess;
  69026. private _grainEffect;
  69027. /**
  69028. * Glow post process which adds a glow to emissive areas of the image
  69029. */
  69030. private _glowLayer;
  69031. /**
  69032. * Animations which can be used to tweak settings over a period of time
  69033. */
  69034. animations: Animation[];
  69035. private _imageProcessingConfigurationObserver;
  69036. private _sharpenEnabled;
  69037. private _bloomEnabled;
  69038. private _depthOfFieldEnabled;
  69039. private _depthOfFieldBlurLevel;
  69040. private _fxaaEnabled;
  69041. private _imageProcessingEnabled;
  69042. private _defaultPipelineTextureType;
  69043. private _bloomScale;
  69044. private _chromaticAberrationEnabled;
  69045. private _grainEnabled;
  69046. private _buildAllowed;
  69047. /**
  69048. * Gets active scene
  69049. */
  69050. get scene(): Scene;
  69051. /**
  69052. * Enable or disable the sharpen process from the pipeline
  69053. */
  69054. set sharpenEnabled(enabled: boolean);
  69055. get sharpenEnabled(): boolean;
  69056. private _resizeObserver;
  69057. private _hardwareScaleLevel;
  69058. private _bloomKernel;
  69059. /**
  69060. * Specifies the size of the bloom blur kernel, relative to the final output size
  69061. */
  69062. get bloomKernel(): number;
  69063. set bloomKernel(value: number);
  69064. /**
  69065. * Specifies the weight of the bloom in the final rendering
  69066. */
  69067. private _bloomWeight;
  69068. /**
  69069. * Specifies the luma threshold for the area that will be blurred by the bloom
  69070. */
  69071. private _bloomThreshold;
  69072. private _hdr;
  69073. /**
  69074. * The strength of the bloom.
  69075. */
  69076. set bloomWeight(value: number);
  69077. get bloomWeight(): number;
  69078. /**
  69079. * The strength of the bloom.
  69080. */
  69081. set bloomThreshold(value: number);
  69082. get bloomThreshold(): number;
  69083. /**
  69084. * The scale of the bloom, lower value will provide better performance.
  69085. */
  69086. set bloomScale(value: number);
  69087. get bloomScale(): number;
  69088. /**
  69089. * Enable or disable the bloom from the pipeline
  69090. */
  69091. set bloomEnabled(enabled: boolean);
  69092. get bloomEnabled(): boolean;
  69093. private _rebuildBloom;
  69094. /**
  69095. * If the depth of field is enabled.
  69096. */
  69097. get depthOfFieldEnabled(): boolean;
  69098. set depthOfFieldEnabled(enabled: boolean);
  69099. /**
  69100. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69101. */
  69102. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69103. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69104. /**
  69105. * If the anti aliasing is enabled.
  69106. */
  69107. set fxaaEnabled(enabled: boolean);
  69108. get fxaaEnabled(): boolean;
  69109. private _samples;
  69110. /**
  69111. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69112. */
  69113. set samples(sampleCount: number);
  69114. get samples(): number;
  69115. /**
  69116. * If image processing is enabled.
  69117. */
  69118. set imageProcessingEnabled(enabled: boolean);
  69119. get imageProcessingEnabled(): boolean;
  69120. /**
  69121. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69122. */
  69123. set glowLayerEnabled(enabled: boolean);
  69124. get glowLayerEnabled(): boolean;
  69125. /**
  69126. * Gets the glow layer (or null if not defined)
  69127. */
  69128. get glowLayer(): Nullable<GlowLayer>;
  69129. /**
  69130. * Enable or disable the chromaticAberration process from the pipeline
  69131. */
  69132. set chromaticAberrationEnabled(enabled: boolean);
  69133. get chromaticAberrationEnabled(): boolean;
  69134. /**
  69135. * Enable or disable the grain process from the pipeline
  69136. */
  69137. set grainEnabled(enabled: boolean);
  69138. get grainEnabled(): boolean;
  69139. /**
  69140. * @constructor
  69141. * @param name - The rendering pipeline name (default: "")
  69142. * @param hdr - If high dynamic range textures should be used (default: true)
  69143. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69144. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69145. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69146. */
  69147. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69148. /**
  69149. * Get the class name
  69150. * @returns "DefaultRenderingPipeline"
  69151. */
  69152. getClassName(): string;
  69153. /**
  69154. * Force the compilation of the entire pipeline.
  69155. */
  69156. prepare(): void;
  69157. private _hasCleared;
  69158. private _prevPostProcess;
  69159. private _prevPrevPostProcess;
  69160. private _setAutoClearAndTextureSharing;
  69161. private _depthOfFieldSceneObserver;
  69162. private _buildPipeline;
  69163. private _disposePostProcesses;
  69164. /**
  69165. * Adds a camera to the pipeline
  69166. * @param camera the camera to be added
  69167. */
  69168. addCamera(camera: Camera): void;
  69169. /**
  69170. * Removes a camera from the pipeline
  69171. * @param camera the camera to remove
  69172. */
  69173. removeCamera(camera: Camera): void;
  69174. /**
  69175. * Dispose of the pipeline and stop all post processes
  69176. */
  69177. dispose(): void;
  69178. /**
  69179. * Serialize the rendering pipeline (Used when exporting)
  69180. * @returns the serialized object
  69181. */
  69182. serialize(): any;
  69183. /**
  69184. * Parse the serialized pipeline
  69185. * @param source Source pipeline.
  69186. * @param scene The scene to load the pipeline to.
  69187. * @param rootUrl The URL of the serialized pipeline.
  69188. * @returns An instantiated pipeline from the serialized object.
  69189. */
  69190. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69191. }
  69192. }
  69193. declare module BABYLON {
  69194. /** @hidden */
  69195. export var lensHighlightsPixelShader: {
  69196. name: string;
  69197. shader: string;
  69198. };
  69199. }
  69200. declare module BABYLON {
  69201. /** @hidden */
  69202. export var depthOfFieldPixelShader: {
  69203. name: string;
  69204. shader: string;
  69205. };
  69206. }
  69207. declare module BABYLON {
  69208. /**
  69209. * BABYLON.JS Chromatic Aberration GLSL Shader
  69210. * Author: Olivier Guyot
  69211. * Separates very slightly R, G and B colors on the edges of the screen
  69212. * Inspired by Francois Tarlier & Martins Upitis
  69213. */
  69214. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69215. /**
  69216. * @ignore
  69217. * The chromatic aberration PostProcess id in the pipeline
  69218. */
  69219. LensChromaticAberrationEffect: string;
  69220. /**
  69221. * @ignore
  69222. * The highlights enhancing PostProcess id in the pipeline
  69223. */
  69224. HighlightsEnhancingEffect: string;
  69225. /**
  69226. * @ignore
  69227. * The depth-of-field PostProcess id in the pipeline
  69228. */
  69229. LensDepthOfFieldEffect: string;
  69230. private _scene;
  69231. private _depthTexture;
  69232. private _grainTexture;
  69233. private _chromaticAberrationPostProcess;
  69234. private _highlightsPostProcess;
  69235. private _depthOfFieldPostProcess;
  69236. private _edgeBlur;
  69237. private _grainAmount;
  69238. private _chromaticAberration;
  69239. private _distortion;
  69240. private _highlightsGain;
  69241. private _highlightsThreshold;
  69242. private _dofDistance;
  69243. private _dofAperture;
  69244. private _dofDarken;
  69245. private _dofPentagon;
  69246. private _blurNoise;
  69247. /**
  69248. * @constructor
  69249. *
  69250. * Effect parameters are as follow:
  69251. * {
  69252. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69253. * edge_blur: number; // from 0 to x (1 for realism)
  69254. * distortion: number; // from 0 to x (1 for realism)
  69255. * grain_amount: number; // from 0 to 1
  69256. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69257. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69258. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69259. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69260. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69261. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69262. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69263. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69264. * }
  69265. * Note: if an effect parameter is unset, effect is disabled
  69266. *
  69267. * @param name The rendering pipeline name
  69268. * @param parameters - An object containing all parameters (see above)
  69269. * @param scene The scene linked to this pipeline
  69270. * @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)
  69271. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69272. */
  69273. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69274. /**
  69275. * Get the class name
  69276. * @returns "LensRenderingPipeline"
  69277. */
  69278. getClassName(): string;
  69279. /**
  69280. * Gets associated scene
  69281. */
  69282. get scene(): Scene;
  69283. /**
  69284. * Gets or sets the edge blur
  69285. */
  69286. get edgeBlur(): number;
  69287. set edgeBlur(value: number);
  69288. /**
  69289. * Gets or sets the grain amount
  69290. */
  69291. get grainAmount(): number;
  69292. set grainAmount(value: number);
  69293. /**
  69294. * Gets or sets the chromatic aberration amount
  69295. */
  69296. get chromaticAberration(): number;
  69297. set chromaticAberration(value: number);
  69298. /**
  69299. * Gets or sets the depth of field aperture
  69300. */
  69301. get dofAperture(): number;
  69302. set dofAperture(value: number);
  69303. /**
  69304. * Gets or sets the edge distortion
  69305. */
  69306. get edgeDistortion(): number;
  69307. set edgeDistortion(value: number);
  69308. /**
  69309. * Gets or sets the depth of field distortion
  69310. */
  69311. get dofDistortion(): number;
  69312. set dofDistortion(value: number);
  69313. /**
  69314. * Gets or sets the darken out of focus amount
  69315. */
  69316. get darkenOutOfFocus(): number;
  69317. set darkenOutOfFocus(value: number);
  69318. /**
  69319. * Gets or sets a boolean indicating if blur noise is enabled
  69320. */
  69321. get blurNoise(): boolean;
  69322. set blurNoise(value: boolean);
  69323. /**
  69324. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69325. */
  69326. get pentagonBokeh(): boolean;
  69327. set pentagonBokeh(value: boolean);
  69328. /**
  69329. * Gets or sets the highlight grain amount
  69330. */
  69331. get highlightsGain(): number;
  69332. set highlightsGain(value: number);
  69333. /**
  69334. * Gets or sets the highlight threshold
  69335. */
  69336. get highlightsThreshold(): number;
  69337. set highlightsThreshold(value: number);
  69338. /**
  69339. * Sets the amount of blur at the edges
  69340. * @param amount blur amount
  69341. */
  69342. setEdgeBlur(amount: number): void;
  69343. /**
  69344. * Sets edge blur to 0
  69345. */
  69346. disableEdgeBlur(): void;
  69347. /**
  69348. * Sets the amout of grain
  69349. * @param amount Amount of grain
  69350. */
  69351. setGrainAmount(amount: number): void;
  69352. /**
  69353. * Set grain amount to 0
  69354. */
  69355. disableGrain(): void;
  69356. /**
  69357. * Sets the chromatic aberration amount
  69358. * @param amount amount of chromatic aberration
  69359. */
  69360. setChromaticAberration(amount: number): void;
  69361. /**
  69362. * Sets chromatic aberration amount to 0
  69363. */
  69364. disableChromaticAberration(): void;
  69365. /**
  69366. * Sets the EdgeDistortion amount
  69367. * @param amount amount of EdgeDistortion
  69368. */
  69369. setEdgeDistortion(amount: number): void;
  69370. /**
  69371. * Sets edge distortion to 0
  69372. */
  69373. disableEdgeDistortion(): void;
  69374. /**
  69375. * Sets the FocusDistance amount
  69376. * @param amount amount of FocusDistance
  69377. */
  69378. setFocusDistance(amount: number): void;
  69379. /**
  69380. * Disables depth of field
  69381. */
  69382. disableDepthOfField(): void;
  69383. /**
  69384. * Sets the Aperture amount
  69385. * @param amount amount of Aperture
  69386. */
  69387. setAperture(amount: number): void;
  69388. /**
  69389. * Sets the DarkenOutOfFocus amount
  69390. * @param amount amount of DarkenOutOfFocus
  69391. */
  69392. setDarkenOutOfFocus(amount: number): void;
  69393. private _pentagonBokehIsEnabled;
  69394. /**
  69395. * Creates a pentagon bokeh effect
  69396. */
  69397. enablePentagonBokeh(): void;
  69398. /**
  69399. * Disables the pentagon bokeh effect
  69400. */
  69401. disablePentagonBokeh(): void;
  69402. /**
  69403. * Enables noise blur
  69404. */
  69405. enableNoiseBlur(): void;
  69406. /**
  69407. * Disables noise blur
  69408. */
  69409. disableNoiseBlur(): void;
  69410. /**
  69411. * Sets the HighlightsGain amount
  69412. * @param amount amount of HighlightsGain
  69413. */
  69414. setHighlightsGain(amount: number): void;
  69415. /**
  69416. * Sets the HighlightsThreshold amount
  69417. * @param amount amount of HighlightsThreshold
  69418. */
  69419. setHighlightsThreshold(amount: number): void;
  69420. /**
  69421. * Disables highlights
  69422. */
  69423. disableHighlights(): void;
  69424. /**
  69425. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69426. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69427. */
  69428. dispose(disableDepthRender?: boolean): void;
  69429. private _createChromaticAberrationPostProcess;
  69430. private _createHighlightsPostProcess;
  69431. private _createDepthOfFieldPostProcess;
  69432. private _createGrainTexture;
  69433. }
  69434. }
  69435. declare module BABYLON {
  69436. /** @hidden */
  69437. export var ssao2PixelShader: {
  69438. name: string;
  69439. shader: string;
  69440. };
  69441. }
  69442. declare module BABYLON {
  69443. /** @hidden */
  69444. export var ssaoCombinePixelShader: {
  69445. name: string;
  69446. shader: string;
  69447. };
  69448. }
  69449. declare module BABYLON {
  69450. /**
  69451. * Render pipeline to produce ssao effect
  69452. */
  69453. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69454. /**
  69455. * @ignore
  69456. * The PassPostProcess id in the pipeline that contains the original scene color
  69457. */
  69458. SSAOOriginalSceneColorEffect: string;
  69459. /**
  69460. * @ignore
  69461. * The SSAO PostProcess id in the pipeline
  69462. */
  69463. SSAORenderEffect: string;
  69464. /**
  69465. * @ignore
  69466. * The horizontal blur PostProcess id in the pipeline
  69467. */
  69468. SSAOBlurHRenderEffect: string;
  69469. /**
  69470. * @ignore
  69471. * The vertical blur PostProcess id in the pipeline
  69472. */
  69473. SSAOBlurVRenderEffect: string;
  69474. /**
  69475. * @ignore
  69476. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69477. */
  69478. SSAOCombineRenderEffect: string;
  69479. /**
  69480. * The output strength of the SSAO post-process. Default value is 1.0.
  69481. */
  69482. totalStrength: number;
  69483. /**
  69484. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69485. */
  69486. maxZ: number;
  69487. /**
  69488. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69489. */
  69490. minZAspect: number;
  69491. private _samples;
  69492. /**
  69493. * Number of samples used for the SSAO calculations. Default value is 8
  69494. */
  69495. set samples(n: number);
  69496. get samples(): number;
  69497. private _textureSamples;
  69498. /**
  69499. * Number of samples to use for antialiasing
  69500. */
  69501. set textureSamples(n: number);
  69502. get textureSamples(): number;
  69503. /**
  69504. * Ratio object used for SSAO ratio and blur ratio
  69505. */
  69506. private _ratio;
  69507. /**
  69508. * Dynamically generated sphere sampler.
  69509. */
  69510. private _sampleSphere;
  69511. /**
  69512. * Blur filter offsets
  69513. */
  69514. private _samplerOffsets;
  69515. private _expensiveBlur;
  69516. /**
  69517. * If bilateral blur should be used
  69518. */
  69519. set expensiveBlur(b: boolean);
  69520. get expensiveBlur(): boolean;
  69521. /**
  69522. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69523. */
  69524. radius: number;
  69525. /**
  69526. * The base color of the SSAO post-process
  69527. * The final result is "base + ssao" between [0, 1]
  69528. */
  69529. base: number;
  69530. /**
  69531. * Support test.
  69532. */
  69533. static get IsSupported(): boolean;
  69534. private _scene;
  69535. private _depthTexture;
  69536. private _normalTexture;
  69537. private _randomTexture;
  69538. private _originalColorPostProcess;
  69539. private _ssaoPostProcess;
  69540. private _blurHPostProcess;
  69541. private _blurVPostProcess;
  69542. private _ssaoCombinePostProcess;
  69543. /**
  69544. * Gets active scene
  69545. */
  69546. get scene(): Scene;
  69547. /**
  69548. * @constructor
  69549. * @param name The rendering pipeline name
  69550. * @param scene The scene linked to this pipeline
  69551. * @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 }
  69552. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69553. */
  69554. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69555. /**
  69556. * Get the class name
  69557. * @returns "SSAO2RenderingPipeline"
  69558. */
  69559. getClassName(): string;
  69560. /**
  69561. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69562. */
  69563. dispose(disableGeometryBufferRenderer?: boolean): void;
  69564. private _createBlurPostProcess;
  69565. /** @hidden */
  69566. _rebuild(): void;
  69567. private _bits;
  69568. private _radicalInverse_VdC;
  69569. private _hammersley;
  69570. private _hemisphereSample_uniform;
  69571. private _generateHemisphere;
  69572. private _createSSAOPostProcess;
  69573. private _createSSAOCombinePostProcess;
  69574. private _createRandomTexture;
  69575. /**
  69576. * Serialize the rendering pipeline (Used when exporting)
  69577. * @returns the serialized object
  69578. */
  69579. serialize(): any;
  69580. /**
  69581. * Parse the serialized pipeline
  69582. * @param source Source pipeline.
  69583. * @param scene The scene to load the pipeline to.
  69584. * @param rootUrl The URL of the serialized pipeline.
  69585. * @returns An instantiated pipeline from the serialized object.
  69586. */
  69587. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69588. }
  69589. }
  69590. declare module BABYLON {
  69591. /** @hidden */
  69592. export var ssaoPixelShader: {
  69593. name: string;
  69594. shader: string;
  69595. };
  69596. }
  69597. declare module BABYLON {
  69598. /**
  69599. * Render pipeline to produce ssao effect
  69600. */
  69601. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69602. /**
  69603. * @ignore
  69604. * The PassPostProcess id in the pipeline that contains the original scene color
  69605. */
  69606. SSAOOriginalSceneColorEffect: string;
  69607. /**
  69608. * @ignore
  69609. * The SSAO PostProcess id in the pipeline
  69610. */
  69611. SSAORenderEffect: string;
  69612. /**
  69613. * @ignore
  69614. * The horizontal blur PostProcess id in the pipeline
  69615. */
  69616. SSAOBlurHRenderEffect: string;
  69617. /**
  69618. * @ignore
  69619. * The vertical blur PostProcess id in the pipeline
  69620. */
  69621. SSAOBlurVRenderEffect: string;
  69622. /**
  69623. * @ignore
  69624. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69625. */
  69626. SSAOCombineRenderEffect: string;
  69627. /**
  69628. * The output strength of the SSAO post-process. Default value is 1.0.
  69629. */
  69630. totalStrength: number;
  69631. /**
  69632. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69633. */
  69634. radius: number;
  69635. /**
  69636. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69637. * Must not be equal to fallOff and superior to fallOff.
  69638. * Default value is 0.0075
  69639. */
  69640. area: number;
  69641. /**
  69642. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69643. * Must not be equal to area and inferior to area.
  69644. * Default value is 0.000001
  69645. */
  69646. fallOff: number;
  69647. /**
  69648. * The base color of the SSAO post-process
  69649. * The final result is "base + ssao" between [0, 1]
  69650. */
  69651. base: number;
  69652. private _scene;
  69653. private _depthTexture;
  69654. private _randomTexture;
  69655. private _originalColorPostProcess;
  69656. private _ssaoPostProcess;
  69657. private _blurHPostProcess;
  69658. private _blurVPostProcess;
  69659. private _ssaoCombinePostProcess;
  69660. private _firstUpdate;
  69661. /**
  69662. * Gets active scene
  69663. */
  69664. get scene(): Scene;
  69665. /**
  69666. * @constructor
  69667. * @param name - The rendering pipeline name
  69668. * @param scene - The scene linked to this pipeline
  69669. * @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 }
  69670. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69671. */
  69672. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69673. /**
  69674. * Get the class name
  69675. * @returns "SSAORenderingPipeline"
  69676. */
  69677. getClassName(): string;
  69678. /**
  69679. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69680. */
  69681. dispose(disableDepthRender?: boolean): void;
  69682. private _createBlurPostProcess;
  69683. /** @hidden */
  69684. _rebuild(): void;
  69685. private _createSSAOPostProcess;
  69686. private _createSSAOCombinePostProcess;
  69687. private _createRandomTexture;
  69688. }
  69689. }
  69690. declare module BABYLON {
  69691. /** @hidden */
  69692. export var screenSpaceReflectionPixelShader: {
  69693. name: string;
  69694. shader: string;
  69695. };
  69696. }
  69697. declare module BABYLON {
  69698. /**
  69699. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69700. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69701. */
  69702. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69703. /**
  69704. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69705. */
  69706. threshold: number;
  69707. /**
  69708. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69709. */
  69710. strength: number;
  69711. /**
  69712. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69713. */
  69714. reflectionSpecularFalloffExponent: number;
  69715. /**
  69716. * 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]
  69717. */
  69718. step: number;
  69719. /**
  69720. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69721. */
  69722. roughnessFactor: number;
  69723. private _geometryBufferRenderer;
  69724. private _enableSmoothReflections;
  69725. private _reflectionSamples;
  69726. private _smoothSteps;
  69727. /**
  69728. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69729. * @param name The name of the effect.
  69730. * @param scene The scene containing the objects to calculate reflections.
  69731. * @param options The required width/height ratio to downsize to before computing the render pass.
  69732. * @param camera The camera to apply the render pass to.
  69733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69734. * @param engine The engine which the post process will be applied. (default: current engine)
  69735. * @param reusable If the post process can be reused on the same frame. (default: false)
  69736. * @param textureType Type of textures used when performing the post process. (default: 0)
  69737. * @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)
  69738. */
  69739. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69740. /**
  69741. * Gets wether or not smoothing reflections is enabled.
  69742. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69743. */
  69744. get enableSmoothReflections(): boolean;
  69745. /**
  69746. * Sets wether or not smoothing reflections is enabled.
  69747. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69748. */
  69749. set enableSmoothReflections(enabled: boolean);
  69750. /**
  69751. * Gets the number of samples taken while computing reflections. More samples count is high,
  69752. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69753. */
  69754. get reflectionSamples(): number;
  69755. /**
  69756. * Sets the number of samples taken while computing reflections. More samples count is high,
  69757. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69758. */
  69759. set reflectionSamples(samples: number);
  69760. /**
  69761. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69762. * more the post-process will require GPU power and can generate a drop in FPS.
  69763. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69764. */
  69765. get smoothSteps(): number;
  69766. set smoothSteps(steps: number);
  69767. private _updateEffectDefines;
  69768. }
  69769. }
  69770. declare module BABYLON {
  69771. /** @hidden */
  69772. export var standardPixelShader: {
  69773. name: string;
  69774. shader: string;
  69775. };
  69776. }
  69777. declare module BABYLON {
  69778. /**
  69779. * Standard rendering pipeline
  69780. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69781. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69782. */
  69783. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69784. /**
  69785. * Public members
  69786. */
  69787. /**
  69788. * Post-process which contains the original scene color before the pipeline applies all the effects
  69789. */
  69790. originalPostProcess: Nullable<PostProcess>;
  69791. /**
  69792. * Post-process used to down scale an image x4
  69793. */
  69794. downSampleX4PostProcess: Nullable<PostProcess>;
  69795. /**
  69796. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69797. */
  69798. brightPassPostProcess: Nullable<PostProcess>;
  69799. /**
  69800. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69801. */
  69802. blurHPostProcesses: PostProcess[];
  69803. /**
  69804. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69805. */
  69806. blurVPostProcesses: PostProcess[];
  69807. /**
  69808. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69809. */
  69810. textureAdderPostProcess: Nullable<PostProcess>;
  69811. /**
  69812. * Post-process used to create volumetric lighting effect
  69813. */
  69814. volumetricLightPostProcess: Nullable<PostProcess>;
  69815. /**
  69816. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69817. */
  69818. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69819. /**
  69820. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69821. */
  69822. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69823. /**
  69824. * Post-process used to merge the volumetric light effect and the real scene color
  69825. */
  69826. volumetricLightMergePostProces: Nullable<PostProcess>;
  69827. /**
  69828. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69829. */
  69830. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69831. /**
  69832. * Base post-process used to calculate the average luminance of the final image for HDR
  69833. */
  69834. luminancePostProcess: Nullable<PostProcess>;
  69835. /**
  69836. * Post-processes used to create down sample post-processes in order to get
  69837. * the average luminance of the final image for HDR
  69838. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69839. */
  69840. luminanceDownSamplePostProcesses: PostProcess[];
  69841. /**
  69842. * Post-process used to create a HDR effect (light adaptation)
  69843. */
  69844. hdrPostProcess: Nullable<PostProcess>;
  69845. /**
  69846. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69847. */
  69848. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69849. /**
  69850. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69851. */
  69852. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69853. /**
  69854. * Post-process used to merge the final HDR post-process and the real scene color
  69855. */
  69856. hdrFinalPostProcess: Nullable<PostProcess>;
  69857. /**
  69858. * Post-process used to create a lens flare effect
  69859. */
  69860. lensFlarePostProcess: Nullable<PostProcess>;
  69861. /**
  69862. * Post-process that merges the result of the lens flare post-process and the real scene color
  69863. */
  69864. lensFlareComposePostProcess: Nullable<PostProcess>;
  69865. /**
  69866. * Post-process used to create a motion blur effect
  69867. */
  69868. motionBlurPostProcess: Nullable<PostProcess>;
  69869. /**
  69870. * Post-process used to create a depth of field effect
  69871. */
  69872. depthOfFieldPostProcess: Nullable<PostProcess>;
  69873. /**
  69874. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69875. */
  69876. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69877. /**
  69878. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69879. */
  69880. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69881. /**
  69882. * Represents the brightness threshold in order to configure the illuminated surfaces
  69883. */
  69884. brightThreshold: number;
  69885. /**
  69886. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69887. */
  69888. blurWidth: number;
  69889. /**
  69890. * Sets if the blur for highlighted surfaces must be only horizontal
  69891. */
  69892. horizontalBlur: boolean;
  69893. /**
  69894. * Gets the overall exposure used by the pipeline
  69895. */
  69896. get exposure(): number;
  69897. /**
  69898. * Sets the overall exposure used by the pipeline
  69899. */
  69900. set exposure(value: number);
  69901. /**
  69902. * Texture used typically to simulate "dirty" on camera lens
  69903. */
  69904. lensTexture: Nullable<Texture>;
  69905. /**
  69906. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69907. */
  69908. volumetricLightCoefficient: number;
  69909. /**
  69910. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69911. */
  69912. volumetricLightPower: number;
  69913. /**
  69914. * Used the set the blur intensity to smooth the volumetric lights
  69915. */
  69916. volumetricLightBlurScale: number;
  69917. /**
  69918. * Light (spot or directional) used to generate the volumetric lights rays
  69919. * The source light must have a shadow generate so the pipeline can get its
  69920. * depth map
  69921. */
  69922. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69923. /**
  69924. * For eye adaptation, represents the minimum luminance the eye can see
  69925. */
  69926. hdrMinimumLuminance: number;
  69927. /**
  69928. * For eye adaptation, represents the decrease luminance speed
  69929. */
  69930. hdrDecreaseRate: number;
  69931. /**
  69932. * For eye adaptation, represents the increase luminance speed
  69933. */
  69934. hdrIncreaseRate: number;
  69935. /**
  69936. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69937. */
  69938. get hdrAutoExposure(): boolean;
  69939. /**
  69940. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69941. */
  69942. set hdrAutoExposure(value: boolean);
  69943. /**
  69944. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69945. */
  69946. lensColorTexture: Nullable<Texture>;
  69947. /**
  69948. * The overall strengh for the lens flare effect
  69949. */
  69950. lensFlareStrength: number;
  69951. /**
  69952. * Dispersion coefficient for lens flare ghosts
  69953. */
  69954. lensFlareGhostDispersal: number;
  69955. /**
  69956. * Main lens flare halo width
  69957. */
  69958. lensFlareHaloWidth: number;
  69959. /**
  69960. * Based on the lens distortion effect, defines how much the lens flare result
  69961. * is distorted
  69962. */
  69963. lensFlareDistortionStrength: number;
  69964. /**
  69965. * Configures the blur intensity used for for lens flare (halo)
  69966. */
  69967. lensFlareBlurWidth: number;
  69968. /**
  69969. * Lens star texture must be used to simulate rays on the flares and is available
  69970. * in the documentation
  69971. */
  69972. lensStarTexture: Nullable<Texture>;
  69973. /**
  69974. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69975. * flare effect by taking account of the dirt texture
  69976. */
  69977. lensFlareDirtTexture: Nullable<Texture>;
  69978. /**
  69979. * Represents the focal length for the depth of field effect
  69980. */
  69981. depthOfFieldDistance: number;
  69982. /**
  69983. * Represents the blur intensity for the blurred part of the depth of field effect
  69984. */
  69985. depthOfFieldBlurWidth: number;
  69986. /**
  69987. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69988. */
  69989. get motionStrength(): number;
  69990. /**
  69991. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69992. */
  69993. set motionStrength(strength: number);
  69994. /**
  69995. * Gets wether or not the motion blur post-process is object based or screen based.
  69996. */
  69997. get objectBasedMotionBlur(): boolean;
  69998. /**
  69999. * Sets wether or not the motion blur post-process should be object based or screen based
  70000. */
  70001. set objectBasedMotionBlur(value: boolean);
  70002. /**
  70003. * List of animations for the pipeline (IAnimatable implementation)
  70004. */
  70005. animations: Animation[];
  70006. /**
  70007. * Private members
  70008. */
  70009. private _scene;
  70010. private _currentDepthOfFieldSource;
  70011. private _basePostProcess;
  70012. private _fixedExposure;
  70013. private _currentExposure;
  70014. private _hdrAutoExposure;
  70015. private _hdrCurrentLuminance;
  70016. private _motionStrength;
  70017. private _isObjectBasedMotionBlur;
  70018. private _floatTextureType;
  70019. private _camerasToBeAttached;
  70020. private _ratio;
  70021. private _bloomEnabled;
  70022. private _depthOfFieldEnabled;
  70023. private _vlsEnabled;
  70024. private _lensFlareEnabled;
  70025. private _hdrEnabled;
  70026. private _motionBlurEnabled;
  70027. private _fxaaEnabled;
  70028. private _screenSpaceReflectionsEnabled;
  70029. private _motionBlurSamples;
  70030. private _volumetricLightStepsCount;
  70031. private _samples;
  70032. /**
  70033. * @ignore
  70034. * Specifies if the bloom pipeline is enabled
  70035. */
  70036. get BloomEnabled(): boolean;
  70037. set BloomEnabled(enabled: boolean);
  70038. /**
  70039. * @ignore
  70040. * Specifies if the depth of field pipeline is enabed
  70041. */
  70042. get DepthOfFieldEnabled(): boolean;
  70043. set DepthOfFieldEnabled(enabled: boolean);
  70044. /**
  70045. * @ignore
  70046. * Specifies if the lens flare pipeline is enabed
  70047. */
  70048. get LensFlareEnabled(): boolean;
  70049. set LensFlareEnabled(enabled: boolean);
  70050. /**
  70051. * @ignore
  70052. * Specifies if the HDR pipeline is enabled
  70053. */
  70054. get HDREnabled(): boolean;
  70055. set HDREnabled(enabled: boolean);
  70056. /**
  70057. * @ignore
  70058. * Specifies if the volumetric lights scattering effect is enabled
  70059. */
  70060. get VLSEnabled(): boolean;
  70061. set VLSEnabled(enabled: boolean);
  70062. /**
  70063. * @ignore
  70064. * Specifies if the motion blur effect is enabled
  70065. */
  70066. get MotionBlurEnabled(): boolean;
  70067. set MotionBlurEnabled(enabled: boolean);
  70068. /**
  70069. * Specifies if anti-aliasing is enabled
  70070. */
  70071. get fxaaEnabled(): boolean;
  70072. set fxaaEnabled(enabled: boolean);
  70073. /**
  70074. * Specifies if screen space reflections are enabled.
  70075. */
  70076. get screenSpaceReflectionsEnabled(): boolean;
  70077. set screenSpaceReflectionsEnabled(enabled: boolean);
  70078. /**
  70079. * Specifies the number of steps used to calculate the volumetric lights
  70080. * Typically in interval [50, 200]
  70081. */
  70082. get volumetricLightStepsCount(): number;
  70083. set volumetricLightStepsCount(count: number);
  70084. /**
  70085. * Specifies the number of samples used for the motion blur effect
  70086. * Typically in interval [16, 64]
  70087. */
  70088. get motionBlurSamples(): number;
  70089. set motionBlurSamples(samples: number);
  70090. /**
  70091. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70092. */
  70093. get samples(): number;
  70094. set samples(sampleCount: number);
  70095. /**
  70096. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70097. * @constructor
  70098. * @param name The rendering pipeline name
  70099. * @param scene The scene linked to this pipeline
  70100. * @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)
  70101. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70102. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70103. */
  70104. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70105. private _buildPipeline;
  70106. private _createDownSampleX4PostProcess;
  70107. private _createBrightPassPostProcess;
  70108. private _createBlurPostProcesses;
  70109. private _createTextureAdderPostProcess;
  70110. private _createVolumetricLightPostProcess;
  70111. private _createLuminancePostProcesses;
  70112. private _createHdrPostProcess;
  70113. private _createLensFlarePostProcess;
  70114. private _createDepthOfFieldPostProcess;
  70115. private _createMotionBlurPostProcess;
  70116. private _getDepthTexture;
  70117. private _disposePostProcesses;
  70118. /**
  70119. * Dispose of the pipeline and stop all post processes
  70120. */
  70121. dispose(): void;
  70122. /**
  70123. * Serialize the rendering pipeline (Used when exporting)
  70124. * @returns the serialized object
  70125. */
  70126. serialize(): any;
  70127. /**
  70128. * Parse the serialized pipeline
  70129. * @param source Source pipeline.
  70130. * @param scene The scene to load the pipeline to.
  70131. * @param rootUrl The URL of the serialized pipeline.
  70132. * @returns An instantiated pipeline from the serialized object.
  70133. */
  70134. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70135. /**
  70136. * Luminance steps
  70137. */
  70138. static LuminanceSteps: number;
  70139. }
  70140. }
  70141. declare module BABYLON {
  70142. /** @hidden */
  70143. export var stereoscopicInterlacePixelShader: {
  70144. name: string;
  70145. shader: string;
  70146. };
  70147. }
  70148. declare module BABYLON {
  70149. /**
  70150. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70151. */
  70152. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70153. private _stepSize;
  70154. private _passedProcess;
  70155. /**
  70156. * Initializes a StereoscopicInterlacePostProcessI
  70157. * @param name The name of the effect.
  70158. * @param rigCameras The rig cameras to be appled to the post process
  70159. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70160. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70162. * @param engine The engine which the post process will be applied. (default: current engine)
  70163. * @param reusable If the post process can be reused on the same frame. (default: false)
  70164. */
  70165. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70166. }
  70167. /**
  70168. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70169. */
  70170. export class StereoscopicInterlacePostProcess extends PostProcess {
  70171. private _stepSize;
  70172. private _passedProcess;
  70173. /**
  70174. * Initializes a StereoscopicInterlacePostProcess
  70175. * @param name The name of the effect.
  70176. * @param rigCameras The rig cameras to be appled to the post process
  70177. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70178. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70179. * @param engine The engine which the post process will be applied. (default: current engine)
  70180. * @param reusable If the post process can be reused on the same frame. (default: false)
  70181. */
  70182. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70183. }
  70184. }
  70185. declare module BABYLON {
  70186. /** @hidden */
  70187. export var tonemapPixelShader: {
  70188. name: string;
  70189. shader: string;
  70190. };
  70191. }
  70192. declare module BABYLON {
  70193. /** Defines operator used for tonemapping */
  70194. export enum TonemappingOperator {
  70195. /** Hable */
  70196. Hable = 0,
  70197. /** Reinhard */
  70198. Reinhard = 1,
  70199. /** HejiDawson */
  70200. HejiDawson = 2,
  70201. /** Photographic */
  70202. Photographic = 3
  70203. }
  70204. /**
  70205. * Defines a post process to apply tone mapping
  70206. */
  70207. export class TonemapPostProcess extends PostProcess {
  70208. private _operator;
  70209. /** Defines the required exposure adjustement */
  70210. exposureAdjustment: number;
  70211. /**
  70212. * Creates a new TonemapPostProcess
  70213. * @param name defines the name of the postprocess
  70214. * @param _operator defines the operator to use
  70215. * @param exposureAdjustment defines the required exposure adjustement
  70216. * @param camera defines the camera to use (can be null)
  70217. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70218. * @param engine defines the hosting engine (can be ignore if camera is set)
  70219. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70220. */
  70221. constructor(name: string, _operator: TonemappingOperator,
  70222. /** Defines the required exposure adjustement */
  70223. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70224. }
  70225. }
  70226. declare module BABYLON {
  70227. /** @hidden */
  70228. export var volumetricLightScatteringPixelShader: {
  70229. name: string;
  70230. shader: string;
  70231. };
  70232. }
  70233. declare module BABYLON {
  70234. /** @hidden */
  70235. export var volumetricLightScatteringPassVertexShader: {
  70236. name: string;
  70237. shader: string;
  70238. };
  70239. }
  70240. declare module BABYLON {
  70241. /** @hidden */
  70242. export var volumetricLightScatteringPassPixelShader: {
  70243. name: string;
  70244. shader: string;
  70245. };
  70246. }
  70247. declare module BABYLON {
  70248. /**
  70249. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70250. */
  70251. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70252. private _volumetricLightScatteringPass;
  70253. private _volumetricLightScatteringRTT;
  70254. private _viewPort;
  70255. private _screenCoordinates;
  70256. private _cachedDefines;
  70257. /**
  70258. * If not undefined, the mesh position is computed from the attached node position
  70259. */
  70260. attachedNode: {
  70261. position: Vector3;
  70262. };
  70263. /**
  70264. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70265. */
  70266. customMeshPosition: Vector3;
  70267. /**
  70268. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70269. */
  70270. useCustomMeshPosition: boolean;
  70271. /**
  70272. * If the post-process should inverse the light scattering direction
  70273. */
  70274. invert: boolean;
  70275. /**
  70276. * The internal mesh used by the post-process
  70277. */
  70278. mesh: Mesh;
  70279. /**
  70280. * @hidden
  70281. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70282. */
  70283. get useDiffuseColor(): boolean;
  70284. set useDiffuseColor(useDiffuseColor: boolean);
  70285. /**
  70286. * Array containing the excluded meshes not rendered in the internal pass
  70287. */
  70288. excludedMeshes: AbstractMesh[];
  70289. /**
  70290. * Controls the overall intensity of the post-process
  70291. */
  70292. exposure: number;
  70293. /**
  70294. * Dissipates each sample's contribution in range [0, 1]
  70295. */
  70296. decay: number;
  70297. /**
  70298. * Controls the overall intensity of each sample
  70299. */
  70300. weight: number;
  70301. /**
  70302. * Controls the density of each sample
  70303. */
  70304. density: number;
  70305. /**
  70306. * @constructor
  70307. * @param name The post-process name
  70308. * @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)
  70309. * @param camera The camera that the post-process will be attached to
  70310. * @param mesh The mesh used to create the light scattering
  70311. * @param samples The post-process quality, default 100
  70312. * @param samplingModeThe post-process filtering mode
  70313. * @param engine The babylon engine
  70314. * @param reusable If the post-process is reusable
  70315. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70316. */
  70317. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70318. /**
  70319. * Returns the string "VolumetricLightScatteringPostProcess"
  70320. * @returns "VolumetricLightScatteringPostProcess"
  70321. */
  70322. getClassName(): string;
  70323. private _isReady;
  70324. /**
  70325. * Sets the new light position for light scattering effect
  70326. * @param position The new custom light position
  70327. */
  70328. setCustomMeshPosition(position: Vector3): void;
  70329. /**
  70330. * Returns the light position for light scattering effect
  70331. * @return Vector3 The custom light position
  70332. */
  70333. getCustomMeshPosition(): Vector3;
  70334. /**
  70335. * Disposes the internal assets and detaches the post-process from the camera
  70336. */
  70337. dispose(camera: Camera): void;
  70338. /**
  70339. * Returns the render target texture used by the post-process
  70340. * @return the render target texture used by the post-process
  70341. */
  70342. getPass(): RenderTargetTexture;
  70343. private _meshExcluded;
  70344. private _createPass;
  70345. private _updateMeshScreenCoordinates;
  70346. /**
  70347. * Creates a default mesh for the Volumeric Light Scattering post-process
  70348. * @param name The mesh name
  70349. * @param scene The scene where to create the mesh
  70350. * @return the default mesh
  70351. */
  70352. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70353. }
  70354. }
  70355. declare module BABYLON {
  70356. interface Scene {
  70357. /** @hidden (Backing field) */
  70358. _boundingBoxRenderer: BoundingBoxRenderer;
  70359. /** @hidden (Backing field) */
  70360. _forceShowBoundingBoxes: boolean;
  70361. /**
  70362. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70363. */
  70364. forceShowBoundingBoxes: boolean;
  70365. /**
  70366. * Gets the bounding box renderer associated with the scene
  70367. * @returns a BoundingBoxRenderer
  70368. */
  70369. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70370. }
  70371. interface AbstractMesh {
  70372. /** @hidden (Backing field) */
  70373. _showBoundingBox: boolean;
  70374. /**
  70375. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70376. */
  70377. showBoundingBox: boolean;
  70378. }
  70379. /**
  70380. * Component responsible of rendering the bounding box of the meshes in a scene.
  70381. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70382. */
  70383. export class BoundingBoxRenderer implements ISceneComponent {
  70384. /**
  70385. * The component name helpfull to identify the component in the list of scene components.
  70386. */
  70387. readonly name: string;
  70388. /**
  70389. * The scene the component belongs to.
  70390. */
  70391. scene: Scene;
  70392. /**
  70393. * Color of the bounding box lines placed in front of an object
  70394. */
  70395. frontColor: Color3;
  70396. /**
  70397. * Color of the bounding box lines placed behind an object
  70398. */
  70399. backColor: Color3;
  70400. /**
  70401. * Defines if the renderer should show the back lines or not
  70402. */
  70403. showBackLines: boolean;
  70404. /**
  70405. * Observable raised before rendering a bounding box
  70406. */
  70407. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70408. /**
  70409. * Observable raised after rendering a bounding box
  70410. */
  70411. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70412. /**
  70413. * @hidden
  70414. */
  70415. renderList: SmartArray<BoundingBox>;
  70416. private _colorShader;
  70417. private _vertexBuffers;
  70418. private _indexBuffer;
  70419. private _fillIndexBuffer;
  70420. private _fillIndexData;
  70421. /**
  70422. * Instantiates a new bounding box renderer in a scene.
  70423. * @param scene the scene the renderer renders in
  70424. */
  70425. constructor(scene: Scene);
  70426. /**
  70427. * Registers the component in a given scene
  70428. */
  70429. register(): void;
  70430. private _evaluateSubMesh;
  70431. private _activeMesh;
  70432. private _prepareRessources;
  70433. private _createIndexBuffer;
  70434. /**
  70435. * Rebuilds the elements related to this component in case of
  70436. * context lost for instance.
  70437. */
  70438. rebuild(): void;
  70439. /**
  70440. * @hidden
  70441. */
  70442. reset(): void;
  70443. /**
  70444. * Render the bounding boxes of a specific rendering group
  70445. * @param renderingGroupId defines the rendering group to render
  70446. */
  70447. render(renderingGroupId: number): void;
  70448. /**
  70449. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70450. * @param mesh Define the mesh to render the occlusion bounding box for
  70451. */
  70452. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70453. /**
  70454. * Dispose and release the resources attached to this renderer.
  70455. */
  70456. dispose(): void;
  70457. }
  70458. }
  70459. declare module BABYLON {
  70460. interface Scene {
  70461. /** @hidden (Backing field) */
  70462. _depthRenderer: {
  70463. [id: string]: DepthRenderer;
  70464. };
  70465. /**
  70466. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70467. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70468. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70469. * @returns the created depth renderer
  70470. */
  70471. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70472. /**
  70473. * Disables a depth renderer for a given camera
  70474. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70475. */
  70476. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70477. }
  70478. /**
  70479. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70480. * in several rendering techniques.
  70481. */
  70482. export class DepthRendererSceneComponent implements ISceneComponent {
  70483. /**
  70484. * The component name helpfull to identify the component in the list of scene components.
  70485. */
  70486. readonly name: string;
  70487. /**
  70488. * The scene the component belongs to.
  70489. */
  70490. scene: Scene;
  70491. /**
  70492. * Creates a new instance of the component for the given scene
  70493. * @param scene Defines the scene to register the component in
  70494. */
  70495. constructor(scene: Scene);
  70496. /**
  70497. * Registers the component in a given scene
  70498. */
  70499. register(): void;
  70500. /**
  70501. * Rebuilds the elements related to this component in case of
  70502. * context lost for instance.
  70503. */
  70504. rebuild(): void;
  70505. /**
  70506. * Disposes the component and the associated ressources
  70507. */
  70508. dispose(): void;
  70509. private _gatherRenderTargets;
  70510. private _gatherActiveCameraRenderTargets;
  70511. }
  70512. }
  70513. declare module BABYLON {
  70514. /** @hidden */
  70515. export var outlinePixelShader: {
  70516. name: string;
  70517. shader: string;
  70518. };
  70519. }
  70520. declare module BABYLON {
  70521. /** @hidden */
  70522. export var outlineVertexShader: {
  70523. name: string;
  70524. shader: string;
  70525. };
  70526. }
  70527. declare module BABYLON {
  70528. interface Scene {
  70529. /** @hidden */
  70530. _outlineRenderer: OutlineRenderer;
  70531. /**
  70532. * Gets the outline renderer associated with the scene
  70533. * @returns a OutlineRenderer
  70534. */
  70535. getOutlineRenderer(): OutlineRenderer;
  70536. }
  70537. interface AbstractMesh {
  70538. /** @hidden (Backing field) */
  70539. _renderOutline: boolean;
  70540. /**
  70541. * Gets or sets a boolean indicating if the outline must be rendered as well
  70542. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70543. */
  70544. renderOutline: boolean;
  70545. /** @hidden (Backing field) */
  70546. _renderOverlay: boolean;
  70547. /**
  70548. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70549. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70550. */
  70551. renderOverlay: boolean;
  70552. }
  70553. /**
  70554. * This class is responsible to draw bothe outline/overlay of meshes.
  70555. * It should not be used directly but through the available method on mesh.
  70556. */
  70557. export class OutlineRenderer implements ISceneComponent {
  70558. /**
  70559. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70560. */
  70561. private static _StencilReference;
  70562. /**
  70563. * The name of the component. Each component must have a unique name.
  70564. */
  70565. name: string;
  70566. /**
  70567. * The scene the component belongs to.
  70568. */
  70569. scene: Scene;
  70570. /**
  70571. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70572. */
  70573. zOffset: number;
  70574. private _engine;
  70575. private _effect;
  70576. private _cachedDefines;
  70577. private _savedDepthWrite;
  70578. /**
  70579. * Instantiates a new outline renderer. (There could be only one per scene).
  70580. * @param scene Defines the scene it belongs to
  70581. */
  70582. constructor(scene: Scene);
  70583. /**
  70584. * Register the component to one instance of a scene.
  70585. */
  70586. register(): void;
  70587. /**
  70588. * Rebuilds the elements related to this component in case of
  70589. * context lost for instance.
  70590. */
  70591. rebuild(): void;
  70592. /**
  70593. * Disposes the component and the associated ressources.
  70594. */
  70595. dispose(): void;
  70596. /**
  70597. * Renders the outline in the canvas.
  70598. * @param subMesh Defines the sumesh to render
  70599. * @param batch Defines the batch of meshes in case of instances
  70600. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70601. */
  70602. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70603. /**
  70604. * Returns whether or not the outline renderer is ready for a given submesh.
  70605. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70606. * @param subMesh Defines the submesh to check readyness for
  70607. * @param useInstances Defines wheter wee are trying to render instances or not
  70608. * @returns true if ready otherwise false
  70609. */
  70610. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70611. private _beforeRenderingMesh;
  70612. private _afterRenderingMesh;
  70613. }
  70614. }
  70615. declare module BABYLON {
  70616. /**
  70617. * Defines the basic options interface of a Sprite Frame Source Size.
  70618. */
  70619. export interface ISpriteJSONSpriteSourceSize {
  70620. /**
  70621. * number of the original width of the Frame
  70622. */
  70623. w: number;
  70624. /**
  70625. * number of the original height of the Frame
  70626. */
  70627. h: number;
  70628. }
  70629. /**
  70630. * Defines the basic options interface of a Sprite Frame Data.
  70631. */
  70632. export interface ISpriteJSONSpriteFrameData {
  70633. /**
  70634. * number of the x offset of the Frame
  70635. */
  70636. x: number;
  70637. /**
  70638. * number of the y offset of the Frame
  70639. */
  70640. y: number;
  70641. /**
  70642. * number of the width of the Frame
  70643. */
  70644. w: number;
  70645. /**
  70646. * number of the height of the Frame
  70647. */
  70648. h: number;
  70649. }
  70650. /**
  70651. * Defines the basic options interface of a JSON Sprite.
  70652. */
  70653. export interface ISpriteJSONSprite {
  70654. /**
  70655. * string name of the Frame
  70656. */
  70657. filename: string;
  70658. /**
  70659. * ISpriteJSONSpriteFrame basic object of the frame data
  70660. */
  70661. frame: ISpriteJSONSpriteFrameData;
  70662. /**
  70663. * boolean to flag is the frame was rotated.
  70664. */
  70665. rotated: boolean;
  70666. /**
  70667. * boolean to flag is the frame was trimmed.
  70668. */
  70669. trimmed: boolean;
  70670. /**
  70671. * ISpriteJSONSpriteFrame basic object of the source data
  70672. */
  70673. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70674. /**
  70675. * ISpriteJSONSpriteFrame basic object of the source data
  70676. */
  70677. sourceSize: ISpriteJSONSpriteSourceSize;
  70678. }
  70679. /**
  70680. * Defines the basic options interface of a JSON atlas.
  70681. */
  70682. export interface ISpriteJSONAtlas {
  70683. /**
  70684. * Array of objects that contain the frame data.
  70685. */
  70686. frames: Array<ISpriteJSONSprite>;
  70687. /**
  70688. * object basic object containing the sprite meta data.
  70689. */
  70690. meta?: object;
  70691. }
  70692. }
  70693. declare module BABYLON {
  70694. /** @hidden */
  70695. export var spriteMapPixelShader: {
  70696. name: string;
  70697. shader: string;
  70698. };
  70699. }
  70700. declare module BABYLON {
  70701. /** @hidden */
  70702. export var spriteMapVertexShader: {
  70703. name: string;
  70704. shader: string;
  70705. };
  70706. }
  70707. declare module BABYLON {
  70708. /**
  70709. * Defines the basic options interface of a SpriteMap
  70710. */
  70711. export interface ISpriteMapOptions {
  70712. /**
  70713. * Vector2 of the number of cells in the grid.
  70714. */
  70715. stageSize?: Vector2;
  70716. /**
  70717. * Vector2 of the size of the output plane in World Units.
  70718. */
  70719. outputSize?: Vector2;
  70720. /**
  70721. * Vector3 of the position of the output plane in World Units.
  70722. */
  70723. outputPosition?: Vector3;
  70724. /**
  70725. * Vector3 of the rotation of the output plane.
  70726. */
  70727. outputRotation?: Vector3;
  70728. /**
  70729. * number of layers that the system will reserve in resources.
  70730. */
  70731. layerCount?: number;
  70732. /**
  70733. * number of max animation frames a single cell will reserve in resources.
  70734. */
  70735. maxAnimationFrames?: number;
  70736. /**
  70737. * number cell index of the base tile when the system compiles.
  70738. */
  70739. baseTile?: number;
  70740. /**
  70741. * boolean flip the sprite after its been repositioned by the framing data.
  70742. */
  70743. flipU?: boolean;
  70744. /**
  70745. * Vector3 scalar of the global RGB values of the SpriteMap.
  70746. */
  70747. colorMultiply?: Vector3;
  70748. }
  70749. /**
  70750. * Defines the IDisposable interface in order to be cleanable from resources.
  70751. */
  70752. export interface ISpriteMap extends IDisposable {
  70753. /**
  70754. * String name of the SpriteMap.
  70755. */
  70756. name: string;
  70757. /**
  70758. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70759. */
  70760. atlasJSON: ISpriteJSONAtlas;
  70761. /**
  70762. * Texture of the SpriteMap.
  70763. */
  70764. spriteSheet: Texture;
  70765. /**
  70766. * The parameters to initialize the SpriteMap with.
  70767. */
  70768. options: ISpriteMapOptions;
  70769. }
  70770. /**
  70771. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70772. */
  70773. export class SpriteMap implements ISpriteMap {
  70774. /** The Name of the spriteMap */
  70775. name: string;
  70776. /** The JSON file with the frame and meta data */
  70777. atlasJSON: ISpriteJSONAtlas;
  70778. /** The systems Sprite Sheet Texture */
  70779. spriteSheet: Texture;
  70780. /** Arguments passed with the Constructor */
  70781. options: ISpriteMapOptions;
  70782. /** Public Sprite Storage array, parsed from atlasJSON */
  70783. sprites: Array<ISpriteJSONSprite>;
  70784. /** Returns the Number of Sprites in the System */
  70785. get spriteCount(): number;
  70786. /** Returns the Position of Output Plane*/
  70787. get position(): Vector3;
  70788. /** Returns the Position of Output Plane*/
  70789. set position(v: Vector3);
  70790. /** Returns the Rotation of Output Plane*/
  70791. get rotation(): Vector3;
  70792. /** Returns the Rotation of Output Plane*/
  70793. set rotation(v: Vector3);
  70794. /** Sets the AnimationMap*/
  70795. get animationMap(): RawTexture;
  70796. /** Sets the AnimationMap*/
  70797. set animationMap(v: RawTexture);
  70798. /** Scene that the SpriteMap was created in */
  70799. private _scene;
  70800. /** Texture Buffer of Float32 that holds tile frame data*/
  70801. private _frameMap;
  70802. /** Texture Buffers of Float32 that holds tileMap data*/
  70803. private _tileMaps;
  70804. /** Texture Buffer of Float32 that holds Animation Data*/
  70805. private _animationMap;
  70806. /** Custom ShaderMaterial Central to the System*/
  70807. private _material;
  70808. /** Custom ShaderMaterial Central to the System*/
  70809. private _output;
  70810. /** Systems Time Ticker*/
  70811. private _time;
  70812. /**
  70813. * Creates a new SpriteMap
  70814. * @param name defines the SpriteMaps Name
  70815. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70816. * @param spriteSheet is the Texture that the Sprites are on.
  70817. * @param options a basic deployment configuration
  70818. * @param scene The Scene that the map is deployed on
  70819. */
  70820. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70821. /**
  70822. * Returns tileID location
  70823. * @returns Vector2 the cell position ID
  70824. */
  70825. getTileID(): Vector2;
  70826. /**
  70827. * Gets the UV location of the mouse over the SpriteMap.
  70828. * @returns Vector2 the UV position of the mouse interaction
  70829. */
  70830. getMousePosition(): Vector2;
  70831. /**
  70832. * Creates the "frame" texture Buffer
  70833. * -------------------------------------
  70834. * Structure of frames
  70835. * "filename": "Falling-Water-2.png",
  70836. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70837. * "rotated": true,
  70838. * "trimmed": true,
  70839. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70840. * "sourceSize": {"w":32,"h":32}
  70841. * @returns RawTexture of the frameMap
  70842. */
  70843. private _createFrameBuffer;
  70844. /**
  70845. * Creates the tileMap texture Buffer
  70846. * @param buffer normally and array of numbers, or a false to generate from scratch
  70847. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70848. * @returns RawTexture of the tileMap
  70849. */
  70850. private _createTileBuffer;
  70851. /**
  70852. * Modifies the data of the tileMaps
  70853. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70854. * @param pos is the iVector2 Coordinates of the Tile
  70855. * @param tile The SpriteIndex of the new Tile
  70856. */
  70857. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70858. /**
  70859. * Creates the animationMap texture Buffer
  70860. * @param buffer normally and array of numbers, or a false to generate from scratch
  70861. * @returns RawTexture of the animationMap
  70862. */
  70863. private _createTileAnimationBuffer;
  70864. /**
  70865. * Modifies the data of the animationMap
  70866. * @param cellID is the Index of the Sprite
  70867. * @param _frame is the target Animation frame
  70868. * @param toCell is the Target Index of the next frame of the animation
  70869. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70870. * @param speed is a global scalar of the time variable on the map.
  70871. */
  70872. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70873. /**
  70874. * Exports the .tilemaps file
  70875. */
  70876. saveTileMaps(): void;
  70877. /**
  70878. * Imports the .tilemaps file
  70879. * @param url of the .tilemaps file
  70880. */
  70881. loadTileMaps(url: string): void;
  70882. /**
  70883. * Release associated resources
  70884. */
  70885. dispose(): void;
  70886. }
  70887. }
  70888. declare module BABYLON {
  70889. /**
  70890. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70891. * @see http://doc.babylonjs.com/babylon101/sprites
  70892. */
  70893. export class SpritePackedManager extends SpriteManager {
  70894. /** defines the packed manager's name */
  70895. name: string;
  70896. /**
  70897. * Creates a new sprite manager from a packed sprite sheet
  70898. * @param name defines the manager's name
  70899. * @param imgUrl defines the sprite sheet url
  70900. * @param capacity defines the maximum allowed number of sprites
  70901. * @param scene defines the hosting scene
  70902. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70903. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70904. * @param samplingMode defines the smapling mode to use with spritesheet
  70905. * @param fromPacked set to true; do not alter
  70906. */
  70907. constructor(
  70908. /** defines the packed manager's name */
  70909. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70910. }
  70911. }
  70912. declare module BABYLON {
  70913. /**
  70914. * Defines the list of states available for a task inside a AssetsManager
  70915. */
  70916. export enum AssetTaskState {
  70917. /**
  70918. * Initialization
  70919. */
  70920. INIT = 0,
  70921. /**
  70922. * Running
  70923. */
  70924. RUNNING = 1,
  70925. /**
  70926. * Done
  70927. */
  70928. DONE = 2,
  70929. /**
  70930. * Error
  70931. */
  70932. ERROR = 3
  70933. }
  70934. /**
  70935. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70936. */
  70937. export abstract class AbstractAssetTask {
  70938. /**
  70939. * Task name
  70940. */ name: string;
  70941. /**
  70942. * Callback called when the task is successful
  70943. */
  70944. onSuccess: (task: any) => void;
  70945. /**
  70946. * Callback called when the task is not successful
  70947. */
  70948. onError: (task: any, message?: string, exception?: any) => void;
  70949. /**
  70950. * Creates a new AssetsManager
  70951. * @param name defines the name of the task
  70952. */
  70953. constructor(
  70954. /**
  70955. * Task name
  70956. */ name: string);
  70957. private _isCompleted;
  70958. private _taskState;
  70959. private _errorObject;
  70960. /**
  70961. * Get if the task is completed
  70962. */
  70963. get isCompleted(): boolean;
  70964. /**
  70965. * Gets the current state of the task
  70966. */
  70967. get taskState(): AssetTaskState;
  70968. /**
  70969. * Gets the current error object (if task is in error)
  70970. */
  70971. get errorObject(): {
  70972. message?: string;
  70973. exception?: any;
  70974. };
  70975. /**
  70976. * Internal only
  70977. * @hidden
  70978. */
  70979. _setErrorObject(message?: string, exception?: any): void;
  70980. /**
  70981. * Execute the current task
  70982. * @param scene defines the scene where you want your assets to be loaded
  70983. * @param onSuccess is a callback called when the task is successfully executed
  70984. * @param onError is a callback called if an error occurs
  70985. */
  70986. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70987. /**
  70988. * Execute the current task
  70989. * @param scene defines the scene where you want your assets to be loaded
  70990. * @param onSuccess is a callback called when the task is successfully executed
  70991. * @param onError is a callback called if an error occurs
  70992. */
  70993. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70994. /**
  70995. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70996. * This can be used with failed tasks that have the reason for failure fixed.
  70997. */
  70998. reset(): void;
  70999. private onErrorCallback;
  71000. private onDoneCallback;
  71001. }
  71002. /**
  71003. * Define the interface used by progress events raised during assets loading
  71004. */
  71005. export interface IAssetsProgressEvent {
  71006. /**
  71007. * Defines the number of remaining tasks to process
  71008. */
  71009. remainingCount: number;
  71010. /**
  71011. * Defines the total number of tasks
  71012. */
  71013. totalCount: number;
  71014. /**
  71015. * Defines the task that was just processed
  71016. */
  71017. task: AbstractAssetTask;
  71018. }
  71019. /**
  71020. * Class used to share progress information about assets loading
  71021. */
  71022. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71023. /**
  71024. * Defines the number of remaining tasks to process
  71025. */
  71026. remainingCount: number;
  71027. /**
  71028. * Defines the total number of tasks
  71029. */
  71030. totalCount: number;
  71031. /**
  71032. * Defines the task that was just processed
  71033. */
  71034. task: AbstractAssetTask;
  71035. /**
  71036. * Creates a AssetsProgressEvent
  71037. * @param remainingCount defines the number of remaining tasks to process
  71038. * @param totalCount defines the total number of tasks
  71039. * @param task defines the task that was just processed
  71040. */
  71041. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71042. }
  71043. /**
  71044. * Define a task used by AssetsManager to load meshes
  71045. */
  71046. export class MeshAssetTask extends AbstractAssetTask {
  71047. /**
  71048. * Defines the name of the task
  71049. */
  71050. name: string;
  71051. /**
  71052. * Defines the list of mesh's names you want to load
  71053. */
  71054. meshesNames: any;
  71055. /**
  71056. * Defines the root url to use as a base to load your meshes and associated resources
  71057. */
  71058. rootUrl: string;
  71059. /**
  71060. * Defines the filename or File of the scene to load from
  71061. */
  71062. sceneFilename: string | File;
  71063. /**
  71064. * Gets the list of loaded meshes
  71065. */
  71066. loadedMeshes: Array<AbstractMesh>;
  71067. /**
  71068. * Gets the list of loaded particle systems
  71069. */
  71070. loadedParticleSystems: Array<IParticleSystem>;
  71071. /**
  71072. * Gets the list of loaded skeletons
  71073. */
  71074. loadedSkeletons: Array<Skeleton>;
  71075. /**
  71076. * Gets the list of loaded animation groups
  71077. */
  71078. loadedAnimationGroups: Array<AnimationGroup>;
  71079. /**
  71080. * Callback called when the task is successful
  71081. */
  71082. onSuccess: (task: MeshAssetTask) => void;
  71083. /**
  71084. * Callback called when the task is successful
  71085. */
  71086. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71087. /**
  71088. * Creates a new MeshAssetTask
  71089. * @param name defines the name of the task
  71090. * @param meshesNames defines the list of mesh's names you want to load
  71091. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71092. * @param sceneFilename defines the filename or File of the scene to load from
  71093. */
  71094. constructor(
  71095. /**
  71096. * Defines the name of the task
  71097. */
  71098. name: string,
  71099. /**
  71100. * Defines the list of mesh's names you want to load
  71101. */
  71102. meshesNames: any,
  71103. /**
  71104. * Defines the root url to use as a base to load your meshes and associated resources
  71105. */
  71106. rootUrl: string,
  71107. /**
  71108. * Defines the filename or File of the scene to load from
  71109. */
  71110. sceneFilename: string | File);
  71111. /**
  71112. * Execute the current task
  71113. * @param scene defines the scene where you want your assets to be loaded
  71114. * @param onSuccess is a callback called when the task is successfully executed
  71115. * @param onError is a callback called if an error occurs
  71116. */
  71117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71118. }
  71119. /**
  71120. * Define a task used by AssetsManager to load text content
  71121. */
  71122. export class TextFileAssetTask extends AbstractAssetTask {
  71123. /**
  71124. * Defines the name of the task
  71125. */
  71126. name: string;
  71127. /**
  71128. * Defines the location of the file to load
  71129. */
  71130. url: string;
  71131. /**
  71132. * Gets the loaded text string
  71133. */
  71134. text: string;
  71135. /**
  71136. * Callback called when the task is successful
  71137. */
  71138. onSuccess: (task: TextFileAssetTask) => void;
  71139. /**
  71140. * Callback called when the task is successful
  71141. */
  71142. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71143. /**
  71144. * Creates a new TextFileAssetTask object
  71145. * @param name defines the name of the task
  71146. * @param url defines the location of the file to load
  71147. */
  71148. constructor(
  71149. /**
  71150. * Defines the name of the task
  71151. */
  71152. name: string,
  71153. /**
  71154. * Defines the location of the file to load
  71155. */
  71156. url: string);
  71157. /**
  71158. * Execute the current task
  71159. * @param scene defines the scene where you want your assets to be loaded
  71160. * @param onSuccess is a callback called when the task is successfully executed
  71161. * @param onError is a callback called if an error occurs
  71162. */
  71163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71164. }
  71165. /**
  71166. * Define a task used by AssetsManager to load binary data
  71167. */
  71168. export class BinaryFileAssetTask extends AbstractAssetTask {
  71169. /**
  71170. * Defines the name of the task
  71171. */
  71172. name: string;
  71173. /**
  71174. * Defines the location of the file to load
  71175. */
  71176. url: string;
  71177. /**
  71178. * Gets the lodaded data (as an array buffer)
  71179. */
  71180. data: ArrayBuffer;
  71181. /**
  71182. * Callback called when the task is successful
  71183. */
  71184. onSuccess: (task: BinaryFileAssetTask) => void;
  71185. /**
  71186. * Callback called when the task is successful
  71187. */
  71188. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71189. /**
  71190. * Creates a new BinaryFileAssetTask object
  71191. * @param name defines the name of the new task
  71192. * @param url defines the location of the file to load
  71193. */
  71194. constructor(
  71195. /**
  71196. * Defines the name of the task
  71197. */
  71198. name: string,
  71199. /**
  71200. * Defines the location of the file to load
  71201. */
  71202. url: string);
  71203. /**
  71204. * Execute the current task
  71205. * @param scene defines the scene where you want your assets to be loaded
  71206. * @param onSuccess is a callback called when the task is successfully executed
  71207. * @param onError is a callback called if an error occurs
  71208. */
  71209. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71210. }
  71211. /**
  71212. * Define a task used by AssetsManager to load images
  71213. */
  71214. export class ImageAssetTask extends AbstractAssetTask {
  71215. /**
  71216. * Defines the name of the task
  71217. */
  71218. name: string;
  71219. /**
  71220. * Defines the location of the image to load
  71221. */
  71222. url: string;
  71223. /**
  71224. * Gets the loaded images
  71225. */
  71226. image: HTMLImageElement;
  71227. /**
  71228. * Callback called when the task is successful
  71229. */
  71230. onSuccess: (task: ImageAssetTask) => void;
  71231. /**
  71232. * Callback called when the task is successful
  71233. */
  71234. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71235. /**
  71236. * Creates a new ImageAssetTask
  71237. * @param name defines the name of the task
  71238. * @param url defines the location of the image to load
  71239. */
  71240. constructor(
  71241. /**
  71242. * Defines the name of the task
  71243. */
  71244. name: string,
  71245. /**
  71246. * Defines the location of the image to load
  71247. */
  71248. url: string);
  71249. /**
  71250. * Execute the current task
  71251. * @param scene defines the scene where you want your assets to be loaded
  71252. * @param onSuccess is a callback called when the task is successfully executed
  71253. * @param onError is a callback called if an error occurs
  71254. */
  71255. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71256. }
  71257. /**
  71258. * Defines the interface used by texture loading tasks
  71259. */
  71260. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71261. /**
  71262. * Gets the loaded texture
  71263. */
  71264. texture: TEX;
  71265. }
  71266. /**
  71267. * Define a task used by AssetsManager to load 2D textures
  71268. */
  71269. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71270. /**
  71271. * Defines the name of the task
  71272. */
  71273. name: string;
  71274. /**
  71275. * Defines the location of the file to load
  71276. */
  71277. url: string;
  71278. /**
  71279. * Defines if mipmap should not be generated (default is false)
  71280. */
  71281. noMipmap?: boolean | undefined;
  71282. /**
  71283. * Defines if texture must be inverted on Y axis (default is true)
  71284. */
  71285. invertY: boolean;
  71286. /**
  71287. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71288. */
  71289. samplingMode: number;
  71290. /**
  71291. * Gets the loaded texture
  71292. */
  71293. texture: Texture;
  71294. /**
  71295. * Callback called when the task is successful
  71296. */
  71297. onSuccess: (task: TextureAssetTask) => void;
  71298. /**
  71299. * Callback called when the task is successful
  71300. */
  71301. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71302. /**
  71303. * Creates a new TextureAssetTask object
  71304. * @param name defines the name of the task
  71305. * @param url defines the location of the file to load
  71306. * @param noMipmap defines if mipmap should not be generated (default is false)
  71307. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71308. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71309. */
  71310. constructor(
  71311. /**
  71312. * Defines the name of the task
  71313. */
  71314. name: string,
  71315. /**
  71316. * Defines the location of the file to load
  71317. */
  71318. url: string,
  71319. /**
  71320. * Defines if mipmap should not be generated (default is false)
  71321. */
  71322. noMipmap?: boolean | undefined,
  71323. /**
  71324. * Defines if texture must be inverted on Y axis (default is true)
  71325. */
  71326. invertY?: boolean,
  71327. /**
  71328. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71329. */
  71330. samplingMode?: number);
  71331. /**
  71332. * Execute the current task
  71333. * @param scene defines the scene where you want your assets to be loaded
  71334. * @param onSuccess is a callback called when the task is successfully executed
  71335. * @param onError is a callback called if an error occurs
  71336. */
  71337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71338. }
  71339. /**
  71340. * Define a task used by AssetsManager to load cube textures
  71341. */
  71342. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71343. /**
  71344. * Defines the name of the task
  71345. */
  71346. name: string;
  71347. /**
  71348. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71349. */
  71350. url: string;
  71351. /**
  71352. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71353. */
  71354. extensions?: string[] | undefined;
  71355. /**
  71356. * Defines if mipmaps should not be generated (default is false)
  71357. */
  71358. noMipmap?: boolean | undefined;
  71359. /**
  71360. * Defines the explicit list of files (undefined by default)
  71361. */
  71362. files?: string[] | undefined;
  71363. /**
  71364. * Gets the loaded texture
  71365. */
  71366. texture: CubeTexture;
  71367. /**
  71368. * Callback called when the task is successful
  71369. */
  71370. onSuccess: (task: CubeTextureAssetTask) => void;
  71371. /**
  71372. * Callback called when the task is successful
  71373. */
  71374. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71375. /**
  71376. * Creates a new CubeTextureAssetTask
  71377. * @param name defines the name of the task
  71378. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71379. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71380. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71381. * @param files defines the explicit list of files (undefined by default)
  71382. */
  71383. constructor(
  71384. /**
  71385. * Defines the name of the task
  71386. */
  71387. name: string,
  71388. /**
  71389. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71390. */
  71391. url: string,
  71392. /**
  71393. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71394. */
  71395. extensions?: string[] | undefined,
  71396. /**
  71397. * Defines if mipmaps should not be generated (default is false)
  71398. */
  71399. noMipmap?: boolean | undefined,
  71400. /**
  71401. * Defines the explicit list of files (undefined by default)
  71402. */
  71403. files?: string[] | undefined);
  71404. /**
  71405. * Execute the current task
  71406. * @param scene defines the scene where you want your assets to be loaded
  71407. * @param onSuccess is a callback called when the task is successfully executed
  71408. * @param onError is a callback called if an error occurs
  71409. */
  71410. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71411. }
  71412. /**
  71413. * Define a task used by AssetsManager to load HDR cube textures
  71414. */
  71415. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71416. /**
  71417. * Defines the name of the task
  71418. */
  71419. name: string;
  71420. /**
  71421. * Defines the location of the file to load
  71422. */
  71423. url: string;
  71424. /**
  71425. * Defines the desired size (the more it increases the longer the generation will be)
  71426. */
  71427. size: number;
  71428. /**
  71429. * Defines if mipmaps should not be generated (default is false)
  71430. */
  71431. noMipmap: boolean;
  71432. /**
  71433. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71434. */
  71435. generateHarmonics: boolean;
  71436. /**
  71437. * 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)
  71438. */
  71439. gammaSpace: boolean;
  71440. /**
  71441. * Internal Use Only
  71442. */
  71443. reserved: boolean;
  71444. /**
  71445. * Gets the loaded texture
  71446. */
  71447. texture: HDRCubeTexture;
  71448. /**
  71449. * Callback called when the task is successful
  71450. */
  71451. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71452. /**
  71453. * Callback called when the task is successful
  71454. */
  71455. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71456. /**
  71457. * Creates a new HDRCubeTextureAssetTask object
  71458. * @param name defines the name of the task
  71459. * @param url defines the location of the file to load
  71460. * @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.
  71461. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71462. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71463. * @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)
  71464. * @param reserved Internal use only
  71465. */
  71466. constructor(
  71467. /**
  71468. * Defines the name of the task
  71469. */
  71470. name: string,
  71471. /**
  71472. * Defines the location of the file to load
  71473. */
  71474. url: string,
  71475. /**
  71476. * Defines the desired size (the more it increases the longer the generation will be)
  71477. */
  71478. size: number,
  71479. /**
  71480. * Defines if mipmaps should not be generated (default is false)
  71481. */
  71482. noMipmap?: boolean,
  71483. /**
  71484. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71485. */
  71486. generateHarmonics?: boolean,
  71487. /**
  71488. * 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)
  71489. */
  71490. gammaSpace?: boolean,
  71491. /**
  71492. * Internal Use Only
  71493. */
  71494. reserved?: boolean);
  71495. /**
  71496. * Execute the current task
  71497. * @param scene defines the scene where you want your assets to be loaded
  71498. * @param onSuccess is a callback called when the task is successfully executed
  71499. * @param onError is a callback called if an error occurs
  71500. */
  71501. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71502. }
  71503. /**
  71504. * Define a task used by AssetsManager to load Equirectangular cube textures
  71505. */
  71506. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71507. /**
  71508. * Defines the name of the task
  71509. */
  71510. name: string;
  71511. /**
  71512. * Defines the location of the file to load
  71513. */
  71514. url: string;
  71515. /**
  71516. * Defines the desired size (the more it increases the longer the generation will be)
  71517. */
  71518. size: number;
  71519. /**
  71520. * Defines if mipmaps should not be generated (default is false)
  71521. */
  71522. noMipmap: boolean;
  71523. /**
  71524. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71525. * but the standard material would require them in Gamma space) (default is true)
  71526. */
  71527. gammaSpace: boolean;
  71528. /**
  71529. * Gets the loaded texture
  71530. */
  71531. texture: EquiRectangularCubeTexture;
  71532. /**
  71533. * Callback called when the task is successful
  71534. */
  71535. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71536. /**
  71537. * Callback called when the task is successful
  71538. */
  71539. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71540. /**
  71541. * Creates a new EquiRectangularCubeTextureAssetTask object
  71542. * @param name defines the name of the task
  71543. * @param url defines the location of the file to load
  71544. * @param size defines the desired size (the more it increases the longer the generation will be)
  71545. * If the size is omitted this implies you are using a preprocessed cubemap.
  71546. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71547. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71548. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71549. * (default is true)
  71550. */
  71551. constructor(
  71552. /**
  71553. * Defines the name of the task
  71554. */
  71555. name: string,
  71556. /**
  71557. * Defines the location of the file to load
  71558. */
  71559. url: string,
  71560. /**
  71561. * Defines the desired size (the more it increases the longer the generation will be)
  71562. */
  71563. size: number,
  71564. /**
  71565. * Defines if mipmaps should not be generated (default is false)
  71566. */
  71567. noMipmap?: boolean,
  71568. /**
  71569. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71570. * but the standard material would require them in Gamma space) (default is true)
  71571. */
  71572. gammaSpace?: boolean);
  71573. /**
  71574. * Execute the current task
  71575. * @param scene defines the scene where you want your assets to be loaded
  71576. * @param onSuccess is a callback called when the task is successfully executed
  71577. * @param onError is a callback called if an error occurs
  71578. */
  71579. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71580. }
  71581. /**
  71582. * This class can be used to easily import assets into a scene
  71583. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71584. */
  71585. export class AssetsManager {
  71586. private _scene;
  71587. private _isLoading;
  71588. protected _tasks: AbstractAssetTask[];
  71589. protected _waitingTasksCount: number;
  71590. protected _totalTasksCount: number;
  71591. /**
  71592. * Callback called when all tasks are processed
  71593. */
  71594. onFinish: (tasks: AbstractAssetTask[]) => void;
  71595. /**
  71596. * Callback called when a task is successful
  71597. */
  71598. onTaskSuccess: (task: AbstractAssetTask) => void;
  71599. /**
  71600. * Callback called when a task had an error
  71601. */
  71602. onTaskError: (task: AbstractAssetTask) => void;
  71603. /**
  71604. * Callback called when a task is done (whatever the result is)
  71605. */
  71606. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71607. /**
  71608. * Observable called when all tasks are processed
  71609. */
  71610. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71611. /**
  71612. * Observable called when a task had an error
  71613. */
  71614. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71615. /**
  71616. * Observable called when all tasks were executed
  71617. */
  71618. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71619. /**
  71620. * Observable called when a task is done (whatever the result is)
  71621. */
  71622. onProgressObservable: Observable<IAssetsProgressEvent>;
  71623. /**
  71624. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71625. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71626. */
  71627. useDefaultLoadingScreen: boolean;
  71628. /**
  71629. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71630. * when all assets have been downloaded.
  71631. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71632. */
  71633. autoHideLoadingUI: boolean;
  71634. /**
  71635. * Creates a new AssetsManager
  71636. * @param scene defines the scene to work on
  71637. */
  71638. constructor(scene: Scene);
  71639. /**
  71640. * Add a MeshAssetTask to the list of active tasks
  71641. * @param taskName defines the name of the new task
  71642. * @param meshesNames defines the name of meshes to load
  71643. * @param rootUrl defines the root url to use to locate files
  71644. * @param sceneFilename defines the filename of the scene file
  71645. * @returns a new MeshAssetTask object
  71646. */
  71647. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71648. /**
  71649. * Add a TextFileAssetTask to the list of active tasks
  71650. * @param taskName defines the name of the new task
  71651. * @param url defines the url of the file to load
  71652. * @returns a new TextFileAssetTask object
  71653. */
  71654. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71655. /**
  71656. * Add a BinaryFileAssetTask to the list of active tasks
  71657. * @param taskName defines the name of the new task
  71658. * @param url defines the url of the file to load
  71659. * @returns a new BinaryFileAssetTask object
  71660. */
  71661. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71662. /**
  71663. * Add a ImageAssetTask to the list of active tasks
  71664. * @param taskName defines the name of the new task
  71665. * @param url defines the url of the file to load
  71666. * @returns a new ImageAssetTask object
  71667. */
  71668. addImageTask(taskName: string, url: string): ImageAssetTask;
  71669. /**
  71670. * Add a TextureAssetTask to the list of active tasks
  71671. * @param taskName defines the name of the new task
  71672. * @param url defines the url of the file to load
  71673. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71674. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71675. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71676. * @returns a new TextureAssetTask object
  71677. */
  71678. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71679. /**
  71680. * Add a CubeTextureAssetTask to the list of active tasks
  71681. * @param taskName defines the name of the new task
  71682. * @param url defines the url of the file to load
  71683. * @param extensions defines the extension to use to load the cube map (can be null)
  71684. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71685. * @param files defines the list of files to load (can be null)
  71686. * @returns a new CubeTextureAssetTask object
  71687. */
  71688. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71689. /**
  71690. *
  71691. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71692. * @param taskName defines the name of the new task
  71693. * @param url defines the url of the file to load
  71694. * @param size defines the size you want for the cubemap (can be null)
  71695. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71696. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71697. * @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)
  71698. * @param reserved Internal use only
  71699. * @returns a new HDRCubeTextureAssetTask object
  71700. */
  71701. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71702. /**
  71703. *
  71704. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71705. * @param taskName defines the name of the new task
  71706. * @param url defines the url of the file to load
  71707. * @param size defines the size you want for the cubemap (can be null)
  71708. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71709. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71710. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71711. * @returns a new EquiRectangularCubeTextureAssetTask object
  71712. */
  71713. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71714. /**
  71715. * Remove a task from the assets manager.
  71716. * @param task the task to remove
  71717. */
  71718. removeTask(task: AbstractAssetTask): void;
  71719. private _decreaseWaitingTasksCount;
  71720. private _runTask;
  71721. /**
  71722. * Reset the AssetsManager and remove all tasks
  71723. * @return the current instance of the AssetsManager
  71724. */
  71725. reset(): AssetsManager;
  71726. /**
  71727. * Start the loading process
  71728. * @return the current instance of the AssetsManager
  71729. */
  71730. load(): AssetsManager;
  71731. /**
  71732. * Start the loading process as an async operation
  71733. * @return a promise returning the list of failed tasks
  71734. */
  71735. loadAsync(): Promise<void>;
  71736. }
  71737. }
  71738. declare module BABYLON {
  71739. /**
  71740. * Wrapper class for promise with external resolve and reject.
  71741. */
  71742. export class Deferred<T> {
  71743. /**
  71744. * The promise associated with this deferred object.
  71745. */
  71746. readonly promise: Promise<T>;
  71747. private _resolve;
  71748. private _reject;
  71749. /**
  71750. * The resolve method of the promise associated with this deferred object.
  71751. */
  71752. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71753. /**
  71754. * The reject method of the promise associated with this deferred object.
  71755. */
  71756. get reject(): (reason?: any) => void;
  71757. /**
  71758. * Constructor for this deferred object.
  71759. */
  71760. constructor();
  71761. }
  71762. }
  71763. declare module BABYLON {
  71764. /**
  71765. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71766. */
  71767. export class MeshExploder {
  71768. private _centerMesh;
  71769. private _meshes;
  71770. private _meshesOrigins;
  71771. private _toCenterVectors;
  71772. private _scaledDirection;
  71773. private _newPosition;
  71774. private _centerPosition;
  71775. /**
  71776. * Explodes meshes from a center mesh.
  71777. * @param meshes The meshes to explode.
  71778. * @param centerMesh The mesh to be center of explosion.
  71779. */
  71780. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71781. private _setCenterMesh;
  71782. /**
  71783. * Get class name
  71784. * @returns "MeshExploder"
  71785. */
  71786. getClassName(): string;
  71787. /**
  71788. * "Exploded meshes"
  71789. * @returns Array of meshes with the centerMesh at index 0.
  71790. */
  71791. getMeshes(): Array<Mesh>;
  71792. /**
  71793. * Explodes meshes giving a specific direction
  71794. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71795. */
  71796. explode(direction?: number): void;
  71797. }
  71798. }
  71799. declare module BABYLON {
  71800. /**
  71801. * Class used to help managing file picking and drag'n'drop
  71802. */
  71803. export class FilesInput {
  71804. /**
  71805. * List of files ready to be loaded
  71806. */
  71807. static get FilesToLoad(): {
  71808. [key: string]: File;
  71809. };
  71810. /**
  71811. * Callback called when a file is processed
  71812. */
  71813. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71814. private _engine;
  71815. private _currentScene;
  71816. private _sceneLoadedCallback;
  71817. private _progressCallback;
  71818. private _additionalRenderLoopLogicCallback;
  71819. private _textureLoadingCallback;
  71820. private _startingProcessingFilesCallback;
  71821. private _onReloadCallback;
  71822. private _errorCallback;
  71823. private _elementToMonitor;
  71824. private _sceneFileToLoad;
  71825. private _filesToLoad;
  71826. /**
  71827. * Creates a new FilesInput
  71828. * @param engine defines the rendering engine
  71829. * @param scene defines the hosting scene
  71830. * @param sceneLoadedCallback callback called when scene is loaded
  71831. * @param progressCallback callback called to track progress
  71832. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71833. * @param textureLoadingCallback callback called when a texture is loading
  71834. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71835. * @param onReloadCallback callback called when a reload is requested
  71836. * @param errorCallback callback call if an error occurs
  71837. */
  71838. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  71839. private _dragEnterHandler;
  71840. private _dragOverHandler;
  71841. private _dropHandler;
  71842. /**
  71843. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71844. * @param elementToMonitor defines the DOM element to track
  71845. */
  71846. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71847. /**
  71848. * Release all associated resources
  71849. */
  71850. dispose(): void;
  71851. private renderFunction;
  71852. private drag;
  71853. private drop;
  71854. private _traverseFolder;
  71855. private _processFiles;
  71856. /**
  71857. * Load files from a drop event
  71858. * @param event defines the drop event to use as source
  71859. */
  71860. loadFiles(event: any): void;
  71861. private _processReload;
  71862. /**
  71863. * Reload the current scene from the loaded files
  71864. */
  71865. reload(): void;
  71866. }
  71867. }
  71868. declare module BABYLON {
  71869. /**
  71870. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71871. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71872. */
  71873. export class SceneOptimization {
  71874. /**
  71875. * Defines the priority of this optimization (0 by default which means first in the list)
  71876. */
  71877. priority: number;
  71878. /**
  71879. * Gets a string describing the action executed by the current optimization
  71880. * @returns description string
  71881. */
  71882. getDescription(): string;
  71883. /**
  71884. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71885. * @param scene defines the current scene where to apply this optimization
  71886. * @param optimizer defines the current optimizer
  71887. * @returns true if everything that can be done was applied
  71888. */
  71889. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71890. /**
  71891. * Creates the SceneOptimization object
  71892. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71893. * @param desc defines the description associated with the optimization
  71894. */
  71895. constructor(
  71896. /**
  71897. * Defines the priority of this optimization (0 by default which means first in the list)
  71898. */
  71899. priority?: number);
  71900. }
  71901. /**
  71902. * Defines an optimization used to reduce the size of render target textures
  71903. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71904. */
  71905. export class TextureOptimization extends SceneOptimization {
  71906. /**
  71907. * Defines the priority of this optimization (0 by default which means first in the list)
  71908. */
  71909. priority: number;
  71910. /**
  71911. * 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
  71912. */
  71913. maximumSize: number;
  71914. /**
  71915. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71916. */
  71917. step: number;
  71918. /**
  71919. * Gets a string describing the action executed by the current optimization
  71920. * @returns description string
  71921. */
  71922. getDescription(): string;
  71923. /**
  71924. * Creates the TextureOptimization object
  71925. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71926. * @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
  71927. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71928. */
  71929. constructor(
  71930. /**
  71931. * Defines the priority of this optimization (0 by default which means first in the list)
  71932. */
  71933. priority?: number,
  71934. /**
  71935. * 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
  71936. */
  71937. maximumSize?: number,
  71938. /**
  71939. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71940. */
  71941. step?: number);
  71942. /**
  71943. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71944. * @param scene defines the current scene where to apply this optimization
  71945. * @param optimizer defines the current optimizer
  71946. * @returns true if everything that can be done was applied
  71947. */
  71948. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71949. }
  71950. /**
  71951. * Defines an optimization used to increase or decrease the rendering resolution
  71952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71953. */
  71954. export class HardwareScalingOptimization extends SceneOptimization {
  71955. /**
  71956. * Defines the priority of this optimization (0 by default which means first in the list)
  71957. */
  71958. priority: number;
  71959. /**
  71960. * Defines the maximum scale to use (2 by default)
  71961. */
  71962. maximumScale: number;
  71963. /**
  71964. * Defines the step to use between two passes (0.5 by default)
  71965. */
  71966. step: number;
  71967. private _currentScale;
  71968. private _directionOffset;
  71969. /**
  71970. * Gets a string describing the action executed by the current optimization
  71971. * @return description string
  71972. */
  71973. getDescription(): string;
  71974. /**
  71975. * Creates the HardwareScalingOptimization object
  71976. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71977. * @param maximumScale defines the maximum scale to use (2 by default)
  71978. * @param step defines the step to use between two passes (0.5 by default)
  71979. */
  71980. constructor(
  71981. /**
  71982. * Defines the priority of this optimization (0 by default which means first in the list)
  71983. */
  71984. priority?: number,
  71985. /**
  71986. * Defines the maximum scale to use (2 by default)
  71987. */
  71988. maximumScale?: number,
  71989. /**
  71990. * Defines the step to use between two passes (0.5 by default)
  71991. */
  71992. step?: number);
  71993. /**
  71994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71995. * @param scene defines the current scene where to apply this optimization
  71996. * @param optimizer defines the current optimizer
  71997. * @returns true if everything that can be done was applied
  71998. */
  71999. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72000. }
  72001. /**
  72002. * Defines an optimization used to remove shadows
  72003. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72004. */
  72005. export class ShadowsOptimization extends SceneOptimization {
  72006. /**
  72007. * Gets a string describing the action executed by the current optimization
  72008. * @return description string
  72009. */
  72010. getDescription(): string;
  72011. /**
  72012. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72013. * @param scene defines the current scene where to apply this optimization
  72014. * @param optimizer defines the current optimizer
  72015. * @returns true if everything that can be done was applied
  72016. */
  72017. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72018. }
  72019. /**
  72020. * Defines an optimization used to turn post-processes off
  72021. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72022. */
  72023. export class PostProcessesOptimization extends SceneOptimization {
  72024. /**
  72025. * Gets a string describing the action executed by the current optimization
  72026. * @return description string
  72027. */
  72028. getDescription(): string;
  72029. /**
  72030. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72031. * @param scene defines the current scene where to apply this optimization
  72032. * @param optimizer defines the current optimizer
  72033. * @returns true if everything that can be done was applied
  72034. */
  72035. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72036. }
  72037. /**
  72038. * Defines an optimization used to turn lens flares off
  72039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72040. */
  72041. export class LensFlaresOptimization extends SceneOptimization {
  72042. /**
  72043. * Gets a string describing the action executed by the current optimization
  72044. * @return description string
  72045. */
  72046. getDescription(): string;
  72047. /**
  72048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72049. * @param scene defines the current scene where to apply this optimization
  72050. * @param optimizer defines the current optimizer
  72051. * @returns true if everything that can be done was applied
  72052. */
  72053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72054. }
  72055. /**
  72056. * Defines an optimization based on user defined callback.
  72057. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72058. */
  72059. export class CustomOptimization extends SceneOptimization {
  72060. /**
  72061. * Callback called to apply the custom optimization.
  72062. */
  72063. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72064. /**
  72065. * Callback called to get custom description
  72066. */
  72067. onGetDescription: () => string;
  72068. /**
  72069. * Gets a string describing the action executed by the current optimization
  72070. * @returns description string
  72071. */
  72072. getDescription(): string;
  72073. /**
  72074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72075. * @param scene defines the current scene where to apply this optimization
  72076. * @param optimizer defines the current optimizer
  72077. * @returns true if everything that can be done was applied
  72078. */
  72079. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72080. }
  72081. /**
  72082. * Defines an optimization used to turn particles off
  72083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72084. */
  72085. export class ParticlesOptimization extends SceneOptimization {
  72086. /**
  72087. * Gets a string describing the action executed by the current optimization
  72088. * @return description string
  72089. */
  72090. getDescription(): string;
  72091. /**
  72092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72093. * @param scene defines the current scene where to apply this optimization
  72094. * @param optimizer defines the current optimizer
  72095. * @returns true if everything that can be done was applied
  72096. */
  72097. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72098. }
  72099. /**
  72100. * Defines an optimization used to turn render targets off
  72101. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72102. */
  72103. export class RenderTargetsOptimization extends SceneOptimization {
  72104. /**
  72105. * Gets a string describing the action executed by the current optimization
  72106. * @return description string
  72107. */
  72108. getDescription(): string;
  72109. /**
  72110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72111. * @param scene defines the current scene where to apply this optimization
  72112. * @param optimizer defines the current optimizer
  72113. * @returns true if everything that can be done was applied
  72114. */
  72115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72116. }
  72117. /**
  72118. * Defines an optimization used to merge meshes with compatible materials
  72119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72120. */
  72121. export class MergeMeshesOptimization extends SceneOptimization {
  72122. private static _UpdateSelectionTree;
  72123. /**
  72124. * Gets or sets a boolean which defines if optimization octree has to be updated
  72125. */
  72126. static get UpdateSelectionTree(): boolean;
  72127. /**
  72128. * Gets or sets a boolean which defines if optimization octree has to be updated
  72129. */
  72130. static set UpdateSelectionTree(value: boolean);
  72131. /**
  72132. * Gets a string describing the action executed by the current optimization
  72133. * @return description string
  72134. */
  72135. getDescription(): string;
  72136. private _canBeMerged;
  72137. /**
  72138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72139. * @param scene defines the current scene where to apply this optimization
  72140. * @param optimizer defines the current optimizer
  72141. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72142. * @returns true if everything that can be done was applied
  72143. */
  72144. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72145. }
  72146. /**
  72147. * Defines a list of options used by SceneOptimizer
  72148. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72149. */
  72150. export class SceneOptimizerOptions {
  72151. /**
  72152. * Defines the target frame rate to reach (60 by default)
  72153. */
  72154. targetFrameRate: number;
  72155. /**
  72156. * Defines the interval between two checkes (2000ms by default)
  72157. */
  72158. trackerDuration: number;
  72159. /**
  72160. * Gets the list of optimizations to apply
  72161. */
  72162. optimizations: SceneOptimization[];
  72163. /**
  72164. * Creates a new list of options used by SceneOptimizer
  72165. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72166. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72167. */
  72168. constructor(
  72169. /**
  72170. * Defines the target frame rate to reach (60 by default)
  72171. */
  72172. targetFrameRate?: number,
  72173. /**
  72174. * Defines the interval between two checkes (2000ms by default)
  72175. */
  72176. trackerDuration?: number);
  72177. /**
  72178. * Add a new optimization
  72179. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72180. * @returns the current SceneOptimizerOptions
  72181. */
  72182. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72183. /**
  72184. * Add a new custom optimization
  72185. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72186. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72187. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72188. * @returns the current SceneOptimizerOptions
  72189. */
  72190. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72191. /**
  72192. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72193. * @param targetFrameRate defines the target frame rate (60 by default)
  72194. * @returns a SceneOptimizerOptions object
  72195. */
  72196. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72197. /**
  72198. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72199. * @param targetFrameRate defines the target frame rate (60 by default)
  72200. * @returns a SceneOptimizerOptions object
  72201. */
  72202. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72203. /**
  72204. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72205. * @param targetFrameRate defines the target frame rate (60 by default)
  72206. * @returns a SceneOptimizerOptions object
  72207. */
  72208. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72209. }
  72210. /**
  72211. * Class used to run optimizations in order to reach a target frame rate
  72212. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72213. */
  72214. export class SceneOptimizer implements IDisposable {
  72215. private _isRunning;
  72216. private _options;
  72217. private _scene;
  72218. private _currentPriorityLevel;
  72219. private _targetFrameRate;
  72220. private _trackerDuration;
  72221. private _currentFrameRate;
  72222. private _sceneDisposeObserver;
  72223. private _improvementMode;
  72224. /**
  72225. * Defines an observable called when the optimizer reaches the target frame rate
  72226. */
  72227. onSuccessObservable: Observable<SceneOptimizer>;
  72228. /**
  72229. * Defines an observable called when the optimizer enables an optimization
  72230. */
  72231. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72232. /**
  72233. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72234. */
  72235. onFailureObservable: Observable<SceneOptimizer>;
  72236. /**
  72237. * Gets a boolean indicating if the optimizer is in improvement mode
  72238. */
  72239. get isInImprovementMode(): boolean;
  72240. /**
  72241. * Gets the current priority level (0 at start)
  72242. */
  72243. get currentPriorityLevel(): number;
  72244. /**
  72245. * Gets the current frame rate checked by the SceneOptimizer
  72246. */
  72247. get currentFrameRate(): number;
  72248. /**
  72249. * Gets or sets the current target frame rate (60 by default)
  72250. */
  72251. get targetFrameRate(): number;
  72252. /**
  72253. * Gets or sets the current target frame rate (60 by default)
  72254. */
  72255. set targetFrameRate(value: number);
  72256. /**
  72257. * Gets or sets the current interval between two checks (every 2000ms by default)
  72258. */
  72259. get trackerDuration(): number;
  72260. /**
  72261. * Gets or sets the current interval between two checks (every 2000ms by default)
  72262. */
  72263. set trackerDuration(value: number);
  72264. /**
  72265. * Gets the list of active optimizations
  72266. */
  72267. get optimizations(): SceneOptimization[];
  72268. /**
  72269. * Creates a new SceneOptimizer
  72270. * @param scene defines the scene to work on
  72271. * @param options defines the options to use with the SceneOptimizer
  72272. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72273. * @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)
  72274. */
  72275. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72276. /**
  72277. * Stops the current optimizer
  72278. */
  72279. stop(): void;
  72280. /**
  72281. * Reset the optimizer to initial step (current priority level = 0)
  72282. */
  72283. reset(): void;
  72284. /**
  72285. * Start the optimizer. By default it will try to reach a specific framerate
  72286. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72287. */
  72288. start(): void;
  72289. private _checkCurrentState;
  72290. /**
  72291. * Release all resources
  72292. */
  72293. dispose(): void;
  72294. /**
  72295. * Helper function to create a SceneOptimizer with one single line of code
  72296. * @param scene defines the scene to work on
  72297. * @param options defines the options to use with the SceneOptimizer
  72298. * @param onSuccess defines a callback to call on success
  72299. * @param onFailure defines a callback to call on failure
  72300. * @returns the new SceneOptimizer object
  72301. */
  72302. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72303. }
  72304. }
  72305. declare module BABYLON {
  72306. /**
  72307. * Class used to serialize a scene into a string
  72308. */
  72309. export class SceneSerializer {
  72310. /**
  72311. * Clear cache used by a previous serialization
  72312. */
  72313. static ClearCache(): void;
  72314. /**
  72315. * Serialize a scene into a JSON compatible object
  72316. * @param scene defines the scene to serialize
  72317. * @returns a JSON compatible object
  72318. */
  72319. static Serialize(scene: Scene): any;
  72320. /**
  72321. * Serialize a mesh into a JSON compatible object
  72322. * @param toSerialize defines the mesh to serialize
  72323. * @param withParents defines if parents must be serialized as well
  72324. * @param withChildren defines if children must be serialized as well
  72325. * @returns a JSON compatible object
  72326. */
  72327. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72328. }
  72329. }
  72330. declare module BABYLON {
  72331. /**
  72332. * Class used to host texture specific utilities
  72333. */
  72334. export class TextureTools {
  72335. /**
  72336. * Uses the GPU to create a copy texture rescaled at a given size
  72337. * @param texture Texture to copy from
  72338. * @param width defines the desired width
  72339. * @param height defines the desired height
  72340. * @param useBilinearMode defines if bilinear mode has to be used
  72341. * @return the generated texture
  72342. */
  72343. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72344. }
  72345. }
  72346. declare module BABYLON {
  72347. /**
  72348. * This represents the different options available for the video capture.
  72349. */
  72350. export interface VideoRecorderOptions {
  72351. /** Defines the mime type of the video. */
  72352. mimeType: string;
  72353. /** Defines the FPS the video should be recorded at. */
  72354. fps: number;
  72355. /** Defines the chunk size for the recording data. */
  72356. recordChunckSize: number;
  72357. /** The audio tracks to attach to the recording. */
  72358. audioTracks?: MediaStreamTrack[];
  72359. }
  72360. /**
  72361. * This can help with recording videos from BabylonJS.
  72362. * This is based on the available WebRTC functionalities of the browser.
  72363. *
  72364. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72365. */
  72366. export class VideoRecorder {
  72367. private static readonly _defaultOptions;
  72368. /**
  72369. * Returns whether or not the VideoRecorder is available in your browser.
  72370. * @param engine Defines the Babylon Engine.
  72371. * @returns true if supported otherwise false.
  72372. */
  72373. static IsSupported(engine: Engine): boolean;
  72374. private readonly _options;
  72375. private _canvas;
  72376. private _mediaRecorder;
  72377. private _recordedChunks;
  72378. private _fileName;
  72379. private _resolve;
  72380. private _reject;
  72381. /**
  72382. * True when a recording is already in progress.
  72383. */
  72384. get isRecording(): boolean;
  72385. /**
  72386. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72387. * @param engine Defines the BabylonJS Engine you wish to record.
  72388. * @param options Defines options that can be used to customize the capture.
  72389. */
  72390. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72391. /**
  72392. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72393. */
  72394. stopRecording(): void;
  72395. /**
  72396. * Starts recording the canvas for a max duration specified in parameters.
  72397. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72398. * If null no automatic download will start and you can rely on the promise to get the data back.
  72399. * @param maxDuration Defines the maximum recording time in seconds.
  72400. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72401. * @return A promise callback at the end of the recording with the video data in Blob.
  72402. */
  72403. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72404. /**
  72405. * Releases internal resources used during the recording.
  72406. */
  72407. dispose(): void;
  72408. private _handleDataAvailable;
  72409. private _handleError;
  72410. private _handleStop;
  72411. }
  72412. }
  72413. declare module BABYLON {
  72414. /**
  72415. * Class containing a set of static utilities functions for screenshots
  72416. */
  72417. export class ScreenshotTools {
  72418. /**
  72419. * Captures a screenshot of the current rendering
  72420. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72421. * @param engine defines the rendering engine
  72422. * @param camera defines the source camera
  72423. * @param size This parameter can be set to a single number or to an object with the
  72424. * following (optional) properties: precision, width, height. If a single number is passed,
  72425. * it will be used for both width and height. If an object is passed, the screenshot size
  72426. * will be derived from the parameters. The precision property is a multiplier allowing
  72427. * rendering at a higher or lower resolution
  72428. * @param successCallback defines the callback receives a single parameter which contains the
  72429. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72430. * src parameter of an <img> to display it
  72431. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72432. * Check your browser for supported MIME types
  72433. */
  72434. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72435. /**
  72436. * Captures a screenshot of the current rendering
  72437. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72438. * @param engine defines the rendering engine
  72439. * @param camera defines the source camera
  72440. * @param size This parameter can be set to a single number or to an object with the
  72441. * following (optional) properties: precision, width, height. If a single number is passed,
  72442. * it will be used for both width and height. If an object is passed, the screenshot size
  72443. * will be derived from the parameters. The precision property is a multiplier allowing
  72444. * rendering at a higher or lower resolution
  72445. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72446. * Check your browser for supported MIME types
  72447. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72448. * to the src parameter of an <img> to display it
  72449. */
  72450. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72451. /**
  72452. * Generates an image screenshot from the specified camera.
  72453. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72454. * @param engine The engine to use for rendering
  72455. * @param camera The camera to use for rendering
  72456. * @param size This parameter can be set to a single number or to an object with the
  72457. * following (optional) properties: precision, width, height. If a single number is passed,
  72458. * it will be used for both width and height. If an object is passed, the screenshot size
  72459. * will be derived from the parameters. The precision property is a multiplier allowing
  72460. * rendering at a higher or lower resolution
  72461. * @param successCallback The callback receives a single parameter which contains the
  72462. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72463. * src parameter of an <img> to display it
  72464. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72465. * Check your browser for supported MIME types
  72466. * @param samples Texture samples (default: 1)
  72467. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72468. * @param fileName A name for for the downloaded file.
  72469. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72470. */
  72471. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72472. /**
  72473. * Generates an image screenshot from the specified camera.
  72474. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72475. * @param engine The engine to use for rendering
  72476. * @param camera The camera to use for rendering
  72477. * @param size This parameter can be set to a single number or to an object with the
  72478. * following (optional) properties: precision, width, height. If a single number is passed,
  72479. * it will be used for both width and height. If an object is passed, the screenshot size
  72480. * will be derived from the parameters. The precision property is a multiplier allowing
  72481. * rendering at a higher or lower resolution
  72482. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72483. * Check your browser for supported MIME types
  72484. * @param samples Texture samples (default: 1)
  72485. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72486. * @param fileName A name for for the downloaded file.
  72487. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72488. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72489. * to the src parameter of an <img> to display it
  72490. */
  72491. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72492. /**
  72493. * Gets height and width for screenshot size
  72494. * @private
  72495. */
  72496. private static _getScreenshotSize;
  72497. }
  72498. }
  72499. declare module BABYLON {
  72500. /**
  72501. * Interface for a data buffer
  72502. */
  72503. export interface IDataBuffer {
  72504. /**
  72505. * Reads bytes from the data buffer.
  72506. * @param byteOffset The byte offset to read
  72507. * @param byteLength The byte length to read
  72508. * @returns A promise that resolves when the bytes are read
  72509. */
  72510. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72511. /**
  72512. * The byte length of the buffer.
  72513. */
  72514. readonly byteLength: number;
  72515. }
  72516. /**
  72517. * Utility class for reading from a data buffer
  72518. */
  72519. export class DataReader {
  72520. /**
  72521. * The data buffer associated with this data reader.
  72522. */
  72523. readonly buffer: IDataBuffer;
  72524. /**
  72525. * The current byte offset from the beginning of the data buffer.
  72526. */
  72527. byteOffset: number;
  72528. private _dataView;
  72529. private _dataByteOffset;
  72530. /**
  72531. * Constructor
  72532. * @param buffer The buffer to read
  72533. */
  72534. constructor(buffer: IDataBuffer);
  72535. /**
  72536. * Loads the given byte length.
  72537. * @param byteLength The byte length to load
  72538. * @returns A promise that resolves when the load is complete
  72539. */
  72540. loadAsync(byteLength: number): Promise<void>;
  72541. /**
  72542. * Read a unsigned 32-bit integer from the currently loaded data range.
  72543. * @returns The 32-bit integer read
  72544. */
  72545. readUint32(): number;
  72546. /**
  72547. * Read a byte array from the currently loaded data range.
  72548. * @param byteLength The byte length to read
  72549. * @returns The byte array read
  72550. */
  72551. readUint8Array(byteLength: number): Uint8Array;
  72552. /**
  72553. * Read a string from the currently loaded data range.
  72554. * @param byteLength The byte length to read
  72555. * @returns The string read
  72556. */
  72557. readString(byteLength: number): string;
  72558. /**
  72559. * Skips the given byte length the currently loaded data range.
  72560. * @param byteLength The byte length to skip
  72561. */
  72562. skipBytes(byteLength: number): void;
  72563. }
  72564. }
  72565. declare module BABYLON {
  72566. /**
  72567. * Class for storing data to local storage if available or in-memory storage otherwise
  72568. */
  72569. export class DataStorage {
  72570. private static _Storage;
  72571. private static _GetStorage;
  72572. /**
  72573. * Reads a string from the data storage
  72574. * @param key The key to read
  72575. * @param defaultValue The value if the key doesn't exist
  72576. * @returns The string value
  72577. */
  72578. static ReadString(key: string, defaultValue: string): string;
  72579. /**
  72580. * Writes a string to the data storage
  72581. * @param key The key to write
  72582. * @param value The value to write
  72583. */
  72584. static WriteString(key: string, value: string): void;
  72585. /**
  72586. * Reads a boolean from the data storage
  72587. * @param key The key to read
  72588. * @param defaultValue The value if the key doesn't exist
  72589. * @returns The boolean value
  72590. */
  72591. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72592. /**
  72593. * Writes a boolean to the data storage
  72594. * @param key The key to write
  72595. * @param value The value to write
  72596. */
  72597. static WriteBoolean(key: string, value: boolean): void;
  72598. /**
  72599. * Reads a number from the data storage
  72600. * @param key The key to read
  72601. * @param defaultValue The value if the key doesn't exist
  72602. * @returns The number value
  72603. */
  72604. static ReadNumber(key: string, defaultValue: number): number;
  72605. /**
  72606. * Writes a number to the data storage
  72607. * @param key The key to write
  72608. * @param value The value to write
  72609. */
  72610. static WriteNumber(key: string, value: number): void;
  72611. }
  72612. }
  72613. declare module BABYLON {
  72614. /**
  72615. * An interface for all Hit test features
  72616. */
  72617. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72618. /**
  72619. * Triggered when new babylon (transformed) hit test results are available
  72620. */
  72621. onHitTestResultObservable: Observable<T[]>;
  72622. }
  72623. /**
  72624. * Options used for hit testing
  72625. */
  72626. export interface IWebXRLegacyHitTestOptions {
  72627. /**
  72628. * Only test when user interacted with the scene. Default - hit test every frame
  72629. */
  72630. testOnPointerDownOnly?: boolean;
  72631. /**
  72632. * The node to use to transform the local results to world coordinates
  72633. */
  72634. worldParentNode?: TransformNode;
  72635. }
  72636. /**
  72637. * Interface defining the babylon result of raycasting/hit-test
  72638. */
  72639. export interface IWebXRLegacyHitResult {
  72640. /**
  72641. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72642. */
  72643. transformationMatrix: Matrix;
  72644. /**
  72645. * The native hit test result
  72646. */
  72647. xrHitResult: XRHitResult | XRHitTestResult;
  72648. }
  72649. /**
  72650. * The currently-working hit-test module.
  72651. * Hit test (or Ray-casting) is used to interact with the real world.
  72652. * For further information read here - https://github.com/immersive-web/hit-test
  72653. */
  72654. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72655. /**
  72656. * options to use when constructing this feature
  72657. */
  72658. readonly options: IWebXRLegacyHitTestOptions;
  72659. private _direction;
  72660. private _mat;
  72661. private _onSelectEnabled;
  72662. private _origin;
  72663. /**
  72664. * The module's name
  72665. */
  72666. static readonly Name: string;
  72667. /**
  72668. * The (Babylon) version of this module.
  72669. * This is an integer representing the implementation version.
  72670. * This number does not correspond to the WebXR specs version
  72671. */
  72672. static readonly Version: number;
  72673. /**
  72674. * Populated with the last native XR Hit Results
  72675. */
  72676. lastNativeXRHitResults: XRHitResult[];
  72677. /**
  72678. * Triggered when new babylon (transformed) hit test results are available
  72679. */
  72680. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72681. /**
  72682. * Creates a new instance of the (legacy version) hit test feature
  72683. * @param _xrSessionManager an instance of WebXRSessionManager
  72684. * @param options options to use when constructing this feature
  72685. */
  72686. constructor(_xrSessionManager: WebXRSessionManager,
  72687. /**
  72688. * options to use when constructing this feature
  72689. */
  72690. options?: IWebXRLegacyHitTestOptions);
  72691. /**
  72692. * execute a hit test with an XR Ray
  72693. *
  72694. * @param xrSession a native xrSession that will execute this hit test
  72695. * @param xrRay the ray (position and direction) to use for ray-casting
  72696. * @param referenceSpace native XR reference space to use for the hit-test
  72697. * @param filter filter function that will filter the results
  72698. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72699. */
  72700. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72701. /**
  72702. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72703. * @param event the (select) event to use to select with
  72704. * @param referenceSpace the reference space to use for this hit test
  72705. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72706. */
  72707. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72708. /**
  72709. * attach this feature
  72710. * Will usually be called by the features manager
  72711. *
  72712. * @returns true if successful.
  72713. */
  72714. attach(): boolean;
  72715. /**
  72716. * detach this feature.
  72717. * Will usually be called by the features manager
  72718. *
  72719. * @returns true if successful.
  72720. */
  72721. detach(): boolean;
  72722. /**
  72723. * Dispose this feature and all of the resources attached
  72724. */
  72725. dispose(): void;
  72726. protected _onXRFrame(frame: XRFrame): void;
  72727. private _onHitTestResults;
  72728. private _onSelect;
  72729. }
  72730. }
  72731. declare module BABYLON {
  72732. /**
  72733. * Options used for hit testing (version 2)
  72734. */
  72735. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72736. /**
  72737. * Do not create a permanent hit test. Will usually be used when only
  72738. * transient inputs are needed.
  72739. */
  72740. disablePermanentHitTest?: boolean;
  72741. /**
  72742. * Enable transient (for example touch-based) hit test inspections
  72743. */
  72744. enableTransientHitTest?: boolean;
  72745. /**
  72746. * Offset ray for the permanent hit test
  72747. */
  72748. offsetRay?: Vector3;
  72749. /**
  72750. * Offset ray for the transient hit test
  72751. */
  72752. transientOffsetRay?: Vector3;
  72753. /**
  72754. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72755. */
  72756. useReferenceSpace?: boolean;
  72757. }
  72758. /**
  72759. * Interface defining the babylon result of hit-test
  72760. */
  72761. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72762. /**
  72763. * The input source that generated this hit test (if transient)
  72764. */
  72765. inputSource?: XRInputSource;
  72766. /**
  72767. * Is this a transient hit test
  72768. */
  72769. isTransient?: boolean;
  72770. /**
  72771. * Position of the hit test result
  72772. */
  72773. position: Vector3;
  72774. /**
  72775. * Rotation of the hit test result
  72776. */
  72777. rotationQuaternion: Quaternion;
  72778. /**
  72779. * The native hit test result
  72780. */
  72781. xrHitResult: XRHitTestResult;
  72782. }
  72783. /**
  72784. * The currently-working hit-test module.
  72785. * Hit test (or Ray-casting) is used to interact with the real world.
  72786. * For further information read here - https://github.com/immersive-web/hit-test
  72787. *
  72788. * Tested on chrome (mobile) 80.
  72789. */
  72790. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72791. /**
  72792. * options to use when constructing this feature
  72793. */
  72794. readonly options: IWebXRHitTestOptions;
  72795. private _tmpMat;
  72796. private _tmpPos;
  72797. private _tmpQuat;
  72798. private _transientXrHitTestSource;
  72799. private _xrHitTestSource;
  72800. private initHitTestSource;
  72801. /**
  72802. * The module's name
  72803. */
  72804. static readonly Name: string;
  72805. /**
  72806. * The (Babylon) version of this module.
  72807. * This is an integer representing the implementation version.
  72808. * This number does not correspond to the WebXR specs version
  72809. */
  72810. static readonly Version: number;
  72811. /**
  72812. * When set to true, each hit test will have its own position/rotation objects
  72813. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72814. * the developers will clone them or copy them as they see fit.
  72815. */
  72816. autoCloneTransformation: boolean;
  72817. /**
  72818. * Triggered when new babylon (transformed) hit test results are available
  72819. */
  72820. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72821. /**
  72822. * Use this to temporarily pause hit test checks.
  72823. */
  72824. paused: boolean;
  72825. /**
  72826. * Creates a new instance of the hit test feature
  72827. * @param _xrSessionManager an instance of WebXRSessionManager
  72828. * @param options options to use when constructing this feature
  72829. */
  72830. constructor(_xrSessionManager: WebXRSessionManager,
  72831. /**
  72832. * options to use when constructing this feature
  72833. */
  72834. options?: IWebXRHitTestOptions);
  72835. /**
  72836. * attach this feature
  72837. * Will usually be called by the features manager
  72838. *
  72839. * @returns true if successful.
  72840. */
  72841. attach(): boolean;
  72842. /**
  72843. * detach this feature.
  72844. * Will usually be called by the features manager
  72845. *
  72846. * @returns true if successful.
  72847. */
  72848. detach(): boolean;
  72849. /**
  72850. * Dispose this feature and all of the resources attached
  72851. */
  72852. dispose(): void;
  72853. protected _onXRFrame(frame: XRFrame): void;
  72854. private _processWebXRHitTestResult;
  72855. }
  72856. }
  72857. declare module BABYLON {
  72858. /**
  72859. * Configuration options of the anchor system
  72860. */
  72861. export interface IWebXRAnchorSystemOptions {
  72862. /**
  72863. * a node that will be used to convert local to world coordinates
  72864. */
  72865. worldParentNode?: TransformNode;
  72866. /**
  72867. * If set to true a reference of the created anchors will be kept until the next session starts
  72868. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72869. */
  72870. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72871. }
  72872. /**
  72873. * A babylon container for an XR Anchor
  72874. */
  72875. export interface IWebXRAnchor {
  72876. /**
  72877. * A babylon-assigned ID for this anchor
  72878. */
  72879. id: number;
  72880. /**
  72881. * Transformation matrix to apply to an object attached to this anchor
  72882. */
  72883. transformationMatrix: Matrix;
  72884. /**
  72885. * The native anchor object
  72886. */
  72887. xrAnchor: XRAnchor;
  72888. /**
  72889. * if defined, this object will be constantly updated by the anchor's position and rotation
  72890. */
  72891. attachedNode?: TransformNode;
  72892. }
  72893. /**
  72894. * An implementation of the anchor system for WebXR.
  72895. * For further information see https://github.com/immersive-web/anchors/
  72896. */
  72897. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72898. private _options;
  72899. private _lastFrameDetected;
  72900. private _trackedAnchors;
  72901. private _referenceSpaceForFrameAnchors;
  72902. private _futureAnchors;
  72903. /**
  72904. * The module's name
  72905. */
  72906. static readonly Name: string;
  72907. /**
  72908. * The (Babylon) version of this module.
  72909. * This is an integer representing the implementation version.
  72910. * This number does not correspond to the WebXR specs version
  72911. */
  72912. static readonly Version: number;
  72913. /**
  72914. * Observers registered here will be executed when a new anchor was added to the session
  72915. */
  72916. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72917. /**
  72918. * Observers registered here will be executed when an anchor was removed from the session
  72919. */
  72920. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72921. /**
  72922. * Observers registered here will be executed when an existing anchor updates
  72923. * This can execute N times every frame
  72924. */
  72925. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72926. /**
  72927. * Set the reference space to use for anchor creation, when not using a hit test.
  72928. * Will default to the session's reference space if not defined
  72929. */
  72930. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72931. /**
  72932. * constructs a new anchor system
  72933. * @param _xrSessionManager an instance of WebXRSessionManager
  72934. * @param _options configuration object for this feature
  72935. */
  72936. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72937. private _tmpVector;
  72938. private _tmpQuaternion;
  72939. private _populateTmpTransformation;
  72940. /**
  72941. * Create a new anchor point using a hit test result at a specific point in the scene
  72942. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72943. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72944. *
  72945. * @param hitTestResult The hit test result to use for this anchor creation
  72946. * @param position an optional position offset for this anchor
  72947. * @param rotationQuaternion an optional rotation offset for this anchor
  72948. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72949. */
  72950. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72951. /**
  72952. * Add a new anchor at a specific position and rotation
  72953. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72954. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72955. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72956. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72957. *
  72958. * @param position the position in which to add an anchor
  72959. * @param rotationQuaternion an optional rotation for the anchor transformation
  72960. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72961. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72962. */
  72963. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72964. /**
  72965. * detach this feature.
  72966. * Will usually be called by the features manager
  72967. *
  72968. * @returns true if successful.
  72969. */
  72970. detach(): boolean;
  72971. /**
  72972. * Dispose this feature and all of the resources attached
  72973. */
  72974. dispose(): void;
  72975. protected _onXRFrame(frame: XRFrame): void;
  72976. /**
  72977. * avoiding using Array.find for global support.
  72978. * @param xrAnchor the plane to find in the array
  72979. */
  72980. private _findIndexInAnchorArray;
  72981. private _updateAnchorWithXRFrame;
  72982. private _createAnchorAtTransformation;
  72983. }
  72984. }
  72985. declare module BABYLON {
  72986. /**
  72987. * Options used in the plane detector module
  72988. */
  72989. export interface IWebXRPlaneDetectorOptions {
  72990. /**
  72991. * The node to use to transform the local results to world coordinates
  72992. */
  72993. worldParentNode?: TransformNode;
  72994. /**
  72995. * If set to true a reference of the created planes will be kept until the next session starts
  72996. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  72997. */
  72998. doNotRemovePlanesOnSessionEnded?: boolean;
  72999. }
  73000. /**
  73001. * A babylon interface for a WebXR plane.
  73002. * A Plane is actually a polygon, built from N points in space
  73003. *
  73004. * Supported in chrome 79, not supported in canary 81 ATM
  73005. */
  73006. export interface IWebXRPlane {
  73007. /**
  73008. * a babylon-assigned ID for this polygon
  73009. */
  73010. id: number;
  73011. /**
  73012. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73013. */
  73014. polygonDefinition: Array<Vector3>;
  73015. /**
  73016. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73017. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73018. */
  73019. transformationMatrix: Matrix;
  73020. /**
  73021. * the native xr-plane object
  73022. */
  73023. xrPlane: XRPlane;
  73024. }
  73025. /**
  73026. * The plane detector is used to detect planes in the real world when in AR
  73027. * For more information see https://github.com/immersive-web/real-world-geometry/
  73028. */
  73029. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73030. private _options;
  73031. private _detectedPlanes;
  73032. private _enabled;
  73033. private _lastFrameDetected;
  73034. /**
  73035. * The module's name
  73036. */
  73037. static readonly Name: string;
  73038. /**
  73039. * The (Babylon) version of this module.
  73040. * This is an integer representing the implementation version.
  73041. * This number does not correspond to the WebXR specs version
  73042. */
  73043. static readonly Version: number;
  73044. /**
  73045. * Observers registered here will be executed when a new plane was added to the session
  73046. */
  73047. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73048. /**
  73049. * Observers registered here will be executed when a plane is no longer detected in the session
  73050. */
  73051. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73052. /**
  73053. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73054. * This can execute N times every frame
  73055. */
  73056. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73057. /**
  73058. * construct a new Plane Detector
  73059. * @param _xrSessionManager an instance of xr Session manager
  73060. * @param _options configuration to use when constructing this feature
  73061. */
  73062. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73063. /**
  73064. * detach this feature.
  73065. * Will usually be called by the features manager
  73066. *
  73067. * @returns true if successful.
  73068. */
  73069. detach(): boolean;
  73070. /**
  73071. * Dispose this feature and all of the resources attached
  73072. */
  73073. dispose(): void;
  73074. protected _onXRFrame(frame: XRFrame): void;
  73075. private _init;
  73076. private _updatePlaneWithXRPlane;
  73077. /**
  73078. * avoiding using Array.find for global support.
  73079. * @param xrPlane the plane to find in the array
  73080. */
  73081. private findIndexInPlaneArray;
  73082. }
  73083. }
  73084. declare module BABYLON {
  73085. /**
  73086. * Options interface for the background remover plugin
  73087. */
  73088. export interface IWebXRBackgroundRemoverOptions {
  73089. /**
  73090. * Further background meshes to disable when entering AR
  73091. */
  73092. backgroundMeshes?: AbstractMesh[];
  73093. /**
  73094. * flags to configure the removal of the environment helper.
  73095. * If not set, the entire background will be removed. If set, flags should be set as well.
  73096. */
  73097. environmentHelperRemovalFlags?: {
  73098. /**
  73099. * Should the skybox be removed (default false)
  73100. */
  73101. skyBox?: boolean;
  73102. /**
  73103. * Should the ground be removed (default false)
  73104. */
  73105. ground?: boolean;
  73106. };
  73107. /**
  73108. * don't disable the environment helper
  73109. */
  73110. ignoreEnvironmentHelper?: boolean;
  73111. }
  73112. /**
  73113. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73114. */
  73115. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73116. /**
  73117. * read-only options to be used in this module
  73118. */
  73119. readonly options: IWebXRBackgroundRemoverOptions;
  73120. /**
  73121. * The module's name
  73122. */
  73123. static readonly Name: string;
  73124. /**
  73125. * The (Babylon) version of this module.
  73126. * This is an integer representing the implementation version.
  73127. * This number does not correspond to the WebXR specs version
  73128. */
  73129. static readonly Version: number;
  73130. /**
  73131. * registered observers will be triggered when the background state changes
  73132. */
  73133. onBackgroundStateChangedObservable: Observable<boolean>;
  73134. /**
  73135. * constructs a new background remover module
  73136. * @param _xrSessionManager the session manager for this module
  73137. * @param options read-only options to be used in this module
  73138. */
  73139. constructor(_xrSessionManager: WebXRSessionManager,
  73140. /**
  73141. * read-only options to be used in this module
  73142. */
  73143. options?: IWebXRBackgroundRemoverOptions);
  73144. /**
  73145. * attach this feature
  73146. * Will usually be called by the features manager
  73147. *
  73148. * @returns true if successful.
  73149. */
  73150. attach(): boolean;
  73151. /**
  73152. * detach this feature.
  73153. * Will usually be called by the features manager
  73154. *
  73155. * @returns true if successful.
  73156. */
  73157. detach(): boolean;
  73158. /**
  73159. * Dispose this feature and all of the resources attached
  73160. */
  73161. dispose(): void;
  73162. protected _onXRFrame(_xrFrame: XRFrame): void;
  73163. private _setBackgroundState;
  73164. }
  73165. }
  73166. declare module BABYLON {
  73167. /**
  73168. * Options for the controller physics feature
  73169. */
  73170. export class IWebXRControllerPhysicsOptions {
  73171. /**
  73172. * Should the headset get its own impostor
  73173. */
  73174. enableHeadsetImpostor?: boolean;
  73175. /**
  73176. * Optional parameters for the headset impostor
  73177. */
  73178. headsetImpostorParams?: {
  73179. /**
  73180. * The type of impostor to create. Default is sphere
  73181. */
  73182. impostorType: number;
  73183. /**
  73184. * the size of the impostor. Defaults to 10cm
  73185. */
  73186. impostorSize?: number | {
  73187. width: number;
  73188. height: number;
  73189. depth: number;
  73190. };
  73191. /**
  73192. * Friction definitions
  73193. */
  73194. friction?: number;
  73195. /**
  73196. * Restitution
  73197. */
  73198. restitution?: number;
  73199. };
  73200. /**
  73201. * The physics properties of the future impostors
  73202. */
  73203. physicsProperties?: {
  73204. /**
  73205. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73206. * Note that this requires a physics engine that supports mesh impostors!
  73207. */
  73208. useControllerMesh?: boolean;
  73209. /**
  73210. * The type of impostor to create. Default is sphere
  73211. */
  73212. impostorType?: number;
  73213. /**
  73214. * the size of the impostor. Defaults to 10cm
  73215. */
  73216. impostorSize?: number | {
  73217. width: number;
  73218. height: number;
  73219. depth: number;
  73220. };
  73221. /**
  73222. * Friction definitions
  73223. */
  73224. friction?: number;
  73225. /**
  73226. * Restitution
  73227. */
  73228. restitution?: number;
  73229. };
  73230. /**
  73231. * the xr input to use with this pointer selection
  73232. */
  73233. xrInput: WebXRInput;
  73234. }
  73235. /**
  73236. * Add physics impostor to your webxr controllers,
  73237. * including naive calculation of their linear and angular velocity
  73238. */
  73239. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73240. private readonly _options;
  73241. private _attachController;
  73242. private _controllers;
  73243. private _debugMode;
  73244. private _delta;
  73245. private _headsetImpostor?;
  73246. private _headsetMesh?;
  73247. private _lastTimestamp;
  73248. private _tmpQuaternion;
  73249. private _tmpVector;
  73250. /**
  73251. * The module's name
  73252. */
  73253. static readonly Name: string;
  73254. /**
  73255. * The (Babylon) version of this module.
  73256. * This is an integer representing the implementation version.
  73257. * This number does not correspond to the webxr specs version
  73258. */
  73259. static readonly Version: number;
  73260. /**
  73261. * Construct a new Controller Physics Feature
  73262. * @param _xrSessionManager the corresponding xr session manager
  73263. * @param _options options to create this feature with
  73264. */
  73265. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73266. /**
  73267. * @hidden
  73268. * enable debugging - will show console outputs and the impostor mesh
  73269. */
  73270. _enablePhysicsDebug(): void;
  73271. /**
  73272. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73273. * @param xrController the controller to add
  73274. */
  73275. addController(xrController: WebXRInputSource): void;
  73276. /**
  73277. * attach this feature
  73278. * Will usually be called by the features manager
  73279. *
  73280. * @returns true if successful.
  73281. */
  73282. attach(): boolean;
  73283. /**
  73284. * detach this feature.
  73285. * Will usually be called by the features manager
  73286. *
  73287. * @returns true if successful.
  73288. */
  73289. detach(): boolean;
  73290. /**
  73291. * Get the headset impostor, if enabled
  73292. * @returns the impostor
  73293. */
  73294. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73295. /**
  73296. * Get the physics impostor of a specific controller.
  73297. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73298. * @param controller the controller or the controller id of which to get the impostor
  73299. * @returns the impostor or null
  73300. */
  73301. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73302. /**
  73303. * Update the physics properties provided in the constructor
  73304. * @param newProperties the new properties object
  73305. */
  73306. setPhysicsProperties(newProperties: {
  73307. impostorType?: number;
  73308. impostorSize?: number | {
  73309. width: number;
  73310. height: number;
  73311. depth: number;
  73312. };
  73313. friction?: number;
  73314. restitution?: number;
  73315. }): void;
  73316. protected _onXRFrame(_xrFrame: any): void;
  73317. private _detachController;
  73318. }
  73319. }
  73320. declare module BABYLON {
  73321. /**
  73322. * The motion controller class for all microsoft mixed reality controllers
  73323. */
  73324. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73325. protected readonly _mapping: {
  73326. defaultButton: {
  73327. valueNodeName: string;
  73328. unpressedNodeName: string;
  73329. pressedNodeName: string;
  73330. };
  73331. defaultAxis: {
  73332. valueNodeName: string;
  73333. minNodeName: string;
  73334. maxNodeName: string;
  73335. };
  73336. buttons: {
  73337. "xr-standard-trigger": {
  73338. rootNodeName: string;
  73339. componentProperty: string;
  73340. states: string[];
  73341. };
  73342. "xr-standard-squeeze": {
  73343. rootNodeName: string;
  73344. componentProperty: string;
  73345. states: string[];
  73346. };
  73347. "xr-standard-touchpad": {
  73348. rootNodeName: string;
  73349. labelAnchorNodeName: string;
  73350. touchPointNodeName: string;
  73351. };
  73352. "xr-standard-thumbstick": {
  73353. rootNodeName: string;
  73354. componentProperty: string;
  73355. states: string[];
  73356. };
  73357. };
  73358. axes: {
  73359. "xr-standard-touchpad": {
  73360. "x-axis": {
  73361. rootNodeName: string;
  73362. };
  73363. "y-axis": {
  73364. rootNodeName: string;
  73365. };
  73366. };
  73367. "xr-standard-thumbstick": {
  73368. "x-axis": {
  73369. rootNodeName: string;
  73370. };
  73371. "y-axis": {
  73372. rootNodeName: string;
  73373. };
  73374. };
  73375. };
  73376. };
  73377. /**
  73378. * The base url used to load the left and right controller models
  73379. */
  73380. static MODEL_BASE_URL: string;
  73381. /**
  73382. * The name of the left controller model file
  73383. */
  73384. static MODEL_LEFT_FILENAME: string;
  73385. /**
  73386. * The name of the right controller model file
  73387. */
  73388. static MODEL_RIGHT_FILENAME: string;
  73389. profileId: string;
  73390. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73391. protected _getFilenameAndPath(): {
  73392. filename: string;
  73393. path: string;
  73394. };
  73395. protected _getModelLoadingConstraints(): boolean;
  73396. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73397. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73398. protected _updateModel(): void;
  73399. }
  73400. }
  73401. declare module BABYLON {
  73402. /**
  73403. * The motion controller class for oculus touch (quest, rift).
  73404. * This class supports legacy mapping as well the standard xr mapping
  73405. */
  73406. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73407. private _forceLegacyControllers;
  73408. private _modelRootNode;
  73409. /**
  73410. * The base url used to load the left and right controller models
  73411. */
  73412. static MODEL_BASE_URL: string;
  73413. /**
  73414. * The name of the left controller model file
  73415. */
  73416. static MODEL_LEFT_FILENAME: string;
  73417. /**
  73418. * The name of the right controller model file
  73419. */
  73420. static MODEL_RIGHT_FILENAME: string;
  73421. /**
  73422. * Base Url for the Quest controller model.
  73423. */
  73424. static QUEST_MODEL_BASE_URL: string;
  73425. profileId: string;
  73426. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73427. protected _getFilenameAndPath(): {
  73428. filename: string;
  73429. path: string;
  73430. };
  73431. protected _getModelLoadingConstraints(): boolean;
  73432. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73433. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73434. protected _updateModel(): void;
  73435. /**
  73436. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73437. * between the touch and touch 2.
  73438. */
  73439. private _isQuest;
  73440. }
  73441. }
  73442. declare module BABYLON {
  73443. /**
  73444. * The motion controller class for the standard HTC-Vive controllers
  73445. */
  73446. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73447. private _modelRootNode;
  73448. /**
  73449. * The base url used to load the left and right controller models
  73450. */
  73451. static MODEL_BASE_URL: string;
  73452. /**
  73453. * File name for the controller model.
  73454. */
  73455. static MODEL_FILENAME: string;
  73456. profileId: string;
  73457. /**
  73458. * Create a new Vive motion controller object
  73459. * @param scene the scene to use to create this controller
  73460. * @param gamepadObject the corresponding gamepad object
  73461. * @param handedness the handedness of the controller
  73462. */
  73463. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73464. protected _getFilenameAndPath(): {
  73465. filename: string;
  73466. path: string;
  73467. };
  73468. protected _getModelLoadingConstraints(): boolean;
  73469. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73470. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73471. protected _updateModel(): void;
  73472. }
  73473. }
  73474. declare module BABYLON {
  73475. /**
  73476. * A cursor which tracks a point on a path
  73477. */
  73478. export class PathCursor {
  73479. private path;
  73480. /**
  73481. * Stores path cursor callbacks for when an onchange event is triggered
  73482. */
  73483. private _onchange;
  73484. /**
  73485. * The value of the path cursor
  73486. */
  73487. value: number;
  73488. /**
  73489. * The animation array of the path cursor
  73490. */
  73491. animations: Animation[];
  73492. /**
  73493. * Initializes the path cursor
  73494. * @param path The path to track
  73495. */
  73496. constructor(path: Path2);
  73497. /**
  73498. * Gets the cursor point on the path
  73499. * @returns A point on the path cursor at the cursor location
  73500. */
  73501. getPoint(): Vector3;
  73502. /**
  73503. * Moves the cursor ahead by the step amount
  73504. * @param step The amount to move the cursor forward
  73505. * @returns This path cursor
  73506. */
  73507. moveAhead(step?: number): PathCursor;
  73508. /**
  73509. * Moves the cursor behind by the step amount
  73510. * @param step The amount to move the cursor back
  73511. * @returns This path cursor
  73512. */
  73513. moveBack(step?: number): PathCursor;
  73514. /**
  73515. * Moves the cursor by the step amount
  73516. * If the step amount is greater than one, an exception is thrown
  73517. * @param step The amount to move the cursor
  73518. * @returns This path cursor
  73519. */
  73520. move(step: number): PathCursor;
  73521. /**
  73522. * Ensures that the value is limited between zero and one
  73523. * @returns This path cursor
  73524. */
  73525. private ensureLimits;
  73526. /**
  73527. * Runs onchange callbacks on change (used by the animation engine)
  73528. * @returns This path cursor
  73529. */
  73530. private raiseOnChange;
  73531. /**
  73532. * Executes a function on change
  73533. * @param f A path cursor onchange callback
  73534. * @returns This path cursor
  73535. */
  73536. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73537. }
  73538. }
  73539. declare module BABYLON {
  73540. /** @hidden */
  73541. export var blurPixelShader: {
  73542. name: string;
  73543. shader: string;
  73544. };
  73545. }
  73546. declare module BABYLON {
  73547. /** @hidden */
  73548. export var pointCloudVertexDeclaration: {
  73549. name: string;
  73550. shader: string;
  73551. };
  73552. }
  73553. // Mixins
  73554. interface Window {
  73555. mozIndexedDB: IDBFactory;
  73556. webkitIndexedDB: IDBFactory;
  73557. msIndexedDB: IDBFactory;
  73558. webkitURL: typeof URL;
  73559. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73560. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73561. WebGLRenderingContext: WebGLRenderingContext;
  73562. MSGesture: MSGesture;
  73563. CANNON: any;
  73564. AudioContext: AudioContext;
  73565. webkitAudioContext: AudioContext;
  73566. PointerEvent: any;
  73567. Math: Math;
  73568. Uint8Array: Uint8ArrayConstructor;
  73569. Float32Array: Float32ArrayConstructor;
  73570. mozURL: typeof URL;
  73571. msURL: typeof URL;
  73572. VRFrameData: any; // WebVR, from specs 1.1
  73573. DracoDecoderModule: any;
  73574. setImmediate(handler: (...args: any[]) => void): number;
  73575. }
  73576. interface HTMLCanvasElement {
  73577. requestPointerLock(): void;
  73578. msRequestPointerLock?(): void;
  73579. mozRequestPointerLock?(): void;
  73580. webkitRequestPointerLock?(): void;
  73581. /** Track wether a record is in progress */
  73582. isRecording: boolean;
  73583. /** Capture Stream method defined by some browsers */
  73584. captureStream(fps?: number): MediaStream;
  73585. }
  73586. interface CanvasRenderingContext2D {
  73587. msImageSmoothingEnabled: boolean;
  73588. }
  73589. interface MouseEvent {
  73590. mozMovementX: number;
  73591. mozMovementY: number;
  73592. webkitMovementX: number;
  73593. webkitMovementY: number;
  73594. msMovementX: number;
  73595. msMovementY: number;
  73596. }
  73597. interface Navigator {
  73598. mozGetVRDevices: (any: any) => any;
  73599. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73600. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73601. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73602. webkitGetGamepads(): Gamepad[];
  73603. msGetGamepads(): Gamepad[];
  73604. webkitGamepads(): Gamepad[];
  73605. }
  73606. interface HTMLVideoElement {
  73607. mozSrcObject: any;
  73608. }
  73609. interface Math {
  73610. fround(x: number): number;
  73611. imul(a: number, b: number): number;
  73612. }
  73613. interface WebGLRenderingContext {
  73614. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73615. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73616. vertexAttribDivisor(index: number, divisor: number): void;
  73617. createVertexArray(): any;
  73618. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73619. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73620. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73621. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73622. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73623. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73624. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73625. // Queries
  73626. createQuery(): WebGLQuery;
  73627. deleteQuery(query: WebGLQuery): void;
  73628. beginQuery(target: number, query: WebGLQuery): void;
  73629. endQuery(target: number): void;
  73630. getQueryParameter(query: WebGLQuery, pname: number): any;
  73631. getQuery(target: number, pname: number): any;
  73632. MAX_SAMPLES: number;
  73633. RGBA8: number;
  73634. READ_FRAMEBUFFER: number;
  73635. DRAW_FRAMEBUFFER: number;
  73636. UNIFORM_BUFFER: number;
  73637. HALF_FLOAT_OES: number;
  73638. RGBA16F: number;
  73639. RGBA32F: number;
  73640. R32F: number;
  73641. RG32F: number;
  73642. RGB32F: number;
  73643. R16F: number;
  73644. RG16F: number;
  73645. RGB16F: number;
  73646. RED: number;
  73647. RG: number;
  73648. R8: number;
  73649. RG8: number;
  73650. UNSIGNED_INT_24_8: number;
  73651. DEPTH24_STENCIL8: number;
  73652. MIN: number;
  73653. MAX: number;
  73654. /* Multiple Render Targets */
  73655. drawBuffers(buffers: number[]): void;
  73656. readBuffer(src: number): void;
  73657. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73658. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73659. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73660. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73661. // Occlusion Query
  73662. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73663. ANY_SAMPLES_PASSED: number;
  73664. QUERY_RESULT_AVAILABLE: number;
  73665. QUERY_RESULT: number;
  73666. }
  73667. interface WebGLProgram {
  73668. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73669. }
  73670. interface EXT_disjoint_timer_query {
  73671. QUERY_COUNTER_BITS_EXT: number;
  73672. TIME_ELAPSED_EXT: number;
  73673. TIMESTAMP_EXT: number;
  73674. GPU_DISJOINT_EXT: number;
  73675. QUERY_RESULT_EXT: number;
  73676. QUERY_RESULT_AVAILABLE_EXT: number;
  73677. queryCounterEXT(query: WebGLQuery, target: number): void;
  73678. createQueryEXT(): WebGLQuery;
  73679. beginQueryEXT(target: number, query: WebGLQuery): void;
  73680. endQueryEXT(target: number): void;
  73681. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73682. deleteQueryEXT(query: WebGLQuery): void;
  73683. }
  73684. interface WebGLUniformLocation {
  73685. _currentState: any;
  73686. }
  73687. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73688. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73689. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73690. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73691. interface WebGLRenderingContext {
  73692. readonly RASTERIZER_DISCARD: number;
  73693. readonly DEPTH_COMPONENT24: number;
  73694. readonly TEXTURE_3D: number;
  73695. readonly TEXTURE_2D_ARRAY: number;
  73696. readonly TEXTURE_COMPARE_FUNC: number;
  73697. readonly TEXTURE_COMPARE_MODE: number;
  73698. readonly COMPARE_REF_TO_TEXTURE: number;
  73699. readonly TEXTURE_WRAP_R: number;
  73700. readonly HALF_FLOAT: number;
  73701. readonly RGB8: number;
  73702. readonly RED_INTEGER: number;
  73703. readonly RG_INTEGER: number;
  73704. readonly RGB_INTEGER: number;
  73705. readonly RGBA_INTEGER: number;
  73706. readonly R8_SNORM: number;
  73707. readonly RG8_SNORM: number;
  73708. readonly RGB8_SNORM: number;
  73709. readonly RGBA8_SNORM: number;
  73710. readonly R8I: number;
  73711. readonly RG8I: number;
  73712. readonly RGB8I: number;
  73713. readonly RGBA8I: number;
  73714. readonly R8UI: number;
  73715. readonly RG8UI: number;
  73716. readonly RGB8UI: number;
  73717. readonly RGBA8UI: number;
  73718. readonly R16I: number;
  73719. readonly RG16I: number;
  73720. readonly RGB16I: number;
  73721. readonly RGBA16I: number;
  73722. readonly R16UI: number;
  73723. readonly RG16UI: number;
  73724. readonly RGB16UI: number;
  73725. readonly RGBA16UI: number;
  73726. readonly R32I: number;
  73727. readonly RG32I: number;
  73728. readonly RGB32I: number;
  73729. readonly RGBA32I: number;
  73730. readonly R32UI: number;
  73731. readonly RG32UI: number;
  73732. readonly RGB32UI: number;
  73733. readonly RGBA32UI: number;
  73734. readonly RGB10_A2UI: number;
  73735. readonly R11F_G11F_B10F: number;
  73736. readonly RGB9_E5: number;
  73737. readonly RGB10_A2: number;
  73738. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73739. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73740. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73741. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73742. readonly DEPTH_COMPONENT32F: number;
  73743. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73744. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73745. 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;
  73746. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73747. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73748. readonly TRANSFORM_FEEDBACK: number;
  73749. readonly INTERLEAVED_ATTRIBS: number;
  73750. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73751. createTransformFeedback(): WebGLTransformFeedback;
  73752. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73753. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73754. beginTransformFeedback(primitiveMode: number): void;
  73755. endTransformFeedback(): void;
  73756. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73757. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73758. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73759. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73760. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73761. }
  73762. interface ImageBitmap {
  73763. readonly width: number;
  73764. readonly height: number;
  73765. close(): void;
  73766. }
  73767. interface WebGLQuery extends WebGLObject {
  73768. }
  73769. declare var WebGLQuery: {
  73770. prototype: WebGLQuery;
  73771. new(): WebGLQuery;
  73772. };
  73773. interface WebGLSampler extends WebGLObject {
  73774. }
  73775. declare var WebGLSampler: {
  73776. prototype: WebGLSampler;
  73777. new(): WebGLSampler;
  73778. };
  73779. interface WebGLSync extends WebGLObject {
  73780. }
  73781. declare var WebGLSync: {
  73782. prototype: WebGLSync;
  73783. new(): WebGLSync;
  73784. };
  73785. interface WebGLTransformFeedback extends WebGLObject {
  73786. }
  73787. declare var WebGLTransformFeedback: {
  73788. prototype: WebGLTransformFeedback;
  73789. new(): WebGLTransformFeedback;
  73790. };
  73791. interface WebGLVertexArrayObject extends WebGLObject {
  73792. }
  73793. declare var WebGLVertexArrayObject: {
  73794. prototype: WebGLVertexArrayObject;
  73795. new(): WebGLVertexArrayObject;
  73796. };
  73797. // Type definitions for WebVR API
  73798. // Project: https://w3c.github.io/webvr/
  73799. // Definitions by: six a <https://github.com/lostfictions>
  73800. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73801. interface VRDisplay extends EventTarget {
  73802. /**
  73803. * Dictionary of capabilities describing the VRDisplay.
  73804. */
  73805. readonly capabilities: VRDisplayCapabilities;
  73806. /**
  73807. * z-depth defining the far plane of the eye view frustum
  73808. * enables mapping of values in the render target depth
  73809. * attachment to scene coordinates. Initially set to 10000.0.
  73810. */
  73811. depthFar: number;
  73812. /**
  73813. * z-depth defining the near plane of the eye view frustum
  73814. * enables mapping of values in the render target depth
  73815. * attachment to scene coordinates. Initially set to 0.01.
  73816. */
  73817. depthNear: number;
  73818. /**
  73819. * An identifier for this distinct VRDisplay. Used as an
  73820. * association point in the Gamepad API.
  73821. */
  73822. readonly displayId: number;
  73823. /**
  73824. * A display name, a user-readable name identifying it.
  73825. */
  73826. readonly displayName: string;
  73827. readonly isConnected: boolean;
  73828. readonly isPresenting: boolean;
  73829. /**
  73830. * If this VRDisplay supports room-scale experiences, the optional
  73831. * stage attribute contains details on the room-scale parameters.
  73832. */
  73833. readonly stageParameters: VRStageParameters | null;
  73834. /**
  73835. * Passing the value returned by `requestAnimationFrame` to
  73836. * `cancelAnimationFrame` will unregister the callback.
  73837. * @param handle Define the hanle of the request to cancel
  73838. */
  73839. cancelAnimationFrame(handle: number): void;
  73840. /**
  73841. * Stops presenting to the VRDisplay.
  73842. * @returns a promise to know when it stopped
  73843. */
  73844. exitPresent(): Promise<void>;
  73845. /**
  73846. * Return the current VREyeParameters for the given eye.
  73847. * @param whichEye Define the eye we want the parameter for
  73848. * @returns the eye parameters
  73849. */
  73850. getEyeParameters(whichEye: string): VREyeParameters;
  73851. /**
  73852. * Populates the passed VRFrameData with the information required to render
  73853. * the current frame.
  73854. * @param frameData Define the data structure to populate
  73855. * @returns true if ok otherwise false
  73856. */
  73857. getFrameData(frameData: VRFrameData): boolean;
  73858. /**
  73859. * Get the layers currently being presented.
  73860. * @returns the list of VR layers
  73861. */
  73862. getLayers(): VRLayer[];
  73863. /**
  73864. * Return a VRPose containing the future predicted pose of the VRDisplay
  73865. * when the current frame will be presented. The value returned will not
  73866. * change until JavaScript has returned control to the browser.
  73867. *
  73868. * The VRPose will contain the position, orientation, velocity,
  73869. * and acceleration of each of these properties.
  73870. * @returns the pose object
  73871. */
  73872. getPose(): VRPose;
  73873. /**
  73874. * Return the current instantaneous pose of the VRDisplay, with no
  73875. * prediction applied.
  73876. * @returns the current instantaneous pose
  73877. */
  73878. getImmediatePose(): VRPose;
  73879. /**
  73880. * The callback passed to `requestAnimationFrame` will be called
  73881. * any time a new frame should be rendered. When the VRDisplay is
  73882. * presenting the callback will be called at the native refresh
  73883. * rate of the HMD. When not presenting this function acts
  73884. * identically to how window.requestAnimationFrame acts. Content should
  73885. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73886. * asynchronously from other displays and at differing refresh rates.
  73887. * @param callback Define the eaction to run next frame
  73888. * @returns the request handle it
  73889. */
  73890. requestAnimationFrame(callback: FrameRequestCallback): number;
  73891. /**
  73892. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73893. * Repeat calls while already presenting will update the VRLayers being displayed.
  73894. * @param layers Define the list of layer to present
  73895. * @returns a promise to know when the request has been fulfilled
  73896. */
  73897. requestPresent(layers: VRLayer[]): Promise<void>;
  73898. /**
  73899. * Reset the pose for this display, treating its current position and
  73900. * orientation as the "origin/zero" values. VRPose.position,
  73901. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73902. * updated when calling resetPose(). This should be called in only
  73903. * sitting-space experiences.
  73904. */
  73905. resetPose(): void;
  73906. /**
  73907. * The VRLayer provided to the VRDisplay will be captured and presented
  73908. * in the HMD. Calling this function has the same effect on the source
  73909. * canvas as any other operation that uses its source image, and canvases
  73910. * created without preserveDrawingBuffer set to true will be cleared.
  73911. * @param pose Define the pose to submit
  73912. */
  73913. submitFrame(pose?: VRPose): void;
  73914. }
  73915. declare var VRDisplay: {
  73916. prototype: VRDisplay;
  73917. new(): VRDisplay;
  73918. };
  73919. interface VRLayer {
  73920. leftBounds?: number[] | Float32Array | null;
  73921. rightBounds?: number[] | Float32Array | null;
  73922. source?: HTMLCanvasElement | null;
  73923. }
  73924. interface VRDisplayCapabilities {
  73925. readonly canPresent: boolean;
  73926. readonly hasExternalDisplay: boolean;
  73927. readonly hasOrientation: boolean;
  73928. readonly hasPosition: boolean;
  73929. readonly maxLayers: number;
  73930. }
  73931. interface VREyeParameters {
  73932. /** @deprecated */
  73933. readonly fieldOfView: VRFieldOfView;
  73934. readonly offset: Float32Array;
  73935. readonly renderHeight: number;
  73936. readonly renderWidth: number;
  73937. }
  73938. interface VRFieldOfView {
  73939. readonly downDegrees: number;
  73940. readonly leftDegrees: number;
  73941. readonly rightDegrees: number;
  73942. readonly upDegrees: number;
  73943. }
  73944. interface VRFrameData {
  73945. readonly leftProjectionMatrix: Float32Array;
  73946. readonly leftViewMatrix: Float32Array;
  73947. readonly pose: VRPose;
  73948. readonly rightProjectionMatrix: Float32Array;
  73949. readonly rightViewMatrix: Float32Array;
  73950. readonly timestamp: number;
  73951. }
  73952. interface VRPose {
  73953. readonly angularAcceleration: Float32Array | null;
  73954. readonly angularVelocity: Float32Array | null;
  73955. readonly linearAcceleration: Float32Array | null;
  73956. readonly linearVelocity: Float32Array | null;
  73957. readonly orientation: Float32Array | null;
  73958. readonly position: Float32Array | null;
  73959. readonly timestamp: number;
  73960. }
  73961. interface VRStageParameters {
  73962. sittingToStandingTransform?: Float32Array;
  73963. sizeX?: number;
  73964. sizeY?: number;
  73965. }
  73966. interface Navigator {
  73967. getVRDisplays(): Promise<VRDisplay[]>;
  73968. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73969. }
  73970. interface Window {
  73971. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73972. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73973. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73974. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73975. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73976. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73977. }
  73978. interface Gamepad {
  73979. readonly displayId: number;
  73980. }
  73981. type XRSessionMode =
  73982. | "inline"
  73983. | "immersive-vr"
  73984. | "immersive-ar";
  73985. type XRReferenceSpaceType =
  73986. | "viewer"
  73987. | "local"
  73988. | "local-floor"
  73989. | "bounded-floor"
  73990. | "unbounded";
  73991. type XREnvironmentBlendMode =
  73992. | "opaque"
  73993. | "additive"
  73994. | "alpha-blend";
  73995. type XRVisibilityState =
  73996. | "visible"
  73997. | "visible-blurred"
  73998. | "hidden";
  73999. type XRHandedness =
  74000. | "none"
  74001. | "left"
  74002. | "right";
  74003. type XRTargetRayMode =
  74004. | "gaze"
  74005. | "tracked-pointer"
  74006. | "screen";
  74007. type XREye =
  74008. | "none"
  74009. | "left"
  74010. | "right";
  74011. type XREventType =
  74012. | "devicechange"
  74013. | "visibilitychange"
  74014. | "end"
  74015. | "inputsourceschange"
  74016. | "select"
  74017. | "selectstart"
  74018. | "selectend"
  74019. | "squeeze"
  74020. | "squeezestart"
  74021. | "squeezeend"
  74022. | "reset";
  74023. interface XRSpace extends EventTarget {
  74024. }
  74025. interface XRRenderState {
  74026. depthNear?: number;
  74027. depthFar?: number;
  74028. inlineVerticalFieldOfView?: number;
  74029. baseLayer?: XRWebGLLayer;
  74030. }
  74031. interface XRInputSource {
  74032. handedness: XRHandedness;
  74033. targetRayMode: XRTargetRayMode;
  74034. targetRaySpace: XRSpace;
  74035. gripSpace: XRSpace | undefined;
  74036. gamepad: Gamepad | undefined;
  74037. profiles: Array<string>;
  74038. }
  74039. interface XRSessionInit {
  74040. optionalFeatures?: string[];
  74041. requiredFeatures?: string[];
  74042. }
  74043. interface XRSession {
  74044. addEventListener: Function;
  74045. removeEventListener: Function;
  74046. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74047. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74048. requestAnimationFrame: Function;
  74049. end(): Promise<void>;
  74050. renderState: XRRenderState;
  74051. inputSources: Array<XRInputSource>;
  74052. // hit test
  74053. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74054. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74055. // legacy AR hit test
  74056. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74057. // legacy plane detection
  74058. updateWorldTrackingState(options: {
  74059. planeDetectionState?: { enabled: boolean; }
  74060. }): void;
  74061. }
  74062. interface XRReferenceSpace extends XRSpace {
  74063. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74064. onreset: any;
  74065. }
  74066. type XRPlaneSet = Set<XRPlane>;
  74067. type XRAnchorSet = Set<XRAnchor>;
  74068. interface XRFrame {
  74069. session: XRSession;
  74070. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74071. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74072. // AR
  74073. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74074. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74075. // Anchors
  74076. trackedAnchors?: XRAnchorSet;
  74077. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74078. // Planes
  74079. worldInformation: {
  74080. detectedPlanes?: XRPlaneSet;
  74081. };
  74082. }
  74083. interface XRViewerPose extends XRPose {
  74084. views: Array<XRView>;
  74085. }
  74086. interface XRPose {
  74087. transform: XRRigidTransform;
  74088. emulatedPosition: boolean;
  74089. }
  74090. interface XRWebGLLayerOptions {
  74091. antialias?: boolean;
  74092. depth?: boolean;
  74093. stencil?: boolean;
  74094. alpha?: boolean;
  74095. multiview?: boolean;
  74096. framebufferScaleFactor?: number;
  74097. }
  74098. declare var XRWebGLLayer: {
  74099. prototype: XRWebGLLayer;
  74100. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74101. };
  74102. interface XRWebGLLayer {
  74103. framebuffer: WebGLFramebuffer;
  74104. framebufferWidth: number;
  74105. framebufferHeight: number;
  74106. getViewport: Function;
  74107. }
  74108. declare class XRRigidTransform {
  74109. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74110. position: DOMPointReadOnly;
  74111. orientation: DOMPointReadOnly;
  74112. matrix: Float32Array;
  74113. inverse: XRRigidTransform;
  74114. }
  74115. interface XRView {
  74116. eye: XREye;
  74117. projectionMatrix: Float32Array;
  74118. transform: XRRigidTransform;
  74119. }
  74120. interface XRInputSourceChangeEvent {
  74121. session: XRSession;
  74122. removed: Array<XRInputSource>;
  74123. added: Array<XRInputSource>;
  74124. }
  74125. interface XRInputSourceEvent extends Event {
  74126. readonly frame: XRFrame;
  74127. readonly inputSource: XRInputSource;
  74128. }
  74129. // Experimental(er) features
  74130. declare class XRRay {
  74131. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74132. origin: DOMPointReadOnly;
  74133. direction: DOMPointReadOnly;
  74134. matrix: Float32Array;
  74135. }
  74136. declare enum XRHitTestTrackableType {
  74137. "point",
  74138. "plane"
  74139. }
  74140. interface XRHitResult {
  74141. hitMatrix: Float32Array;
  74142. }
  74143. interface XRTransientInputHitTestResult {
  74144. readonly inputSource: XRInputSource;
  74145. readonly results: Array<XRHitTestResult>;
  74146. }
  74147. interface XRHitTestResult {
  74148. getPose(baseSpace: XRSpace): XRPose | undefined;
  74149. // When anchor system is enabled
  74150. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74151. }
  74152. interface XRHitTestSource {
  74153. cancel(): void;
  74154. }
  74155. interface XRTransientInputHitTestSource {
  74156. cancel(): void;
  74157. }
  74158. interface XRHitTestOptionsInit {
  74159. space: XRSpace;
  74160. entityTypes?: Array<XRHitTestTrackableType>;
  74161. offsetRay?: XRRay;
  74162. }
  74163. interface XRTransientInputHitTestOptionsInit {
  74164. profile: string;
  74165. entityTypes?: Array<XRHitTestTrackableType>;
  74166. offsetRay?: XRRay;
  74167. }
  74168. interface XRAnchor {
  74169. anchorSpace: XRSpace;
  74170. delete(): void;
  74171. }
  74172. interface XRPlane {
  74173. orientation: "Horizontal" | "Vertical";
  74174. planeSpace: XRSpace;
  74175. polygon: Array<DOMPointReadOnly>;
  74176. lastChangedTime: number;
  74177. }
  74178. /**
  74179. * @ignore
  74180. */
  74181. declare module BABYLON.GLTF2.Exporter {
  74182. }
  74183. /**
  74184. * @ignore
  74185. */
  74186. declare module BABYLON.GLTF1 {
  74187. }
  74188. declare module BABYLON.GUI {
  74189. /**
  74190. * Class used to specific a value and its associated unit
  74191. */
  74192. export class ValueAndUnit {
  74193. /** defines the unit to store */
  74194. unit: number;
  74195. /** defines a boolean indicating if the value can be negative */
  74196. negativeValueAllowed: boolean;
  74197. private _value;
  74198. private _originalUnit;
  74199. /**
  74200. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74201. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74202. */
  74203. ignoreAdaptiveScaling: boolean;
  74204. /**
  74205. * Creates a new ValueAndUnit
  74206. * @param value defines the value to store
  74207. * @param unit defines the unit to store
  74208. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74209. */
  74210. constructor(value: number,
  74211. /** defines the unit to store */
  74212. unit?: number,
  74213. /** defines a boolean indicating if the value can be negative */
  74214. negativeValueAllowed?: boolean);
  74215. /** Gets a boolean indicating if the value is a percentage */
  74216. get isPercentage(): boolean;
  74217. /** Gets a boolean indicating if the value is store as pixel */
  74218. get isPixel(): boolean;
  74219. /** Gets direct internal value */
  74220. get internalValue(): number;
  74221. /**
  74222. * Gets value as pixel
  74223. * @param host defines the root host
  74224. * @param refValue defines the reference value for percentages
  74225. * @returns the value as pixel
  74226. */
  74227. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74228. /**
  74229. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74230. * @param value defines the value to store
  74231. * @param unit defines the unit to store
  74232. * @returns the current ValueAndUnit
  74233. */
  74234. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74235. /**
  74236. * Gets the value accordingly to its unit
  74237. * @param host defines the root host
  74238. * @returns the value
  74239. */
  74240. getValue(host: AdvancedDynamicTexture): number;
  74241. /**
  74242. * Gets a string representation of the value
  74243. * @param host defines the root host
  74244. * @param decimals defines an optional number of decimals to display
  74245. * @returns a string
  74246. */
  74247. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74248. /**
  74249. * Store a value parsed from a string
  74250. * @param source defines the source string
  74251. * @returns true if the value was successfully parsed
  74252. */
  74253. fromString(source: string | number): boolean;
  74254. private static _Regex;
  74255. private static _UNITMODE_PERCENTAGE;
  74256. private static _UNITMODE_PIXEL;
  74257. /** UNITMODE_PERCENTAGE */
  74258. static get UNITMODE_PERCENTAGE(): number;
  74259. /** UNITMODE_PIXEL */
  74260. static get UNITMODE_PIXEL(): number;
  74261. }
  74262. }
  74263. declare module BABYLON.GUI {
  74264. /**
  74265. * Define a style used by control to automatically setup properties based on a template.
  74266. * Only support font related properties so far
  74267. */
  74268. export class Style implements BABYLON.IDisposable {
  74269. private _fontFamily;
  74270. private _fontStyle;
  74271. private _fontWeight;
  74272. /** @hidden */
  74273. _host: AdvancedDynamicTexture;
  74274. /** @hidden */
  74275. _fontSize: ValueAndUnit;
  74276. /**
  74277. * BABYLON.Observable raised when the style values are changed
  74278. */
  74279. onChangedObservable: BABYLON.Observable<Style>;
  74280. /**
  74281. * Creates a new style object
  74282. * @param host defines the AdvancedDynamicTexture which hosts this style
  74283. */
  74284. constructor(host: AdvancedDynamicTexture);
  74285. /**
  74286. * Gets or sets the font size
  74287. */
  74288. get fontSize(): string | number;
  74289. set fontSize(value: string | number);
  74290. /**
  74291. * Gets or sets the font family
  74292. */
  74293. get fontFamily(): string;
  74294. set fontFamily(value: string);
  74295. /**
  74296. * Gets or sets the font style
  74297. */
  74298. get fontStyle(): string;
  74299. set fontStyle(value: string);
  74300. /** Gets or sets font weight */
  74301. get fontWeight(): string;
  74302. set fontWeight(value: string);
  74303. /** Dispose all associated resources */
  74304. dispose(): void;
  74305. }
  74306. }
  74307. declare module BABYLON.GUI {
  74308. /**
  74309. * Class used to transport BABYLON.Vector2 information for pointer events
  74310. */
  74311. export class Vector2WithInfo extends BABYLON.Vector2 {
  74312. /** defines the current mouse button index */
  74313. buttonIndex: number;
  74314. /**
  74315. * Creates a new Vector2WithInfo
  74316. * @param source defines the vector2 data to transport
  74317. * @param buttonIndex defines the current mouse button index
  74318. */
  74319. constructor(source: BABYLON.Vector2,
  74320. /** defines the current mouse button index */
  74321. buttonIndex?: number);
  74322. }
  74323. /** Class used to provide 2D matrix features */
  74324. export class Matrix2D {
  74325. /** Gets the internal array of 6 floats used to store matrix data */
  74326. m: Float32Array;
  74327. /**
  74328. * Creates a new matrix
  74329. * @param m00 defines value for (0, 0)
  74330. * @param m01 defines value for (0, 1)
  74331. * @param m10 defines value for (1, 0)
  74332. * @param m11 defines value for (1, 1)
  74333. * @param m20 defines value for (2, 0)
  74334. * @param m21 defines value for (2, 1)
  74335. */
  74336. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74337. /**
  74338. * Fills the matrix from direct values
  74339. * @param m00 defines value for (0, 0)
  74340. * @param m01 defines value for (0, 1)
  74341. * @param m10 defines value for (1, 0)
  74342. * @param m11 defines value for (1, 1)
  74343. * @param m20 defines value for (2, 0)
  74344. * @param m21 defines value for (2, 1)
  74345. * @returns the current modified matrix
  74346. */
  74347. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74348. /**
  74349. * Gets matrix determinant
  74350. * @returns the determinant
  74351. */
  74352. determinant(): number;
  74353. /**
  74354. * Inverses the matrix and stores it in a target matrix
  74355. * @param result defines the target matrix
  74356. * @returns the current matrix
  74357. */
  74358. invertToRef(result: Matrix2D): Matrix2D;
  74359. /**
  74360. * Multiplies the current matrix with another one
  74361. * @param other defines the second operand
  74362. * @param result defines the target matrix
  74363. * @returns the current matrix
  74364. */
  74365. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74366. /**
  74367. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74368. * @param x defines the x coordinate to transform
  74369. * @param y defines the x coordinate to transform
  74370. * @param result defines the target vector2
  74371. * @returns the current matrix
  74372. */
  74373. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74374. /**
  74375. * Creates an identity matrix
  74376. * @returns a new matrix
  74377. */
  74378. static Identity(): Matrix2D;
  74379. /**
  74380. * Creates a translation matrix and stores it in a target matrix
  74381. * @param x defines the x coordinate of the translation
  74382. * @param y defines the y coordinate of the translation
  74383. * @param result defines the target matrix
  74384. */
  74385. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74386. /**
  74387. * Creates a scaling matrix and stores it in a target matrix
  74388. * @param x defines the x coordinate of the scaling
  74389. * @param y defines the y coordinate of the scaling
  74390. * @param result defines the target matrix
  74391. */
  74392. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74393. /**
  74394. * Creates a rotation matrix and stores it in a target matrix
  74395. * @param angle defines the rotation angle
  74396. * @param result defines the target matrix
  74397. */
  74398. static RotationToRef(angle: number, result: Matrix2D): void;
  74399. private static _TempPreTranslationMatrix;
  74400. private static _TempPostTranslationMatrix;
  74401. private static _TempRotationMatrix;
  74402. private static _TempScalingMatrix;
  74403. private static _TempCompose0;
  74404. private static _TempCompose1;
  74405. private static _TempCompose2;
  74406. /**
  74407. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74408. * @param tx defines the x coordinate of the translation
  74409. * @param ty defines the y coordinate of the translation
  74410. * @param angle defines the rotation angle
  74411. * @param scaleX defines the x coordinate of the scaling
  74412. * @param scaleY defines the y coordinate of the scaling
  74413. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74414. * @param result defines the target matrix
  74415. */
  74416. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74417. }
  74418. }
  74419. declare module BABYLON.GUI {
  74420. /**
  74421. * Class used to store 2D control sizes
  74422. */
  74423. export class Measure {
  74424. /** defines left coordinate */
  74425. left: number;
  74426. /** defines top coordinate */
  74427. top: number;
  74428. /** defines width dimension */
  74429. width: number;
  74430. /** defines height dimension */
  74431. height: number;
  74432. /**
  74433. * Creates a new measure
  74434. * @param left defines left coordinate
  74435. * @param top defines top coordinate
  74436. * @param width defines width dimension
  74437. * @param height defines height dimension
  74438. */
  74439. constructor(
  74440. /** defines left coordinate */
  74441. left: number,
  74442. /** defines top coordinate */
  74443. top: number,
  74444. /** defines width dimension */
  74445. width: number,
  74446. /** defines height dimension */
  74447. height: number);
  74448. /**
  74449. * Copy from another measure
  74450. * @param other defines the other measure to copy from
  74451. */
  74452. copyFrom(other: Measure): void;
  74453. /**
  74454. * Copy from a group of 4 floats
  74455. * @param left defines left coordinate
  74456. * @param top defines top coordinate
  74457. * @param width defines width dimension
  74458. * @param height defines height dimension
  74459. */
  74460. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74461. /**
  74462. * Computes the axis aligned bounding box measure for two given measures
  74463. * @param a Input measure
  74464. * @param b Input measure
  74465. * @param result the resulting bounding measure
  74466. */
  74467. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74468. /**
  74469. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74470. * @param transform the matrix to transform the measure before computing the AABB
  74471. * @param result the resulting AABB
  74472. */
  74473. transformToRef(transform: Matrix2D, result: Measure): void;
  74474. /**
  74475. * Check equality between this measure and another one
  74476. * @param other defines the other measures
  74477. * @returns true if both measures are equals
  74478. */
  74479. isEqualsTo(other: Measure): boolean;
  74480. /**
  74481. * Creates an empty measure
  74482. * @returns a new measure
  74483. */
  74484. static Empty(): Measure;
  74485. }
  74486. }
  74487. declare module BABYLON.GUI {
  74488. /**
  74489. * Interface used to define a control that can receive focus
  74490. */
  74491. export interface IFocusableControl {
  74492. /**
  74493. * Function called when the control receives the focus
  74494. */
  74495. onFocus(): void;
  74496. /**
  74497. * Function called when the control loses the focus
  74498. */
  74499. onBlur(): void;
  74500. /**
  74501. * Function called to let the control handle keyboard events
  74502. * @param evt defines the current keyboard event
  74503. */
  74504. processKeyboard(evt: KeyboardEvent): void;
  74505. /**
  74506. * Function called to get the list of controls that should not steal the focus from this control
  74507. * @returns an array of controls
  74508. */
  74509. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74510. }
  74511. /**
  74512. * Class used to create texture to support 2D GUI elements
  74513. * @see http://doc.babylonjs.com/how_to/gui
  74514. */
  74515. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74516. private _isDirty;
  74517. private _renderObserver;
  74518. private _resizeObserver;
  74519. private _preKeyboardObserver;
  74520. private _pointerMoveObserver;
  74521. private _pointerObserver;
  74522. private _canvasPointerOutObserver;
  74523. private _background;
  74524. /** @hidden */
  74525. _rootContainer: Container;
  74526. /** @hidden */
  74527. _lastPickedControl: Control;
  74528. /** @hidden */
  74529. _lastControlOver: {
  74530. [pointerId: number]: Control;
  74531. };
  74532. /** @hidden */
  74533. _lastControlDown: {
  74534. [pointerId: number]: Control;
  74535. };
  74536. /** @hidden */
  74537. _capturingControl: {
  74538. [pointerId: number]: Control;
  74539. };
  74540. /** @hidden */
  74541. _shouldBlockPointer: boolean;
  74542. /** @hidden */
  74543. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74544. /** @hidden */
  74545. _linkedControls: Control[];
  74546. private _isFullscreen;
  74547. private _fullscreenViewport;
  74548. private _idealWidth;
  74549. private _idealHeight;
  74550. private _useSmallestIdeal;
  74551. private _renderAtIdealSize;
  74552. private _focusedControl;
  74553. private _blockNextFocusCheck;
  74554. private _renderScale;
  74555. private _rootElement;
  74556. private _cursorChanged;
  74557. private _defaultMousePointerId;
  74558. /** @hidden */
  74559. _numLayoutCalls: number;
  74560. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74561. get numLayoutCalls(): number;
  74562. /** @hidden */
  74563. _numRenderCalls: number;
  74564. /** Gets the number of render calls made the last time the ADT has been rendered */
  74565. get numRenderCalls(): number;
  74566. /**
  74567. * Define type to string to ensure compatibility across browsers
  74568. * Safari doesn't support DataTransfer constructor
  74569. */
  74570. private _clipboardData;
  74571. /**
  74572. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74573. */
  74574. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74575. /**
  74576. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74577. */
  74578. onControlPickedObservable: BABYLON.Observable<Control>;
  74579. /**
  74580. * BABYLON.Observable event triggered before layout is evaluated
  74581. */
  74582. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74583. /**
  74584. * BABYLON.Observable event triggered after the layout was evaluated
  74585. */
  74586. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74587. /**
  74588. * BABYLON.Observable event triggered before the texture is rendered
  74589. */
  74590. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74591. /**
  74592. * BABYLON.Observable event triggered after the texture was rendered
  74593. */
  74594. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74595. /**
  74596. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74597. */
  74598. premulAlpha: boolean;
  74599. /**
  74600. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74601. * Useful when you want more antialiasing
  74602. */
  74603. get renderScale(): number;
  74604. set renderScale(value: number);
  74605. /** Gets or sets the background color */
  74606. get background(): string;
  74607. set background(value: string);
  74608. /**
  74609. * Gets or sets the ideal width used to design controls.
  74610. * The GUI will then rescale everything accordingly
  74611. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74612. */
  74613. get idealWidth(): number;
  74614. set idealWidth(value: number);
  74615. /**
  74616. * Gets or sets the ideal height used to design controls.
  74617. * The GUI will then rescale everything accordingly
  74618. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74619. */
  74620. get idealHeight(): number;
  74621. set idealHeight(value: number);
  74622. /**
  74623. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74624. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74625. */
  74626. get useSmallestIdeal(): boolean;
  74627. set useSmallestIdeal(value: boolean);
  74628. /**
  74629. * Gets or sets a boolean indicating if adaptive scaling must be used
  74630. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74631. */
  74632. get renderAtIdealSize(): boolean;
  74633. set renderAtIdealSize(value: boolean);
  74634. /**
  74635. * Gets the ratio used when in "ideal mode"
  74636. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74637. * */
  74638. get idealRatio(): number;
  74639. /**
  74640. * Gets the underlying layer used to render the texture when in fullscreen mode
  74641. */
  74642. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74643. /**
  74644. * Gets the root container control
  74645. */
  74646. get rootContainer(): Container;
  74647. /**
  74648. * Returns an array containing the root container.
  74649. * This is mostly used to let the Inspector introspects the ADT
  74650. * @returns an array containing the rootContainer
  74651. */
  74652. getChildren(): Array<Container>;
  74653. /**
  74654. * Will return all controls that are inside this texture
  74655. * @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
  74656. * @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
  74657. * @return all child controls
  74658. */
  74659. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74660. /**
  74661. * Gets or sets the current focused control
  74662. */
  74663. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74664. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74665. /**
  74666. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74667. */
  74668. get isForeground(): boolean;
  74669. set isForeground(value: boolean);
  74670. /**
  74671. * Gets or set information about clipboardData
  74672. */
  74673. get clipboardData(): string;
  74674. set clipboardData(value: string);
  74675. /**
  74676. * Creates a new AdvancedDynamicTexture
  74677. * @param name defines the name of the texture
  74678. * @param width defines the width of the texture
  74679. * @param height defines the height of the texture
  74680. * @param scene defines the hosting scene
  74681. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74682. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74683. */
  74684. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74685. /**
  74686. * Get the current class name of the texture useful for serialization or dynamic coding.
  74687. * @returns "AdvancedDynamicTexture"
  74688. */
  74689. getClassName(): string;
  74690. /**
  74691. * Function used to execute a function on all controls
  74692. * @param func defines the function to execute
  74693. * @param container defines the container where controls belong. If null the root container will be used
  74694. */
  74695. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74696. private _useInvalidateRectOptimization;
  74697. /**
  74698. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74699. */
  74700. get useInvalidateRectOptimization(): boolean;
  74701. set useInvalidateRectOptimization(value: boolean);
  74702. private _invalidatedRectangle;
  74703. /**
  74704. * Invalidates a rectangle area on the gui texture
  74705. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74706. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74707. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74708. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74709. */
  74710. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74711. /**
  74712. * Marks the texture as dirty forcing a complete update
  74713. */
  74714. markAsDirty(): void;
  74715. /**
  74716. * Helper function used to create a new style
  74717. * @returns a new style
  74718. * @see http://doc.babylonjs.com/how_to/gui#styles
  74719. */
  74720. createStyle(): Style;
  74721. /**
  74722. * Adds a new control to the root container
  74723. * @param control defines the control to add
  74724. * @returns the current texture
  74725. */
  74726. addControl(control: Control): AdvancedDynamicTexture;
  74727. /**
  74728. * Removes a control from the root container
  74729. * @param control defines the control to remove
  74730. * @returns the current texture
  74731. */
  74732. removeControl(control: Control): AdvancedDynamicTexture;
  74733. /**
  74734. * Release all resources
  74735. */
  74736. dispose(): void;
  74737. private _onResize;
  74738. /** @hidden */
  74739. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74740. /**
  74741. * Get screen coordinates for a vector3
  74742. * @param position defines the position to project
  74743. * @param worldMatrix defines the world matrix to use
  74744. * @returns the projected position
  74745. */
  74746. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74747. private _checkUpdate;
  74748. private _clearMeasure;
  74749. private _render;
  74750. /** @hidden */
  74751. _changeCursor(cursor: string): void;
  74752. /** @hidden */
  74753. _registerLastControlDown(control: Control, pointerId: number): void;
  74754. private _doPicking;
  74755. /** @hidden */
  74756. _cleanControlAfterRemovalFromList(list: {
  74757. [pointerId: number]: Control;
  74758. }, control: Control): void;
  74759. /** @hidden */
  74760. _cleanControlAfterRemoval(control: Control): void;
  74761. /** Attach to all scene events required to support pointer events */
  74762. attach(): void;
  74763. /** @hidden */
  74764. private onClipboardCopy;
  74765. /** @hidden */
  74766. private onClipboardCut;
  74767. /** @hidden */
  74768. private onClipboardPaste;
  74769. /**
  74770. * Register the clipboard Events onto the canvas
  74771. */
  74772. registerClipboardEvents(): void;
  74773. /**
  74774. * Unregister the clipboard Events from the canvas
  74775. */
  74776. unRegisterClipboardEvents(): void;
  74777. /**
  74778. * Connect the texture to a hosting mesh to enable interactions
  74779. * @param mesh defines the mesh to attach to
  74780. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74781. */
  74782. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74783. /**
  74784. * Move the focus to a specific control
  74785. * @param control defines the control which will receive the focus
  74786. */
  74787. moveFocusToControl(control: IFocusableControl): void;
  74788. private _manageFocus;
  74789. private _attachToOnPointerOut;
  74790. /**
  74791. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74792. * @param mesh defines the mesh which will receive the texture
  74793. * @param width defines the texture width (1024 by default)
  74794. * @param height defines the texture height (1024 by default)
  74795. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74796. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74797. * @returns a new AdvancedDynamicTexture
  74798. */
  74799. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74800. /**
  74801. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74802. * In this mode the texture will rely on a layer for its rendering.
  74803. * This allows it to be treated like any other layer.
  74804. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74805. * LayerMask is set through advancedTexture.layer.layerMask
  74806. * @param name defines name for the texture
  74807. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74808. * @param scene defines the hsoting scene
  74809. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74810. * @returns a new AdvancedDynamicTexture
  74811. */
  74812. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74813. }
  74814. }
  74815. declare module BABYLON.GUI {
  74816. /**
  74817. * Root class used for all 2D controls
  74818. * @see http://doc.babylonjs.com/how_to/gui#controls
  74819. */
  74820. export class Control {
  74821. /** defines the name of the control */
  74822. name?: string | undefined;
  74823. /**
  74824. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74825. */
  74826. static AllowAlphaInheritance: boolean;
  74827. private _alpha;
  74828. private _alphaSet;
  74829. private _zIndex;
  74830. /** @hidden */
  74831. _host: AdvancedDynamicTexture;
  74832. /** Gets or sets the control parent */
  74833. parent: BABYLON.Nullable<Container>;
  74834. /** @hidden */
  74835. _currentMeasure: Measure;
  74836. private _fontFamily;
  74837. private _fontStyle;
  74838. private _fontWeight;
  74839. private _fontSize;
  74840. private _font;
  74841. /** @hidden */
  74842. _width: ValueAndUnit;
  74843. /** @hidden */
  74844. _height: ValueAndUnit;
  74845. /** @hidden */
  74846. protected _fontOffset: {
  74847. ascent: number;
  74848. height: number;
  74849. descent: number;
  74850. };
  74851. private _color;
  74852. private _style;
  74853. private _styleObserver;
  74854. /** @hidden */
  74855. protected _horizontalAlignment: number;
  74856. /** @hidden */
  74857. protected _verticalAlignment: number;
  74858. /** @hidden */
  74859. protected _isDirty: boolean;
  74860. /** @hidden */
  74861. protected _wasDirty: boolean;
  74862. /** @hidden */
  74863. _tempParentMeasure: Measure;
  74864. /** @hidden */
  74865. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74866. /** @hidden */
  74867. protected _cachedParentMeasure: Measure;
  74868. private _paddingLeft;
  74869. private _paddingRight;
  74870. private _paddingTop;
  74871. private _paddingBottom;
  74872. /** @hidden */
  74873. _left: ValueAndUnit;
  74874. /** @hidden */
  74875. _top: ValueAndUnit;
  74876. private _scaleX;
  74877. private _scaleY;
  74878. private _rotation;
  74879. private _transformCenterX;
  74880. private _transformCenterY;
  74881. /** @hidden */
  74882. _transformMatrix: Matrix2D;
  74883. /** @hidden */
  74884. protected _invertTransformMatrix: Matrix2D;
  74885. /** @hidden */
  74886. protected _transformedPosition: BABYLON.Vector2;
  74887. private _isMatrixDirty;
  74888. private _cachedOffsetX;
  74889. private _cachedOffsetY;
  74890. private _isVisible;
  74891. private _isHighlighted;
  74892. /** @hidden */
  74893. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74894. private _fontSet;
  74895. private _dummyVector2;
  74896. private _downCount;
  74897. private _enterCount;
  74898. private _doNotRender;
  74899. private _downPointerIds;
  74900. protected _isEnabled: boolean;
  74901. protected _disabledColor: string;
  74902. protected _disabledColorItem: string;
  74903. /** @hidden */
  74904. protected _rebuildLayout: boolean;
  74905. /** @hidden */
  74906. _customData: any;
  74907. /** @hidden */
  74908. _isClipped: boolean;
  74909. /** @hidden */
  74910. _automaticSize: boolean;
  74911. /** @hidden */
  74912. _tag: any;
  74913. /**
  74914. * 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
  74915. */
  74916. uniqueId: number;
  74917. /**
  74918. * Gets or sets an object used to store user defined information for the node
  74919. */
  74920. metadata: any;
  74921. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74922. isHitTestVisible: boolean;
  74923. /** Gets or sets a boolean indicating if the control can block pointer events */
  74924. isPointerBlocker: boolean;
  74925. /** Gets or sets a boolean indicating if the control can be focusable */
  74926. isFocusInvisible: boolean;
  74927. /**
  74928. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74929. * 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
  74930. */
  74931. clipChildren: boolean;
  74932. /**
  74933. * Gets or sets a boolean indicating that control content must be clipped
  74934. * 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
  74935. */
  74936. clipContent: boolean;
  74937. /**
  74938. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74939. */
  74940. useBitmapCache: boolean;
  74941. private _cacheData;
  74942. private _shadowOffsetX;
  74943. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74944. get shadowOffsetX(): number;
  74945. set shadowOffsetX(value: number);
  74946. private _shadowOffsetY;
  74947. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74948. get shadowOffsetY(): number;
  74949. set shadowOffsetY(value: number);
  74950. private _shadowBlur;
  74951. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74952. get shadowBlur(): number;
  74953. set shadowBlur(value: number);
  74954. private _shadowColor;
  74955. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74956. get shadowColor(): string;
  74957. set shadowColor(value: string);
  74958. /** Gets or sets the cursor to use when the control is hovered */
  74959. hoverCursor: string;
  74960. /** @hidden */
  74961. protected _linkOffsetX: ValueAndUnit;
  74962. /** @hidden */
  74963. protected _linkOffsetY: ValueAndUnit;
  74964. /** Gets the control type name */
  74965. get typeName(): string;
  74966. /**
  74967. * Get the current class name of the control.
  74968. * @returns current class name
  74969. */
  74970. getClassName(): string;
  74971. /**
  74972. * An event triggered when pointer wheel is scrolled
  74973. */
  74974. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74975. /**
  74976. * An event triggered when the pointer move over the control.
  74977. */
  74978. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74979. /**
  74980. * An event triggered when the pointer move out of the control.
  74981. */
  74982. onPointerOutObservable: BABYLON.Observable<Control>;
  74983. /**
  74984. * An event triggered when the pointer taps the control
  74985. */
  74986. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74987. /**
  74988. * An event triggered when pointer up
  74989. */
  74990. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74991. /**
  74992. * An event triggered when a control is clicked on
  74993. */
  74994. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  74995. /**
  74996. * An event triggered when pointer enters the control
  74997. */
  74998. onPointerEnterObservable: BABYLON.Observable<Control>;
  74999. /**
  75000. * An event triggered when the control is marked as dirty
  75001. */
  75002. onDirtyObservable: BABYLON.Observable<Control>;
  75003. /**
  75004. * An event triggered before drawing the control
  75005. */
  75006. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75007. /**
  75008. * An event triggered after the control was drawn
  75009. */
  75010. onAfterDrawObservable: BABYLON.Observable<Control>;
  75011. /**
  75012. * An event triggered when the control has been disposed
  75013. */
  75014. onDisposeObservable: BABYLON.Observable<Control>;
  75015. /**
  75016. * Get the hosting AdvancedDynamicTexture
  75017. */
  75018. get host(): AdvancedDynamicTexture;
  75019. /** Gets or set information about font offsets (used to render and align text) */
  75020. get fontOffset(): {
  75021. ascent: number;
  75022. height: number;
  75023. descent: number;
  75024. };
  75025. set fontOffset(offset: {
  75026. ascent: number;
  75027. height: number;
  75028. descent: number;
  75029. });
  75030. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75031. get alpha(): number;
  75032. set alpha(value: number);
  75033. /**
  75034. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75035. */
  75036. get isHighlighted(): boolean;
  75037. set isHighlighted(value: boolean);
  75038. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75039. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75040. */
  75041. get scaleX(): number;
  75042. set scaleX(value: number);
  75043. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75044. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75045. */
  75046. get scaleY(): number;
  75047. set scaleY(value: number);
  75048. /** Gets or sets the rotation angle (0 by default)
  75049. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75050. */
  75051. get rotation(): number;
  75052. set rotation(value: number);
  75053. /** Gets or sets the transformation center on Y axis (0 by default)
  75054. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75055. */
  75056. get transformCenterY(): number;
  75057. set transformCenterY(value: number);
  75058. /** Gets or sets the transformation center on X axis (0 by default)
  75059. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75060. */
  75061. get transformCenterX(): number;
  75062. set transformCenterX(value: number);
  75063. /**
  75064. * Gets or sets the horizontal alignment
  75065. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75066. */
  75067. get horizontalAlignment(): number;
  75068. set horizontalAlignment(value: number);
  75069. /**
  75070. * Gets or sets the vertical alignment
  75071. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75072. */
  75073. get verticalAlignment(): number;
  75074. set verticalAlignment(value: number);
  75075. /**
  75076. * Gets or sets control width
  75077. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75078. */
  75079. get width(): string | number;
  75080. set width(value: string | number);
  75081. /**
  75082. * Gets or sets the control width in pixel
  75083. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75084. */
  75085. get widthInPixels(): number;
  75086. set widthInPixels(value: number);
  75087. /**
  75088. * Gets or sets control height
  75089. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75090. */
  75091. get height(): string | number;
  75092. set height(value: string | number);
  75093. /**
  75094. * Gets or sets control height in pixel
  75095. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75096. */
  75097. get heightInPixels(): number;
  75098. set heightInPixels(value: number);
  75099. /** Gets or set font family */
  75100. get fontFamily(): string;
  75101. set fontFamily(value: string);
  75102. /** Gets or sets font style */
  75103. get fontStyle(): string;
  75104. set fontStyle(value: string);
  75105. /** Gets or sets font weight */
  75106. get fontWeight(): string;
  75107. set fontWeight(value: string);
  75108. /**
  75109. * Gets or sets style
  75110. * @see http://doc.babylonjs.com/how_to/gui#styles
  75111. */
  75112. get style(): BABYLON.Nullable<Style>;
  75113. set style(value: BABYLON.Nullable<Style>);
  75114. /** @hidden */
  75115. get _isFontSizeInPercentage(): boolean;
  75116. /** Gets or sets font size in pixels */
  75117. get fontSizeInPixels(): number;
  75118. set fontSizeInPixels(value: number);
  75119. /** Gets or sets font size */
  75120. get fontSize(): string | number;
  75121. set fontSize(value: string | number);
  75122. /** Gets or sets foreground color */
  75123. get color(): string;
  75124. set color(value: string);
  75125. /** Gets or sets z index which is used to reorder controls on the z axis */
  75126. get zIndex(): number;
  75127. set zIndex(value: number);
  75128. /** Gets or sets a boolean indicating if the control can be rendered */
  75129. get notRenderable(): boolean;
  75130. set notRenderable(value: boolean);
  75131. /** Gets or sets a boolean indicating if the control is visible */
  75132. get isVisible(): boolean;
  75133. set isVisible(value: boolean);
  75134. /** Gets a boolean indicating that the control needs to update its rendering */
  75135. get isDirty(): boolean;
  75136. /**
  75137. * Gets the current linked mesh (or null if none)
  75138. */
  75139. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75140. /**
  75141. * Gets or sets a value indicating the padding to use on the left of the control
  75142. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75143. */
  75144. get paddingLeft(): string | number;
  75145. set paddingLeft(value: string | number);
  75146. /**
  75147. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75148. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75149. */
  75150. get paddingLeftInPixels(): number;
  75151. set paddingLeftInPixels(value: number);
  75152. /**
  75153. * Gets or sets a value indicating the padding to use on the right of the control
  75154. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75155. */
  75156. get paddingRight(): string | number;
  75157. set paddingRight(value: string | number);
  75158. /**
  75159. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75160. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75161. */
  75162. get paddingRightInPixels(): number;
  75163. set paddingRightInPixels(value: number);
  75164. /**
  75165. * Gets or sets a value indicating the padding to use on the top of the control
  75166. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75167. */
  75168. get paddingTop(): string | number;
  75169. set paddingTop(value: string | number);
  75170. /**
  75171. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75172. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75173. */
  75174. get paddingTopInPixels(): number;
  75175. set paddingTopInPixels(value: number);
  75176. /**
  75177. * Gets or sets a value indicating the padding to use on the bottom of the control
  75178. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75179. */
  75180. get paddingBottom(): string | number;
  75181. set paddingBottom(value: string | number);
  75182. /**
  75183. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75184. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75185. */
  75186. get paddingBottomInPixels(): number;
  75187. set paddingBottomInPixels(value: number);
  75188. /**
  75189. * Gets or sets a value indicating the left coordinate of the control
  75190. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75191. */
  75192. get left(): string | number;
  75193. set left(value: string | number);
  75194. /**
  75195. * Gets or sets a value indicating the left coordinate in pixels of the control
  75196. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75197. */
  75198. get leftInPixels(): number;
  75199. set leftInPixels(value: number);
  75200. /**
  75201. * Gets or sets a value indicating the top coordinate of the control
  75202. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75203. */
  75204. get top(): string | number;
  75205. set top(value: string | number);
  75206. /**
  75207. * Gets or sets a value indicating the top coordinate in pixels of the control
  75208. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75209. */
  75210. get topInPixels(): number;
  75211. set topInPixels(value: number);
  75212. /**
  75213. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75214. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75215. */
  75216. get linkOffsetX(): string | number;
  75217. set linkOffsetX(value: string | number);
  75218. /**
  75219. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75220. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75221. */
  75222. get linkOffsetXInPixels(): number;
  75223. set linkOffsetXInPixels(value: number);
  75224. /**
  75225. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75226. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75227. */
  75228. get linkOffsetY(): string | number;
  75229. set linkOffsetY(value: string | number);
  75230. /**
  75231. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75232. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75233. */
  75234. get linkOffsetYInPixels(): number;
  75235. set linkOffsetYInPixels(value: number);
  75236. /** Gets the center coordinate on X axis */
  75237. get centerX(): number;
  75238. /** Gets the center coordinate on Y axis */
  75239. get centerY(): number;
  75240. /** Gets or sets if control is Enabled*/
  75241. get isEnabled(): boolean;
  75242. set isEnabled(value: boolean);
  75243. /** Gets or sets background color of control if it's disabled*/
  75244. get disabledColor(): string;
  75245. set disabledColor(value: string);
  75246. /** Gets or sets front color of control if it's disabled*/
  75247. get disabledColorItem(): string;
  75248. set disabledColorItem(value: string);
  75249. /**
  75250. * Creates a new control
  75251. * @param name defines the name of the control
  75252. */
  75253. constructor(
  75254. /** defines the name of the control */
  75255. name?: string | undefined);
  75256. /** @hidden */
  75257. protected _getTypeName(): string;
  75258. /**
  75259. * Gets the first ascendant in the hierarchy of the given type
  75260. * @param className defines the required type
  75261. * @returns the ascendant or null if not found
  75262. */
  75263. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75264. /** @hidden */
  75265. _resetFontCache(): void;
  75266. /**
  75267. * Determines if a container is an ascendant of the current control
  75268. * @param container defines the container to look for
  75269. * @returns true if the container is one of the ascendant of the control
  75270. */
  75271. isAscendant(container: Control): boolean;
  75272. /**
  75273. * Gets coordinates in local control space
  75274. * @param globalCoordinates defines the coordinates to transform
  75275. * @returns the new coordinates in local space
  75276. */
  75277. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75278. /**
  75279. * Gets coordinates in local control space
  75280. * @param globalCoordinates defines the coordinates to transform
  75281. * @param result defines the target vector2 where to store the result
  75282. * @returns the current control
  75283. */
  75284. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75285. /**
  75286. * Gets coordinates in parent local control space
  75287. * @param globalCoordinates defines the coordinates to transform
  75288. * @returns the new coordinates in parent local space
  75289. */
  75290. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75291. /**
  75292. * Move the current control to a vector3 position projected onto the screen.
  75293. * @param position defines the target position
  75294. * @param scene defines the hosting scene
  75295. */
  75296. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75297. /**
  75298. * Will store all controls that have this control as ascendant in a given array
  75299. * @param results defines the array where to store the descendants
  75300. * @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
  75301. * @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
  75302. */
  75303. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75304. /**
  75305. * Will return all controls that have this control as ascendant
  75306. * @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
  75307. * @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
  75308. * @return all child controls
  75309. */
  75310. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75311. /**
  75312. * Link current control with a target mesh
  75313. * @param mesh defines the mesh to link with
  75314. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75315. */
  75316. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75317. /** @hidden */
  75318. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75319. /** @hidden */
  75320. _offsetLeft(offset: number): void;
  75321. /** @hidden */
  75322. _offsetTop(offset: number): void;
  75323. /** @hidden */
  75324. _markMatrixAsDirty(): void;
  75325. /** @hidden */
  75326. _flagDescendantsAsMatrixDirty(): void;
  75327. /** @hidden */
  75328. _intersectsRect(rect: Measure): boolean;
  75329. /** @hidden */
  75330. protected invalidateRect(): void;
  75331. /** @hidden */
  75332. _markAsDirty(force?: boolean): void;
  75333. /** @hidden */
  75334. _markAllAsDirty(): void;
  75335. /** @hidden */
  75336. _link(host: AdvancedDynamicTexture): void;
  75337. /** @hidden */
  75338. protected _transform(context?: CanvasRenderingContext2D): void;
  75339. /** @hidden */
  75340. _renderHighlight(context: CanvasRenderingContext2D): void;
  75341. /** @hidden */
  75342. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75343. /** @hidden */
  75344. protected _applyStates(context: CanvasRenderingContext2D): void;
  75345. /** @hidden */
  75346. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75347. /** @hidden */
  75348. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75349. protected _evaluateClippingState(parentMeasure: Measure): void;
  75350. /** @hidden */
  75351. _measure(): void;
  75352. /** @hidden */
  75353. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75354. /** @hidden */
  75355. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75356. /** @hidden */
  75357. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75358. /** @hidden */
  75359. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75360. private static _ClipMeasure;
  75361. private _tmpMeasureA;
  75362. private _clip;
  75363. /** @hidden */
  75364. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75365. /** @hidden */
  75366. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75367. /**
  75368. * Tests if a given coordinates belong to the current control
  75369. * @param x defines x coordinate to test
  75370. * @param y defines y coordinate to test
  75371. * @returns true if the coordinates are inside the control
  75372. */
  75373. contains(x: number, y: number): boolean;
  75374. /** @hidden */
  75375. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75376. /** @hidden */
  75377. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75378. /** @hidden */
  75379. _onPointerEnter(target: Control): boolean;
  75380. /** @hidden */
  75381. _onPointerOut(target: Control, force?: boolean): void;
  75382. /** @hidden */
  75383. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75384. /** @hidden */
  75385. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75386. /** @hidden */
  75387. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75388. /** @hidden */
  75389. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75390. /** @hidden */
  75391. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75392. private _prepareFont;
  75393. /** Releases associated resources */
  75394. dispose(): void;
  75395. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75396. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75397. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75398. private static _VERTICAL_ALIGNMENT_TOP;
  75399. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75400. private static _VERTICAL_ALIGNMENT_CENTER;
  75401. /** HORIZONTAL_ALIGNMENT_LEFT */
  75402. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75403. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75404. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75405. /** HORIZONTAL_ALIGNMENT_CENTER */
  75406. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75407. /** VERTICAL_ALIGNMENT_TOP */
  75408. static get VERTICAL_ALIGNMENT_TOP(): number;
  75409. /** VERTICAL_ALIGNMENT_BOTTOM */
  75410. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75411. /** VERTICAL_ALIGNMENT_CENTER */
  75412. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75413. private static _FontHeightSizes;
  75414. /** @hidden */
  75415. static _GetFontOffset(font: string): {
  75416. ascent: number;
  75417. height: number;
  75418. descent: number;
  75419. };
  75420. /**
  75421. * Creates a stack panel that can be used to render headers
  75422. * @param control defines the control to associate with the header
  75423. * @param text defines the text of the header
  75424. * @param size defines the size of the header
  75425. * @param options defines options used to configure the header
  75426. * @returns a new StackPanel
  75427. * @ignore
  75428. * @hidden
  75429. */
  75430. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75431. isHorizontal: boolean;
  75432. controlFirst: boolean;
  75433. }) => any;
  75434. /** @hidden */
  75435. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75436. }
  75437. }
  75438. declare module BABYLON.GUI {
  75439. /**
  75440. * Root class for 2D containers
  75441. * @see http://doc.babylonjs.com/how_to/gui#containers
  75442. */
  75443. export class Container extends Control {
  75444. name?: string | undefined;
  75445. /** @hidden */
  75446. _children: Control[];
  75447. /** @hidden */
  75448. protected _measureForChildren: Measure;
  75449. /** @hidden */
  75450. protected _background: string;
  75451. /** @hidden */
  75452. protected _adaptWidthToChildren: boolean;
  75453. /** @hidden */
  75454. protected _adaptHeightToChildren: boolean;
  75455. /**
  75456. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75457. */
  75458. logLayoutCycleErrors: boolean;
  75459. /**
  75460. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75461. */
  75462. maxLayoutCycle: number;
  75463. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75464. get adaptHeightToChildren(): boolean;
  75465. set adaptHeightToChildren(value: boolean);
  75466. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75467. get adaptWidthToChildren(): boolean;
  75468. set adaptWidthToChildren(value: boolean);
  75469. /** Gets or sets background color */
  75470. get background(): string;
  75471. set background(value: string);
  75472. /** Gets the list of children */
  75473. get children(): Control[];
  75474. /**
  75475. * Creates a new Container
  75476. * @param name defines the name of the container
  75477. */
  75478. constructor(name?: string | undefined);
  75479. protected _getTypeName(): string;
  75480. _flagDescendantsAsMatrixDirty(): void;
  75481. /**
  75482. * Gets a child using its name
  75483. * @param name defines the child name to look for
  75484. * @returns the child control if found
  75485. */
  75486. getChildByName(name: string): BABYLON.Nullable<Control>;
  75487. /**
  75488. * Gets a child using its type and its name
  75489. * @param name defines the child name to look for
  75490. * @param type defines the child type to look for
  75491. * @returns the child control if found
  75492. */
  75493. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75494. /**
  75495. * Search for a specific control in children
  75496. * @param control defines the control to look for
  75497. * @returns true if the control is in child list
  75498. */
  75499. containsControl(control: Control): boolean;
  75500. /**
  75501. * Adds a new control to the current container
  75502. * @param control defines the control to add
  75503. * @returns the current container
  75504. */
  75505. addControl(control: BABYLON.Nullable<Control>): Container;
  75506. /**
  75507. * Removes all controls from the current container
  75508. * @returns the current container
  75509. */
  75510. clearControls(): Container;
  75511. /**
  75512. * Removes a control from the current container
  75513. * @param control defines the control to remove
  75514. * @returns the current container
  75515. */
  75516. removeControl(control: Control): Container;
  75517. /** @hidden */
  75518. _reOrderControl(control: Control): void;
  75519. /** @hidden */
  75520. _offsetLeft(offset: number): void;
  75521. /** @hidden */
  75522. _offsetTop(offset: number): void;
  75523. /** @hidden */
  75524. _markAllAsDirty(): void;
  75525. /** @hidden */
  75526. protected _localDraw(context: CanvasRenderingContext2D): void;
  75527. /** @hidden */
  75528. _link(host: AdvancedDynamicTexture): void;
  75529. /** @hidden */
  75530. protected _beforeLayout(): void;
  75531. /** @hidden */
  75532. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75533. /** @hidden */
  75534. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75535. protected _postMeasure(): void;
  75536. /** @hidden */
  75537. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75538. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75539. /** @hidden */
  75540. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75541. /** @hidden */
  75542. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75543. /** Releases associated resources */
  75544. dispose(): void;
  75545. }
  75546. }
  75547. declare module BABYLON.GUI {
  75548. /** Class used to create rectangle container */
  75549. export class Rectangle extends Container {
  75550. name?: string | undefined;
  75551. private _thickness;
  75552. private _cornerRadius;
  75553. /** Gets or sets border thickness */
  75554. get thickness(): number;
  75555. set thickness(value: number);
  75556. /** Gets or sets the corner radius angle */
  75557. get cornerRadius(): number;
  75558. set cornerRadius(value: number);
  75559. /**
  75560. * Creates a new Rectangle
  75561. * @param name defines the control name
  75562. */
  75563. constructor(name?: string | undefined);
  75564. protected _getTypeName(): string;
  75565. protected _localDraw(context: CanvasRenderingContext2D): void;
  75566. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75567. private _drawRoundedRect;
  75568. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75569. }
  75570. }
  75571. declare module BABYLON.GUI {
  75572. /**
  75573. * Enum that determines the text-wrapping mode to use.
  75574. */
  75575. export enum TextWrapping {
  75576. /**
  75577. * Clip the text when it's larger than Control.width; this is the default mode.
  75578. */
  75579. Clip = 0,
  75580. /**
  75581. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75582. */
  75583. WordWrap = 1,
  75584. /**
  75585. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75586. */
  75587. Ellipsis = 2
  75588. }
  75589. /**
  75590. * Class used to create text block control
  75591. */
  75592. export class TextBlock extends Control {
  75593. /**
  75594. * Defines the name of the control
  75595. */
  75596. name?: string | undefined;
  75597. private _text;
  75598. private _textWrapping;
  75599. private _textHorizontalAlignment;
  75600. private _textVerticalAlignment;
  75601. private _lines;
  75602. private _resizeToFit;
  75603. private _lineSpacing;
  75604. private _outlineWidth;
  75605. private _outlineColor;
  75606. /**
  75607. * An event triggered after the text is changed
  75608. */
  75609. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75610. /**
  75611. * An event triggered after the text was broken up into lines
  75612. */
  75613. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75614. /**
  75615. * Function used to split a string into words. By default, a string is split at each space character found
  75616. */
  75617. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75618. /**
  75619. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75620. */
  75621. get lines(): any[];
  75622. /**
  75623. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75624. */
  75625. get resizeToFit(): boolean;
  75626. /**
  75627. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75628. */
  75629. set resizeToFit(value: boolean);
  75630. /**
  75631. * Gets or sets a boolean indicating if text must be wrapped
  75632. */
  75633. get textWrapping(): TextWrapping | boolean;
  75634. /**
  75635. * Gets or sets a boolean indicating if text must be wrapped
  75636. */
  75637. set textWrapping(value: TextWrapping | boolean);
  75638. /**
  75639. * Gets or sets text to display
  75640. */
  75641. get text(): string;
  75642. /**
  75643. * Gets or sets text to display
  75644. */
  75645. set text(value: string);
  75646. /**
  75647. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75648. */
  75649. get textHorizontalAlignment(): number;
  75650. /**
  75651. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75652. */
  75653. set textHorizontalAlignment(value: number);
  75654. /**
  75655. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75656. */
  75657. get textVerticalAlignment(): number;
  75658. /**
  75659. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75660. */
  75661. set textVerticalAlignment(value: number);
  75662. /**
  75663. * Gets or sets line spacing value
  75664. */
  75665. set lineSpacing(value: string | number);
  75666. /**
  75667. * Gets or sets line spacing value
  75668. */
  75669. get lineSpacing(): string | number;
  75670. /**
  75671. * Gets or sets outlineWidth of the text to display
  75672. */
  75673. get outlineWidth(): number;
  75674. /**
  75675. * Gets or sets outlineWidth of the text to display
  75676. */
  75677. set outlineWidth(value: number);
  75678. /**
  75679. * Gets or sets outlineColor of the text to display
  75680. */
  75681. get outlineColor(): string;
  75682. /**
  75683. * Gets or sets outlineColor of the text to display
  75684. */
  75685. set outlineColor(value: string);
  75686. /**
  75687. * Creates a new TextBlock object
  75688. * @param name defines the name of the control
  75689. * @param text defines the text to display (emptry string by default)
  75690. */
  75691. constructor(
  75692. /**
  75693. * Defines the name of the control
  75694. */
  75695. name?: string | undefined, text?: string);
  75696. protected _getTypeName(): string;
  75697. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75698. private _drawText;
  75699. /** @hidden */
  75700. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75701. protected _applyStates(context: CanvasRenderingContext2D): void;
  75702. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75703. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75704. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75705. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75706. protected _renderLines(context: CanvasRenderingContext2D): void;
  75707. /**
  75708. * Given a width constraint applied on the text block, find the expected height
  75709. * @returns expected height
  75710. */
  75711. computeExpectedHeight(): number;
  75712. dispose(): void;
  75713. }
  75714. }
  75715. declare module BABYLON.GUI {
  75716. /**
  75717. * Class used to create 2D images
  75718. */
  75719. export class Image extends Control {
  75720. name?: string | undefined;
  75721. private _workingCanvas;
  75722. private _domImage;
  75723. private _imageWidth;
  75724. private _imageHeight;
  75725. private _loaded;
  75726. private _stretch;
  75727. private _source;
  75728. private _autoScale;
  75729. private _sourceLeft;
  75730. private _sourceTop;
  75731. private _sourceWidth;
  75732. private _sourceHeight;
  75733. private _svgAttributesComputationCompleted;
  75734. private _isSVG;
  75735. private _cellWidth;
  75736. private _cellHeight;
  75737. private _cellId;
  75738. private _populateNinePatchSlicesFromImage;
  75739. private _sliceLeft;
  75740. private _sliceRight;
  75741. private _sliceTop;
  75742. private _sliceBottom;
  75743. private _detectPointerOnOpaqueOnly;
  75744. /**
  75745. * BABYLON.Observable notified when the content is loaded
  75746. */
  75747. onImageLoadedObservable: BABYLON.Observable<Image>;
  75748. /**
  75749. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75750. */
  75751. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75752. /**
  75753. * Gets a boolean indicating that the content is loaded
  75754. */
  75755. get isLoaded(): boolean;
  75756. /**
  75757. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75758. */
  75759. get populateNinePatchSlicesFromImage(): boolean;
  75760. set populateNinePatchSlicesFromImage(value: boolean);
  75761. /**
  75762. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75763. * Beware using this as this will comsume more memory as the image has to be stored twice
  75764. */
  75765. get detectPointerOnOpaqueOnly(): boolean;
  75766. set detectPointerOnOpaqueOnly(value: boolean);
  75767. /**
  75768. * Gets or sets the left value for slicing (9-patch)
  75769. */
  75770. get sliceLeft(): number;
  75771. set sliceLeft(value: number);
  75772. /**
  75773. * Gets or sets the right value for slicing (9-patch)
  75774. */
  75775. get sliceRight(): number;
  75776. set sliceRight(value: number);
  75777. /**
  75778. * Gets or sets the top value for slicing (9-patch)
  75779. */
  75780. get sliceTop(): number;
  75781. set sliceTop(value: number);
  75782. /**
  75783. * Gets or sets the bottom value for slicing (9-patch)
  75784. */
  75785. get sliceBottom(): number;
  75786. set sliceBottom(value: number);
  75787. /**
  75788. * Gets or sets the left coordinate in the source image
  75789. */
  75790. get sourceLeft(): number;
  75791. set sourceLeft(value: number);
  75792. /**
  75793. * Gets or sets the top coordinate in the source image
  75794. */
  75795. get sourceTop(): number;
  75796. set sourceTop(value: number);
  75797. /**
  75798. * Gets or sets the width to capture in the source image
  75799. */
  75800. get sourceWidth(): number;
  75801. set sourceWidth(value: number);
  75802. /**
  75803. * Gets or sets the height to capture in the source image
  75804. */
  75805. get sourceHeight(): number;
  75806. set sourceHeight(value: number);
  75807. /** Indicates if the format of the image is SVG */
  75808. get isSVG(): boolean;
  75809. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75810. get svgAttributesComputationCompleted(): boolean;
  75811. /**
  75812. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75813. * @see http://doc.babylonjs.com/how_to/gui#image
  75814. */
  75815. get autoScale(): boolean;
  75816. set autoScale(value: boolean);
  75817. /** Gets or sets the streching mode used by the image */
  75818. get stretch(): number;
  75819. set stretch(value: number);
  75820. /** @hidden */
  75821. _rotate90(n: number, preserveProperties?: boolean): Image;
  75822. private _handleRotationForSVGImage;
  75823. private _rotate90SourceProperties;
  75824. /**
  75825. * Gets or sets the internal DOM image used to render the control
  75826. */
  75827. set domImage(value: HTMLImageElement);
  75828. get domImage(): HTMLImageElement;
  75829. private _onImageLoaded;
  75830. private _extractNinePatchSliceDataFromImage;
  75831. /**
  75832. * Gets or sets image source url
  75833. */
  75834. set source(value: BABYLON.Nullable<string>);
  75835. /**
  75836. * Checks for svg document with icon id present
  75837. */
  75838. private _svgCheck;
  75839. /**
  75840. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75841. * given external svg file and icon id
  75842. */
  75843. private _getSVGAttribs;
  75844. /**
  75845. * Gets or sets the cell width to use when animation sheet is enabled
  75846. * @see http://doc.babylonjs.com/how_to/gui#image
  75847. */
  75848. get cellWidth(): number;
  75849. set cellWidth(value: number);
  75850. /**
  75851. * Gets or sets the cell height to use when animation sheet is enabled
  75852. * @see http://doc.babylonjs.com/how_to/gui#image
  75853. */
  75854. get cellHeight(): number;
  75855. set cellHeight(value: number);
  75856. /**
  75857. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75858. * @see http://doc.babylonjs.com/how_to/gui#image
  75859. */
  75860. get cellId(): number;
  75861. set cellId(value: number);
  75862. /**
  75863. * Creates a new Image
  75864. * @param name defines the control name
  75865. * @param url defines the image url
  75866. */
  75867. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75868. /**
  75869. * Tests if a given coordinates belong to the current control
  75870. * @param x defines x coordinate to test
  75871. * @param y defines y coordinate to test
  75872. * @returns true if the coordinates are inside the control
  75873. */
  75874. contains(x: number, y: number): boolean;
  75875. protected _getTypeName(): string;
  75876. /** Force the control to synchronize with its content */
  75877. synchronizeSizeWithContent(): void;
  75878. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75879. private _prepareWorkingCanvasForOpaqueDetection;
  75880. private _drawImage;
  75881. _draw(context: CanvasRenderingContext2D): void;
  75882. private _renderCornerPatch;
  75883. private _renderNinePatch;
  75884. dispose(): void;
  75885. /** STRETCH_NONE */
  75886. static readonly STRETCH_NONE: number;
  75887. /** STRETCH_FILL */
  75888. static readonly STRETCH_FILL: number;
  75889. /** STRETCH_UNIFORM */
  75890. static readonly STRETCH_UNIFORM: number;
  75891. /** STRETCH_EXTEND */
  75892. static readonly STRETCH_EXTEND: number;
  75893. /** NINE_PATCH */
  75894. static readonly STRETCH_NINE_PATCH: number;
  75895. }
  75896. }
  75897. declare module BABYLON.GUI {
  75898. /**
  75899. * Class used to create 2D buttons
  75900. */
  75901. export class Button extends Rectangle {
  75902. name?: string | undefined;
  75903. /**
  75904. * Function called to generate a pointer enter animation
  75905. */
  75906. pointerEnterAnimation: () => void;
  75907. /**
  75908. * Function called to generate a pointer out animation
  75909. */
  75910. pointerOutAnimation: () => void;
  75911. /**
  75912. * Function called to generate a pointer down animation
  75913. */
  75914. pointerDownAnimation: () => void;
  75915. /**
  75916. * Function called to generate a pointer up animation
  75917. */
  75918. pointerUpAnimation: () => void;
  75919. /**
  75920. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75921. */
  75922. delegatePickingToChildren: boolean;
  75923. private _image;
  75924. /**
  75925. * Returns the image part of the button (if any)
  75926. */
  75927. get image(): BABYLON.Nullable<Image>;
  75928. private _textBlock;
  75929. /**
  75930. * Returns the image part of the button (if any)
  75931. */
  75932. get textBlock(): BABYLON.Nullable<TextBlock>;
  75933. /**
  75934. * Creates a new Button
  75935. * @param name defines the name of the button
  75936. */
  75937. constructor(name?: string | undefined);
  75938. protected _getTypeName(): string;
  75939. /** @hidden */
  75940. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75941. /** @hidden */
  75942. _onPointerEnter(target: Control): boolean;
  75943. /** @hidden */
  75944. _onPointerOut(target: Control, force?: boolean): void;
  75945. /** @hidden */
  75946. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75947. /** @hidden */
  75948. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75949. /**
  75950. * Creates a new button made with an image and a text
  75951. * @param name defines the name of the button
  75952. * @param text defines the text of the button
  75953. * @param imageUrl defines the url of the image
  75954. * @returns a new Button
  75955. */
  75956. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75957. /**
  75958. * Creates a new button made with an image
  75959. * @param name defines the name of the button
  75960. * @param imageUrl defines the url of the image
  75961. * @returns a new Button
  75962. */
  75963. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75964. /**
  75965. * Creates a new button made with a text
  75966. * @param name defines the name of the button
  75967. * @param text defines the text of the button
  75968. * @returns a new Button
  75969. */
  75970. static CreateSimpleButton(name: string, text: string): Button;
  75971. /**
  75972. * Creates a new button made with an image and a centered text
  75973. * @param name defines the name of the button
  75974. * @param text defines the text of the button
  75975. * @param imageUrl defines the url of the image
  75976. * @returns a new Button
  75977. */
  75978. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75979. }
  75980. }
  75981. declare module BABYLON.GUI {
  75982. /**
  75983. * Class used to create a 2D stack panel container
  75984. */
  75985. export class StackPanel extends Container {
  75986. name?: string | undefined;
  75987. private _isVertical;
  75988. private _manualWidth;
  75989. private _manualHeight;
  75990. private _doNotTrackManualChanges;
  75991. /**
  75992. * Gets or sets a boolean indicating that layou warnings should be ignored
  75993. */
  75994. ignoreLayoutWarnings: boolean;
  75995. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  75996. get isVertical(): boolean;
  75997. set isVertical(value: boolean);
  75998. /**
  75999. * Gets or sets panel width.
  76000. * This value should not be set when in horizontal mode as it will be computed automatically
  76001. */
  76002. set width(value: string | number);
  76003. get width(): string | number;
  76004. /**
  76005. * Gets or sets panel height.
  76006. * This value should not be set when in vertical mode as it will be computed automatically
  76007. */
  76008. set height(value: string | number);
  76009. get height(): string | number;
  76010. /**
  76011. * Creates a new StackPanel
  76012. * @param name defines control name
  76013. */
  76014. constructor(name?: string | undefined);
  76015. protected _getTypeName(): string;
  76016. /** @hidden */
  76017. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76018. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76019. protected _postMeasure(): void;
  76020. }
  76021. }
  76022. declare module BABYLON.GUI {
  76023. /**
  76024. * Class used to represent a 2D checkbox
  76025. */
  76026. export class Checkbox extends Control {
  76027. name?: string | undefined;
  76028. private _isChecked;
  76029. private _background;
  76030. private _checkSizeRatio;
  76031. private _thickness;
  76032. /** Gets or sets border thickness */
  76033. get thickness(): number;
  76034. set thickness(value: number);
  76035. /**
  76036. * BABYLON.Observable raised when isChecked property changes
  76037. */
  76038. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76039. /** Gets or sets a value indicating the ratio between overall size and check size */
  76040. get checkSizeRatio(): number;
  76041. set checkSizeRatio(value: number);
  76042. /** Gets or sets background color */
  76043. get background(): string;
  76044. set background(value: string);
  76045. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76046. get isChecked(): boolean;
  76047. set isChecked(value: boolean);
  76048. /**
  76049. * Creates a new CheckBox
  76050. * @param name defines the control name
  76051. */
  76052. constructor(name?: string | undefined);
  76053. protected _getTypeName(): string;
  76054. /** @hidden */
  76055. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76056. /** @hidden */
  76057. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76058. /**
  76059. * Utility function to easily create a checkbox with a header
  76060. * @param title defines the label to use for the header
  76061. * @param onValueChanged defines the callback to call when value changes
  76062. * @returns a StackPanel containing the checkbox and a textBlock
  76063. */
  76064. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76065. }
  76066. }
  76067. declare module BABYLON.GUI {
  76068. /**
  76069. * Class used to store key control properties
  76070. */
  76071. export class KeyPropertySet {
  76072. /** Width */
  76073. width?: string;
  76074. /** Height */
  76075. height?: string;
  76076. /** Left padding */
  76077. paddingLeft?: string;
  76078. /** Right padding */
  76079. paddingRight?: string;
  76080. /** Top padding */
  76081. paddingTop?: string;
  76082. /** Bottom padding */
  76083. paddingBottom?: string;
  76084. /** Foreground color */
  76085. color?: string;
  76086. /** Background color */
  76087. background?: string;
  76088. }
  76089. /**
  76090. * Class used to create virtual keyboard
  76091. */
  76092. export class VirtualKeyboard extends StackPanel {
  76093. /** BABYLON.Observable raised when a key is pressed */
  76094. onKeyPressObservable: BABYLON.Observable<string>;
  76095. /** Gets or sets default key button width */
  76096. defaultButtonWidth: string;
  76097. /** Gets or sets default key button height */
  76098. defaultButtonHeight: string;
  76099. /** Gets or sets default key button left padding */
  76100. defaultButtonPaddingLeft: string;
  76101. /** Gets or sets default key button right padding */
  76102. defaultButtonPaddingRight: string;
  76103. /** Gets or sets default key button top padding */
  76104. defaultButtonPaddingTop: string;
  76105. /** Gets or sets default key button bottom padding */
  76106. defaultButtonPaddingBottom: string;
  76107. /** Gets or sets default key button foreground color */
  76108. defaultButtonColor: string;
  76109. /** Gets or sets default key button background color */
  76110. defaultButtonBackground: string;
  76111. /** Gets or sets shift button foreground color */
  76112. shiftButtonColor: string;
  76113. /** Gets or sets shift button thickness*/
  76114. selectedShiftThickness: number;
  76115. /** Gets shift key state */
  76116. shiftState: number;
  76117. protected _getTypeName(): string;
  76118. private _createKey;
  76119. /**
  76120. * Adds a new row of keys
  76121. * @param keys defines the list of keys to add
  76122. * @param propertySets defines the associated property sets
  76123. */
  76124. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76125. /**
  76126. * Set the shift key to a specific state
  76127. * @param shiftState defines the new shift state
  76128. */
  76129. applyShiftState(shiftState: number): void;
  76130. private _currentlyConnectedInputText;
  76131. private _connectedInputTexts;
  76132. private _onKeyPressObserver;
  76133. /** Gets the input text control currently attached to the keyboard */
  76134. get connectedInputText(): BABYLON.Nullable<InputText>;
  76135. /**
  76136. * Connects the keyboard with an input text control
  76137. *
  76138. * @param input defines the target control
  76139. */
  76140. connect(input: InputText): void;
  76141. /**
  76142. * Disconnects the keyboard from connected InputText controls
  76143. *
  76144. * @param input optionally defines a target control, otherwise all are disconnected
  76145. */
  76146. disconnect(input?: InputText): void;
  76147. private _removeConnectedInputObservables;
  76148. /**
  76149. * Release all resources
  76150. */
  76151. dispose(): void;
  76152. /**
  76153. * Creates a new keyboard using a default layout
  76154. *
  76155. * @param name defines control name
  76156. * @returns a new VirtualKeyboard
  76157. */
  76158. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76159. }
  76160. }
  76161. declare module BABYLON.GUI {
  76162. /**
  76163. * Class used to create input text control
  76164. */
  76165. export class InputText extends Control implements IFocusableControl {
  76166. name?: string | undefined;
  76167. private _text;
  76168. private _placeholderText;
  76169. private _background;
  76170. private _focusedBackground;
  76171. private _focusedColor;
  76172. private _placeholderColor;
  76173. private _thickness;
  76174. private _margin;
  76175. private _autoStretchWidth;
  76176. private _maxWidth;
  76177. private _isFocused;
  76178. private _blinkTimeout;
  76179. private _blinkIsEven;
  76180. private _cursorOffset;
  76181. private _scrollLeft;
  76182. private _textWidth;
  76183. private _clickedCoordinate;
  76184. private _deadKey;
  76185. private _addKey;
  76186. private _currentKey;
  76187. private _isTextHighlightOn;
  76188. private _textHighlightColor;
  76189. private _highligherOpacity;
  76190. private _highlightedText;
  76191. private _startHighlightIndex;
  76192. private _endHighlightIndex;
  76193. private _cursorIndex;
  76194. private _onFocusSelectAll;
  76195. private _isPointerDown;
  76196. private _onClipboardObserver;
  76197. private _onPointerDblTapObserver;
  76198. /** @hidden */
  76199. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76200. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76201. promptMessage: string;
  76202. /** Force disable prompt on mobile device */
  76203. disableMobilePrompt: boolean;
  76204. /** BABYLON.Observable raised when the text changes */
  76205. onTextChangedObservable: BABYLON.Observable<InputText>;
  76206. /** BABYLON.Observable raised just before an entered character is to be added */
  76207. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76208. /** BABYLON.Observable raised when the control gets the focus */
  76209. onFocusObservable: BABYLON.Observable<InputText>;
  76210. /** BABYLON.Observable raised when the control loses the focus */
  76211. onBlurObservable: BABYLON.Observable<InputText>;
  76212. /**Observable raised when the text is highlighted */
  76213. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76214. /**Observable raised when copy event is triggered */
  76215. onTextCopyObservable: BABYLON.Observable<InputText>;
  76216. /** BABYLON.Observable raised when cut event is triggered */
  76217. onTextCutObservable: BABYLON.Observable<InputText>;
  76218. /** BABYLON.Observable raised when paste event is triggered */
  76219. onTextPasteObservable: BABYLON.Observable<InputText>;
  76220. /** BABYLON.Observable raised when a key event was processed */
  76221. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76222. /** Gets or sets the maximum width allowed by the control */
  76223. get maxWidth(): string | number;
  76224. /** Gets the maximum width allowed by the control in pixels */
  76225. get maxWidthInPixels(): number;
  76226. set maxWidth(value: string | number);
  76227. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76228. get highligherOpacity(): number;
  76229. set highligherOpacity(value: number);
  76230. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76231. get onFocusSelectAll(): boolean;
  76232. set onFocusSelectAll(value: boolean);
  76233. /** Gets or sets the text hightlight color */
  76234. get textHighlightColor(): string;
  76235. set textHighlightColor(value: string);
  76236. /** Gets or sets control margin */
  76237. get margin(): string;
  76238. /** Gets control margin in pixels */
  76239. get marginInPixels(): number;
  76240. set margin(value: string);
  76241. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76242. get autoStretchWidth(): boolean;
  76243. set autoStretchWidth(value: boolean);
  76244. /** Gets or sets border thickness */
  76245. get thickness(): number;
  76246. set thickness(value: number);
  76247. /** Gets or sets the background color when focused */
  76248. get focusedBackground(): string;
  76249. set focusedBackground(value: string);
  76250. /** Gets or sets the background color when focused */
  76251. get focusedColor(): string;
  76252. set focusedColor(value: string);
  76253. /** Gets or sets the background color */
  76254. get background(): string;
  76255. set background(value: string);
  76256. /** Gets or sets the placeholder color */
  76257. get placeholderColor(): string;
  76258. set placeholderColor(value: string);
  76259. /** Gets or sets the text displayed when the control is empty */
  76260. get placeholderText(): string;
  76261. set placeholderText(value: string);
  76262. /** Gets or sets the dead key flag */
  76263. get deadKey(): boolean;
  76264. set deadKey(flag: boolean);
  76265. /** Gets or sets the highlight text */
  76266. get highlightedText(): string;
  76267. set highlightedText(text: string);
  76268. /** Gets or sets if the current key should be added */
  76269. get addKey(): boolean;
  76270. set addKey(flag: boolean);
  76271. /** Gets or sets the value of the current key being entered */
  76272. get currentKey(): string;
  76273. set currentKey(key: string);
  76274. /** Gets or sets the text displayed in the control */
  76275. get text(): string;
  76276. set text(value: string);
  76277. /** Gets or sets control width */
  76278. get width(): string | number;
  76279. set width(value: string | number);
  76280. /**
  76281. * Creates a new InputText
  76282. * @param name defines the control name
  76283. * @param text defines the text of the control
  76284. */
  76285. constructor(name?: string | undefined, text?: string);
  76286. /** @hidden */
  76287. onBlur(): void;
  76288. /** @hidden */
  76289. onFocus(): void;
  76290. protected _getTypeName(): string;
  76291. /**
  76292. * Function called to get the list of controls that should not steal the focus from this control
  76293. * @returns an array of controls
  76294. */
  76295. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76296. /** @hidden */
  76297. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76298. /** @hidden */
  76299. private _updateValueFromCursorIndex;
  76300. /** @hidden */
  76301. private _processDblClick;
  76302. /** @hidden */
  76303. private _selectAllText;
  76304. /**
  76305. * Handles the keyboard event
  76306. * @param evt Defines the KeyboardEvent
  76307. */
  76308. processKeyboard(evt: KeyboardEvent): void;
  76309. /** @hidden */
  76310. private _onCopyText;
  76311. /** @hidden */
  76312. private _onCutText;
  76313. /** @hidden */
  76314. private _onPasteText;
  76315. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76316. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76317. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76318. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76319. protected _beforeRenderText(text: string): string;
  76320. dispose(): void;
  76321. }
  76322. }
  76323. declare module BABYLON.GUI {
  76324. /**
  76325. * Class used to create a 2D grid container
  76326. */
  76327. export class Grid extends Container {
  76328. name?: string | undefined;
  76329. private _rowDefinitions;
  76330. private _columnDefinitions;
  76331. private _cells;
  76332. private _childControls;
  76333. /**
  76334. * Gets the number of columns
  76335. */
  76336. get columnCount(): number;
  76337. /**
  76338. * Gets the number of rows
  76339. */
  76340. get rowCount(): number;
  76341. /** Gets the list of children */
  76342. get children(): Control[];
  76343. /** Gets the list of cells (e.g. the containers) */
  76344. get cells(): {
  76345. [key: string]: Container;
  76346. };
  76347. /**
  76348. * Gets the definition of a specific row
  76349. * @param index defines the index of the row
  76350. * @returns the row definition
  76351. */
  76352. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76353. /**
  76354. * Gets the definition of a specific column
  76355. * @param index defines the index of the column
  76356. * @returns the column definition
  76357. */
  76358. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76359. /**
  76360. * Adds a new row to the grid
  76361. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76362. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76363. * @returns the current grid
  76364. */
  76365. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76366. /**
  76367. * Adds a new column to the grid
  76368. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76369. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76370. * @returns the current grid
  76371. */
  76372. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76373. /**
  76374. * Update a row definition
  76375. * @param index defines the index of the row to update
  76376. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76377. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76378. * @returns the current grid
  76379. */
  76380. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76381. /**
  76382. * Update a column definition
  76383. * @param index defines the index of the column to update
  76384. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76385. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76386. * @returns the current grid
  76387. */
  76388. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76389. /**
  76390. * Gets the list of children stored in a specific cell
  76391. * @param row defines the row to check
  76392. * @param column defines the column to check
  76393. * @returns the list of controls
  76394. */
  76395. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76396. /**
  76397. * Gets a string representing the child cell info (row x column)
  76398. * @param child defines the control to get info from
  76399. * @returns a string containing the child cell info (row x column)
  76400. */
  76401. getChildCellInfo(child: Control): string;
  76402. private _removeCell;
  76403. private _offsetCell;
  76404. /**
  76405. * Remove a column definition at specified index
  76406. * @param index defines the index of the column to remove
  76407. * @returns the current grid
  76408. */
  76409. removeColumnDefinition(index: number): Grid;
  76410. /**
  76411. * Remove a row definition at specified index
  76412. * @param index defines the index of the row to remove
  76413. * @returns the current grid
  76414. */
  76415. removeRowDefinition(index: number): Grid;
  76416. /**
  76417. * Adds a new control to the current grid
  76418. * @param control defines the control to add
  76419. * @param row defines the row where to add the control (0 by default)
  76420. * @param column defines the column where to add the control (0 by default)
  76421. * @returns the current grid
  76422. */
  76423. addControl(control: Control, row?: number, column?: number): Grid;
  76424. /**
  76425. * Removes a control from the current container
  76426. * @param control defines the control to remove
  76427. * @returns the current container
  76428. */
  76429. removeControl(control: Control): Container;
  76430. /**
  76431. * Creates a new Grid
  76432. * @param name defines control name
  76433. */
  76434. constructor(name?: string | undefined);
  76435. protected _getTypeName(): string;
  76436. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76437. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76438. _flagDescendantsAsMatrixDirty(): void;
  76439. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76440. /** Releases associated resources */
  76441. dispose(): void;
  76442. }
  76443. }
  76444. declare module BABYLON.GUI {
  76445. /** Class used to create color pickers */
  76446. export class ColorPicker extends Control {
  76447. name?: string | undefined;
  76448. private static _Epsilon;
  76449. private _colorWheelCanvas;
  76450. private _value;
  76451. private _tmpColor;
  76452. private _pointerStartedOnSquare;
  76453. private _pointerStartedOnWheel;
  76454. private _squareLeft;
  76455. private _squareTop;
  76456. private _squareSize;
  76457. private _h;
  76458. private _s;
  76459. private _v;
  76460. private _lastPointerDownID;
  76461. /**
  76462. * BABYLON.Observable raised when the value changes
  76463. */
  76464. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76465. /** Gets or sets the color of the color picker */
  76466. get value(): BABYLON.Color3;
  76467. set value(value: BABYLON.Color3);
  76468. /**
  76469. * Gets or sets control width
  76470. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76471. */
  76472. get width(): string | number;
  76473. set width(value: string | number);
  76474. /**
  76475. * Gets or sets control height
  76476. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76477. */
  76478. get height(): string | number;
  76479. /** Gets or sets control height */
  76480. set height(value: string | number);
  76481. /** Gets or sets control size */
  76482. get size(): string | number;
  76483. set size(value: string | number);
  76484. /**
  76485. * Creates a new ColorPicker
  76486. * @param name defines the control name
  76487. */
  76488. constructor(name?: string | undefined);
  76489. protected _getTypeName(): string;
  76490. /** @hidden */
  76491. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76492. private _updateSquareProps;
  76493. private _drawGradientSquare;
  76494. private _drawCircle;
  76495. private _createColorWheelCanvas;
  76496. /** @hidden */
  76497. _draw(context: CanvasRenderingContext2D): void;
  76498. private _pointerIsDown;
  76499. private _updateValueFromPointer;
  76500. private _isPointOnSquare;
  76501. private _isPointOnWheel;
  76502. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76503. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76504. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76505. /**
  76506. * This function expands the color picker by creating a color picker dialog with manual
  76507. * color value input and the ability to save colors into an array to be used later in
  76508. * subsequent launches of the dialogue.
  76509. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76510. * @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.
  76511. * @returns picked color as a hex string and the saved colors array as hex strings.
  76512. */
  76513. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76514. pickerWidth?: string;
  76515. pickerHeight?: string;
  76516. headerHeight?: string;
  76517. lastColor?: string;
  76518. swatchLimit?: number;
  76519. numSwatchesPerLine?: number;
  76520. savedColors?: Array<string>;
  76521. }): Promise<{
  76522. savedColors?: string[];
  76523. pickedColor: string;
  76524. }>;
  76525. }
  76526. }
  76527. declare module BABYLON.GUI {
  76528. /** Class used to create 2D ellipse containers */
  76529. export class Ellipse extends Container {
  76530. name?: string | undefined;
  76531. private _thickness;
  76532. /** Gets or sets border thickness */
  76533. get thickness(): number;
  76534. set thickness(value: number);
  76535. /**
  76536. * Creates a new Ellipse
  76537. * @param name defines the control name
  76538. */
  76539. constructor(name?: string | undefined);
  76540. protected _getTypeName(): string;
  76541. protected _localDraw(context: CanvasRenderingContext2D): void;
  76542. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76543. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76544. }
  76545. }
  76546. declare module BABYLON.GUI {
  76547. /**
  76548. * Class used to create a password control
  76549. */
  76550. export class InputPassword extends InputText {
  76551. protected _beforeRenderText(text: string): string;
  76552. }
  76553. }
  76554. declare module BABYLON.GUI {
  76555. /** Class used to render 2D lines */
  76556. export class Line extends Control {
  76557. name?: string | undefined;
  76558. private _lineWidth;
  76559. private _x1;
  76560. private _y1;
  76561. private _x2;
  76562. private _y2;
  76563. private _dash;
  76564. private _connectedControl;
  76565. private _connectedControlDirtyObserver;
  76566. /** Gets or sets the dash pattern */
  76567. get dash(): Array<number>;
  76568. set dash(value: Array<number>);
  76569. /** Gets or sets the control connected with the line end */
  76570. get connectedControl(): Control;
  76571. set connectedControl(value: Control);
  76572. /** Gets or sets start coordinates on X axis */
  76573. get x1(): string | number;
  76574. set x1(value: string | number);
  76575. /** Gets or sets start coordinates on Y axis */
  76576. get y1(): string | number;
  76577. set y1(value: string | number);
  76578. /** Gets or sets end coordinates on X axis */
  76579. get x2(): string | number;
  76580. set x2(value: string | number);
  76581. /** Gets or sets end coordinates on Y axis */
  76582. get y2(): string | number;
  76583. set y2(value: string | number);
  76584. /** Gets or sets line width */
  76585. get lineWidth(): number;
  76586. set lineWidth(value: number);
  76587. /** Gets or sets horizontal alignment */
  76588. set horizontalAlignment(value: number);
  76589. /** Gets or sets vertical alignment */
  76590. set verticalAlignment(value: number);
  76591. private get _effectiveX2();
  76592. private get _effectiveY2();
  76593. /**
  76594. * Creates a new Line
  76595. * @param name defines the control name
  76596. */
  76597. constructor(name?: string | undefined);
  76598. protected _getTypeName(): string;
  76599. _draw(context: CanvasRenderingContext2D): void;
  76600. _measure(): void;
  76601. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76602. /**
  76603. * Move one end of the line given 3D cartesian coordinates.
  76604. * @param position Targeted world position
  76605. * @param scene BABYLON.Scene
  76606. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76607. */
  76608. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76609. /**
  76610. * Move one end of the line to a position in screen absolute space.
  76611. * @param projectedPosition Position in screen absolute space (X, Y)
  76612. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76613. */
  76614. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76615. }
  76616. }
  76617. declare module BABYLON.GUI {
  76618. /**
  76619. * Class used to store a point for a MultiLine object.
  76620. * The point can be pure 2D coordinates, a mesh or a control
  76621. */
  76622. export class MultiLinePoint {
  76623. private _multiLine;
  76624. private _x;
  76625. private _y;
  76626. private _control;
  76627. private _mesh;
  76628. private _controlObserver;
  76629. private _meshObserver;
  76630. /** @hidden */
  76631. _point: BABYLON.Vector2;
  76632. /**
  76633. * Creates a new MultiLinePoint
  76634. * @param multiLine defines the source MultiLine object
  76635. */
  76636. constructor(multiLine: MultiLine);
  76637. /** Gets or sets x coordinate */
  76638. get x(): string | number;
  76639. set x(value: string | number);
  76640. /** Gets or sets y coordinate */
  76641. get y(): string | number;
  76642. set y(value: string | number);
  76643. /** Gets or sets the control associated with this point */
  76644. get control(): BABYLON.Nullable<Control>;
  76645. set control(value: BABYLON.Nullable<Control>);
  76646. /** Gets or sets the mesh associated with this point */
  76647. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76648. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76649. /** Resets links */
  76650. resetLinks(): void;
  76651. /**
  76652. * Gets a translation vector
  76653. * @returns the translation vector
  76654. */
  76655. translate(): BABYLON.Vector2;
  76656. private _translatePoint;
  76657. /** Release associated resources */
  76658. dispose(): void;
  76659. }
  76660. }
  76661. declare module BABYLON.GUI {
  76662. /**
  76663. * Class used to create multi line control
  76664. */
  76665. export class MultiLine extends Control {
  76666. name?: string | undefined;
  76667. private _lineWidth;
  76668. private _dash;
  76669. private _points;
  76670. private _minX;
  76671. private _minY;
  76672. private _maxX;
  76673. private _maxY;
  76674. /**
  76675. * Creates a new MultiLine
  76676. * @param name defines the control name
  76677. */
  76678. constructor(name?: string | undefined);
  76679. /** Gets or sets dash pattern */
  76680. get dash(): Array<number>;
  76681. set dash(value: Array<number>);
  76682. /**
  76683. * Gets point stored at specified index
  76684. * @param index defines the index to look for
  76685. * @returns the requested point if found
  76686. */
  76687. getAt(index: number): MultiLinePoint;
  76688. /** Function called when a point is updated */
  76689. onPointUpdate: () => void;
  76690. /**
  76691. * Adds new points to the point collection
  76692. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76693. * @returns the list of created MultiLinePoint
  76694. */
  76695. add(...items: (AbstractMesh | Control | {
  76696. x: string | number;
  76697. y: string | number;
  76698. })[]): MultiLinePoint[];
  76699. /**
  76700. * Adds a new point to the point collection
  76701. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76702. * @returns the created MultiLinePoint
  76703. */
  76704. push(item?: (AbstractMesh | Control | {
  76705. x: string | number;
  76706. y: string | number;
  76707. })): MultiLinePoint;
  76708. /**
  76709. * Remove a specific value or point from the active point collection
  76710. * @param value defines the value or point to remove
  76711. */
  76712. remove(value: number | MultiLinePoint): void;
  76713. /**
  76714. * Resets this object to initial state (no point)
  76715. */
  76716. reset(): void;
  76717. /**
  76718. * Resets all links
  76719. */
  76720. resetLinks(): void;
  76721. /** Gets or sets line width */
  76722. get lineWidth(): number;
  76723. set lineWidth(value: number);
  76724. set horizontalAlignment(value: number);
  76725. set verticalAlignment(value: number);
  76726. protected _getTypeName(): string;
  76727. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76728. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76729. _measure(): void;
  76730. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76731. dispose(): void;
  76732. }
  76733. }
  76734. declare module BABYLON.GUI {
  76735. /**
  76736. * Class used to create radio button controls
  76737. */
  76738. export class RadioButton extends Control {
  76739. name?: string | undefined;
  76740. private _isChecked;
  76741. private _background;
  76742. private _checkSizeRatio;
  76743. private _thickness;
  76744. /** Gets or sets border thickness */
  76745. get thickness(): number;
  76746. set thickness(value: number);
  76747. /** Gets or sets group name */
  76748. group: string;
  76749. /** BABYLON.Observable raised when isChecked is changed */
  76750. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76751. /** Gets or sets a value indicating the ratio between overall size and check size */
  76752. get checkSizeRatio(): number;
  76753. set checkSizeRatio(value: number);
  76754. /** Gets or sets background color */
  76755. get background(): string;
  76756. set background(value: string);
  76757. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76758. get isChecked(): boolean;
  76759. set isChecked(value: boolean);
  76760. /**
  76761. * Creates a new RadioButton
  76762. * @param name defines the control name
  76763. */
  76764. constructor(name?: string | undefined);
  76765. protected _getTypeName(): string;
  76766. _draw(context: CanvasRenderingContext2D): void;
  76767. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76768. /**
  76769. * Utility function to easily create a radio button with a header
  76770. * @param title defines the label to use for the header
  76771. * @param group defines the group to use for the radio button
  76772. * @param isChecked defines the initial state of the radio button
  76773. * @param onValueChanged defines the callback to call when value changes
  76774. * @returns a StackPanel containing the radio button and a textBlock
  76775. */
  76776. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76777. }
  76778. }
  76779. declare module BABYLON.GUI {
  76780. /**
  76781. * Class used to create slider controls
  76782. */
  76783. export class BaseSlider extends Control {
  76784. name?: string | undefined;
  76785. protected _thumbWidth: ValueAndUnit;
  76786. private _minimum;
  76787. private _maximum;
  76788. private _value;
  76789. private _isVertical;
  76790. protected _barOffset: ValueAndUnit;
  76791. private _isThumbClamped;
  76792. protected _displayThumb: boolean;
  76793. private _step;
  76794. private _lastPointerDownID;
  76795. protected _effectiveBarOffset: number;
  76796. protected _renderLeft: number;
  76797. protected _renderTop: number;
  76798. protected _renderWidth: number;
  76799. protected _renderHeight: number;
  76800. protected _backgroundBoxLength: number;
  76801. protected _backgroundBoxThickness: number;
  76802. protected _effectiveThumbThickness: number;
  76803. /** BABYLON.Observable raised when the sldier value changes */
  76804. onValueChangedObservable: BABYLON.Observable<number>;
  76805. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76806. get displayThumb(): boolean;
  76807. set displayThumb(value: boolean);
  76808. /** Gets or sets a step to apply to values (0 by default) */
  76809. get step(): number;
  76810. set step(value: number);
  76811. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76812. get barOffset(): string | number;
  76813. /** Gets main bar offset in pixels*/
  76814. get barOffsetInPixels(): number;
  76815. set barOffset(value: string | number);
  76816. /** Gets or sets thumb width */
  76817. get thumbWidth(): string | number;
  76818. /** Gets thumb width in pixels */
  76819. get thumbWidthInPixels(): number;
  76820. set thumbWidth(value: string | number);
  76821. /** Gets or sets minimum value */
  76822. get minimum(): number;
  76823. set minimum(value: number);
  76824. /** Gets or sets maximum value */
  76825. get maximum(): number;
  76826. set maximum(value: number);
  76827. /** Gets or sets current value */
  76828. get value(): number;
  76829. set value(value: number);
  76830. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76831. get isVertical(): boolean;
  76832. set isVertical(value: boolean);
  76833. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76834. get isThumbClamped(): boolean;
  76835. set isThumbClamped(value: boolean);
  76836. /**
  76837. * Creates a new BaseSlider
  76838. * @param name defines the control name
  76839. */
  76840. constructor(name?: string | undefined);
  76841. protected _getTypeName(): string;
  76842. protected _getThumbPosition(): number;
  76843. protected _getThumbThickness(type: string): number;
  76844. protected _prepareRenderingData(type: string): void;
  76845. private _pointerIsDown;
  76846. /** @hidden */
  76847. protected _updateValueFromPointer(x: number, y: number): void;
  76848. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76849. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76850. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76851. }
  76852. }
  76853. declare module BABYLON.GUI {
  76854. /**
  76855. * Class used to create slider controls
  76856. */
  76857. export class Slider extends BaseSlider {
  76858. name?: string | undefined;
  76859. private _background;
  76860. private _borderColor;
  76861. private _isThumbCircle;
  76862. protected _displayValueBar: boolean;
  76863. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76864. get displayValueBar(): boolean;
  76865. set displayValueBar(value: boolean);
  76866. /** Gets or sets border color */
  76867. get borderColor(): string;
  76868. set borderColor(value: string);
  76869. /** Gets or sets background color */
  76870. get background(): string;
  76871. set background(value: string);
  76872. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76873. get isThumbCircle(): boolean;
  76874. set isThumbCircle(value: boolean);
  76875. /**
  76876. * Creates a new Slider
  76877. * @param name defines the control name
  76878. */
  76879. constructor(name?: string | undefined);
  76880. protected _getTypeName(): string;
  76881. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76882. }
  76883. }
  76884. declare module BABYLON.GUI {
  76885. /** Class used to create a RadioGroup
  76886. * which contains groups of radio buttons
  76887. */
  76888. export class SelectorGroup {
  76889. /** name of SelectorGroup */
  76890. name: string;
  76891. private _groupPanel;
  76892. private _selectors;
  76893. private _groupHeader;
  76894. /**
  76895. * Creates a new SelectorGroup
  76896. * @param name of group, used as a group heading
  76897. */
  76898. constructor(
  76899. /** name of SelectorGroup */
  76900. name: string);
  76901. /** Gets the groupPanel of the SelectorGroup */
  76902. get groupPanel(): StackPanel;
  76903. /** Gets the selectors array */
  76904. get selectors(): StackPanel[];
  76905. /** Gets and sets the group header */
  76906. get header(): string;
  76907. set header(label: string);
  76908. /** @hidden */
  76909. private _addGroupHeader;
  76910. /** @hidden*/
  76911. _getSelector(selectorNb: number): StackPanel | undefined;
  76912. /** Removes the selector at the given position
  76913. * @param selectorNb the position of the selector within the group
  76914. */
  76915. removeSelector(selectorNb: number): void;
  76916. }
  76917. /** Class used to create a CheckboxGroup
  76918. * which contains groups of checkbox buttons
  76919. */
  76920. export class CheckboxGroup extends SelectorGroup {
  76921. /** Adds a checkbox as a control
  76922. * @param text is the label for the selector
  76923. * @param func is the function called when the Selector is checked
  76924. * @param checked is true when Selector is checked
  76925. */
  76926. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76927. /** @hidden */
  76928. _setSelectorLabel(selectorNb: number, label: string): void;
  76929. /** @hidden */
  76930. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76931. /** @hidden */
  76932. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76933. /** @hidden */
  76934. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76935. }
  76936. /** Class used to create a RadioGroup
  76937. * which contains groups of radio buttons
  76938. */
  76939. export class RadioGroup extends SelectorGroup {
  76940. private _selectNb;
  76941. /** Adds a radio button as a control
  76942. * @param label is the label for the selector
  76943. * @param func is the function called when the Selector is checked
  76944. * @param checked is true when Selector is checked
  76945. */
  76946. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76947. /** @hidden */
  76948. _setSelectorLabel(selectorNb: number, label: string): void;
  76949. /** @hidden */
  76950. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76951. /** @hidden */
  76952. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76953. /** @hidden */
  76954. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76955. }
  76956. /** Class used to create a SliderGroup
  76957. * which contains groups of slider buttons
  76958. */
  76959. export class SliderGroup extends SelectorGroup {
  76960. /**
  76961. * Adds a slider to the SelectorGroup
  76962. * @param label is the label for the SliderBar
  76963. * @param func is the function called when the Slider moves
  76964. * @param unit is a string describing the units used, eg degrees or metres
  76965. * @param min is the minimum value for the Slider
  76966. * @param max is the maximum value for the Slider
  76967. * @param value is the start value for the Slider between min and max
  76968. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76969. */
  76970. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76971. /** @hidden */
  76972. _setSelectorLabel(selectorNb: number, label: string): void;
  76973. /** @hidden */
  76974. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76975. /** @hidden */
  76976. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76977. /** @hidden */
  76978. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76979. }
  76980. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76981. * @see http://doc.babylonjs.com/how_to/selector
  76982. */
  76983. export class SelectionPanel extends Rectangle {
  76984. /** name of SelectionPanel */
  76985. name: string;
  76986. /** an array of SelectionGroups */
  76987. groups: SelectorGroup[];
  76988. private _panel;
  76989. private _buttonColor;
  76990. private _buttonBackground;
  76991. private _headerColor;
  76992. private _barColor;
  76993. private _barHeight;
  76994. private _spacerHeight;
  76995. private _labelColor;
  76996. private _groups;
  76997. private _bars;
  76998. /**
  76999. * Creates a new SelectionPanel
  77000. * @param name of SelectionPanel
  77001. * @param groups is an array of SelectionGroups
  77002. */
  77003. constructor(
  77004. /** name of SelectionPanel */
  77005. name: string,
  77006. /** an array of SelectionGroups */
  77007. groups?: SelectorGroup[]);
  77008. protected _getTypeName(): string;
  77009. /** Gets or sets the headerColor */
  77010. get headerColor(): string;
  77011. set headerColor(color: string);
  77012. private _setHeaderColor;
  77013. /** Gets or sets the button color */
  77014. get buttonColor(): string;
  77015. set buttonColor(color: string);
  77016. private _setbuttonColor;
  77017. /** Gets or sets the label color */
  77018. get labelColor(): string;
  77019. set labelColor(color: string);
  77020. private _setLabelColor;
  77021. /** Gets or sets the button background */
  77022. get buttonBackground(): string;
  77023. set buttonBackground(color: string);
  77024. private _setButtonBackground;
  77025. /** Gets or sets the color of separator bar */
  77026. get barColor(): string;
  77027. set barColor(color: string);
  77028. private _setBarColor;
  77029. /** Gets or sets the height of separator bar */
  77030. get barHeight(): string;
  77031. set barHeight(value: string);
  77032. private _setBarHeight;
  77033. /** Gets or sets the height of spacers*/
  77034. get spacerHeight(): string;
  77035. set spacerHeight(value: string);
  77036. private _setSpacerHeight;
  77037. /** Adds a bar between groups */
  77038. private _addSpacer;
  77039. /** Add a group to the selection panel
  77040. * @param group is the selector group to add
  77041. */
  77042. addGroup(group: SelectorGroup): void;
  77043. /** Remove the group from the given position
  77044. * @param groupNb is the position of the group in the list
  77045. */
  77046. removeGroup(groupNb: number): void;
  77047. /** Change a group header label
  77048. * @param label is the new group header label
  77049. * @param groupNb is the number of the group to relabel
  77050. * */
  77051. setHeaderName(label: string, groupNb: number): void;
  77052. /** Change selector label to the one given
  77053. * @param label is the new selector label
  77054. * @param groupNb is the number of the groupcontaining the selector
  77055. * @param selectorNb is the number of the selector within a group to relabel
  77056. * */
  77057. relabel(label: string, groupNb: number, selectorNb: number): void;
  77058. /** For a given group position remove the selector at the given position
  77059. * @param groupNb is the number of the group to remove the selector from
  77060. * @param selectorNb is the number of the selector within the group
  77061. */
  77062. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77063. /** For a given group position of correct type add a checkbox button
  77064. * @param groupNb is the number of the group to remove the selector from
  77065. * @param label is the label for the selector
  77066. * @param func is the function called when the Selector is checked
  77067. * @param checked is true when Selector is checked
  77068. */
  77069. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77070. /** For a given group position of correct type add a radio button
  77071. * @param groupNb is the number of the group to remove the selector from
  77072. * @param label is the label for the selector
  77073. * @param func is the function called when the Selector is checked
  77074. * @param checked is true when Selector is checked
  77075. */
  77076. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77077. /**
  77078. * For a given slider group add a slider
  77079. * @param groupNb is the number of the group to add the slider to
  77080. * @param label is the label for the Slider
  77081. * @param func is the function called when the Slider moves
  77082. * @param unit is a string describing the units used, eg degrees or metres
  77083. * @param min is the minimum value for the Slider
  77084. * @param max is the maximum value for the Slider
  77085. * @param value is the start value for the Slider between min and max
  77086. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77087. */
  77088. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77089. }
  77090. }
  77091. declare module BABYLON.GUI {
  77092. /**
  77093. * Class used to hold a the container for ScrollViewer
  77094. * @hidden
  77095. */
  77096. export class _ScrollViewerWindow extends Container {
  77097. parentClientWidth: number;
  77098. parentClientHeight: number;
  77099. private _freezeControls;
  77100. private _parentMeasure;
  77101. private _oldLeft;
  77102. private _oldTop;
  77103. get freezeControls(): boolean;
  77104. set freezeControls(value: boolean);
  77105. private _bucketWidth;
  77106. private _bucketHeight;
  77107. private _buckets;
  77108. private _bucketLen;
  77109. get bucketWidth(): number;
  77110. get bucketHeight(): number;
  77111. setBucketSizes(width: number, height: number): void;
  77112. private _useBuckets;
  77113. private _makeBuckets;
  77114. private _dispatchInBuckets;
  77115. private _updateMeasures;
  77116. private _updateChildrenMeasures;
  77117. private _restoreMeasures;
  77118. /**
  77119. * Creates a new ScrollViewerWindow
  77120. * @param name of ScrollViewerWindow
  77121. */
  77122. constructor(name?: string);
  77123. protected _getTypeName(): string;
  77124. /** @hidden */
  77125. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77126. /** @hidden */
  77127. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77128. private _scrollChildren;
  77129. private _scrollChildrenWithBuckets;
  77130. /** @hidden */
  77131. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77132. protected _postMeasure(): void;
  77133. }
  77134. }
  77135. declare module BABYLON.GUI {
  77136. /**
  77137. * Class used to create slider controls
  77138. */
  77139. export class ScrollBar extends BaseSlider {
  77140. name?: string | undefined;
  77141. private _background;
  77142. private _borderColor;
  77143. private _tempMeasure;
  77144. /** Gets or sets border color */
  77145. get borderColor(): string;
  77146. set borderColor(value: string);
  77147. /** Gets or sets background color */
  77148. get background(): string;
  77149. set background(value: string);
  77150. /**
  77151. * Creates a new Slider
  77152. * @param name defines the control name
  77153. */
  77154. constructor(name?: string | undefined);
  77155. protected _getTypeName(): string;
  77156. protected _getThumbThickness(): number;
  77157. _draw(context: CanvasRenderingContext2D): void;
  77158. private _first;
  77159. private _originX;
  77160. private _originY;
  77161. /** @hidden */
  77162. protected _updateValueFromPointer(x: number, y: number): void;
  77163. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77164. }
  77165. }
  77166. declare module BABYLON.GUI {
  77167. /**
  77168. * Class used to create slider controls
  77169. */
  77170. export class ImageScrollBar extends BaseSlider {
  77171. name?: string | undefined;
  77172. private _backgroundBaseImage;
  77173. private _backgroundImage;
  77174. private _thumbImage;
  77175. private _thumbBaseImage;
  77176. private _thumbLength;
  77177. private _thumbHeight;
  77178. private _barImageHeight;
  77179. private _tempMeasure;
  77180. /** Number of 90° rotation to apply on the images when in vertical mode */
  77181. num90RotationInVerticalMode: number;
  77182. /**
  77183. * Gets or sets the image used to render the background for horizontal bar
  77184. */
  77185. get backgroundImage(): Image;
  77186. set backgroundImage(value: Image);
  77187. /**
  77188. * Gets or sets the image used to render the thumb
  77189. */
  77190. get thumbImage(): Image;
  77191. set thumbImage(value: Image);
  77192. /**
  77193. * Gets or sets the length of the thumb
  77194. */
  77195. get thumbLength(): number;
  77196. set thumbLength(value: number);
  77197. /**
  77198. * Gets or sets the height of the thumb
  77199. */
  77200. get thumbHeight(): number;
  77201. set thumbHeight(value: number);
  77202. /**
  77203. * Gets or sets the height of the bar image
  77204. */
  77205. get barImageHeight(): number;
  77206. set barImageHeight(value: number);
  77207. /**
  77208. * Creates a new ImageScrollBar
  77209. * @param name defines the control name
  77210. */
  77211. constructor(name?: string | undefined);
  77212. protected _getTypeName(): string;
  77213. protected _getThumbThickness(): number;
  77214. _draw(context: CanvasRenderingContext2D): void;
  77215. private _first;
  77216. private _originX;
  77217. private _originY;
  77218. /** @hidden */
  77219. protected _updateValueFromPointer(x: number, y: number): void;
  77220. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77221. }
  77222. }
  77223. declare module BABYLON.GUI {
  77224. /**
  77225. * Class used to hold a viewer window and sliders in a grid
  77226. */
  77227. export class ScrollViewer extends Rectangle {
  77228. private _grid;
  77229. private _horizontalBarSpace;
  77230. private _verticalBarSpace;
  77231. private _dragSpace;
  77232. private _horizontalBar;
  77233. private _verticalBar;
  77234. private _barColor;
  77235. private _barBackground;
  77236. private _barImage;
  77237. private _horizontalBarImage;
  77238. private _verticalBarImage;
  77239. private _barBackgroundImage;
  77240. private _horizontalBarBackgroundImage;
  77241. private _verticalBarBackgroundImage;
  77242. private _barSize;
  77243. private _window;
  77244. private _pointerIsOver;
  77245. private _wheelPrecision;
  77246. private _onWheelObserver;
  77247. private _clientWidth;
  77248. private _clientHeight;
  77249. private _useImageBar;
  77250. private _thumbLength;
  77251. private _thumbHeight;
  77252. private _barImageHeight;
  77253. private _horizontalBarImageHeight;
  77254. private _verticalBarImageHeight;
  77255. private _oldWindowContentsWidth;
  77256. private _oldWindowContentsHeight;
  77257. /**
  77258. * Gets the horizontal scrollbar
  77259. */
  77260. get horizontalBar(): ScrollBar | ImageScrollBar;
  77261. /**
  77262. * Gets the vertical scrollbar
  77263. */
  77264. get verticalBar(): ScrollBar | ImageScrollBar;
  77265. /**
  77266. * Adds a new control to the current container
  77267. * @param control defines the control to add
  77268. * @returns the current container
  77269. */
  77270. addControl(control: BABYLON.Nullable<Control>): Container;
  77271. /**
  77272. * Removes a control from the current container
  77273. * @param control defines the control to remove
  77274. * @returns the current container
  77275. */
  77276. removeControl(control: Control): Container;
  77277. /** Gets the list of children */
  77278. get children(): Control[];
  77279. _flagDescendantsAsMatrixDirty(): void;
  77280. /**
  77281. * Freezes or unfreezes the controls in the window.
  77282. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77283. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77284. */
  77285. get freezeControls(): boolean;
  77286. set freezeControls(value: boolean);
  77287. /** Gets the bucket width */
  77288. get bucketWidth(): number;
  77289. /** Gets the bucket height */
  77290. get bucketHeight(): number;
  77291. /**
  77292. * Sets the bucket sizes.
  77293. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77294. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77295. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77296. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77297. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77298. * used), that's why it is not enabled by default.
  77299. * @param width width of the bucket
  77300. * @param height height of the bucket
  77301. */
  77302. setBucketSizes(width: number, height: number): void;
  77303. private _forceHorizontalBar;
  77304. private _forceVerticalBar;
  77305. /**
  77306. * Forces the horizontal scroll bar to be displayed
  77307. */
  77308. get forceHorizontalBar(): boolean;
  77309. set forceHorizontalBar(value: boolean);
  77310. /**
  77311. * Forces the vertical scroll bar to be displayed
  77312. */
  77313. get forceVerticalBar(): boolean;
  77314. set forceVerticalBar(value: boolean);
  77315. /**
  77316. * Creates a new ScrollViewer
  77317. * @param name of ScrollViewer
  77318. */
  77319. constructor(name?: string, isImageBased?: boolean);
  77320. /** Reset the scroll viewer window to initial size */
  77321. resetWindow(): void;
  77322. protected _getTypeName(): string;
  77323. private _buildClientSizes;
  77324. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77325. protected _postMeasure(): void;
  77326. /**
  77327. * Gets or sets the mouse wheel precision
  77328. * from 0 to 1 with a default value of 0.05
  77329. * */
  77330. get wheelPrecision(): number;
  77331. set wheelPrecision(value: number);
  77332. /** Gets or sets the scroll bar container background color */
  77333. get scrollBackground(): string;
  77334. set scrollBackground(color: string);
  77335. /** Gets or sets the bar color */
  77336. get barColor(): string;
  77337. set barColor(color: string);
  77338. /** Gets or sets the bar image */
  77339. get thumbImage(): Image;
  77340. set thumbImage(value: Image);
  77341. /** Gets or sets the horizontal bar image */
  77342. get horizontalThumbImage(): Image;
  77343. set horizontalThumbImage(value: Image);
  77344. /** Gets or sets the vertical bar image */
  77345. get verticalThumbImage(): Image;
  77346. set verticalThumbImage(value: Image);
  77347. /** Gets or sets the size of the bar */
  77348. get barSize(): number;
  77349. set barSize(value: number);
  77350. /** Gets or sets the length of the thumb */
  77351. get thumbLength(): number;
  77352. set thumbLength(value: number);
  77353. /** Gets or sets the height of the thumb */
  77354. get thumbHeight(): number;
  77355. set thumbHeight(value: number);
  77356. /** Gets or sets the height of the bar image */
  77357. get barImageHeight(): number;
  77358. set barImageHeight(value: number);
  77359. /** Gets or sets the height of the horizontal bar image */
  77360. get horizontalBarImageHeight(): number;
  77361. set horizontalBarImageHeight(value: number);
  77362. /** Gets or sets the height of the vertical bar image */
  77363. get verticalBarImageHeight(): number;
  77364. set verticalBarImageHeight(value: number);
  77365. /** Gets or sets the bar background */
  77366. get barBackground(): string;
  77367. set barBackground(color: string);
  77368. /** Gets or sets the bar background image */
  77369. get barImage(): Image;
  77370. set barImage(value: Image);
  77371. /** Gets or sets the horizontal bar background image */
  77372. get horizontalBarImage(): Image;
  77373. set horizontalBarImage(value: Image);
  77374. /** Gets or sets the vertical bar background image */
  77375. get verticalBarImage(): Image;
  77376. set verticalBarImage(value: Image);
  77377. private _setWindowPosition;
  77378. /** @hidden */
  77379. private _updateScroller;
  77380. _link(host: AdvancedDynamicTexture): void;
  77381. /** @hidden */
  77382. private _addBar;
  77383. /** @hidden */
  77384. private _attachWheel;
  77385. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77386. /** Releases associated resources */
  77387. dispose(): void;
  77388. }
  77389. }
  77390. declare module BABYLON.GUI {
  77391. /** Class used to render a grid */
  77392. export class DisplayGrid extends Control {
  77393. name?: string | undefined;
  77394. private _cellWidth;
  77395. private _cellHeight;
  77396. private _minorLineTickness;
  77397. private _minorLineColor;
  77398. private _majorLineTickness;
  77399. private _majorLineColor;
  77400. private _majorLineFrequency;
  77401. private _background;
  77402. private _displayMajorLines;
  77403. private _displayMinorLines;
  77404. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77405. get displayMinorLines(): boolean;
  77406. set displayMinorLines(value: boolean);
  77407. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77408. get displayMajorLines(): boolean;
  77409. set displayMajorLines(value: boolean);
  77410. /** Gets or sets background color (Black by default) */
  77411. get background(): string;
  77412. set background(value: string);
  77413. /** Gets or sets the width of each cell (20 by default) */
  77414. get cellWidth(): number;
  77415. set cellWidth(value: number);
  77416. /** Gets or sets the height of each cell (20 by default) */
  77417. get cellHeight(): number;
  77418. set cellHeight(value: number);
  77419. /** Gets or sets the tickness of minor lines (1 by default) */
  77420. get minorLineTickness(): number;
  77421. set minorLineTickness(value: number);
  77422. /** Gets or sets the color of minor lines (DarkGray by default) */
  77423. get minorLineColor(): string;
  77424. set minorLineColor(value: string);
  77425. /** Gets or sets the tickness of major lines (2 by default) */
  77426. get majorLineTickness(): number;
  77427. set majorLineTickness(value: number);
  77428. /** Gets or sets the color of major lines (White by default) */
  77429. get majorLineColor(): string;
  77430. set majorLineColor(value: string);
  77431. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77432. get majorLineFrequency(): number;
  77433. set majorLineFrequency(value: number);
  77434. /**
  77435. * Creates a new GridDisplayRectangle
  77436. * @param name defines the control name
  77437. */
  77438. constructor(name?: string | undefined);
  77439. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77440. protected _getTypeName(): string;
  77441. }
  77442. }
  77443. declare module BABYLON.GUI {
  77444. /**
  77445. * Class used to create slider controls based on images
  77446. */
  77447. export class ImageBasedSlider extends BaseSlider {
  77448. name?: string | undefined;
  77449. private _backgroundImage;
  77450. private _thumbImage;
  77451. private _valueBarImage;
  77452. private _tempMeasure;
  77453. get displayThumb(): boolean;
  77454. set displayThumb(value: boolean);
  77455. /**
  77456. * Gets or sets the image used to render the background
  77457. */
  77458. get backgroundImage(): Image;
  77459. set backgroundImage(value: Image);
  77460. /**
  77461. * Gets or sets the image used to render the value bar
  77462. */
  77463. get valueBarImage(): Image;
  77464. set valueBarImage(value: Image);
  77465. /**
  77466. * Gets or sets the image used to render the thumb
  77467. */
  77468. get thumbImage(): Image;
  77469. set thumbImage(value: Image);
  77470. /**
  77471. * Creates a new ImageBasedSlider
  77472. * @param name defines the control name
  77473. */
  77474. constructor(name?: string | undefined);
  77475. protected _getTypeName(): string;
  77476. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77477. }
  77478. }
  77479. declare module BABYLON.GUI {
  77480. /**
  77481. * Forcing an export so that this code will execute
  77482. * @hidden
  77483. */
  77484. const name = "Statics";
  77485. }
  77486. declare module BABYLON.GUI {
  77487. /**
  77488. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77489. */
  77490. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77491. /**
  77492. * Define the instrumented AdvancedDynamicTexture.
  77493. */
  77494. texture: AdvancedDynamicTexture;
  77495. private _captureRenderTime;
  77496. private _renderTime;
  77497. private _captureLayoutTime;
  77498. private _layoutTime;
  77499. private _onBeginRenderObserver;
  77500. private _onEndRenderObserver;
  77501. private _onBeginLayoutObserver;
  77502. private _onEndLayoutObserver;
  77503. /**
  77504. * Gets the perf counter used to capture render time
  77505. */
  77506. get renderTimeCounter(): BABYLON.PerfCounter;
  77507. /**
  77508. * Gets the perf counter used to capture layout time
  77509. */
  77510. get layoutTimeCounter(): BABYLON.PerfCounter;
  77511. /**
  77512. * Enable or disable the render time capture
  77513. */
  77514. get captureRenderTime(): boolean;
  77515. set captureRenderTime(value: boolean);
  77516. /**
  77517. * Enable or disable the layout time capture
  77518. */
  77519. get captureLayoutTime(): boolean;
  77520. set captureLayoutTime(value: boolean);
  77521. /**
  77522. * Instantiates a new advanced dynamic texture instrumentation.
  77523. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77524. * @param texture Defines the AdvancedDynamicTexture to instrument
  77525. */
  77526. constructor(
  77527. /**
  77528. * Define the instrumented AdvancedDynamicTexture.
  77529. */
  77530. texture: AdvancedDynamicTexture);
  77531. /**
  77532. * Dispose and release associated resources.
  77533. */
  77534. dispose(): void;
  77535. }
  77536. }
  77537. declare module BABYLON.GUI {
  77538. /**
  77539. * Class used to load GUI via XML.
  77540. */
  77541. export class XmlLoader {
  77542. private _nodes;
  77543. private _nodeTypes;
  77544. private _isLoaded;
  77545. private _objectAttributes;
  77546. private _parentClass;
  77547. /**
  77548. * Create a new xml loader
  77549. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77550. */
  77551. constructor(parentClass?: null);
  77552. private _getChainElement;
  77553. private _getClassAttribute;
  77554. private _createGuiElement;
  77555. private _parseGrid;
  77556. private _parseElement;
  77557. private _prepareSourceElement;
  77558. private _parseElementsFromSource;
  77559. private _parseXml;
  77560. /**
  77561. * Gets if the loading has finished.
  77562. * @returns whether the loading has finished or not
  77563. */
  77564. isLoaded(): boolean;
  77565. /**
  77566. * Gets a loaded node / control by id.
  77567. * @param id the Controls id set in the xml
  77568. * @returns element of type Control
  77569. */
  77570. getNodeById(id: string): any;
  77571. /**
  77572. * Gets all loaded nodes / controls
  77573. * @returns Array of controls
  77574. */
  77575. getNodes(): any;
  77576. /**
  77577. * Initiates the xml layout loading
  77578. * @param xmlFile defines the xml layout to load
  77579. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77580. * @param callback defines the callback called on layout load.
  77581. */
  77582. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77583. }
  77584. }
  77585. declare module BABYLON.GUI {
  77586. /**
  77587. * Class used to create containers for controls
  77588. */
  77589. export class Container3D extends Control3D {
  77590. private _blockLayout;
  77591. /**
  77592. * Gets the list of child controls
  77593. */
  77594. protected _children: Control3D[];
  77595. /**
  77596. * Gets the list of child controls
  77597. */
  77598. get children(): Array<Control3D>;
  77599. /**
  77600. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77601. * This is helpful to optimize layout operation when adding multiple children in a row
  77602. */
  77603. get blockLayout(): boolean;
  77604. set blockLayout(value: boolean);
  77605. /**
  77606. * Creates a new container
  77607. * @param name defines the container name
  77608. */
  77609. constructor(name?: string);
  77610. /**
  77611. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77612. * @returns the current container
  77613. */
  77614. updateLayout(): Container3D;
  77615. /**
  77616. * Gets a boolean indicating if the given control is in the children of this control
  77617. * @param control defines the control to check
  77618. * @returns true if the control is in the child list
  77619. */
  77620. containsControl(control: Control3D): boolean;
  77621. /**
  77622. * Adds a control to the children of this control
  77623. * @param control defines the control to add
  77624. * @returns the current container
  77625. */
  77626. addControl(control: Control3D): Container3D;
  77627. /**
  77628. * This function will be called everytime a new control is added
  77629. */
  77630. protected _arrangeChildren(): void;
  77631. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77632. /**
  77633. * Removes a control from the children of this control
  77634. * @param control defines the control to remove
  77635. * @returns the current container
  77636. */
  77637. removeControl(control: Control3D): Container3D;
  77638. protected _getTypeName(): string;
  77639. /**
  77640. * Releases all associated resources
  77641. */
  77642. dispose(): void;
  77643. /** Control rotation will remain unchanged */
  77644. static readonly UNSET_ORIENTATION: number;
  77645. /** Control will rotate to make it look at sphere central axis */
  77646. static readonly FACEORIGIN_ORIENTATION: number;
  77647. /** Control will rotate to make it look back at sphere central axis */
  77648. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77649. /** Control will rotate to look at z axis (0, 0, 1) */
  77650. static readonly FACEFORWARD_ORIENTATION: number;
  77651. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77652. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77653. }
  77654. }
  77655. declare module BABYLON.GUI {
  77656. /**
  77657. * Class used to manage 3D user interface
  77658. * @see http://doc.babylonjs.com/how_to/gui3d
  77659. */
  77660. export class GUI3DManager implements BABYLON.IDisposable {
  77661. private _scene;
  77662. private _sceneDisposeObserver;
  77663. private _utilityLayer;
  77664. private _rootContainer;
  77665. private _pointerObserver;
  77666. private _pointerOutObserver;
  77667. /** @hidden */
  77668. _lastPickedControl: Control3D;
  77669. /** @hidden */
  77670. _lastControlOver: {
  77671. [pointerId: number]: Control3D;
  77672. };
  77673. /** @hidden */
  77674. _lastControlDown: {
  77675. [pointerId: number]: Control3D;
  77676. };
  77677. /**
  77678. * BABYLON.Observable raised when the point picked by the pointer events changed
  77679. */
  77680. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77681. /** @hidden */
  77682. _sharedMaterials: {
  77683. [key: string]: BABYLON.Material;
  77684. };
  77685. /** Gets the hosting scene */
  77686. get scene(): BABYLON.Scene;
  77687. /** Gets associated utility layer */
  77688. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77689. /**
  77690. * Creates a new GUI3DManager
  77691. * @param scene
  77692. */
  77693. constructor(scene?: BABYLON.Scene);
  77694. private _handlePointerOut;
  77695. private _doPicking;
  77696. /**
  77697. * Gets the root container
  77698. */
  77699. get rootContainer(): Container3D;
  77700. /**
  77701. * Gets a boolean indicating if the given control is in the root child list
  77702. * @param control defines the control to check
  77703. * @returns true if the control is in the root child list
  77704. */
  77705. containsControl(control: Control3D): boolean;
  77706. /**
  77707. * Adds a control to the root child list
  77708. * @param control defines the control to add
  77709. * @returns the current manager
  77710. */
  77711. addControl(control: Control3D): GUI3DManager;
  77712. /**
  77713. * Removes a control from the root child list
  77714. * @param control defines the control to remove
  77715. * @returns the current container
  77716. */
  77717. removeControl(control: Control3D): GUI3DManager;
  77718. /**
  77719. * Releases all associated resources
  77720. */
  77721. dispose(): void;
  77722. }
  77723. }
  77724. declare module BABYLON.GUI {
  77725. /**
  77726. * Class used to transport BABYLON.Vector3 information for pointer events
  77727. */
  77728. export class Vector3WithInfo extends BABYLON.Vector3 {
  77729. /** defines the current mouse button index */
  77730. buttonIndex: number;
  77731. /**
  77732. * Creates a new Vector3WithInfo
  77733. * @param source defines the vector3 data to transport
  77734. * @param buttonIndex defines the current mouse button index
  77735. */
  77736. constructor(source: BABYLON.Vector3,
  77737. /** defines the current mouse button index */
  77738. buttonIndex?: number);
  77739. }
  77740. }
  77741. declare module BABYLON.GUI {
  77742. /**
  77743. * Class used as base class for controls
  77744. */
  77745. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77746. /** Defines the control name */
  77747. name?: string | undefined;
  77748. /** @hidden */
  77749. _host: GUI3DManager;
  77750. private _node;
  77751. private _downCount;
  77752. private _enterCount;
  77753. private _downPointerIds;
  77754. private _isVisible;
  77755. /** Gets or sets the control position in world space */
  77756. get position(): BABYLON.Vector3;
  77757. set position(value: BABYLON.Vector3);
  77758. /** Gets or sets the control scaling in world space */
  77759. get scaling(): BABYLON.Vector3;
  77760. set scaling(value: BABYLON.Vector3);
  77761. /** Callback used to start pointer enter animation */
  77762. pointerEnterAnimation: () => void;
  77763. /** Callback used to start pointer out animation */
  77764. pointerOutAnimation: () => void;
  77765. /** Callback used to start pointer down animation */
  77766. pointerDownAnimation: () => void;
  77767. /** Callback used to start pointer up animation */
  77768. pointerUpAnimation: () => void;
  77769. /**
  77770. * An event triggered when the pointer move over the control
  77771. */
  77772. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77773. /**
  77774. * An event triggered when the pointer move out of the control
  77775. */
  77776. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77777. /**
  77778. * An event triggered when the pointer taps the control
  77779. */
  77780. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77781. /**
  77782. * An event triggered when pointer is up
  77783. */
  77784. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77785. /**
  77786. * An event triggered when a control is clicked on (with a mouse)
  77787. */
  77788. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77789. /**
  77790. * An event triggered when pointer enters the control
  77791. */
  77792. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77793. /**
  77794. * Gets or sets the parent container
  77795. */
  77796. parent: BABYLON.Nullable<Container3D>;
  77797. private _behaviors;
  77798. /**
  77799. * Gets the list of attached behaviors
  77800. * @see http://doc.babylonjs.com/features/behaviour
  77801. */
  77802. get behaviors(): BABYLON.Behavior<Control3D>[];
  77803. /**
  77804. * Attach a behavior to the control
  77805. * @see http://doc.babylonjs.com/features/behaviour
  77806. * @param behavior defines the behavior to attach
  77807. * @returns the current control
  77808. */
  77809. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77810. /**
  77811. * Remove an attached behavior
  77812. * @see http://doc.babylonjs.com/features/behaviour
  77813. * @param behavior defines the behavior to attach
  77814. * @returns the current control
  77815. */
  77816. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77817. /**
  77818. * Gets an attached behavior by name
  77819. * @param name defines the name of the behavior to look for
  77820. * @see http://doc.babylonjs.com/features/behaviour
  77821. * @returns null if behavior was not found else the requested behavior
  77822. */
  77823. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77824. /** Gets or sets a boolean indicating if the control is visible */
  77825. get isVisible(): boolean;
  77826. set isVisible(value: boolean);
  77827. /**
  77828. * Creates a new control
  77829. * @param name defines the control name
  77830. */
  77831. constructor(
  77832. /** Defines the control name */
  77833. name?: string | undefined);
  77834. /**
  77835. * Gets a string representing the class name
  77836. */
  77837. get typeName(): string;
  77838. /**
  77839. * Get the current class name of the control.
  77840. * @returns current class name
  77841. */
  77842. getClassName(): string;
  77843. protected _getTypeName(): string;
  77844. /**
  77845. * Gets the transform node used by this control
  77846. */
  77847. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77848. /**
  77849. * Gets the mesh used to render this control
  77850. */
  77851. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77852. /**
  77853. * Link the control as child of the given node
  77854. * @param node defines the node to link to. Use null to unlink the control
  77855. * @returns the current control
  77856. */
  77857. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77858. /** @hidden **/
  77859. _prepareNode(scene: BABYLON.Scene): void;
  77860. /**
  77861. * Node creation.
  77862. * Can be overriden by children
  77863. * @param scene defines the scene where the node must be attached
  77864. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77865. */
  77866. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77867. /**
  77868. * Affect a material to the given mesh
  77869. * @param mesh defines the mesh which will represent the control
  77870. */
  77871. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77872. /** @hidden */
  77873. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77874. /** @hidden */
  77875. _onPointerEnter(target: Control3D): boolean;
  77876. /** @hidden */
  77877. _onPointerOut(target: Control3D): void;
  77878. /** @hidden */
  77879. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77880. /** @hidden */
  77881. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77882. /** @hidden */
  77883. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77884. /** @hidden */
  77885. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77886. /** @hidden */
  77887. _disposeNode(): void;
  77888. /**
  77889. * Releases all associated resources
  77890. */
  77891. dispose(): void;
  77892. }
  77893. }
  77894. declare module BABYLON.GUI {
  77895. /**
  77896. * Class used as a root to all buttons
  77897. */
  77898. export class AbstractButton3D extends Control3D {
  77899. /**
  77900. * Creates a new button
  77901. * @param name defines the control name
  77902. */
  77903. constructor(name?: string);
  77904. protected _getTypeName(): string;
  77905. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77906. }
  77907. }
  77908. declare module BABYLON.GUI {
  77909. /**
  77910. * Class used to create a button in 3D
  77911. */
  77912. export class Button3D extends AbstractButton3D {
  77913. /** @hidden */
  77914. protected _currentMaterial: BABYLON.Material;
  77915. private _facadeTexture;
  77916. private _content;
  77917. private _contentResolution;
  77918. private _contentScaleRatio;
  77919. /**
  77920. * Gets or sets the texture resolution used to render content (512 by default)
  77921. */
  77922. get contentResolution(): BABYLON.int;
  77923. set contentResolution(value: BABYLON.int);
  77924. /**
  77925. * Gets or sets the texture scale ratio used to render content (2 by default)
  77926. */
  77927. get contentScaleRatio(): number;
  77928. set contentScaleRatio(value: number);
  77929. protected _disposeFacadeTexture(): void;
  77930. protected _resetContent(): void;
  77931. /**
  77932. * Creates a new button
  77933. * @param name defines the control name
  77934. */
  77935. constructor(name?: string);
  77936. /**
  77937. * Gets or sets the GUI 2D content used to display the button's facade
  77938. */
  77939. get content(): Control;
  77940. set content(value: Control);
  77941. /**
  77942. * Apply the facade texture (created from the content property).
  77943. * This function can be overloaded by child classes
  77944. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77945. */
  77946. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77947. protected _getTypeName(): string;
  77948. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77949. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77950. /**
  77951. * Releases all associated resources
  77952. */
  77953. dispose(): void;
  77954. }
  77955. }
  77956. declare module BABYLON.GUI {
  77957. /**
  77958. * Abstract class used to create a container panel deployed on the surface of a volume
  77959. */
  77960. export abstract class VolumeBasedPanel extends Container3D {
  77961. private _columns;
  77962. private _rows;
  77963. private _rowThenColum;
  77964. private _orientation;
  77965. protected _cellWidth: number;
  77966. protected _cellHeight: number;
  77967. /**
  77968. * Gets or sets the distance between elements
  77969. */
  77970. margin: number;
  77971. /**
  77972. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77973. * | Value | Type | Description |
  77974. * | ----- | ----------------------------------- | ----------- |
  77975. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77976. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77977. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77978. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77979. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77980. */
  77981. get orientation(): number;
  77982. set orientation(value: number);
  77983. /**
  77984. * Gets or sets the number of columns requested (10 by default).
  77985. * The panel will automatically compute the number of rows based on number of child controls.
  77986. */
  77987. get columns(): BABYLON.int;
  77988. set columns(value: BABYLON.int);
  77989. /**
  77990. * Gets or sets a the number of rows requested.
  77991. * The panel will automatically compute the number of columns based on number of child controls.
  77992. */
  77993. get rows(): BABYLON.int;
  77994. set rows(value: BABYLON.int);
  77995. /**
  77996. * Creates new VolumeBasedPanel
  77997. */
  77998. constructor();
  77999. protected _arrangeChildren(): void;
  78000. /** Child classes must implement this function to provide correct control positioning */
  78001. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78002. /** Child classes can implement this function to provide additional processing */
  78003. protected _finalProcessing(): void;
  78004. }
  78005. }
  78006. declare module BABYLON.GUI {
  78007. /**
  78008. * Class used to create a container panel deployed on the surface of a cylinder
  78009. */
  78010. export class CylinderPanel extends VolumeBasedPanel {
  78011. private _radius;
  78012. /**
  78013. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78014. */
  78015. get radius(): BABYLON.float;
  78016. set radius(value: BABYLON.float);
  78017. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78018. private _cylindricalMapping;
  78019. }
  78020. }
  78021. declare module BABYLON.GUI {
  78022. /** @hidden */
  78023. export var fluentVertexShader: {
  78024. name: string;
  78025. shader: string;
  78026. };
  78027. }
  78028. declare module BABYLON.GUI {
  78029. /** @hidden */
  78030. export var fluentPixelShader: {
  78031. name: string;
  78032. shader: string;
  78033. };
  78034. }
  78035. declare module BABYLON.GUI {
  78036. /** @hidden */
  78037. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78038. INNERGLOW: boolean;
  78039. BORDER: boolean;
  78040. HOVERLIGHT: boolean;
  78041. TEXTURE: boolean;
  78042. constructor();
  78043. }
  78044. /**
  78045. * Class used to render controls with fluent desgin
  78046. */
  78047. export class FluentMaterial extends BABYLON.PushMaterial {
  78048. /**
  78049. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78050. */
  78051. innerGlowColorIntensity: number;
  78052. /**
  78053. * Gets or sets the inner glow color (white by default)
  78054. */
  78055. innerGlowColor: BABYLON.Color3;
  78056. /**
  78057. * Gets or sets alpha value (default is 1.0)
  78058. */
  78059. alpha: number;
  78060. /**
  78061. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78062. */
  78063. albedoColor: BABYLON.Color3;
  78064. /**
  78065. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78066. */
  78067. renderBorders: boolean;
  78068. /**
  78069. * Gets or sets border width (default is 0.5)
  78070. */
  78071. borderWidth: number;
  78072. /**
  78073. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78074. */
  78075. edgeSmoothingValue: number;
  78076. /**
  78077. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78078. */
  78079. borderMinValue: number;
  78080. /**
  78081. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78082. */
  78083. renderHoverLight: boolean;
  78084. /**
  78085. * Gets or sets the radius used to render the hover light (default is 1.0)
  78086. */
  78087. hoverRadius: number;
  78088. /**
  78089. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78090. */
  78091. hoverColor: BABYLON.Color4;
  78092. /**
  78093. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78094. */
  78095. hoverPosition: BABYLON.Vector3;
  78096. private _albedoTexture;
  78097. /** Gets or sets the texture to use for albedo color */
  78098. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78099. /**
  78100. * Creates a new Fluent material
  78101. * @param name defines the name of the material
  78102. * @param scene defines the hosting scene
  78103. */
  78104. constructor(name: string, scene: BABYLON.Scene);
  78105. needAlphaBlending(): boolean;
  78106. needAlphaTesting(): boolean;
  78107. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78108. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78109. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78110. getActiveTextures(): BABYLON.BaseTexture[];
  78111. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78112. dispose(forceDisposeEffect?: boolean): void;
  78113. clone(name: string): FluentMaterial;
  78114. serialize(): any;
  78115. getClassName(): string;
  78116. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78117. }
  78118. }
  78119. declare module BABYLON.GUI {
  78120. /**
  78121. * Class used to create a holographic button in 3D
  78122. */
  78123. export class HolographicButton extends Button3D {
  78124. private _backPlate;
  78125. private _textPlate;
  78126. private _frontPlate;
  78127. private _text;
  78128. private _imageUrl;
  78129. private _shareMaterials;
  78130. private _frontMaterial;
  78131. private _backMaterial;
  78132. private _plateMaterial;
  78133. private _pickedPointObserver;
  78134. private _tooltipFade;
  78135. private _tooltipTextBlock;
  78136. private _tooltipTexture;
  78137. private _tooltipMesh;
  78138. private _tooltipHoverObserver;
  78139. private _tooltipOutObserver;
  78140. private _disposeTooltip;
  78141. /**
  78142. * Rendering ground id of all the mesh in the button
  78143. */
  78144. set renderingGroupId(id: number);
  78145. get renderingGroupId(): number;
  78146. /**
  78147. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78148. */
  78149. set tooltipText(text: BABYLON.Nullable<string>);
  78150. get tooltipText(): BABYLON.Nullable<string>;
  78151. /**
  78152. * Gets or sets text for the button
  78153. */
  78154. get text(): string;
  78155. set text(value: string);
  78156. /**
  78157. * Gets or sets the image url for the button
  78158. */
  78159. get imageUrl(): string;
  78160. set imageUrl(value: string);
  78161. /**
  78162. * Gets the back material used by this button
  78163. */
  78164. get backMaterial(): FluentMaterial;
  78165. /**
  78166. * Gets the front material used by this button
  78167. */
  78168. get frontMaterial(): FluentMaterial;
  78169. /**
  78170. * Gets the plate material used by this button
  78171. */
  78172. get plateMaterial(): BABYLON.StandardMaterial;
  78173. /**
  78174. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78175. */
  78176. get shareMaterials(): boolean;
  78177. /**
  78178. * Creates a new button
  78179. * @param name defines the control name
  78180. */
  78181. constructor(name?: string, shareMaterials?: boolean);
  78182. protected _getTypeName(): string;
  78183. private _rebuildContent;
  78184. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78185. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78186. private _createBackMaterial;
  78187. private _createFrontMaterial;
  78188. private _createPlateMaterial;
  78189. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78190. /**
  78191. * Releases all associated resources
  78192. */
  78193. dispose(): void;
  78194. }
  78195. }
  78196. declare module BABYLON.GUI {
  78197. /**
  78198. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78199. */
  78200. export class MeshButton3D extends Button3D {
  78201. /** @hidden */
  78202. protected _currentMesh: BABYLON.Mesh;
  78203. /**
  78204. * Creates a new 3D button based on a mesh
  78205. * @param mesh mesh to become a 3D button
  78206. * @param name defines the control name
  78207. */
  78208. constructor(mesh: BABYLON.Mesh, name?: string);
  78209. protected _getTypeName(): string;
  78210. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78211. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78212. }
  78213. }
  78214. declare module BABYLON.GUI {
  78215. /**
  78216. * Class used to create a container panel deployed on the surface of a plane
  78217. */
  78218. export class PlanePanel extends VolumeBasedPanel {
  78219. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78220. }
  78221. }
  78222. declare module BABYLON.GUI {
  78223. /**
  78224. * Class used to create a container panel where items get randomized planar mapping
  78225. */
  78226. export class ScatterPanel extends VolumeBasedPanel {
  78227. private _iteration;
  78228. /**
  78229. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78230. */
  78231. get iteration(): BABYLON.float;
  78232. set iteration(value: BABYLON.float);
  78233. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78234. private _scatterMapping;
  78235. protected _finalProcessing(): void;
  78236. }
  78237. }
  78238. declare module BABYLON.GUI {
  78239. /**
  78240. * Class used to create a container panel deployed on the surface of a sphere
  78241. */
  78242. export class SpherePanel extends VolumeBasedPanel {
  78243. private _radius;
  78244. /**
  78245. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78246. */
  78247. get radius(): BABYLON.float;
  78248. set radius(value: BABYLON.float);
  78249. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78250. private _sphericalMapping;
  78251. }
  78252. }
  78253. declare module BABYLON.GUI {
  78254. /**
  78255. * Class used to create a stack panel in 3D on XY plane
  78256. */
  78257. export class StackPanel3D extends Container3D {
  78258. private _isVertical;
  78259. /**
  78260. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78261. */
  78262. get isVertical(): boolean;
  78263. set isVertical(value: boolean);
  78264. /**
  78265. * Gets or sets the distance between elements
  78266. */
  78267. margin: number;
  78268. /**
  78269. * Creates new StackPanel
  78270. * @param isVertical
  78271. */
  78272. constructor(isVertical?: boolean);
  78273. protected _arrangeChildren(): void;
  78274. }
  78275. }
  78276. declare module BABYLON {
  78277. /**
  78278. * Configuration for glTF validation
  78279. */
  78280. export interface IGLTFValidationConfiguration {
  78281. /**
  78282. * The url of the glTF validator.
  78283. */
  78284. url: string;
  78285. }
  78286. /**
  78287. * glTF validation
  78288. */
  78289. export class GLTFValidation {
  78290. /**
  78291. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78292. */
  78293. static Configuration: IGLTFValidationConfiguration;
  78294. private static _LoadScriptPromise;
  78295. /**
  78296. * Validate a glTF asset using the glTF-Validator.
  78297. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78298. * @param rootUrl The root url for the glTF
  78299. * @param fileName The file name for the glTF
  78300. * @param getExternalResource The callback to get external resources for the glTF validator
  78301. * @returns A promise that resolves with the glTF validation results once complete
  78302. */
  78303. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78304. }
  78305. }
  78306. declare module BABYLON {
  78307. /**
  78308. * Mode that determines the coordinate system to use.
  78309. */
  78310. export enum GLTFLoaderCoordinateSystemMode {
  78311. /**
  78312. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78313. */
  78314. AUTO = 0,
  78315. /**
  78316. * Sets the useRightHandedSystem flag on the scene.
  78317. */
  78318. FORCE_RIGHT_HANDED = 1
  78319. }
  78320. /**
  78321. * Mode that determines what animations will start.
  78322. */
  78323. export enum GLTFLoaderAnimationStartMode {
  78324. /**
  78325. * No animation will start.
  78326. */
  78327. NONE = 0,
  78328. /**
  78329. * The first animation will start.
  78330. */
  78331. FIRST = 1,
  78332. /**
  78333. * All animations will start.
  78334. */
  78335. ALL = 2
  78336. }
  78337. /**
  78338. * Interface that contains the data for the glTF asset.
  78339. */
  78340. export interface IGLTFLoaderData {
  78341. /**
  78342. * The object that represents the glTF JSON.
  78343. */
  78344. json: Object;
  78345. /**
  78346. * The BIN chunk of a binary glTF.
  78347. */
  78348. bin: Nullable<IDataBuffer>;
  78349. }
  78350. /**
  78351. * Interface for extending the loader.
  78352. */
  78353. export interface IGLTFLoaderExtension {
  78354. /**
  78355. * The name of this extension.
  78356. */
  78357. readonly name: string;
  78358. /**
  78359. * Defines whether this extension is enabled.
  78360. */
  78361. enabled: boolean;
  78362. /**
  78363. * Defines the order of this extension.
  78364. * The loader sorts the extensions using these values when loading.
  78365. */
  78366. order?: number;
  78367. }
  78368. /**
  78369. * Loader state.
  78370. */
  78371. export enum GLTFLoaderState {
  78372. /**
  78373. * The asset is loading.
  78374. */
  78375. LOADING = 0,
  78376. /**
  78377. * The asset is ready for rendering.
  78378. */
  78379. READY = 1,
  78380. /**
  78381. * The asset is completely loaded.
  78382. */
  78383. COMPLETE = 2
  78384. }
  78385. /** @hidden */
  78386. export interface IImportMeshAsyncOutput {
  78387. meshes: AbstractMesh[];
  78388. particleSystems: IParticleSystem[];
  78389. skeletons: Skeleton[];
  78390. animationGroups: AnimationGroup[];
  78391. lights: Light[];
  78392. transformNodes: TransformNode[];
  78393. }
  78394. /** @hidden */
  78395. export interface IGLTFLoader extends IDisposable {
  78396. readonly state: Nullable<GLTFLoaderState>;
  78397. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78398. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78399. }
  78400. /**
  78401. * File loader for loading glTF files into a scene.
  78402. */
  78403. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78404. /** @hidden */
  78405. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78406. /** @hidden */
  78407. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78408. /**
  78409. * Raised when the asset has been parsed
  78410. */
  78411. onParsedObservable: Observable<IGLTFLoaderData>;
  78412. private _onParsedObserver;
  78413. /**
  78414. * Raised when the asset has been parsed
  78415. */
  78416. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78417. /**
  78418. * 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.
  78419. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78420. * Defaults to true.
  78421. * @hidden
  78422. */
  78423. static IncrementalLoading: boolean;
  78424. /**
  78425. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78426. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78427. * @hidden
  78428. */
  78429. static HomogeneousCoordinates: boolean;
  78430. /**
  78431. * The coordinate system mode. Defaults to AUTO.
  78432. */
  78433. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78434. /**
  78435. * The animation start mode. Defaults to FIRST.
  78436. */
  78437. animationStartMode: GLTFLoaderAnimationStartMode;
  78438. /**
  78439. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78440. */
  78441. compileMaterials: boolean;
  78442. /**
  78443. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78444. */
  78445. useClipPlane: boolean;
  78446. /**
  78447. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78448. */
  78449. compileShadowGenerators: boolean;
  78450. /**
  78451. * Defines if the Alpha blended materials are only applied as coverage.
  78452. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78453. * If true, no extra effects are applied to transparent pixels.
  78454. */
  78455. transparencyAsCoverage: boolean;
  78456. /**
  78457. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78458. * Enabling will disable offline support and glTF validator.
  78459. * Defaults to false.
  78460. */
  78461. useRangeRequests: boolean;
  78462. /**
  78463. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78464. */
  78465. createInstances: boolean;
  78466. /**
  78467. * Function called before loading a url referenced by the asset.
  78468. */
  78469. preprocessUrlAsync: (url: string) => Promise<string>;
  78470. /**
  78471. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78472. */
  78473. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78474. private _onMeshLoadedObserver;
  78475. /**
  78476. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78477. */
  78478. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78479. /**
  78480. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78481. */
  78482. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78483. private _onTextureLoadedObserver;
  78484. /**
  78485. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78486. */
  78487. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78488. /**
  78489. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78490. */
  78491. readonly onMaterialLoadedObservable: Observable<Material>;
  78492. private _onMaterialLoadedObserver;
  78493. /**
  78494. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78495. */
  78496. set onMaterialLoaded(callback: (material: Material) => void);
  78497. /**
  78498. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78499. */
  78500. readonly onCameraLoadedObservable: Observable<Camera>;
  78501. private _onCameraLoadedObserver;
  78502. /**
  78503. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78504. */
  78505. set onCameraLoaded(callback: (camera: Camera) => void);
  78506. /**
  78507. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78508. * For assets with LODs, raised when all of the LODs are complete.
  78509. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78510. */
  78511. readonly onCompleteObservable: Observable<void>;
  78512. private _onCompleteObserver;
  78513. /**
  78514. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78515. * For assets with LODs, raised when all of the LODs are complete.
  78516. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78517. */
  78518. set onComplete(callback: () => void);
  78519. /**
  78520. * Observable raised when an error occurs.
  78521. */
  78522. readonly onErrorObservable: Observable<any>;
  78523. private _onErrorObserver;
  78524. /**
  78525. * Callback raised when an error occurs.
  78526. */
  78527. set onError(callback: (reason: any) => void);
  78528. /**
  78529. * Observable raised after the loader is disposed.
  78530. */
  78531. readonly onDisposeObservable: Observable<void>;
  78532. private _onDisposeObserver;
  78533. /**
  78534. * Callback raised after the loader is disposed.
  78535. */
  78536. set onDispose(callback: () => void);
  78537. /**
  78538. * Observable raised after a loader extension is created.
  78539. * Set additional options for a loader extension in this event.
  78540. */
  78541. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78542. private _onExtensionLoadedObserver;
  78543. /**
  78544. * Callback raised after a loader extension is created.
  78545. */
  78546. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78547. /**
  78548. * Defines if the loader logging is enabled.
  78549. */
  78550. get loggingEnabled(): boolean;
  78551. set loggingEnabled(value: boolean);
  78552. /**
  78553. * Defines if the loader should capture performance counters.
  78554. */
  78555. get capturePerformanceCounters(): boolean;
  78556. set capturePerformanceCounters(value: boolean);
  78557. /**
  78558. * Defines if the loader should validate the asset.
  78559. */
  78560. validate: boolean;
  78561. /**
  78562. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78563. */
  78564. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78565. private _onValidatedObserver;
  78566. /**
  78567. * Callback raised after a loader extension is created.
  78568. */
  78569. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78570. private _loader;
  78571. /**
  78572. * Name of the loader ("gltf")
  78573. */
  78574. name: string;
  78575. /** @hidden */
  78576. extensions: ISceneLoaderPluginExtensions;
  78577. /**
  78578. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78579. */
  78580. dispose(): void;
  78581. /** @hidden */
  78582. _clear(): void;
  78583. /** @hidden */
  78584. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78585. /** @hidden */
  78586. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78587. /** @hidden */
  78588. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78589. meshes: AbstractMesh[];
  78590. particleSystems: IParticleSystem[];
  78591. skeletons: Skeleton[];
  78592. animationGroups: AnimationGroup[];
  78593. }>;
  78594. /** @hidden */
  78595. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78596. /** @hidden */
  78597. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78598. /** @hidden */
  78599. canDirectLoad(data: string): boolean;
  78600. /** @hidden */
  78601. directLoad(scene: Scene, data: string): any;
  78602. /**
  78603. * The callback that allows custom handling of the root url based on the response url.
  78604. * @param rootUrl the original root url
  78605. * @param responseURL the response url if available
  78606. * @returns the new root url
  78607. */
  78608. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78609. /** @hidden */
  78610. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78611. /**
  78612. * The loader state or null if the loader is not active.
  78613. */
  78614. get loaderState(): Nullable<GLTFLoaderState>;
  78615. /**
  78616. * Returns a promise that resolves when the asset is completely loaded.
  78617. * @returns a promise that resolves when the asset is completely loaded.
  78618. */
  78619. whenCompleteAsync(): Promise<void>;
  78620. private _validate;
  78621. private _getLoader;
  78622. private _parseJson;
  78623. private _unpackBinaryAsync;
  78624. private _unpackBinaryV1Async;
  78625. private _unpackBinaryV2Async;
  78626. private static _parseVersion;
  78627. private static _compareVersion;
  78628. private static readonly _logSpaces;
  78629. private _logIndentLevel;
  78630. private _loggingEnabled;
  78631. /** @hidden */
  78632. _log: (message: string) => void;
  78633. /** @hidden */
  78634. _logOpen(message: string): void;
  78635. /** @hidden */
  78636. _logClose(): void;
  78637. private _logEnabled;
  78638. private _logDisabled;
  78639. private _capturePerformanceCounters;
  78640. /** @hidden */
  78641. _startPerformanceCounter: (counterName: string) => void;
  78642. /** @hidden */
  78643. _endPerformanceCounter: (counterName: string) => void;
  78644. private _startPerformanceCounterEnabled;
  78645. private _startPerformanceCounterDisabled;
  78646. private _endPerformanceCounterEnabled;
  78647. private _endPerformanceCounterDisabled;
  78648. }
  78649. }
  78650. declare module BABYLON.GLTF1 {
  78651. /**
  78652. * Enums
  78653. * @hidden
  78654. */
  78655. export enum EComponentType {
  78656. BYTE = 5120,
  78657. UNSIGNED_BYTE = 5121,
  78658. SHORT = 5122,
  78659. UNSIGNED_SHORT = 5123,
  78660. FLOAT = 5126
  78661. }
  78662. /** @hidden */
  78663. export enum EShaderType {
  78664. FRAGMENT = 35632,
  78665. VERTEX = 35633
  78666. }
  78667. /** @hidden */
  78668. export enum EParameterType {
  78669. BYTE = 5120,
  78670. UNSIGNED_BYTE = 5121,
  78671. SHORT = 5122,
  78672. UNSIGNED_SHORT = 5123,
  78673. INT = 5124,
  78674. UNSIGNED_INT = 5125,
  78675. FLOAT = 5126,
  78676. FLOAT_VEC2 = 35664,
  78677. FLOAT_VEC3 = 35665,
  78678. FLOAT_VEC4 = 35666,
  78679. INT_VEC2 = 35667,
  78680. INT_VEC3 = 35668,
  78681. INT_VEC4 = 35669,
  78682. BOOL = 35670,
  78683. BOOL_VEC2 = 35671,
  78684. BOOL_VEC3 = 35672,
  78685. BOOL_VEC4 = 35673,
  78686. FLOAT_MAT2 = 35674,
  78687. FLOAT_MAT3 = 35675,
  78688. FLOAT_MAT4 = 35676,
  78689. SAMPLER_2D = 35678
  78690. }
  78691. /** @hidden */
  78692. export enum ETextureWrapMode {
  78693. CLAMP_TO_EDGE = 33071,
  78694. MIRRORED_REPEAT = 33648,
  78695. REPEAT = 10497
  78696. }
  78697. /** @hidden */
  78698. export enum ETextureFilterType {
  78699. NEAREST = 9728,
  78700. LINEAR = 9728,
  78701. NEAREST_MIPMAP_NEAREST = 9984,
  78702. LINEAR_MIPMAP_NEAREST = 9985,
  78703. NEAREST_MIPMAP_LINEAR = 9986,
  78704. LINEAR_MIPMAP_LINEAR = 9987
  78705. }
  78706. /** @hidden */
  78707. export enum ETextureFormat {
  78708. ALPHA = 6406,
  78709. RGB = 6407,
  78710. RGBA = 6408,
  78711. LUMINANCE = 6409,
  78712. LUMINANCE_ALPHA = 6410
  78713. }
  78714. /** @hidden */
  78715. export enum ECullingType {
  78716. FRONT = 1028,
  78717. BACK = 1029,
  78718. FRONT_AND_BACK = 1032
  78719. }
  78720. /** @hidden */
  78721. export enum EBlendingFunction {
  78722. ZERO = 0,
  78723. ONE = 1,
  78724. SRC_COLOR = 768,
  78725. ONE_MINUS_SRC_COLOR = 769,
  78726. DST_COLOR = 774,
  78727. ONE_MINUS_DST_COLOR = 775,
  78728. SRC_ALPHA = 770,
  78729. ONE_MINUS_SRC_ALPHA = 771,
  78730. DST_ALPHA = 772,
  78731. ONE_MINUS_DST_ALPHA = 773,
  78732. CONSTANT_COLOR = 32769,
  78733. ONE_MINUS_CONSTANT_COLOR = 32770,
  78734. CONSTANT_ALPHA = 32771,
  78735. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78736. SRC_ALPHA_SATURATE = 776
  78737. }
  78738. /** @hidden */
  78739. export interface IGLTFProperty {
  78740. extensions?: {
  78741. [key: string]: any;
  78742. };
  78743. extras?: Object;
  78744. }
  78745. /** @hidden */
  78746. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78747. name?: string;
  78748. }
  78749. /** @hidden */
  78750. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78751. bufferView: string;
  78752. byteOffset: number;
  78753. byteStride: number;
  78754. count: number;
  78755. type: string;
  78756. componentType: EComponentType;
  78757. max?: number[];
  78758. min?: number[];
  78759. name?: string;
  78760. }
  78761. /** @hidden */
  78762. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78763. buffer: string;
  78764. byteOffset: number;
  78765. byteLength: number;
  78766. byteStride: number;
  78767. target?: number;
  78768. }
  78769. /** @hidden */
  78770. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78771. uri: string;
  78772. byteLength?: number;
  78773. type?: string;
  78774. }
  78775. /** @hidden */
  78776. export interface IGLTFShader extends IGLTFChildRootProperty {
  78777. uri: string;
  78778. type: EShaderType;
  78779. }
  78780. /** @hidden */
  78781. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78782. attributes: string[];
  78783. fragmentShader: string;
  78784. vertexShader: string;
  78785. }
  78786. /** @hidden */
  78787. export interface IGLTFTechniqueParameter {
  78788. type: number;
  78789. count?: number;
  78790. semantic?: string;
  78791. node?: string;
  78792. value?: number | boolean | string | Array<any>;
  78793. source?: string;
  78794. babylonValue?: any;
  78795. }
  78796. /** @hidden */
  78797. export interface IGLTFTechniqueCommonProfile {
  78798. lightingModel: string;
  78799. texcoordBindings: Object;
  78800. parameters?: Array<any>;
  78801. }
  78802. /** @hidden */
  78803. export interface IGLTFTechniqueStatesFunctions {
  78804. blendColor?: number[];
  78805. blendEquationSeparate?: number[];
  78806. blendFuncSeparate?: number[];
  78807. colorMask: boolean[];
  78808. cullFace: number[];
  78809. }
  78810. /** @hidden */
  78811. export interface IGLTFTechniqueStates {
  78812. enable: number[];
  78813. functions: IGLTFTechniqueStatesFunctions;
  78814. }
  78815. /** @hidden */
  78816. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78817. parameters: {
  78818. [key: string]: IGLTFTechniqueParameter;
  78819. };
  78820. program: string;
  78821. attributes: {
  78822. [key: string]: string;
  78823. };
  78824. uniforms: {
  78825. [key: string]: string;
  78826. };
  78827. states: IGLTFTechniqueStates;
  78828. }
  78829. /** @hidden */
  78830. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78831. technique?: string;
  78832. values: string[];
  78833. }
  78834. /** @hidden */
  78835. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78836. attributes: {
  78837. [key: string]: string;
  78838. };
  78839. indices: string;
  78840. material: string;
  78841. mode?: number;
  78842. }
  78843. /** @hidden */
  78844. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78845. primitives: IGLTFMeshPrimitive[];
  78846. }
  78847. /** @hidden */
  78848. export interface IGLTFImage extends IGLTFChildRootProperty {
  78849. uri: string;
  78850. }
  78851. /** @hidden */
  78852. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78853. magFilter?: number;
  78854. minFilter?: number;
  78855. wrapS?: number;
  78856. wrapT?: number;
  78857. }
  78858. /** @hidden */
  78859. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78860. sampler: string;
  78861. source: string;
  78862. format?: ETextureFormat;
  78863. internalFormat?: ETextureFormat;
  78864. target?: number;
  78865. type?: number;
  78866. babylonTexture?: Texture;
  78867. }
  78868. /** @hidden */
  78869. export interface IGLTFAmbienLight {
  78870. color?: number[];
  78871. }
  78872. /** @hidden */
  78873. export interface IGLTFDirectionalLight {
  78874. color?: number[];
  78875. }
  78876. /** @hidden */
  78877. export interface IGLTFPointLight {
  78878. color?: number[];
  78879. constantAttenuation?: number;
  78880. linearAttenuation?: number;
  78881. quadraticAttenuation?: number;
  78882. }
  78883. /** @hidden */
  78884. export interface IGLTFSpotLight {
  78885. color?: number[];
  78886. constantAttenuation?: number;
  78887. fallOfAngle?: number;
  78888. fallOffExponent?: number;
  78889. linearAttenuation?: number;
  78890. quadraticAttenuation?: number;
  78891. }
  78892. /** @hidden */
  78893. export interface IGLTFLight extends IGLTFChildRootProperty {
  78894. type: string;
  78895. }
  78896. /** @hidden */
  78897. export interface IGLTFCameraOrthographic {
  78898. xmag: number;
  78899. ymag: number;
  78900. zfar: number;
  78901. znear: number;
  78902. }
  78903. /** @hidden */
  78904. export interface IGLTFCameraPerspective {
  78905. aspectRatio: number;
  78906. yfov: number;
  78907. zfar: number;
  78908. znear: number;
  78909. }
  78910. /** @hidden */
  78911. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78912. type: string;
  78913. }
  78914. /** @hidden */
  78915. export interface IGLTFAnimationChannelTarget {
  78916. id: string;
  78917. path: string;
  78918. }
  78919. /** @hidden */
  78920. export interface IGLTFAnimationChannel {
  78921. sampler: string;
  78922. target: IGLTFAnimationChannelTarget;
  78923. }
  78924. /** @hidden */
  78925. export interface IGLTFAnimationSampler {
  78926. input: string;
  78927. output: string;
  78928. interpolation?: string;
  78929. }
  78930. /** @hidden */
  78931. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78932. channels?: IGLTFAnimationChannel[];
  78933. parameters?: {
  78934. [key: string]: string;
  78935. };
  78936. samplers?: {
  78937. [key: string]: IGLTFAnimationSampler;
  78938. };
  78939. }
  78940. /** @hidden */
  78941. export interface IGLTFNodeInstanceSkin {
  78942. skeletons: string[];
  78943. skin: string;
  78944. meshes: string[];
  78945. }
  78946. /** @hidden */
  78947. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78948. bindShapeMatrix: number[];
  78949. inverseBindMatrices: string;
  78950. jointNames: string[];
  78951. babylonSkeleton?: Skeleton;
  78952. }
  78953. /** @hidden */
  78954. export interface IGLTFNode extends IGLTFChildRootProperty {
  78955. camera?: string;
  78956. children: string[];
  78957. skin?: string;
  78958. jointName?: string;
  78959. light?: string;
  78960. matrix: number[];
  78961. mesh?: string;
  78962. meshes?: string[];
  78963. rotation?: number[];
  78964. scale?: number[];
  78965. translation?: number[];
  78966. babylonNode?: Node;
  78967. }
  78968. /** @hidden */
  78969. export interface IGLTFScene extends IGLTFChildRootProperty {
  78970. nodes: string[];
  78971. }
  78972. /** @hidden */
  78973. export interface IGLTFRuntime {
  78974. extensions: {
  78975. [key: string]: any;
  78976. };
  78977. accessors: {
  78978. [key: string]: IGLTFAccessor;
  78979. };
  78980. buffers: {
  78981. [key: string]: IGLTFBuffer;
  78982. };
  78983. bufferViews: {
  78984. [key: string]: IGLTFBufferView;
  78985. };
  78986. meshes: {
  78987. [key: string]: IGLTFMesh;
  78988. };
  78989. lights: {
  78990. [key: string]: IGLTFLight;
  78991. };
  78992. cameras: {
  78993. [key: string]: IGLTFCamera;
  78994. };
  78995. nodes: {
  78996. [key: string]: IGLTFNode;
  78997. };
  78998. images: {
  78999. [key: string]: IGLTFImage;
  79000. };
  79001. textures: {
  79002. [key: string]: IGLTFTexture;
  79003. };
  79004. shaders: {
  79005. [key: string]: IGLTFShader;
  79006. };
  79007. programs: {
  79008. [key: string]: IGLTFProgram;
  79009. };
  79010. samplers: {
  79011. [key: string]: IGLTFSampler;
  79012. };
  79013. techniques: {
  79014. [key: string]: IGLTFTechnique;
  79015. };
  79016. materials: {
  79017. [key: string]: IGLTFMaterial;
  79018. };
  79019. animations: {
  79020. [key: string]: IGLTFAnimation;
  79021. };
  79022. skins: {
  79023. [key: string]: IGLTFSkins;
  79024. };
  79025. currentScene?: Object;
  79026. scenes: {
  79027. [key: string]: IGLTFScene;
  79028. };
  79029. extensionsUsed: string[];
  79030. extensionsRequired?: string[];
  79031. buffersCount: number;
  79032. shaderscount: number;
  79033. scene: Scene;
  79034. rootUrl: string;
  79035. loadedBufferCount: number;
  79036. loadedBufferViews: {
  79037. [name: string]: ArrayBufferView;
  79038. };
  79039. loadedShaderCount: number;
  79040. importOnlyMeshes: boolean;
  79041. importMeshesNames?: string[];
  79042. dummyNodes: Node[];
  79043. forAssetContainer: boolean;
  79044. }
  79045. /** @hidden */
  79046. export interface INodeToRoot {
  79047. bone: Bone;
  79048. node: IGLTFNode;
  79049. id: string;
  79050. }
  79051. /** @hidden */
  79052. export interface IJointNode {
  79053. node: IGLTFNode;
  79054. id: string;
  79055. }
  79056. }
  79057. declare module BABYLON.GLTF1 {
  79058. /**
  79059. * Utils functions for GLTF
  79060. * @hidden
  79061. */
  79062. export class GLTFUtils {
  79063. /**
  79064. * Sets the given "parameter" matrix
  79065. * @param scene: the Scene object
  79066. * @param source: the source node where to pick the matrix
  79067. * @param parameter: the GLTF technique parameter
  79068. * @param uniformName: the name of the shader's uniform
  79069. * @param shaderMaterial: the shader material
  79070. */
  79071. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79072. /**
  79073. * Sets the given "parameter" matrix
  79074. * @param shaderMaterial: the shader material
  79075. * @param uniform: the name of the shader's uniform
  79076. * @param value: the value of the uniform
  79077. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79078. */
  79079. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79080. /**
  79081. * Returns the wrap mode of the texture
  79082. * @param mode: the mode value
  79083. */
  79084. static GetWrapMode(mode: number): number;
  79085. /**
  79086. * Returns the byte stride giving an accessor
  79087. * @param accessor: the GLTF accessor objet
  79088. */
  79089. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79090. /**
  79091. * Returns the texture filter mode giving a mode value
  79092. * @param mode: the filter mode value
  79093. */
  79094. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79095. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79096. /**
  79097. * Returns a buffer from its accessor
  79098. * @param gltfRuntime: the GLTF runtime
  79099. * @param accessor: the GLTF accessor
  79100. */
  79101. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79102. /**
  79103. * Decodes a buffer view into a string
  79104. * @param view: the buffer view
  79105. */
  79106. static DecodeBufferToText(view: ArrayBufferView): string;
  79107. /**
  79108. * Returns the default material of gltf. Related to
  79109. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79110. * @param scene: the Babylon.js scene
  79111. */
  79112. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79113. private static _DefaultMaterial;
  79114. }
  79115. }
  79116. declare module BABYLON.GLTF1 {
  79117. /**
  79118. * Implementation of the base glTF spec
  79119. * @hidden
  79120. */
  79121. export class GLTFLoaderBase {
  79122. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79123. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79124. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79125. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79126. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79127. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79128. }
  79129. /**
  79130. * glTF V1 Loader
  79131. * @hidden
  79132. */
  79133. export class GLTFLoader implements IGLTFLoader {
  79134. static Extensions: {
  79135. [name: string]: GLTFLoaderExtension;
  79136. };
  79137. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79138. state: Nullable<GLTFLoaderState>;
  79139. dispose(): void;
  79140. private _importMeshAsync;
  79141. /**
  79142. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79143. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79144. * @param scene the scene the meshes should be added to
  79145. * @param forAssetContainer defines if the entities must be stored in the scene
  79146. * @param data gltf data containing information of the meshes in a loaded file
  79147. * @param rootUrl root url to load from
  79148. * @param onProgress event that fires when loading progress has occured
  79149. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79150. */
  79151. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79152. private _loadAsync;
  79153. /**
  79154. * Imports all objects from a loaded gltf file and adds them to the scene
  79155. * @param scene the scene the objects should be added to
  79156. * @param data gltf data containing information of the meshes in a loaded file
  79157. * @param rootUrl root url to load from
  79158. * @param onProgress event that fires when loading progress has occured
  79159. * @returns a promise which completes when objects have been loaded to the scene
  79160. */
  79161. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  79162. private _loadShadersAsync;
  79163. private _loadBuffersAsync;
  79164. private _createNodes;
  79165. }
  79166. /** @hidden */
  79167. export abstract class GLTFLoaderExtension {
  79168. private _name;
  79169. constructor(name: string);
  79170. get name(): string;
  79171. /**
  79172. * Defines an override for loading the runtime
  79173. * Return true to stop further extensions from loading the runtime
  79174. */
  79175. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79176. /**
  79177. * Defines an onverride for creating gltf runtime
  79178. * Return true to stop further extensions from creating the runtime
  79179. */
  79180. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79181. /**
  79182. * Defines an override for loading buffers
  79183. * Return true to stop further extensions from loading this buffer
  79184. */
  79185. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79186. /**
  79187. * Defines an override for loading texture buffers
  79188. * Return true to stop further extensions from loading this texture data
  79189. */
  79190. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79191. /**
  79192. * Defines an override for creating textures
  79193. * Return true to stop further extensions from loading this texture
  79194. */
  79195. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79196. /**
  79197. * Defines an override for loading shader strings
  79198. * Return true to stop further extensions from loading this shader data
  79199. */
  79200. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79201. /**
  79202. * Defines an override for loading materials
  79203. * Return true to stop further extensions from loading this material
  79204. */
  79205. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79206. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79207. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79208. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79209. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79210. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79211. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79212. private static LoadTextureBufferAsync;
  79213. private static CreateTextureAsync;
  79214. private static ApplyExtensions;
  79215. }
  79216. }
  79217. declare module BABYLON.GLTF1 {
  79218. /** @hidden */
  79219. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79220. private _bin;
  79221. constructor();
  79222. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79223. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79224. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79225. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79226. }
  79227. }
  79228. declare module BABYLON.GLTF1 {
  79229. /** @hidden */
  79230. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79231. constructor();
  79232. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79233. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79234. private _loadTexture;
  79235. }
  79236. }
  79237. declare module BABYLON.GLTF2.Loader {
  79238. /**
  79239. * Loader interface with an index field.
  79240. */
  79241. export interface IArrayItem {
  79242. /**
  79243. * The index of this item in the array.
  79244. */
  79245. index: number;
  79246. }
  79247. /**
  79248. * Loader interface with additional members.
  79249. */
  79250. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79251. /** @hidden */
  79252. _data?: Promise<ArrayBufferView>;
  79253. /** @hidden */
  79254. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79255. }
  79256. /**
  79257. * Loader interface with additional members.
  79258. */
  79259. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79260. }
  79261. /** @hidden */
  79262. export interface _IAnimationSamplerData {
  79263. input: Float32Array;
  79264. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79265. output: Float32Array;
  79266. }
  79267. /**
  79268. * Loader interface with additional members.
  79269. */
  79270. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79271. /** @hidden */
  79272. _data?: Promise<_IAnimationSamplerData>;
  79273. }
  79274. /**
  79275. * Loader interface with additional members.
  79276. */
  79277. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79278. channels: IAnimationChannel[];
  79279. samplers: IAnimationSampler[];
  79280. /** @hidden */
  79281. _babylonAnimationGroup?: AnimationGroup;
  79282. }
  79283. /**
  79284. * Loader interface with additional members.
  79285. */
  79286. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79287. /** @hidden */
  79288. _data?: Promise<ArrayBufferView>;
  79289. }
  79290. /**
  79291. * Loader interface with additional members.
  79292. */
  79293. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79294. /** @hidden */
  79295. _data?: Promise<ArrayBufferView>;
  79296. /** @hidden */
  79297. _babylonBuffer?: Promise<Buffer>;
  79298. }
  79299. /**
  79300. * Loader interface with additional members.
  79301. */
  79302. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79303. }
  79304. /**
  79305. * Loader interface with additional members.
  79306. */
  79307. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79308. /** @hidden */
  79309. _data?: Promise<ArrayBufferView>;
  79310. }
  79311. /**
  79312. * Loader interface with additional members.
  79313. */
  79314. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79315. }
  79316. /**
  79317. * Loader interface with additional members.
  79318. */
  79319. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79320. }
  79321. /**
  79322. * Loader interface with additional members.
  79323. */
  79324. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79325. baseColorTexture?: ITextureInfo;
  79326. metallicRoughnessTexture?: ITextureInfo;
  79327. }
  79328. /**
  79329. * Loader interface with additional members.
  79330. */
  79331. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79332. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79333. normalTexture?: IMaterialNormalTextureInfo;
  79334. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79335. emissiveTexture?: ITextureInfo;
  79336. /** @hidden */
  79337. _data?: {
  79338. [babylonDrawMode: number]: {
  79339. babylonMaterial: Material;
  79340. babylonMeshes: AbstractMesh[];
  79341. promise: Promise<void>;
  79342. };
  79343. };
  79344. }
  79345. /**
  79346. * Loader interface with additional members.
  79347. */
  79348. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79349. primitives: IMeshPrimitive[];
  79350. }
  79351. /**
  79352. * Loader interface with additional members.
  79353. */
  79354. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79355. /** @hidden */
  79356. _instanceData?: {
  79357. babylonSourceMesh: Mesh;
  79358. promise: Promise<any>;
  79359. };
  79360. }
  79361. /**
  79362. * Loader interface with additional members.
  79363. */
  79364. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79365. /**
  79366. * The parent glTF node.
  79367. */
  79368. parent?: INode;
  79369. /** @hidden */
  79370. _babylonTransformNode?: TransformNode;
  79371. /** @hidden */
  79372. _primitiveBabylonMeshes?: AbstractMesh[];
  79373. /** @hidden */
  79374. _babylonBones?: Bone[];
  79375. /** @hidden */
  79376. _numMorphTargets?: number;
  79377. }
  79378. /** @hidden */
  79379. export interface _ISamplerData {
  79380. noMipMaps: boolean;
  79381. samplingMode: number;
  79382. wrapU: number;
  79383. wrapV: number;
  79384. }
  79385. /**
  79386. * Loader interface with additional members.
  79387. */
  79388. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79389. /** @hidden */
  79390. _data?: _ISamplerData;
  79391. }
  79392. /**
  79393. * Loader interface with additional members.
  79394. */
  79395. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79396. }
  79397. /**
  79398. * Loader interface with additional members.
  79399. */
  79400. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79401. /** @hidden */
  79402. _data?: {
  79403. babylonSkeleton: Skeleton;
  79404. promise: Promise<void>;
  79405. };
  79406. }
  79407. /**
  79408. * Loader interface with additional members.
  79409. */
  79410. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79411. }
  79412. /**
  79413. * Loader interface with additional members.
  79414. */
  79415. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79416. }
  79417. /**
  79418. * Loader interface with additional members.
  79419. */
  79420. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79421. accessors?: IAccessor[];
  79422. animations?: IAnimation[];
  79423. buffers?: IBuffer[];
  79424. bufferViews?: IBufferView[];
  79425. cameras?: ICamera[];
  79426. images?: IImage[];
  79427. materials?: IMaterial[];
  79428. meshes?: IMesh[];
  79429. nodes?: INode[];
  79430. samplers?: ISampler[];
  79431. scenes?: IScene[];
  79432. skins?: ISkin[];
  79433. textures?: ITexture[];
  79434. }
  79435. }
  79436. declare module BABYLON.GLTF2 {
  79437. /**
  79438. * Interface for a glTF loader extension.
  79439. */
  79440. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79441. /**
  79442. * Called after the loader state changes to LOADING.
  79443. */
  79444. onLoading?(): void;
  79445. /**
  79446. * Called after the loader state changes to READY.
  79447. */
  79448. onReady?(): void;
  79449. /**
  79450. * Define this method to modify the default behavior when loading scenes.
  79451. * @param context The context when loading the asset
  79452. * @param scene The glTF scene property
  79453. * @returns A promise that resolves when the load is complete or null if not handled
  79454. */
  79455. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79456. /**
  79457. * Define this method to modify the default behavior when loading nodes.
  79458. * @param context The context when loading the asset
  79459. * @param node The glTF node property
  79460. * @param assign A function called synchronously after parsing the glTF properties
  79461. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79462. */
  79463. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79464. /**
  79465. * Define this method to modify the default behavior when loading cameras.
  79466. * @param context The context when loading the asset
  79467. * @param camera The glTF camera property
  79468. * @param assign A function called synchronously after parsing the glTF properties
  79469. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79470. */
  79471. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79472. /**
  79473. * @hidden
  79474. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79475. * @param context The context when loading the asset
  79476. * @param primitive The glTF mesh primitive property
  79477. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79478. */
  79479. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79480. /**
  79481. * @hidden
  79482. * Define this method to modify the default behavior when loading data for mesh primitives.
  79483. * @param context The context when loading the asset
  79484. * @param name The mesh name when loading the asset
  79485. * @param node The glTF node when loading the asset
  79486. * @param mesh The glTF mesh when loading the asset
  79487. * @param primitive The glTF mesh primitive property
  79488. * @param assign A function called synchronously after parsing the glTF properties
  79489. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79490. */
  79491. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79492. /**
  79493. * @hidden
  79494. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79495. * @param context The context when loading the asset
  79496. * @param material The glTF material property
  79497. * @param assign A function called synchronously after parsing the glTF properties
  79498. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79499. */
  79500. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79501. /**
  79502. * Define this method to modify the default behavior when creating materials.
  79503. * @param context The context when loading the asset
  79504. * @param material The glTF material property
  79505. * @param babylonDrawMode The draw mode for the Babylon material
  79506. * @returns The Babylon material or null if not handled
  79507. */
  79508. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79509. /**
  79510. * Define this method to modify the default behavior when loading material properties.
  79511. * @param context The context when loading the asset
  79512. * @param material The glTF material property
  79513. * @param babylonMaterial The Babylon material
  79514. * @returns A promise that resolves when the load is complete or null if not handled
  79515. */
  79516. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79517. /**
  79518. * Define this method to modify the default behavior when loading texture infos.
  79519. * @param context The context when loading the asset
  79520. * @param textureInfo The glTF texture info property
  79521. * @param assign A function called synchronously after parsing the glTF properties
  79522. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79523. */
  79524. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79525. /**
  79526. * @hidden
  79527. * Define this method to modify the default behavior when loading textures.
  79528. * @param context The context when loading the asset
  79529. * @param texture The glTF texture property
  79530. * @param assign A function called synchronously after parsing the glTF properties
  79531. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79532. */
  79533. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79534. /**
  79535. * Define this method to modify the default behavior when loading animations.
  79536. * @param context The context when loading the asset
  79537. * @param animation The glTF animation property
  79538. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79539. */
  79540. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79541. /**
  79542. * @hidden
  79543. * Define this method to modify the default behavior when loading skins.
  79544. * @param context The context when loading the asset
  79545. * @param node The glTF node property
  79546. * @param skin The glTF skin property
  79547. * @returns A promise that resolves when the load is complete or null if not handled
  79548. */
  79549. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79550. /**
  79551. * @hidden
  79552. * Define this method to modify the default behavior when loading uris.
  79553. * @param context The context when loading the asset
  79554. * @param property The glTF property associated with the uri
  79555. * @param uri The uri to load
  79556. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79557. */
  79558. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79559. /**
  79560. * Define this method to modify the default behavior when loading buffer views.
  79561. * @param context The context when loading the asset
  79562. * @param bufferView The glTF buffer view property
  79563. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79564. */
  79565. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79566. /**
  79567. * Define this method to modify the default behavior when loading buffers.
  79568. * @param context The context when loading the asset
  79569. * @param buffer The glTF buffer property
  79570. * @param byteOffset The byte offset to load
  79571. * @param byteLength The byte length to load
  79572. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79573. */
  79574. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79575. }
  79576. }
  79577. declare module BABYLON.GLTF2 {
  79578. /**
  79579. * Helper class for working with arrays when loading the glTF asset
  79580. */
  79581. export class ArrayItem {
  79582. /**
  79583. * Gets an item from the given array.
  79584. * @param context The context when loading the asset
  79585. * @param array The array to get the item from
  79586. * @param index The index to the array
  79587. * @returns The array item
  79588. */
  79589. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79590. /**
  79591. * Assign an `index` field to each item of the given array.
  79592. * @param array The array of items
  79593. */
  79594. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79595. }
  79596. /**
  79597. * The glTF 2.0 loader
  79598. */
  79599. export class GLTFLoader implements IGLTFLoader {
  79600. /** @hidden */
  79601. _completePromises: Promise<any>[];
  79602. /** @hidden */
  79603. _forAssetContainer: boolean;
  79604. /** Storage */
  79605. _babylonLights: Light[];
  79606. /** @hidden */
  79607. _disableInstancedMesh: number;
  79608. private _disposed;
  79609. private _parent;
  79610. private _state;
  79611. private _extensions;
  79612. private _rootUrl;
  79613. private _fileName;
  79614. private _uniqueRootUrl;
  79615. private _gltf;
  79616. private _bin;
  79617. private _babylonScene;
  79618. private _rootBabylonMesh;
  79619. private _defaultBabylonMaterialData;
  79620. private _progressCallback?;
  79621. private _requests;
  79622. private static _RegisteredExtensions;
  79623. /**
  79624. * The default glTF sampler.
  79625. */
  79626. static readonly DefaultSampler: ISampler;
  79627. /**
  79628. * Registers a loader extension.
  79629. * @param name The name of the loader extension.
  79630. * @param factory The factory function that creates the loader extension.
  79631. */
  79632. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79633. /**
  79634. * Unregisters a loader extension.
  79635. * @param name The name of the loader extension.
  79636. * @returns A boolean indicating whether the extension has been unregistered
  79637. */
  79638. static UnregisterExtension(name: string): boolean;
  79639. /**
  79640. * The loader state.
  79641. */
  79642. get state(): Nullable<GLTFLoaderState>;
  79643. /**
  79644. * The object that represents the glTF JSON.
  79645. */
  79646. get gltf(): IGLTF;
  79647. /**
  79648. * The BIN chunk of a binary glTF.
  79649. */
  79650. get bin(): Nullable<IDataBuffer>;
  79651. /**
  79652. * The parent file loader.
  79653. */
  79654. get parent(): GLTFFileLoader;
  79655. /**
  79656. * The Babylon scene when loading the asset.
  79657. */
  79658. get babylonScene(): Scene;
  79659. /**
  79660. * The root Babylon mesh when loading the asset.
  79661. */
  79662. get rootBabylonMesh(): Mesh;
  79663. /** @hidden */
  79664. constructor(parent: GLTFFileLoader);
  79665. /** @hidden */
  79666. dispose(): void;
  79667. /** @hidden */
  79668. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79669. /** @hidden */
  79670. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79671. private _loadAsync;
  79672. private _loadData;
  79673. private _setupData;
  79674. private _loadExtensions;
  79675. private _checkExtensions;
  79676. private _setState;
  79677. private _createRootNode;
  79678. /**
  79679. * Loads a glTF scene.
  79680. * @param context The context when loading the asset
  79681. * @param scene The glTF scene property
  79682. * @returns A promise that resolves when the load is complete
  79683. */
  79684. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79685. private _forEachPrimitive;
  79686. private _getMeshes;
  79687. private _getTransformNodes;
  79688. private _getSkeletons;
  79689. private _getAnimationGroups;
  79690. private _startAnimations;
  79691. /**
  79692. * Loads a glTF node.
  79693. * @param context The context when loading the asset
  79694. * @param node The glTF node property
  79695. * @param assign A function called synchronously after parsing the glTF properties
  79696. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79697. */
  79698. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79699. private _loadMeshAsync;
  79700. /**
  79701. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79702. * @param context The context when loading the asset
  79703. * @param name The mesh name when loading the asset
  79704. * @param node The glTF node when loading the asset
  79705. * @param mesh The glTF mesh when loading the asset
  79706. * @param primitive The glTF mesh primitive property
  79707. * @param assign A function called synchronously after parsing the glTF properties
  79708. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79709. */
  79710. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79711. private _loadVertexDataAsync;
  79712. private _createMorphTargets;
  79713. private _loadMorphTargetsAsync;
  79714. private _loadMorphTargetVertexDataAsync;
  79715. private static _LoadTransform;
  79716. private _loadSkinAsync;
  79717. private _loadBones;
  79718. private _loadBone;
  79719. private _loadSkinInverseBindMatricesDataAsync;
  79720. private _updateBoneMatrices;
  79721. private _getNodeMatrix;
  79722. /**
  79723. * Loads a glTF camera.
  79724. * @param context The context when loading the asset
  79725. * @param camera The glTF camera property
  79726. * @param assign A function called synchronously after parsing the glTF properties
  79727. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79728. */
  79729. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79730. private _loadAnimationsAsync;
  79731. /**
  79732. * Loads a glTF animation.
  79733. * @param context The context when loading the asset
  79734. * @param animation The glTF animation property
  79735. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79736. */
  79737. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79738. /**
  79739. * @hidden Loads a glTF animation channel.
  79740. * @param context The context when loading the asset
  79741. * @param animationContext The context of the animation when loading the asset
  79742. * @param animation The glTF animation property
  79743. * @param channel The glTF animation channel property
  79744. * @param babylonAnimationGroup The babylon animation group property
  79745. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79746. * @returns A void promise when the channel load is complete
  79747. */
  79748. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79749. private _loadAnimationSamplerAsync;
  79750. private _loadBufferAsync;
  79751. /**
  79752. * Loads a glTF buffer view.
  79753. * @param context The context when loading the asset
  79754. * @param bufferView The glTF buffer view property
  79755. * @returns A promise that resolves with the loaded data when the load is complete
  79756. */
  79757. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79758. private _loadAccessorAsync;
  79759. /** @hidden */
  79760. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79761. private _loadIndicesAccessorAsync;
  79762. private _loadVertexBufferViewAsync;
  79763. private _loadVertexAccessorAsync;
  79764. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79765. /** @hidden */
  79766. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79767. private _createDefaultMaterial;
  79768. /**
  79769. * Creates a Babylon material from a glTF material.
  79770. * @param context The context when loading the asset
  79771. * @param material The glTF material property
  79772. * @param babylonDrawMode The draw mode for the Babylon material
  79773. * @returns The Babylon material
  79774. */
  79775. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79776. /**
  79777. * Loads properties from a glTF material into a Babylon material.
  79778. * @param context The context when loading the asset
  79779. * @param material The glTF material property
  79780. * @param babylonMaterial The Babylon material
  79781. * @returns A promise that resolves when the load is complete
  79782. */
  79783. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79784. /**
  79785. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79786. * @param context The context when loading the asset
  79787. * @param material The glTF material property
  79788. * @param babylonMaterial The Babylon material
  79789. * @returns A promise that resolves when the load is complete
  79790. */
  79791. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79792. /**
  79793. * Loads the alpha properties from a glTF material into a Babylon material.
  79794. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79795. * @param context The context when loading the asset
  79796. * @param material The glTF material property
  79797. * @param babylonMaterial The Babylon material
  79798. */
  79799. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79800. /**
  79801. * Loads a glTF texture info.
  79802. * @param context The context when loading the asset
  79803. * @param textureInfo The glTF texture info property
  79804. * @param assign A function called synchronously after parsing the glTF properties
  79805. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79806. */
  79807. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79808. /** @hidden */
  79809. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79810. /** @hidden */
  79811. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79812. private _loadSampler;
  79813. /**
  79814. * Loads a glTF image.
  79815. * @param context The context when loading the asset
  79816. * @param image The glTF image property
  79817. * @returns A promise that resolves with the loaded data when the load is complete
  79818. */
  79819. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79820. /**
  79821. * Loads a glTF uri.
  79822. * @param context The context when loading the asset
  79823. * @param property The glTF property associated with the uri
  79824. * @param uri The base64 or relative uri
  79825. * @returns A promise that resolves with the loaded data when the load is complete
  79826. */
  79827. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79828. private _onProgress;
  79829. /**
  79830. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79831. * @param babylonObject the Babylon object with metadata
  79832. * @param pointer the JSON pointer
  79833. */
  79834. static AddPointerMetadata(babylonObject: {
  79835. metadata: any;
  79836. }, pointer: string): void;
  79837. private static _GetTextureWrapMode;
  79838. private static _GetTextureSamplingMode;
  79839. private static _GetTypedArrayConstructor;
  79840. private static _GetTypedArray;
  79841. private static _GetNumComponents;
  79842. private static _ValidateUri;
  79843. private static _GetDrawMode;
  79844. private _compileMaterialsAsync;
  79845. private _compileShadowGeneratorsAsync;
  79846. private _forEachExtensions;
  79847. private _applyExtensions;
  79848. private _extensionsOnLoading;
  79849. private _extensionsOnReady;
  79850. private _extensionsLoadSceneAsync;
  79851. private _extensionsLoadNodeAsync;
  79852. private _extensionsLoadCameraAsync;
  79853. private _extensionsLoadVertexDataAsync;
  79854. private _extensionsLoadMeshPrimitiveAsync;
  79855. private _extensionsLoadMaterialAsync;
  79856. private _extensionsCreateMaterial;
  79857. private _extensionsLoadMaterialPropertiesAsync;
  79858. private _extensionsLoadTextureInfoAsync;
  79859. private _extensionsLoadTextureAsync;
  79860. private _extensionsLoadAnimationAsync;
  79861. private _extensionsLoadSkinAsync;
  79862. private _extensionsLoadUriAsync;
  79863. private _extensionsLoadBufferViewAsync;
  79864. private _extensionsLoadBufferAsync;
  79865. /**
  79866. * Helper method called by a loader extension to load an glTF extension.
  79867. * @param context The context when loading the asset
  79868. * @param property The glTF property to load the extension from
  79869. * @param extensionName The name of the extension to load
  79870. * @param actionAsync The action to run
  79871. * @returns The promise returned by actionAsync or null if the extension does not exist
  79872. */
  79873. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79874. /**
  79875. * Helper method called by a loader extension to load a glTF extra.
  79876. * @param context The context when loading the asset
  79877. * @param property The glTF property to load the extra from
  79878. * @param extensionName The name of the extension to load
  79879. * @param actionAsync The action to run
  79880. * @returns The promise returned by actionAsync or null if the extra does not exist
  79881. */
  79882. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79883. /**
  79884. * Checks for presence of an extension.
  79885. * @param name The name of the extension to check
  79886. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79887. */
  79888. isExtensionUsed(name: string): boolean;
  79889. /**
  79890. * Increments the indentation level and logs a message.
  79891. * @param message The message to log
  79892. */
  79893. logOpen(message: string): void;
  79894. /**
  79895. * Decrements the indentation level.
  79896. */
  79897. logClose(): void;
  79898. /**
  79899. * Logs a message
  79900. * @param message The message to log
  79901. */
  79902. log(message: string): void;
  79903. /**
  79904. * Starts a performance counter.
  79905. * @param counterName The name of the performance counter
  79906. */
  79907. startPerformanceCounter(counterName: string): void;
  79908. /**
  79909. * Ends a performance counter.
  79910. * @param counterName The name of the performance counter
  79911. */
  79912. endPerformanceCounter(counterName: string): void;
  79913. }
  79914. }
  79915. declare module BABYLON.GLTF2.Loader.Extensions {
  79916. /**
  79917. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79918. */
  79919. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79920. /**
  79921. * The name of this extension.
  79922. */
  79923. readonly name: string;
  79924. /**
  79925. * Defines whether this extension is enabled.
  79926. */
  79927. enabled: boolean;
  79928. private _loader;
  79929. private _lights?;
  79930. /** @hidden */
  79931. constructor(loader: GLTFLoader);
  79932. /** @hidden */
  79933. dispose(): void;
  79934. /** @hidden */
  79935. onLoading(): void;
  79936. /** @hidden */
  79937. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79938. private _loadLightAsync;
  79939. }
  79940. }
  79941. declare module BABYLON.GLTF2.Loader.Extensions {
  79942. /**
  79943. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79944. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79945. * !!! Experimental Extension Subject to Changes !!!
  79946. */
  79947. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79948. /**
  79949. * The name of this extension.
  79950. */
  79951. readonly name: string;
  79952. /**
  79953. * Defines whether this extension is enabled.
  79954. */
  79955. enabled: boolean;
  79956. private _loader;
  79957. /** @hidden */
  79958. constructor(loader: GLTFLoader);
  79959. /** @hidden */
  79960. dispose(): void;
  79961. /** @hidden */
  79962. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79963. }
  79964. }
  79965. declare module BABYLON.GLTF2.Loader.Extensions {
  79966. /**
  79967. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79968. */
  79969. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79970. /**
  79971. * The name of this extension.
  79972. */
  79973. readonly name: string;
  79974. /**
  79975. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79976. */
  79977. dracoCompression?: DracoCompression;
  79978. /**
  79979. * Defines whether this extension is enabled.
  79980. */
  79981. enabled: boolean;
  79982. private _loader;
  79983. /** @hidden */
  79984. constructor(loader: GLTFLoader);
  79985. /** @hidden */
  79986. dispose(): void;
  79987. /** @hidden */
  79988. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79989. }
  79990. }
  79991. declare module BABYLON.GLTF2.Loader.Extensions {
  79992. /**
  79993. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  79994. */
  79995. export class KHR_lights implements IGLTFLoaderExtension {
  79996. /**
  79997. * The name of this extension.
  79998. */
  79999. readonly name: string;
  80000. /**
  80001. * Defines whether this extension is enabled.
  80002. */
  80003. enabled: boolean;
  80004. private _loader;
  80005. private _lights?;
  80006. /** @hidden */
  80007. constructor(loader: GLTFLoader);
  80008. /** @hidden */
  80009. dispose(): void;
  80010. /** @hidden */
  80011. onLoading(): void;
  80012. /** @hidden */
  80013. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80014. }
  80015. }
  80016. declare module BABYLON.GLTF2.Loader.Extensions {
  80017. /**
  80018. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80019. */
  80020. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80021. /**
  80022. * The name of this extension.
  80023. */
  80024. readonly name: string;
  80025. /**
  80026. * Defines whether this extension is enabled.
  80027. */
  80028. enabled: boolean;
  80029. /**
  80030. * Defines a number that determines the order the extensions are applied.
  80031. */
  80032. order: number;
  80033. private _loader;
  80034. /** @hidden */
  80035. constructor(loader: GLTFLoader);
  80036. /** @hidden */
  80037. dispose(): void;
  80038. /** @hidden */
  80039. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80040. private _loadSpecularGlossinessPropertiesAsync;
  80041. }
  80042. }
  80043. declare module BABYLON.GLTF2.Loader.Extensions {
  80044. /**
  80045. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80046. */
  80047. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80048. /**
  80049. * The name of this extension.
  80050. */
  80051. readonly name: string;
  80052. /**
  80053. * Defines whether this extension is enabled.
  80054. */
  80055. enabled: boolean;
  80056. /**
  80057. * Defines a number that determines the order the extensions are applied.
  80058. */
  80059. order: number;
  80060. private _loader;
  80061. /** @hidden */
  80062. constructor(loader: GLTFLoader);
  80063. /** @hidden */
  80064. dispose(): void;
  80065. /** @hidden */
  80066. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80067. private _loadUnlitPropertiesAsync;
  80068. }
  80069. }
  80070. declare module BABYLON.GLTF2.Loader.Extensions {
  80071. /**
  80072. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80073. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80074. * !!! Experimental Extension Subject to Changes !!!
  80075. */
  80076. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80077. /**
  80078. * The name of this extension.
  80079. */
  80080. readonly name: string;
  80081. /**
  80082. * Defines whether this extension is enabled.
  80083. */
  80084. enabled: boolean;
  80085. /**
  80086. * Defines a number that determines the order the extensions are applied.
  80087. */
  80088. order: number;
  80089. private _loader;
  80090. /** @hidden */
  80091. constructor(loader: GLTFLoader);
  80092. /** @hidden */
  80093. dispose(): void;
  80094. /** @hidden */
  80095. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80096. private _loadClearCoatPropertiesAsync;
  80097. }
  80098. }
  80099. declare module BABYLON.GLTF2.Loader.Extensions {
  80100. /**
  80101. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80102. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80103. * !!! Experimental Extension Subject to Changes !!!
  80104. */
  80105. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80106. /**
  80107. * The name of this extension.
  80108. */
  80109. readonly name: string;
  80110. /**
  80111. * Defines whether this extension is enabled.
  80112. */
  80113. enabled: boolean;
  80114. /**
  80115. * Defines a number that determines the order the extensions are applied.
  80116. */
  80117. order: number;
  80118. private _loader;
  80119. /** @hidden */
  80120. constructor(loader: GLTFLoader);
  80121. /** @hidden */
  80122. dispose(): void;
  80123. /** @hidden */
  80124. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80125. private _loadSheenPropertiesAsync;
  80126. }
  80127. }
  80128. declare module BABYLON.GLTF2.Loader.Extensions {
  80129. /**
  80130. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80131. * !!! Experimental Extension Subject to Changes !!!
  80132. */
  80133. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80134. /**
  80135. * The name of this extension.
  80136. */
  80137. readonly name: string;
  80138. /**
  80139. * Defines whether this extension is enabled.
  80140. */
  80141. enabled: boolean;
  80142. /**
  80143. * Defines a number that determines the order the extensions are applied.
  80144. */
  80145. order: number;
  80146. private _loader;
  80147. /** @hidden */
  80148. constructor(loader: GLTFLoader);
  80149. /** @hidden */
  80150. dispose(): void;
  80151. /** @hidden */
  80152. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80153. private _loadSpecularPropertiesAsync;
  80154. }
  80155. }
  80156. declare module BABYLON.GLTF2.Loader.Extensions {
  80157. /**
  80158. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80159. * !!! Experimental Extension Subject to Changes !!!
  80160. */
  80161. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80162. /**
  80163. * Default ior Value from the spec.
  80164. */
  80165. private static readonly _DEFAULT_IOR;
  80166. /**
  80167. * The name of this extension.
  80168. */
  80169. readonly name: string;
  80170. /**
  80171. * Defines whether this extension is enabled.
  80172. */
  80173. enabled: boolean;
  80174. /**
  80175. * Defines a number that determines the order the extensions are applied.
  80176. */
  80177. order: number;
  80178. private _loader;
  80179. /** @hidden */
  80180. constructor(loader: GLTFLoader);
  80181. /** @hidden */
  80182. dispose(): void;
  80183. /** @hidden */
  80184. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80185. private _loadIorPropertiesAsync;
  80186. }
  80187. }
  80188. declare module BABYLON.GLTF2.Loader.Extensions {
  80189. /**
  80190. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80191. * !!! Experimental Extension Subject to Changes !!!
  80192. */
  80193. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80194. /**
  80195. * The name of this extension.
  80196. */
  80197. readonly name: string;
  80198. /**
  80199. * Defines whether this extension is enabled.
  80200. */
  80201. enabled: boolean;
  80202. private _loader;
  80203. /**
  80204. * The default variant name.
  80205. */
  80206. defaultVariant: string | undefined;
  80207. private _tagsToMap;
  80208. /** @hidden */
  80209. constructor(loader: GLTFLoader);
  80210. /** @hidden */
  80211. dispose(): void;
  80212. /**
  80213. * Return a list of available variants for this asset.
  80214. * @returns {string[]}
  80215. */
  80216. getVariants(): string[];
  80217. /**
  80218. * Select a variant by providing a list of variant tag names.
  80219. *
  80220. * @param {(string | string[])} variantName
  80221. */
  80222. selectVariant(variantName: string | string[]): void;
  80223. /**
  80224. * Select a variant by providing a single variant tag.
  80225. *
  80226. * @param {string} variantName
  80227. */
  80228. selectVariantTag(variantName: string): void;
  80229. /** @hidden */
  80230. onLoading(): void;
  80231. /** @hidden */
  80232. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80233. }
  80234. }
  80235. declare module BABYLON.GLTF2.Loader.Extensions {
  80236. /**
  80237. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80238. * !!! Experimental Extension Subject to Changes !!!
  80239. */
  80240. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80241. /**
  80242. * The name of this extension.
  80243. */
  80244. readonly name: string;
  80245. /**
  80246. * Defines whether this extension is enabled.
  80247. */
  80248. enabled: boolean;
  80249. /**
  80250. * Defines a number that determines the order the extensions are applied.
  80251. */
  80252. order: number;
  80253. private _loader;
  80254. /** @hidden */
  80255. constructor(loader: GLTFLoader);
  80256. /** @hidden */
  80257. dispose(): void;
  80258. /** @hidden */
  80259. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80260. private _loadTransparentPropertiesAsync;
  80261. }
  80262. }
  80263. declare module BABYLON.GLTF2.Loader.Extensions {
  80264. /**
  80265. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80266. */
  80267. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80268. /**
  80269. * The name of this extension.
  80270. */
  80271. readonly name: string;
  80272. /**
  80273. * Defines whether this extension is enabled.
  80274. */
  80275. enabled: boolean;
  80276. /** @hidden */
  80277. constructor(loader: GLTFLoader);
  80278. /** @hidden */
  80279. dispose(): void;
  80280. }
  80281. }
  80282. declare module BABYLON.GLTF2.Loader.Extensions {
  80283. /**
  80284. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80285. * !!! Experimental Extension Subject to Changes !!!
  80286. */
  80287. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80288. /** The name of this extension. */
  80289. readonly name: string;
  80290. /** Defines whether this extension is enabled. */
  80291. enabled: boolean;
  80292. private _loader;
  80293. /** @hidden */
  80294. constructor(loader: GLTFLoader);
  80295. /** @hidden */
  80296. dispose(): void;
  80297. /** @hidden */
  80298. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80299. }
  80300. }
  80301. declare module BABYLON.GLTF2.Loader.Extensions {
  80302. /**
  80303. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80304. */
  80305. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80306. /**
  80307. * The name of this extension.
  80308. */
  80309. readonly name: string;
  80310. /**
  80311. * Defines whether this extension is enabled.
  80312. */
  80313. enabled: boolean;
  80314. private _loader;
  80315. /** @hidden */
  80316. constructor(loader: GLTFLoader);
  80317. /** @hidden */
  80318. dispose(): void;
  80319. /** @hidden */
  80320. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80321. }
  80322. }
  80323. declare module BABYLON.GLTF2.Loader.Extensions {
  80324. /**
  80325. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80326. * !!! Experimental Extension Subject to Changes !!!
  80327. */
  80328. export class KHR_xmp implements IGLTFLoaderExtension {
  80329. /**
  80330. * The name of this extension.
  80331. */
  80332. readonly name: string;
  80333. /**
  80334. * Defines whether this extension is enabled.
  80335. */
  80336. enabled: boolean;
  80337. /**
  80338. * Defines a number that determines the order the extensions are applied.
  80339. */
  80340. order: number;
  80341. private _loader;
  80342. /** @hidden */
  80343. constructor(loader: GLTFLoader);
  80344. /** @hidden */
  80345. dispose(): void;
  80346. /**
  80347. * Called after the loader state changes to LOADING.
  80348. */
  80349. onLoading(): void;
  80350. }
  80351. }
  80352. declare module BABYLON.GLTF2.Loader.Extensions {
  80353. /**
  80354. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80355. */
  80356. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80357. /**
  80358. * The name of this extension.
  80359. */
  80360. readonly name: string;
  80361. /**
  80362. * Defines whether this extension is enabled.
  80363. */
  80364. enabled: boolean;
  80365. private _loader;
  80366. private _clips;
  80367. private _emitters;
  80368. /** @hidden */
  80369. constructor(loader: GLTFLoader);
  80370. /** @hidden */
  80371. dispose(): void;
  80372. /** @hidden */
  80373. onLoading(): void;
  80374. /** @hidden */
  80375. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80376. /** @hidden */
  80377. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80378. /** @hidden */
  80379. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80380. private _loadClipAsync;
  80381. private _loadEmitterAsync;
  80382. private _getEventAction;
  80383. private _loadAnimationEventAsync;
  80384. }
  80385. }
  80386. declare module BABYLON.GLTF2.Loader.Extensions {
  80387. /**
  80388. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80389. */
  80390. export class MSFT_lod implements IGLTFLoaderExtension {
  80391. /**
  80392. * The name of this extension.
  80393. */
  80394. readonly name: string;
  80395. /**
  80396. * Defines whether this extension is enabled.
  80397. */
  80398. enabled: boolean;
  80399. /**
  80400. * Defines a number that determines the order the extensions are applied.
  80401. */
  80402. order: number;
  80403. /**
  80404. * Maximum number of LODs to load, starting from the lowest LOD.
  80405. */
  80406. maxLODsToLoad: number;
  80407. /**
  80408. * Observable raised when all node LODs of one level are loaded.
  80409. * The event data is the index of the loaded LOD starting from zero.
  80410. * Dispose the loader to cancel the loading of the next level of LODs.
  80411. */
  80412. onNodeLODsLoadedObservable: Observable<number>;
  80413. /**
  80414. * Observable raised when all material LODs of one level are loaded.
  80415. * The event data is the index of the loaded LOD starting from zero.
  80416. * Dispose the loader to cancel the loading of the next level of LODs.
  80417. */
  80418. onMaterialLODsLoadedObservable: Observable<number>;
  80419. private _loader;
  80420. private _nodeIndexLOD;
  80421. private _nodeSignalLODs;
  80422. private _nodePromiseLODs;
  80423. private _materialIndexLOD;
  80424. private _materialSignalLODs;
  80425. private _materialPromiseLODs;
  80426. private _indexLOD;
  80427. private _bufferLODs;
  80428. /** @hidden */
  80429. constructor(loader: GLTFLoader);
  80430. /** @hidden */
  80431. dispose(): void;
  80432. /** @hidden */
  80433. onReady(): void;
  80434. /** @hidden */
  80435. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80436. /** @hidden */
  80437. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80438. /** @hidden */
  80439. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80440. /** @hidden */
  80441. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80442. /** @hidden */
  80443. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80444. private _loadBufferLOD;
  80445. /**
  80446. * Gets an array of LOD properties from lowest to highest.
  80447. */
  80448. private _getLODs;
  80449. private _disposeTransformNode;
  80450. private _disposeMaterials;
  80451. }
  80452. }
  80453. declare module BABYLON.GLTF2.Loader.Extensions {
  80454. /** @hidden */
  80455. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80456. readonly name: string;
  80457. enabled: boolean;
  80458. private _loader;
  80459. constructor(loader: GLTFLoader);
  80460. dispose(): void;
  80461. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80462. }
  80463. }
  80464. declare module BABYLON.GLTF2.Loader.Extensions {
  80465. /** @hidden */
  80466. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80467. readonly name: string;
  80468. enabled: boolean;
  80469. private _loader;
  80470. constructor(loader: GLTFLoader);
  80471. dispose(): void;
  80472. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80473. }
  80474. }
  80475. declare module BABYLON.GLTF2.Loader.Extensions {
  80476. /**
  80477. * Store glTF extras (if present) in BJS objects' metadata
  80478. */
  80479. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80480. /**
  80481. * The name of this extension.
  80482. */
  80483. readonly name: string;
  80484. /**
  80485. * Defines whether this extension is enabled.
  80486. */
  80487. enabled: boolean;
  80488. private _loader;
  80489. private _assignExtras;
  80490. /** @hidden */
  80491. constructor(loader: GLTFLoader);
  80492. /** @hidden */
  80493. dispose(): void;
  80494. /** @hidden */
  80495. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80496. /** @hidden */
  80497. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80498. /** @hidden */
  80499. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80500. }
  80501. }
  80502. declare module BABYLON {
  80503. /**
  80504. * Class reading and parsing the MTL file bundled with the obj file.
  80505. */
  80506. export class MTLFileLoader {
  80507. /**
  80508. * Invert Y-Axis of referenced textures on load
  80509. */
  80510. static INVERT_TEXTURE_Y: boolean;
  80511. /**
  80512. * All material loaded from the mtl will be set here
  80513. */
  80514. materials: StandardMaterial[];
  80515. /**
  80516. * This function will read the mtl file and create each material described inside
  80517. * This function could be improve by adding :
  80518. * -some component missing (Ni, Tf...)
  80519. * -including the specific options available
  80520. *
  80521. * @param scene defines the scene the material will be created in
  80522. * @param data defines the mtl data to parse
  80523. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80524. * @param forAssetContainer defines if the material should be registered in the scene
  80525. */
  80526. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80527. /**
  80528. * Gets the texture for the material.
  80529. *
  80530. * If the material is imported from input file,
  80531. * We sanitize the url to ensure it takes the textre from aside the material.
  80532. *
  80533. * @param rootUrl The root url to load from
  80534. * @param value The value stored in the mtl
  80535. * @return The Texture
  80536. */
  80537. private static _getTexture;
  80538. }
  80539. }
  80540. declare module BABYLON {
  80541. /**
  80542. * Options for loading OBJ/MTL files
  80543. */
  80544. type MeshLoadOptions = {
  80545. /**
  80546. * Defines if UVs are optimized by default during load.
  80547. */
  80548. OptimizeWithUV: boolean;
  80549. /**
  80550. * Defines custom scaling of UV coordinates of loaded meshes.
  80551. */
  80552. UVScaling: Vector2;
  80553. /**
  80554. * Invert model on y-axis (does a model scaling inversion)
  80555. */
  80556. InvertY: boolean;
  80557. /**
  80558. * Invert Y-Axis of referenced textures on load
  80559. */
  80560. InvertTextureY: boolean;
  80561. /**
  80562. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80563. */
  80564. ImportVertexColors: boolean;
  80565. /**
  80566. * Compute the normals for the model, even if normals are present in the file.
  80567. */
  80568. ComputeNormals: boolean;
  80569. /**
  80570. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80571. */
  80572. SkipMaterials: boolean;
  80573. /**
  80574. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80575. */
  80576. MaterialLoadingFailsSilently: boolean;
  80577. };
  80578. /**
  80579. * OBJ file type loader.
  80580. * This is a babylon scene loader plugin.
  80581. */
  80582. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80583. /**
  80584. * Defines if UVs are optimized by default during load.
  80585. */
  80586. static OPTIMIZE_WITH_UV: boolean;
  80587. /**
  80588. * Invert model on y-axis (does a model scaling inversion)
  80589. */
  80590. static INVERT_Y: boolean;
  80591. /**
  80592. * Invert Y-Axis of referenced textures on load
  80593. */
  80594. static get INVERT_TEXTURE_Y(): boolean;
  80595. static set INVERT_TEXTURE_Y(value: boolean);
  80596. /**
  80597. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80598. */
  80599. static IMPORT_VERTEX_COLORS: boolean;
  80600. /**
  80601. * Compute the normals for the model, even if normals are present in the file.
  80602. */
  80603. static COMPUTE_NORMALS: boolean;
  80604. /**
  80605. * Defines custom scaling of UV coordinates of loaded meshes.
  80606. */
  80607. static UV_SCALING: Vector2;
  80608. /**
  80609. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80610. */
  80611. static SKIP_MATERIALS: boolean;
  80612. /**
  80613. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80614. *
  80615. * Defaults to true for backwards compatibility.
  80616. */
  80617. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80618. /**
  80619. * Defines the name of the plugin.
  80620. */
  80621. name: string;
  80622. /**
  80623. * Defines the extension the plugin is able to load.
  80624. */
  80625. extensions: string;
  80626. /** @hidden */
  80627. obj: RegExp;
  80628. /** @hidden */
  80629. group: RegExp;
  80630. /** @hidden */
  80631. mtllib: RegExp;
  80632. /** @hidden */
  80633. usemtl: RegExp;
  80634. /** @hidden */
  80635. smooth: RegExp;
  80636. /** @hidden */
  80637. vertexPattern: RegExp;
  80638. /** @hidden */
  80639. normalPattern: RegExp;
  80640. /** @hidden */
  80641. uvPattern: RegExp;
  80642. /** @hidden */
  80643. facePattern1: RegExp;
  80644. /** @hidden */
  80645. facePattern2: RegExp;
  80646. /** @hidden */
  80647. facePattern3: RegExp;
  80648. /** @hidden */
  80649. facePattern4: RegExp;
  80650. /** @hidden */
  80651. facePattern5: RegExp;
  80652. private _forAssetContainer;
  80653. private _meshLoadOptions;
  80654. /**
  80655. * Creates loader for .OBJ files
  80656. *
  80657. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80658. */
  80659. constructor(meshLoadOptions?: MeshLoadOptions);
  80660. private static get currentMeshLoadOptions();
  80661. /**
  80662. * Calls synchronously the MTL file attached to this obj.
  80663. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80664. * Without this function materials are not displayed in the first frame (but displayed after).
  80665. * In consequence it is impossible to get material information in your HTML file
  80666. *
  80667. * @param url The URL of the MTL file
  80668. * @param rootUrl
  80669. * @param onSuccess Callback function to be called when the MTL file is loaded
  80670. * @private
  80671. */
  80672. private _loadMTL;
  80673. /**
  80674. * Instantiates a OBJ file loader plugin.
  80675. * @returns the created plugin
  80676. */
  80677. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80678. /**
  80679. * If the data string can be loaded directly.
  80680. *
  80681. * @param data string containing the file data
  80682. * @returns if the data can be loaded directly
  80683. */
  80684. canDirectLoad(data: string): boolean;
  80685. /**
  80686. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80687. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80688. * @param scene the scene the meshes should be added to
  80689. * @param data the OBJ data to load
  80690. * @param rootUrl root url to load from
  80691. * @param onProgress event that fires when loading progress has occured
  80692. * @param fileName Defines the name of the file to load
  80693. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80694. */
  80695. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80696. meshes: AbstractMesh[];
  80697. particleSystems: IParticleSystem[];
  80698. skeletons: Skeleton[];
  80699. animationGroups: AnimationGroup[];
  80700. }>;
  80701. /**
  80702. * Imports all objects from the loaded OBJ data and adds them to the scene
  80703. * @param scene the scene the objects should be added to
  80704. * @param data the OBJ data to load
  80705. * @param rootUrl root url to load from
  80706. * @param onProgress event that fires when loading progress has occured
  80707. * @param fileName Defines the name of the file to load
  80708. * @returns a promise which completes when objects have been loaded to the scene
  80709. */
  80710. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80711. /**
  80712. * Load into an asset container.
  80713. * @param scene The scene to load into
  80714. * @param data The data to import
  80715. * @param rootUrl The root url for scene and resources
  80716. * @param onProgress The callback when the load progresses
  80717. * @param fileName Defines the name of the file to load
  80718. * @returns The loaded asset container
  80719. */
  80720. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80721. /**
  80722. * Read the OBJ file and create an Array of meshes.
  80723. * Each mesh contains all information given by the OBJ and the MTL file.
  80724. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80725. *
  80726. * @param meshesNames
  80727. * @param scene Scene The scene where are displayed the data
  80728. * @param data String The content of the obj file
  80729. * @param rootUrl String The path to the folder
  80730. * @returns Array<AbstractMesh>
  80731. * @private
  80732. */
  80733. private _parseSolid;
  80734. }
  80735. }
  80736. declare module BABYLON {
  80737. /**
  80738. * STL file type loader.
  80739. * This is a babylon scene loader plugin.
  80740. */
  80741. export class STLFileLoader implements ISceneLoaderPlugin {
  80742. /** @hidden */
  80743. solidPattern: RegExp;
  80744. /** @hidden */
  80745. facetsPattern: RegExp;
  80746. /** @hidden */
  80747. normalPattern: RegExp;
  80748. /** @hidden */
  80749. vertexPattern: RegExp;
  80750. /**
  80751. * Defines the name of the plugin.
  80752. */
  80753. name: string;
  80754. /**
  80755. * Defines the extensions the stl loader is able to load.
  80756. * force data to come in as an ArrayBuffer
  80757. * we'll convert to string if it looks like it's an ASCII .stl
  80758. */
  80759. extensions: ISceneLoaderPluginExtensions;
  80760. /**
  80761. * Import meshes into a scene.
  80762. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80763. * @param scene The scene to import into
  80764. * @param data The data to import
  80765. * @param rootUrl The root url for scene and resources
  80766. * @param meshes The meshes array to import into
  80767. * @param particleSystems The particle systems array to import into
  80768. * @param skeletons The skeletons array to import into
  80769. * @param onError The callback when import fails
  80770. * @returns True if successful or false otherwise
  80771. */
  80772. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80773. /**
  80774. * Load into a scene.
  80775. * @param scene The scene to load into
  80776. * @param data The data to import
  80777. * @param rootUrl The root url for scene and resources
  80778. * @param onError The callback when import fails
  80779. * @returns true if successful or false otherwise
  80780. */
  80781. load(scene: Scene, data: any, rootUrl: string): boolean;
  80782. /**
  80783. * Load into an asset container.
  80784. * @param scene The scene to load into
  80785. * @param data The data to import
  80786. * @param rootUrl The root url for scene and resources
  80787. * @param onError The callback when import fails
  80788. * @returns The loaded asset container
  80789. */
  80790. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80791. private _isBinary;
  80792. private _parseBinary;
  80793. private _parseASCII;
  80794. }
  80795. }
  80796. declare module BABYLON {
  80797. /**
  80798. * Class for generating OBJ data from a Babylon scene.
  80799. */
  80800. export class OBJExport {
  80801. /**
  80802. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80803. * @param mesh defines the list of meshes to serialize
  80804. * @param materials defines if materials should be exported
  80805. * @param matlibname defines the name of the associated mtl file
  80806. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80807. * @returns the OBJ content
  80808. */
  80809. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80810. /**
  80811. * Exports the material(s) of a mesh in .MTL file format (text)
  80812. * @param mesh defines the mesh to extract the material from
  80813. * @returns the mtl content
  80814. */
  80815. static MTL(mesh: Mesh): string;
  80816. }
  80817. }
  80818. declare module BABYLON {
  80819. /** @hidden */
  80820. export var __IGLTFExporterExtension: number;
  80821. /**
  80822. * Interface for extending the exporter
  80823. * @hidden
  80824. */
  80825. export interface IGLTFExporterExtension {
  80826. /**
  80827. * The name of this extension
  80828. */
  80829. readonly name: string;
  80830. /**
  80831. * Defines whether this extension is enabled
  80832. */
  80833. enabled: boolean;
  80834. /**
  80835. * Defines whether this extension is required
  80836. */
  80837. required: boolean;
  80838. }
  80839. }
  80840. declare module BABYLON.GLTF2.Exporter {
  80841. /** @hidden */
  80842. export var __IGLTFExporterExtensionV2: number;
  80843. /**
  80844. * Interface for a glTF exporter extension
  80845. * @hidden
  80846. */
  80847. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80848. /**
  80849. * Define this method to modify the default behavior before exporting a texture
  80850. * @param context The context when loading the asset
  80851. * @param babylonTexture The Babylon.js texture
  80852. * @param mimeType The mime-type of the generated image
  80853. * @returns A promise that resolves with the exported texture
  80854. */
  80855. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80856. /**
  80857. * Define this method to get notified when a texture info is created
  80858. * @param context The context when loading the asset
  80859. * @param textureInfo The glTF texture info
  80860. * @param babylonTexture The Babylon.js texture
  80861. */
  80862. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80863. /**
  80864. * Define this method to modify the default behavior when exporting texture info
  80865. * @param context The context when loading the asset
  80866. * @param meshPrimitive glTF mesh primitive
  80867. * @param babylonSubMesh Babylon submesh
  80868. * @param binaryWriter glTF serializer binary writer instance
  80869. * @returns nullable IMeshPrimitive promise
  80870. */
  80871. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80872. /**
  80873. * Define this method to modify the default behavior when exporting a node
  80874. * @param context The context when exporting the node
  80875. * @param node glTF node
  80876. * @param babylonNode BabylonJS node
  80877. * @returns nullable INode promise
  80878. */
  80879. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80880. [key: number]: number;
  80881. }): Promise<Nullable<INode>>;
  80882. /**
  80883. * Define this method to modify the default behavior when exporting a material
  80884. * @param material glTF material
  80885. * @param babylonMaterial BabylonJS material
  80886. * @returns nullable IMaterial promise
  80887. */
  80888. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80889. /**
  80890. * Define this method to return additional textures to export from a material
  80891. * @param material glTF material
  80892. * @param babylonMaterial BabylonJS material
  80893. * @returns List of textures
  80894. */
  80895. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80896. /** Gets a boolean indicating that this extension was used */
  80897. wasUsed: boolean;
  80898. /** Gets a boolean indicating that this extension is required for the file to work */
  80899. required: boolean;
  80900. /**
  80901. * Called after the exporter state changes to EXPORTING
  80902. */
  80903. onExporting?(): void;
  80904. }
  80905. }
  80906. declare module BABYLON.GLTF2.Exporter {
  80907. /**
  80908. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80909. * @hidden
  80910. */
  80911. export class _GLTFMaterialExporter {
  80912. /**
  80913. * Represents the dielectric specular values for R, G and B
  80914. */
  80915. private static readonly _DielectricSpecular;
  80916. /**
  80917. * Allows the maximum specular power to be defined for material calculations
  80918. */
  80919. private static readonly _MaxSpecularPower;
  80920. /**
  80921. * Mapping to store textures
  80922. */
  80923. private _textureMap;
  80924. /**
  80925. * Numeric tolerance value
  80926. */
  80927. private static readonly _Epsilon;
  80928. /**
  80929. * Reference to the glTF Exporter
  80930. */
  80931. private _exporter;
  80932. constructor(exporter: _Exporter);
  80933. /**
  80934. * Specifies if two colors are approximately equal in value
  80935. * @param color1 first color to compare to
  80936. * @param color2 second color to compare to
  80937. * @param epsilon threshold value
  80938. */
  80939. private static FuzzyEquals;
  80940. /**
  80941. * Gets the materials from a Babylon scene and converts them to glTF materials
  80942. * @param scene babylonjs scene
  80943. * @param mimeType texture mime type
  80944. * @param images array of images
  80945. * @param textures array of textures
  80946. * @param materials array of materials
  80947. * @param imageData mapping of texture names to base64 textures
  80948. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80949. */
  80950. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80951. /**
  80952. * Makes a copy of the glTF material without the texture parameters
  80953. * @param originalMaterial original glTF material
  80954. * @returns glTF material without texture parameters
  80955. */
  80956. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80957. /**
  80958. * Specifies if the material has any texture parameters present
  80959. * @param material glTF Material
  80960. * @returns boolean specifying if texture parameters are present
  80961. */
  80962. _hasTexturesPresent(material: IMaterial): boolean;
  80963. /**
  80964. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80965. * @param babylonStandardMaterial
  80966. * @returns glTF Metallic Roughness Material representation
  80967. */
  80968. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80969. /**
  80970. * Computes the metallic factor
  80971. * @param diffuse diffused value
  80972. * @param specular specular value
  80973. * @param oneMinusSpecularStrength one minus the specular strength
  80974. * @returns metallic value
  80975. */
  80976. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80977. /**
  80978. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80979. * @param glTFMaterial glTF material
  80980. * @param babylonMaterial Babylon material
  80981. */
  80982. private static _SetAlphaMode;
  80983. /**
  80984. * Converts a Babylon Standard Material to a glTF Material
  80985. * @param babylonStandardMaterial BJS Standard Material
  80986. * @param mimeType mime type to use for the textures
  80987. * @param images array of glTF image interfaces
  80988. * @param textures array of glTF texture interfaces
  80989. * @param materials array of glTF material interfaces
  80990. * @param imageData map of image file name to data
  80991. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80992. */
  80993. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  80994. private _finishMaterial;
  80995. /**
  80996. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  80997. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  80998. * @param mimeType mime type to use for the textures
  80999. * @param images array of glTF image interfaces
  81000. * @param textures array of glTF texture interfaces
  81001. * @param materials array of glTF material interfaces
  81002. * @param imageData map of image file name to data
  81003. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81004. */
  81005. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81006. /**
  81007. * Converts an image typed array buffer to a base64 image
  81008. * @param buffer typed array buffer
  81009. * @param width width of the image
  81010. * @param height height of the image
  81011. * @param mimeType mimetype of the image
  81012. * @returns base64 image string
  81013. */
  81014. private _createBase64FromCanvasAsync;
  81015. /**
  81016. * Generates a white texture based on the specified width and height
  81017. * @param width width of the texture in pixels
  81018. * @param height height of the texture in pixels
  81019. * @param scene babylonjs scene
  81020. * @returns white texture
  81021. */
  81022. private _createWhiteTexture;
  81023. /**
  81024. * 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
  81025. * @param texture1 first texture to resize
  81026. * @param texture2 second texture to resize
  81027. * @param scene babylonjs scene
  81028. * @returns resized textures or null
  81029. */
  81030. private _resizeTexturesToSameDimensions;
  81031. /**
  81032. * Converts an array of pixels to a Float32Array
  81033. * Throws an error if the pixel format is not supported
  81034. * @param pixels - array buffer containing pixel values
  81035. * @returns Float32 of pixels
  81036. */
  81037. private _convertPixelArrayToFloat32;
  81038. /**
  81039. * Convert Specular Glossiness Textures to Metallic Roughness
  81040. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81041. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81042. * @param diffuseTexture texture used to store diffuse information
  81043. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81044. * @param factors specular glossiness material factors
  81045. * @param mimeType the mime type to use for the texture
  81046. * @returns pbr metallic roughness interface or null
  81047. */
  81048. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81049. /**
  81050. * Converts specular glossiness material properties to metallic roughness
  81051. * @param specularGlossiness interface with specular glossiness material properties
  81052. * @returns interface with metallic roughness material properties
  81053. */
  81054. private _convertSpecularGlossinessToMetallicRoughness;
  81055. /**
  81056. * Calculates the surface reflectance, independent of lighting conditions
  81057. * @param color Color source to calculate brightness from
  81058. * @returns number representing the perceived brightness, or zero if color is undefined
  81059. */
  81060. private _getPerceivedBrightness;
  81061. /**
  81062. * Returns the maximum color component value
  81063. * @param color
  81064. * @returns maximum color component value, or zero if color is null or undefined
  81065. */
  81066. private _getMaxComponent;
  81067. /**
  81068. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81069. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81070. * @param mimeType mime type to use for the textures
  81071. * @param images array of glTF image interfaces
  81072. * @param textures array of glTF texture interfaces
  81073. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81074. * @param imageData map of image file name to data
  81075. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81076. * @returns glTF PBR Metallic Roughness factors
  81077. */
  81078. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81079. private _getGLTFTextureSampler;
  81080. private _getGLTFTextureWrapMode;
  81081. private _getGLTFTextureWrapModesSampler;
  81082. /**
  81083. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81084. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81085. * @param mimeType mime type to use for the textures
  81086. * @param images array of glTF image interfaces
  81087. * @param textures array of glTF texture interfaces
  81088. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81089. * @param imageData map of image file name to data
  81090. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81091. * @returns glTF PBR Metallic Roughness factors
  81092. */
  81093. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81094. /**
  81095. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81096. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81097. * @param mimeType mime type to use for the textures
  81098. * @param images array of glTF image interfaces
  81099. * @param textures array of glTF texture interfaces
  81100. * @param materials array of glTF material interfaces
  81101. * @param imageData map of image file name to data
  81102. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81103. */
  81104. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81105. private setMetallicRoughnessPbrMaterial;
  81106. private getPixelsFromTexture;
  81107. /**
  81108. * Extracts a texture from a Babylon texture into file data and glTF data
  81109. * @param babylonTexture Babylon texture to extract
  81110. * @param mimeType Mime Type of the babylonTexture
  81111. * @return glTF texture info, or null if the texture format is not supported
  81112. */
  81113. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81114. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81115. /**
  81116. * Builds a texture from base64 string
  81117. * @param base64Texture base64 texture string
  81118. * @param baseTextureName Name to use for the texture
  81119. * @param mimeType image mime type for the texture
  81120. * @param images array of images
  81121. * @param textures array of textures
  81122. * @param imageData map of image data
  81123. * @returns glTF texture info, or null if the texture format is not supported
  81124. */
  81125. private _getTextureInfoFromBase64;
  81126. }
  81127. }
  81128. declare module BABYLON {
  81129. /**
  81130. * Class for holding and downloading glTF file data
  81131. */
  81132. export class GLTFData {
  81133. /**
  81134. * Object which contains the file name as the key and its data as the value
  81135. */
  81136. glTFFiles: {
  81137. [fileName: string]: string | Blob;
  81138. };
  81139. /**
  81140. * Initializes the glTF file object
  81141. */
  81142. constructor();
  81143. /**
  81144. * Downloads the glTF data as files based on their names and data
  81145. */
  81146. downloadFiles(): void;
  81147. }
  81148. }
  81149. declare module BABYLON {
  81150. /**
  81151. * Holds a collection of exporter options and parameters
  81152. */
  81153. export interface IExportOptions {
  81154. /**
  81155. * Function which indicates whether a babylon node should be exported or not
  81156. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81157. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81158. */
  81159. shouldExportNode?(node: Node): boolean;
  81160. /**
  81161. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81162. * @param metadata source metadata to read from
  81163. * @returns the data to store to glTF node extras
  81164. */
  81165. metadataSelector?(metadata: any): any;
  81166. /**
  81167. * The sample rate to bake animation curves
  81168. */
  81169. animationSampleRate?: number;
  81170. /**
  81171. * Begin serialization without waiting for the scene to be ready
  81172. */
  81173. exportWithoutWaitingForScene?: boolean;
  81174. /**
  81175. * Indicates if coordinate system swapping root nodes should be included in export
  81176. */
  81177. includeCoordinateSystemConversionNodes?: boolean;
  81178. }
  81179. /**
  81180. * Class for generating glTF data from a Babylon scene.
  81181. */
  81182. export class GLTF2Export {
  81183. /**
  81184. * Exports the geometry of the scene to .gltf file format asynchronously
  81185. * @param scene Babylon scene with scene hierarchy information
  81186. * @param filePrefix File prefix to use when generating the glTF file
  81187. * @param options Exporter options
  81188. * @returns Returns an object with a .gltf file and associates texture names
  81189. * as keys and their data and paths as values
  81190. */
  81191. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81192. private static _PreExportAsync;
  81193. private static _PostExportAsync;
  81194. /**
  81195. * Exports the geometry of the scene to .glb file format asychronously
  81196. * @param scene Babylon scene with scene hierarchy information
  81197. * @param filePrefix File prefix to use when generating glb file
  81198. * @param options Exporter options
  81199. * @returns Returns an object with a .glb filename as key and data as value
  81200. */
  81201. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81202. }
  81203. }
  81204. declare module BABYLON.GLTF2.Exporter {
  81205. /**
  81206. * @hidden
  81207. */
  81208. export class _GLTFUtilities {
  81209. /**
  81210. * Creates a buffer view based on the supplied arguments
  81211. * @param bufferIndex index value of the specified buffer
  81212. * @param byteOffset byte offset value
  81213. * @param byteLength byte length of the bufferView
  81214. * @param byteStride byte distance between conequential elements
  81215. * @param name name of the buffer view
  81216. * @returns bufferView for glTF
  81217. */
  81218. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81219. /**
  81220. * Creates an accessor based on the supplied arguments
  81221. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81222. * @param name The name of the accessor
  81223. * @param type The type of the accessor
  81224. * @param componentType The datatype of components in the attribute
  81225. * @param count The number of attributes referenced by this accessor
  81226. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81227. * @param min Minimum value of each component in this attribute
  81228. * @param max Maximum value of each component in this attribute
  81229. * @returns accessor for glTF
  81230. */
  81231. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81232. /**
  81233. * Calculates the minimum and maximum values of an array of position floats
  81234. * @param positions Positions array of a mesh
  81235. * @param vertexStart Starting vertex offset to calculate min and max values
  81236. * @param vertexCount Number of vertices to check for min and max values
  81237. * @returns min number array and max number array
  81238. */
  81239. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81240. min: number[];
  81241. max: number[];
  81242. };
  81243. /**
  81244. * Converts a new right-handed Vector3
  81245. * @param vector vector3 array
  81246. * @returns right-handed Vector3
  81247. */
  81248. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81249. /**
  81250. * Converts a Vector3 to right-handed
  81251. * @param vector Vector3 to convert to right-handed
  81252. */
  81253. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81254. /**
  81255. * Converts a three element number array to right-handed
  81256. * @param vector number array to convert to right-handed
  81257. */
  81258. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81259. /**
  81260. * Converts a new right-handed Vector3
  81261. * @param vector vector3 array
  81262. * @returns right-handed Vector3
  81263. */
  81264. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81265. /**
  81266. * Converts a Vector3 to right-handed
  81267. * @param vector Vector3 to convert to right-handed
  81268. */
  81269. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81270. /**
  81271. * Converts a three element number array to right-handed
  81272. * @param vector number array to convert to right-handed
  81273. */
  81274. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81275. /**
  81276. * Converts a Vector4 to right-handed
  81277. * @param vector Vector4 to convert to right-handed
  81278. */
  81279. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81280. /**
  81281. * Converts a Vector4 to right-handed
  81282. * @param vector Vector4 to convert to right-handed
  81283. */
  81284. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81285. /**
  81286. * Converts a Quaternion to right-handed
  81287. * @param quaternion Source quaternion to convert to right-handed
  81288. */
  81289. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81290. /**
  81291. * Converts a Quaternion to right-handed
  81292. * @param quaternion Source quaternion to convert to right-handed
  81293. */
  81294. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81295. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81296. }
  81297. }
  81298. declare module BABYLON.GLTF2.Exporter {
  81299. /**
  81300. * Converts Babylon Scene into glTF 2.0.
  81301. * @hidden
  81302. */
  81303. export class _Exporter {
  81304. /**
  81305. * Stores the glTF to export
  81306. */
  81307. _glTF: IGLTF;
  81308. /**
  81309. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81310. */
  81311. _bufferViews: IBufferView[];
  81312. /**
  81313. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81314. */
  81315. _accessors: IAccessor[];
  81316. /**
  81317. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81318. */
  81319. _nodes: INode[];
  81320. /**
  81321. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81322. */
  81323. private _scenes;
  81324. /**
  81325. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81326. */
  81327. private _meshes;
  81328. /**
  81329. * Stores all the generated material information, which represents the appearance of each primitive
  81330. */
  81331. _materials: IMaterial[];
  81332. _materialMap: {
  81333. [materialID: number]: number;
  81334. };
  81335. /**
  81336. * Stores all the generated texture information, which is referenced by glTF materials
  81337. */
  81338. _textures: ITexture[];
  81339. /**
  81340. * Stores all the generated image information, which is referenced by glTF textures
  81341. */
  81342. _images: IImage[];
  81343. /**
  81344. * Stores all the texture samplers
  81345. */
  81346. _samplers: ISampler[];
  81347. /**
  81348. * Stores all the generated animation samplers, which is referenced by glTF animations
  81349. */
  81350. /**
  81351. * Stores the animations for glTF models
  81352. */
  81353. private _animations;
  81354. /**
  81355. * Stores the total amount of bytes stored in the glTF buffer
  81356. */
  81357. private _totalByteLength;
  81358. /**
  81359. * Stores a reference to the Babylon scene containing the source geometry and material information
  81360. */
  81361. _babylonScene: Scene;
  81362. /**
  81363. * Stores a map of the image data, where the key is the file name and the value
  81364. * is the image data
  81365. */
  81366. _imageData: {
  81367. [fileName: string]: {
  81368. data: Uint8Array;
  81369. mimeType: ImageMimeType;
  81370. };
  81371. };
  81372. /**
  81373. * Stores a map of the unique id of a node to its index in the node array
  81374. */
  81375. _nodeMap: {
  81376. [key: number]: number;
  81377. };
  81378. /**
  81379. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81380. */
  81381. _convertToRightHandedSystem: boolean;
  81382. /**
  81383. * Specifies if a Babylon node should be converted to right-handed on export
  81384. */
  81385. _convertToRightHandedSystemMap: {
  81386. [nodeId: number]: boolean;
  81387. };
  81388. _includeCoordinateSystemConversionNodes: boolean;
  81389. /**
  81390. * Baked animation sample rate
  81391. */
  81392. private _animationSampleRate;
  81393. private _options;
  81394. private _localEngine;
  81395. _glTFMaterialExporter: _GLTFMaterialExporter;
  81396. private _extensions;
  81397. private static _ExtensionNames;
  81398. private static _ExtensionFactories;
  81399. private _applyExtension;
  81400. private _applyExtensions;
  81401. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81402. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81403. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81404. [key: number]: number;
  81405. }): Promise<Nullable<INode>>;
  81406. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81407. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81408. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81409. private _forEachExtensions;
  81410. private _extensionsOnExporting;
  81411. /**
  81412. * Load glTF serializer extensions
  81413. */
  81414. private _loadExtensions;
  81415. /**
  81416. * Creates a glTF Exporter instance, which can accept optional exporter options
  81417. * @param babylonScene Babylon scene object
  81418. * @param options Options to modify the behavior of the exporter
  81419. */
  81420. constructor(babylonScene: Scene, options?: IExportOptions);
  81421. dispose(): void;
  81422. /**
  81423. * Registers a glTF exporter extension
  81424. * @param name Name of the extension to export
  81425. * @param factory The factory function that creates the exporter extension
  81426. */
  81427. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81428. /**
  81429. * Un-registers an exporter extension
  81430. * @param name The name fo the exporter extension
  81431. * @returns A boolean indicating whether the extension has been un-registered
  81432. */
  81433. static UnregisterExtension(name: string): boolean;
  81434. /**
  81435. * Lazy load a local engine
  81436. */
  81437. _getLocalEngine(): Engine;
  81438. private reorderIndicesBasedOnPrimitiveMode;
  81439. /**
  81440. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81441. * clock-wise during export to glTF
  81442. * @param submesh BabylonJS submesh
  81443. * @param primitiveMode Primitive mode of the mesh
  81444. * @param sideOrientation the winding order of the submesh
  81445. * @param vertexBufferKind The type of vertex attribute
  81446. * @param meshAttributeArray The vertex attribute data
  81447. * @param byteOffset The offset to the binary data
  81448. * @param binaryWriter The binary data for the glTF file
  81449. * @param convertToRightHandedSystem Converts the values to right-handed
  81450. */
  81451. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81452. /**
  81453. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81454. * clock-wise during export to glTF
  81455. * @param submesh BabylonJS submesh
  81456. * @param primitiveMode Primitive mode of the mesh
  81457. * @param sideOrientation the winding order of the submesh
  81458. * @param vertexBufferKind The type of vertex attribute
  81459. * @param meshAttributeArray The vertex attribute data
  81460. * @param byteOffset The offset to the binary data
  81461. * @param binaryWriter The binary data for the glTF file
  81462. * @param convertToRightHandedSystem Converts the values to right-handed
  81463. */
  81464. private reorderTriangleFillMode;
  81465. /**
  81466. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81467. * clock-wise during export to glTF
  81468. * @param submesh BabylonJS submesh
  81469. * @param primitiveMode Primitive mode of the mesh
  81470. * @param sideOrientation the winding order of the submesh
  81471. * @param vertexBufferKind The type of vertex attribute
  81472. * @param meshAttributeArray The vertex attribute data
  81473. * @param byteOffset The offset to the binary data
  81474. * @param binaryWriter The binary data for the glTF file
  81475. * @param convertToRightHandedSystem Converts the values to right-handed
  81476. */
  81477. private reorderTriangleStripDrawMode;
  81478. /**
  81479. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81480. * clock-wise during export to glTF
  81481. * @param submesh BabylonJS submesh
  81482. * @param primitiveMode Primitive mode of the mesh
  81483. * @param sideOrientation the winding order of the submesh
  81484. * @param vertexBufferKind The type of vertex attribute
  81485. * @param meshAttributeArray The vertex attribute data
  81486. * @param byteOffset The offset to the binary data
  81487. * @param binaryWriter The binary data for the glTF file
  81488. * @param convertToRightHandedSystem Converts the values to right-handed
  81489. */
  81490. private reorderTriangleFanMode;
  81491. /**
  81492. * Writes the vertex attribute data to binary
  81493. * @param vertices The vertices to write to the binary writer
  81494. * @param byteOffset The offset into the binary writer to overwrite binary data
  81495. * @param vertexAttributeKind The vertex attribute type
  81496. * @param meshAttributeArray The vertex attribute data
  81497. * @param binaryWriter The writer containing the binary data
  81498. * @param convertToRightHandedSystem Converts the values to right-handed
  81499. */
  81500. private writeVertexAttributeData;
  81501. /**
  81502. * Writes mesh attribute data to a data buffer
  81503. * Returns the bytelength of the data
  81504. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81505. * @param meshAttributeArray Array containing the attribute data
  81506. * @param binaryWriter The buffer to write the binary data to
  81507. * @param indices Used to specify the order of the vertex data
  81508. * @param convertToRightHandedSystem Converts the values to right-handed
  81509. */
  81510. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81511. /**
  81512. * Generates glTF json data
  81513. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81514. * @param glTFPrefix Text to use when prefixing a glTF file
  81515. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81516. * @returns json data as string
  81517. */
  81518. private generateJSON;
  81519. /**
  81520. * Generates data for .gltf and .bin files based on the glTF prefix string
  81521. * @param glTFPrefix Text to use when prefixing a glTF file
  81522. * @param dispose Dispose the exporter
  81523. * @returns GLTFData with glTF file data
  81524. */
  81525. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81526. /**
  81527. * Creates a binary buffer for glTF
  81528. * @returns array buffer for binary data
  81529. */
  81530. private _generateBinaryAsync;
  81531. /**
  81532. * Pads the number to a multiple of 4
  81533. * @param num number to pad
  81534. * @returns padded number
  81535. */
  81536. private _getPadding;
  81537. /**
  81538. * @hidden
  81539. */
  81540. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81541. /**
  81542. * Sets the TRS for each node
  81543. * @param node glTF Node for storing the transformation data
  81544. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  81545. * @param convertToRightHandedSystem Converts the values to right-handed
  81546. */
  81547. private setNodeTransformation;
  81548. private getVertexBufferFromMesh;
  81549. /**
  81550. * Creates a bufferview based on the vertices type for the Babylon mesh
  81551. * @param kind Indicates the type of vertices data
  81552. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  81553. * @param binaryWriter The buffer to write the bufferview data to
  81554. * @param convertToRightHandedSystem Converts the values to right-handed
  81555. */
  81556. private createBufferViewKind;
  81557. /**
  81558. * The primitive mode of the Babylon mesh
  81559. * @param babylonMesh The BabylonJS mesh
  81560. */
  81561. private getMeshPrimitiveMode;
  81562. /**
  81563. * Sets the primitive mode of the glTF mesh primitive
  81564. * @param meshPrimitive glTF mesh primitive
  81565. * @param primitiveMode The primitive mode
  81566. */
  81567. private setPrimitiveMode;
  81568. /**
  81569. * Sets the vertex attribute accessor based of the glTF mesh primitive
  81570. * @param meshPrimitive glTF mesh primitive
  81571. * @param attributeKind vertex attribute
  81572. * @returns boolean specifying if uv coordinates are present
  81573. */
  81574. private setAttributeKind;
  81575. /**
  81576. * Sets data for the primitive attributes of each submesh
  81577. * @param mesh glTF Mesh object to store the primitive attribute information
  81578. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  81579. * @param binaryWriter Buffer to write the attribute data to
  81580. * @param convertToRightHandedSystem Converts the values to right-handed
  81581. */
  81582. private setPrimitiveAttributesAsync;
  81583. /**
  81584. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  81585. * @param node The node to check
  81586. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81587. */
  81588. private isBabylonCoordinateSystemConvertingNode;
  81589. /**
  81590. * Creates a glTF scene based on the array of meshes
  81591. * Returns the the total byte offset
  81592. * @param babylonScene Babylon scene to get the mesh data from
  81593. * @param binaryWriter Buffer to write binary data to
  81594. */
  81595. private createSceneAsync;
  81596. /**
  81597. * Creates a mapping of Node unique id to node index and handles animations
  81598. * @param babylonScene Babylon Scene
  81599. * @param nodes Babylon transform nodes
  81600. * @param binaryWriter Buffer to write binary data to
  81601. * @returns Node mapping of unique id to index
  81602. */
  81603. private createNodeMapAndAnimationsAsync;
  81604. /**
  81605. * Creates a glTF node from a Babylon mesh
  81606. * @param babylonMesh Source Babylon mesh
  81607. * @param binaryWriter Buffer for storing geometry data
  81608. * @param convertToRightHandedSystem Converts the values to right-handed
  81609. * @param nodeMap Node mapping of unique id to glTF node index
  81610. * @returns glTF node
  81611. */
  81612. private createNodeAsync;
  81613. }
  81614. /**
  81615. * @hidden
  81616. *
  81617. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81618. */
  81619. export class _BinaryWriter {
  81620. /**
  81621. * Array buffer which stores all binary data
  81622. */
  81623. private _arrayBuffer;
  81624. /**
  81625. * View of the array buffer
  81626. */
  81627. private _dataView;
  81628. /**
  81629. * byte offset of data in array buffer
  81630. */
  81631. private _byteOffset;
  81632. /**
  81633. * Initialize binary writer with an initial byte length
  81634. * @param byteLength Initial byte length of the array buffer
  81635. */
  81636. constructor(byteLength: number);
  81637. /**
  81638. * Resize the array buffer to the specified byte length
  81639. * @param byteLength
  81640. */
  81641. private resizeBuffer;
  81642. /**
  81643. * Get an array buffer with the length of the byte offset
  81644. * @returns ArrayBuffer resized to the byte offset
  81645. */
  81646. getArrayBuffer(): ArrayBuffer;
  81647. /**
  81648. * Get the byte offset of the array buffer
  81649. * @returns byte offset
  81650. */
  81651. getByteOffset(): number;
  81652. /**
  81653. * Stores an UInt8 in the array buffer
  81654. * @param entry
  81655. * @param byteOffset If defined, specifies where to set the value as an offset.
  81656. */
  81657. setUInt8(entry: number, byteOffset?: number): void;
  81658. /**
  81659. * Gets an UInt32 in the array buffer
  81660. * @param entry
  81661. * @param byteOffset If defined, specifies where to set the value as an offset.
  81662. */
  81663. getUInt32(byteOffset: number): number;
  81664. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81665. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81666. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81667. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81668. /**
  81669. * Stores a Float32 in the array buffer
  81670. * @param entry
  81671. */
  81672. setFloat32(entry: number, byteOffset?: number): void;
  81673. /**
  81674. * Stores an UInt32 in the array buffer
  81675. * @param entry
  81676. * @param byteOffset If defined, specifies where to set the value as an offset.
  81677. */
  81678. setUInt32(entry: number, byteOffset?: number): void;
  81679. }
  81680. }
  81681. declare module BABYLON.GLTF2.Exporter {
  81682. /**
  81683. * @hidden
  81684. * Interface to store animation data.
  81685. */
  81686. export interface _IAnimationData {
  81687. /**
  81688. * Keyframe data.
  81689. */
  81690. inputs: number[];
  81691. /**
  81692. * Value data.
  81693. */
  81694. outputs: number[][];
  81695. /**
  81696. * Animation interpolation data.
  81697. */
  81698. samplerInterpolation: AnimationSamplerInterpolation;
  81699. /**
  81700. * Minimum keyframe value.
  81701. */
  81702. inputsMin: number;
  81703. /**
  81704. * Maximum keyframe value.
  81705. */
  81706. inputsMax: number;
  81707. }
  81708. /**
  81709. * @hidden
  81710. */
  81711. export interface _IAnimationInfo {
  81712. /**
  81713. * The target channel for the animation
  81714. */
  81715. animationChannelTargetPath: AnimationChannelTargetPath;
  81716. /**
  81717. * The glTF accessor type for the data.
  81718. */
  81719. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81720. /**
  81721. * Specifies if quaternions should be used.
  81722. */
  81723. useQuaternion: boolean;
  81724. }
  81725. /**
  81726. * @hidden
  81727. * Utility class for generating glTF animation data from BabylonJS.
  81728. */
  81729. export class _GLTFAnimation {
  81730. /**
  81731. * @ignore
  81732. *
  81733. * Creates glTF channel animation from BabylonJS animation.
  81734. * @param babylonTransformNode - BabylonJS mesh.
  81735. * @param animation - animation.
  81736. * @param animationChannelTargetPath - The target animation channel.
  81737. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81738. * @param useQuaternion - Specifies if quaternions are used.
  81739. * @returns nullable IAnimationData
  81740. */
  81741. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81742. private static _DeduceAnimationInfo;
  81743. /**
  81744. * @ignore
  81745. * Create node animations from the transform node animations
  81746. * @param babylonNode
  81747. * @param runtimeGLTFAnimation
  81748. * @param idleGLTFAnimations
  81749. * @param nodeMap
  81750. * @param nodes
  81751. * @param binaryWriter
  81752. * @param bufferViews
  81753. * @param accessors
  81754. * @param convertToRightHandedSystem
  81755. * @param animationSampleRate
  81756. */
  81757. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81758. [key: number]: number;
  81759. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81760. /**
  81761. * @ignore
  81762. * Create node animations from the animation groups
  81763. * @param babylonScene
  81764. * @param glTFAnimations
  81765. * @param nodeMap
  81766. * @param nodes
  81767. * @param binaryWriter
  81768. * @param bufferViews
  81769. * @param accessors
  81770. * @param convertToRightHandedSystemMap
  81771. * @param animationSampleRate
  81772. */
  81773. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81774. [key: number]: number;
  81775. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81776. [nodeId: number]: boolean;
  81777. }, animationSampleRate: number): void;
  81778. private static AddAnimation;
  81779. /**
  81780. * Create a baked animation
  81781. * @param babylonTransformNode BabylonJS mesh
  81782. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81783. * @param animationChannelTargetPath animation target channel
  81784. * @param minFrame minimum animation frame
  81785. * @param maxFrame maximum animation frame
  81786. * @param fps frames per second of the animation
  81787. * @param inputs input key frames of the animation
  81788. * @param outputs output key frame data of the animation
  81789. * @param convertToRightHandedSystem converts the values to right-handed
  81790. * @param useQuaternion specifies if quaternions should be used
  81791. */
  81792. private static _CreateBakedAnimation;
  81793. private static _ConvertFactorToVector3OrQuaternion;
  81794. private static _SetInterpolatedValue;
  81795. /**
  81796. * Creates linear animation from the animation key frames
  81797. * @param babylonTransformNode BabylonJS mesh
  81798. * @param animation BabylonJS animation
  81799. * @param animationChannelTargetPath The target animation channel
  81800. * @param frameDelta The difference between the last and first frame of the animation
  81801. * @param inputs Array to store the key frame times
  81802. * @param outputs Array to store the key frame data
  81803. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81804. * @param useQuaternion Specifies if quaternions are used in the animation
  81805. */
  81806. private static _CreateLinearOrStepAnimation;
  81807. /**
  81808. * Creates cubic spline animation from the animation key frames
  81809. * @param babylonTransformNode BabylonJS mesh
  81810. * @param animation BabylonJS animation
  81811. * @param animationChannelTargetPath The target animation channel
  81812. * @param frameDelta The difference between the last and first frame of the animation
  81813. * @param inputs Array to store the key frame times
  81814. * @param outputs Array to store the key frame data
  81815. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81816. * @param useQuaternion Specifies if quaternions are used in the animation
  81817. */
  81818. private static _CreateCubicSplineAnimation;
  81819. private static _GetBasePositionRotationOrScale;
  81820. /**
  81821. * Adds a key frame value
  81822. * @param keyFrame
  81823. * @param animation
  81824. * @param outputs
  81825. * @param animationChannelTargetPath
  81826. * @param basePositionRotationOrScale
  81827. * @param convertToRightHandedSystem
  81828. * @param useQuaternion
  81829. */
  81830. private static _AddKeyframeValue;
  81831. /**
  81832. * Determine the interpolation based on the key frames
  81833. * @param keyFrames
  81834. * @param animationChannelTargetPath
  81835. * @param useQuaternion
  81836. */
  81837. private static _DeduceInterpolation;
  81838. /**
  81839. * Adds an input tangent or output tangent to the output data
  81840. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81841. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81842. * @param outputs The animation data by keyframe
  81843. * @param animationChannelTargetPath The target animation channel
  81844. * @param interpolation The interpolation type
  81845. * @param keyFrame The key frame with the animation data
  81846. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81847. * @param useQuaternion Specifies if quaternions are used
  81848. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81849. */
  81850. private static AddSplineTangent;
  81851. /**
  81852. * Get the minimum and maximum key frames' frame values
  81853. * @param keyFrames animation key frames
  81854. * @returns the minimum and maximum key frame value
  81855. */
  81856. private static calculateMinMaxKeyFrames;
  81857. }
  81858. }
  81859. declare module BABYLON.GLTF2.Exporter {
  81860. /** @hidden */
  81861. export var textureTransformPixelShader: {
  81862. name: string;
  81863. shader: string;
  81864. };
  81865. }
  81866. declare module BABYLON.GLTF2.Exporter.Extensions {
  81867. /**
  81868. * @hidden
  81869. */
  81870. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81871. private _recordedTextures;
  81872. /** Name of this extension */
  81873. readonly name: string;
  81874. /** Defines whether this extension is enabled */
  81875. enabled: boolean;
  81876. /** Defines whether this extension is required */
  81877. required: boolean;
  81878. /** Reference to the glTF exporter */
  81879. private _wasUsed;
  81880. constructor(exporter: _Exporter);
  81881. dispose(): void;
  81882. /** @hidden */
  81883. get wasUsed(): boolean;
  81884. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81885. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81886. /**
  81887. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81888. * @param babylonTexture
  81889. * @param offset
  81890. * @param rotation
  81891. * @param scale
  81892. * @param scene
  81893. */
  81894. private _textureTransformTextureAsync;
  81895. }
  81896. }
  81897. declare module BABYLON.GLTF2.Exporter.Extensions {
  81898. /**
  81899. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81900. */
  81901. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81902. /** The name of this extension. */
  81903. readonly name: string;
  81904. /** Defines whether this extension is enabled. */
  81905. enabled: boolean;
  81906. /** Defines whether this extension is required */
  81907. required: boolean;
  81908. /** Reference to the glTF exporter */
  81909. private _exporter;
  81910. private _lights;
  81911. /** @hidden */
  81912. constructor(exporter: _Exporter);
  81913. /** @hidden */
  81914. dispose(): void;
  81915. /** @hidden */
  81916. get wasUsed(): boolean;
  81917. /** @hidden */
  81918. onExporting(): void;
  81919. /**
  81920. * Define this method to modify the default behavior when exporting a node
  81921. * @param context The context when exporting the node
  81922. * @param node glTF node
  81923. * @param babylonNode BabylonJS node
  81924. * @param nodeMap Node mapping of unique id to glTF node index
  81925. * @returns nullable INode promise
  81926. */
  81927. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81928. [key: number]: number;
  81929. }): Promise<Nullable<INode>>;
  81930. }
  81931. }
  81932. declare module BABYLON.GLTF2.Exporter.Extensions {
  81933. /**
  81934. * @hidden
  81935. */
  81936. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81937. /** Name of this extension */
  81938. readonly name: string;
  81939. /** Defines whether this extension is enabled */
  81940. enabled: boolean;
  81941. /** Defines whether this extension is required */
  81942. required: boolean;
  81943. /** Reference to the glTF exporter */
  81944. private _textureInfos;
  81945. private _exportedTextures;
  81946. private _wasUsed;
  81947. constructor(exporter: _Exporter);
  81948. dispose(): void;
  81949. /** @hidden */
  81950. get wasUsed(): boolean;
  81951. private _getTextureIndex;
  81952. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81953. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81954. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81955. }
  81956. }
  81957. declare module BABYLON {
  81958. /**
  81959. * Class for generating STL data from a Babylon scene.
  81960. */
  81961. export class STLExport {
  81962. /**
  81963. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81964. * @param meshes list defines the mesh to serialize
  81965. * @param download triggers the automatic download of the file.
  81966. * @param fileName changes the downloads fileName.
  81967. * @param binary changes the STL to a binary type.
  81968. * @param isLittleEndian toggle for binary type exporter.
  81969. * @returns the STL as UTF8 string
  81970. */
  81971. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81972. }
  81973. }
  81974. declare module "babylonjs-gltf2interface" {
  81975. export = BABYLON.GLTF2;
  81976. }
  81977. /**
  81978. * Module for glTF 2.0 Interface
  81979. */
  81980. declare module BABYLON.GLTF2 {
  81981. /**
  81982. * The datatype of the components in the attribute
  81983. */
  81984. const enum AccessorComponentType {
  81985. /**
  81986. * Byte
  81987. */
  81988. BYTE = 5120,
  81989. /**
  81990. * Unsigned Byte
  81991. */
  81992. UNSIGNED_BYTE = 5121,
  81993. /**
  81994. * Short
  81995. */
  81996. SHORT = 5122,
  81997. /**
  81998. * Unsigned Short
  81999. */
  82000. UNSIGNED_SHORT = 5123,
  82001. /**
  82002. * Unsigned Int
  82003. */
  82004. UNSIGNED_INT = 5125,
  82005. /**
  82006. * Float
  82007. */
  82008. FLOAT = 5126,
  82009. }
  82010. /**
  82011. * Specifies if the attirbute is a scalar, vector, or matrix
  82012. */
  82013. const enum AccessorType {
  82014. /**
  82015. * Scalar
  82016. */
  82017. SCALAR = "SCALAR",
  82018. /**
  82019. * Vector2
  82020. */
  82021. VEC2 = "VEC2",
  82022. /**
  82023. * Vector3
  82024. */
  82025. VEC3 = "VEC3",
  82026. /**
  82027. * Vector4
  82028. */
  82029. VEC4 = "VEC4",
  82030. /**
  82031. * Matrix2x2
  82032. */
  82033. MAT2 = "MAT2",
  82034. /**
  82035. * Matrix3x3
  82036. */
  82037. MAT3 = "MAT3",
  82038. /**
  82039. * Matrix4x4
  82040. */
  82041. MAT4 = "MAT4",
  82042. }
  82043. /**
  82044. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82045. */
  82046. const enum AnimationChannelTargetPath {
  82047. /**
  82048. * Translation
  82049. */
  82050. TRANSLATION = "translation",
  82051. /**
  82052. * Rotation
  82053. */
  82054. ROTATION = "rotation",
  82055. /**
  82056. * Scale
  82057. */
  82058. SCALE = "scale",
  82059. /**
  82060. * Weights
  82061. */
  82062. WEIGHTS = "weights",
  82063. }
  82064. /**
  82065. * Interpolation algorithm
  82066. */
  82067. const enum AnimationSamplerInterpolation {
  82068. /**
  82069. * The animated values are linearly interpolated between keyframes
  82070. */
  82071. LINEAR = "LINEAR",
  82072. /**
  82073. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82074. */
  82075. STEP = "STEP",
  82076. /**
  82077. * The animation's interpolation is computed using a cubic spline with specified tangents
  82078. */
  82079. CUBICSPLINE = "CUBICSPLINE",
  82080. }
  82081. /**
  82082. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82083. */
  82084. const enum CameraType {
  82085. /**
  82086. * A perspective camera containing properties to create a perspective projection matrix
  82087. */
  82088. PERSPECTIVE = "perspective",
  82089. /**
  82090. * An orthographic camera containing properties to create an orthographic projection matrix
  82091. */
  82092. ORTHOGRAPHIC = "orthographic",
  82093. }
  82094. /**
  82095. * The mime-type of the image
  82096. */
  82097. const enum ImageMimeType {
  82098. /**
  82099. * JPEG Mime-type
  82100. */
  82101. JPEG = "image/jpeg",
  82102. /**
  82103. * PNG Mime-type
  82104. */
  82105. PNG = "image/png",
  82106. }
  82107. /**
  82108. * The alpha rendering mode of the material
  82109. */
  82110. const enum MaterialAlphaMode {
  82111. /**
  82112. * The alpha value is ignored and the rendered output is fully opaque
  82113. */
  82114. OPAQUE = "OPAQUE",
  82115. /**
  82116. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82117. */
  82118. MASK = "MASK",
  82119. /**
  82120. * 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)
  82121. */
  82122. BLEND = "BLEND",
  82123. }
  82124. /**
  82125. * The type of the primitives to render
  82126. */
  82127. const enum MeshPrimitiveMode {
  82128. /**
  82129. * Points
  82130. */
  82131. POINTS = 0,
  82132. /**
  82133. * Lines
  82134. */
  82135. LINES = 1,
  82136. /**
  82137. * Line Loop
  82138. */
  82139. LINE_LOOP = 2,
  82140. /**
  82141. * Line Strip
  82142. */
  82143. LINE_STRIP = 3,
  82144. /**
  82145. * Triangles
  82146. */
  82147. TRIANGLES = 4,
  82148. /**
  82149. * Triangle Strip
  82150. */
  82151. TRIANGLE_STRIP = 5,
  82152. /**
  82153. * Triangle Fan
  82154. */
  82155. TRIANGLE_FAN = 6,
  82156. }
  82157. /**
  82158. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82159. */
  82160. const enum TextureMagFilter {
  82161. /**
  82162. * Nearest
  82163. */
  82164. NEAREST = 9728,
  82165. /**
  82166. * Linear
  82167. */
  82168. LINEAR = 9729,
  82169. }
  82170. /**
  82171. * Minification filter. All valid values correspond to WebGL enums
  82172. */
  82173. const enum TextureMinFilter {
  82174. /**
  82175. * Nearest
  82176. */
  82177. NEAREST = 9728,
  82178. /**
  82179. * Linear
  82180. */
  82181. LINEAR = 9729,
  82182. /**
  82183. * Nearest Mip-Map Nearest
  82184. */
  82185. NEAREST_MIPMAP_NEAREST = 9984,
  82186. /**
  82187. * Linear Mipmap Nearest
  82188. */
  82189. LINEAR_MIPMAP_NEAREST = 9985,
  82190. /**
  82191. * Nearest Mipmap Linear
  82192. */
  82193. NEAREST_MIPMAP_LINEAR = 9986,
  82194. /**
  82195. * Linear Mipmap Linear
  82196. */
  82197. LINEAR_MIPMAP_LINEAR = 9987,
  82198. }
  82199. /**
  82200. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82201. */
  82202. const enum TextureWrapMode {
  82203. /**
  82204. * Clamp to Edge
  82205. */
  82206. CLAMP_TO_EDGE = 33071,
  82207. /**
  82208. * Mirrored Repeat
  82209. */
  82210. MIRRORED_REPEAT = 33648,
  82211. /**
  82212. * Repeat
  82213. */
  82214. REPEAT = 10497,
  82215. }
  82216. /**
  82217. * glTF Property
  82218. */
  82219. interface IProperty {
  82220. /**
  82221. * Dictionary object with extension-specific objects
  82222. */
  82223. extensions?: {
  82224. [key: string]: any;
  82225. };
  82226. /**
  82227. * Application-Specific data
  82228. */
  82229. extras?: any;
  82230. }
  82231. /**
  82232. * glTF Child of Root Property
  82233. */
  82234. interface IChildRootProperty extends IProperty {
  82235. /**
  82236. * The user-defined name of this object
  82237. */
  82238. name?: string;
  82239. }
  82240. /**
  82241. * Indices of those attributes that deviate from their initialization value
  82242. */
  82243. interface IAccessorSparseIndices extends IProperty {
  82244. /**
  82245. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82246. */
  82247. bufferView: number;
  82248. /**
  82249. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82250. */
  82251. byteOffset?: number;
  82252. /**
  82253. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82254. */
  82255. componentType: AccessorComponentType;
  82256. }
  82257. /**
  82258. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82259. */
  82260. interface IAccessorSparseValues extends IProperty {
  82261. /**
  82262. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82263. */
  82264. bufferView: number;
  82265. /**
  82266. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82267. */
  82268. byteOffset?: number;
  82269. }
  82270. /**
  82271. * Sparse storage of attributes that deviate from their initialization value
  82272. */
  82273. interface IAccessorSparse extends IProperty {
  82274. /**
  82275. * The number of attributes encoded in this sparse accessor
  82276. */
  82277. count: number;
  82278. /**
  82279. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82280. */
  82281. indices: IAccessorSparseIndices;
  82282. /**
  82283. * 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
  82284. */
  82285. values: IAccessorSparseValues;
  82286. }
  82287. /**
  82288. * 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
  82289. */
  82290. interface IAccessor extends IChildRootProperty {
  82291. /**
  82292. * The index of the bufferview
  82293. */
  82294. bufferView?: number;
  82295. /**
  82296. * The offset relative to the start of the bufferView in bytes
  82297. */
  82298. byteOffset?: number;
  82299. /**
  82300. * The datatype of components in the attribute
  82301. */
  82302. componentType: AccessorComponentType;
  82303. /**
  82304. * Specifies whether integer data values should be normalized
  82305. */
  82306. normalized?: boolean;
  82307. /**
  82308. * The number of attributes referenced by this accessor
  82309. */
  82310. count: number;
  82311. /**
  82312. * Specifies if the attribute is a scalar, vector, or matrix
  82313. */
  82314. type: AccessorType;
  82315. /**
  82316. * Maximum value of each component in this attribute
  82317. */
  82318. max?: number[];
  82319. /**
  82320. * Minimum value of each component in this attribute
  82321. */
  82322. min?: number[];
  82323. /**
  82324. * Sparse storage of attributes that deviate from their initialization value
  82325. */
  82326. sparse?: IAccessorSparse;
  82327. }
  82328. /**
  82329. * Targets an animation's sampler at a node's property
  82330. */
  82331. interface IAnimationChannel extends IProperty {
  82332. /**
  82333. * The index of a sampler in this animation used to compute the value for the target
  82334. */
  82335. sampler: number;
  82336. /**
  82337. * The index of the node and TRS property to target
  82338. */
  82339. target: IAnimationChannelTarget;
  82340. }
  82341. /**
  82342. * The index of the node and TRS property that an animation channel targets
  82343. */
  82344. interface IAnimationChannelTarget extends IProperty {
  82345. /**
  82346. * The index of the node to target
  82347. */
  82348. node: number;
  82349. /**
  82350. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82351. */
  82352. path: AnimationChannelTargetPath;
  82353. }
  82354. /**
  82355. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82356. */
  82357. interface IAnimationSampler extends IProperty {
  82358. /**
  82359. * The index of an accessor containing keyframe input values, e.g., time
  82360. */
  82361. input: number;
  82362. /**
  82363. * Interpolation algorithm
  82364. */
  82365. interpolation?: AnimationSamplerInterpolation;
  82366. /**
  82367. * The index of an accessor, containing keyframe output values
  82368. */
  82369. output: number;
  82370. }
  82371. /**
  82372. * A keyframe animation
  82373. */
  82374. interface IAnimation extends IChildRootProperty {
  82375. /**
  82376. * An array of channels, each of which targets an animation's sampler at a node's property
  82377. */
  82378. channels: IAnimationChannel[];
  82379. /**
  82380. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82381. */
  82382. samplers: IAnimationSampler[];
  82383. }
  82384. /**
  82385. * Metadata about the glTF asset
  82386. */
  82387. interface IAsset extends IChildRootProperty {
  82388. /**
  82389. * A copyright message suitable for display to credit the content creator
  82390. */
  82391. copyright?: string;
  82392. /**
  82393. * Tool that generated this glTF model. Useful for debugging
  82394. */
  82395. generator?: string;
  82396. /**
  82397. * The glTF version that this asset targets
  82398. */
  82399. version: string;
  82400. /**
  82401. * The minimum glTF version that this asset targets
  82402. */
  82403. minVersion?: string;
  82404. }
  82405. /**
  82406. * A buffer points to binary geometry, animation, or skins
  82407. */
  82408. interface IBuffer extends IChildRootProperty {
  82409. /**
  82410. * 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
  82411. */
  82412. uri?: string;
  82413. /**
  82414. * The length of the buffer in bytes
  82415. */
  82416. byteLength: number;
  82417. }
  82418. /**
  82419. * A view into a buffer generally representing a subset of the buffer
  82420. */
  82421. interface IBufferView extends IChildRootProperty {
  82422. /**
  82423. * The index of the buffer
  82424. */
  82425. buffer: number;
  82426. /**
  82427. * The offset into the buffer in bytes
  82428. */
  82429. byteOffset?: number;
  82430. /**
  82431. * The lenth of the bufferView in bytes
  82432. */
  82433. byteLength: number;
  82434. /**
  82435. * The stride, in bytes
  82436. */
  82437. byteStride?: number;
  82438. }
  82439. /**
  82440. * An orthographic camera containing properties to create an orthographic projection matrix
  82441. */
  82442. interface ICameraOrthographic extends IProperty {
  82443. /**
  82444. * The floating-point horizontal magnification of the view. Must not be zero
  82445. */
  82446. xmag: number;
  82447. /**
  82448. * The floating-point vertical magnification of the view. Must not be zero
  82449. */
  82450. ymag: number;
  82451. /**
  82452. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82453. */
  82454. zfar: number;
  82455. /**
  82456. * The floating-point distance to the near clipping plane
  82457. */
  82458. znear: number;
  82459. }
  82460. /**
  82461. * A perspective camera containing properties to create a perspective projection matrix
  82462. */
  82463. interface ICameraPerspective extends IProperty {
  82464. /**
  82465. * The floating-point aspect ratio of the field of view
  82466. */
  82467. aspectRatio?: number;
  82468. /**
  82469. * The floating-point vertical field of view in radians
  82470. */
  82471. yfov: number;
  82472. /**
  82473. * The floating-point distance to the far clipping plane
  82474. */
  82475. zfar?: number;
  82476. /**
  82477. * The floating-point distance to the near clipping plane
  82478. */
  82479. znear: number;
  82480. }
  82481. /**
  82482. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82483. */
  82484. interface ICamera extends IChildRootProperty {
  82485. /**
  82486. * An orthographic camera containing properties to create an orthographic projection matrix
  82487. */
  82488. orthographic?: ICameraOrthographic;
  82489. /**
  82490. * A perspective camera containing properties to create a perspective projection matrix
  82491. */
  82492. perspective?: ICameraPerspective;
  82493. /**
  82494. * Specifies if the camera uses a perspective or orthographic projection
  82495. */
  82496. type: CameraType;
  82497. }
  82498. /**
  82499. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82500. */
  82501. interface IImage extends IChildRootProperty {
  82502. /**
  82503. * 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
  82504. */
  82505. uri?: string;
  82506. /**
  82507. * The image's MIME type
  82508. */
  82509. mimeType?: ImageMimeType;
  82510. /**
  82511. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82512. */
  82513. bufferView?: number;
  82514. }
  82515. /**
  82516. * Material Normal Texture Info
  82517. */
  82518. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82519. /**
  82520. * The scalar multiplier applied to each normal vector of the normal texture
  82521. */
  82522. scale?: number;
  82523. }
  82524. /**
  82525. * Material Occlusion Texture Info
  82526. */
  82527. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82528. /**
  82529. * A scalar multiplier controlling the amount of occlusion applied
  82530. */
  82531. strength?: number;
  82532. }
  82533. /**
  82534. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  82535. */
  82536. interface IMaterialPbrMetallicRoughness {
  82537. /**
  82538. * The material's base color factor
  82539. */
  82540. baseColorFactor?: number[];
  82541. /**
  82542. * The base color texture
  82543. */
  82544. baseColorTexture?: ITextureInfo;
  82545. /**
  82546. * The metalness of the material
  82547. */
  82548. metallicFactor?: number;
  82549. /**
  82550. * The roughness of the material
  82551. */
  82552. roughnessFactor?: number;
  82553. /**
  82554. * The metallic-roughness texture
  82555. */
  82556. metallicRoughnessTexture?: ITextureInfo;
  82557. }
  82558. /**
  82559. * The material appearance of a primitive
  82560. */
  82561. interface IMaterial extends IChildRootProperty {
  82562. /**
  82563. * 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
  82564. */
  82565. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82566. /**
  82567. * The normal map texture
  82568. */
  82569. normalTexture?: IMaterialNormalTextureInfo;
  82570. /**
  82571. * The occlusion map texture
  82572. */
  82573. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82574. /**
  82575. * The emissive map texture
  82576. */
  82577. emissiveTexture?: ITextureInfo;
  82578. /**
  82579. * 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
  82580. */
  82581. emissiveFactor?: number[];
  82582. /**
  82583. * The alpha rendering mode of the material
  82584. */
  82585. alphaMode?: MaterialAlphaMode;
  82586. /**
  82587. * The alpha cutoff value of the material
  82588. */
  82589. alphaCutoff?: number;
  82590. /**
  82591. * Specifies whether the material is double sided
  82592. */
  82593. doubleSided?: boolean;
  82594. }
  82595. /**
  82596. * Geometry to be rendered with the given material
  82597. */
  82598. interface IMeshPrimitive extends IProperty {
  82599. /**
  82600. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82601. */
  82602. attributes: {
  82603. [name: string]: number;
  82604. };
  82605. /**
  82606. * The index of the accessor that contains the indices
  82607. */
  82608. indices?: number;
  82609. /**
  82610. * The index of the material to apply to this primitive when rendering
  82611. */
  82612. material?: number;
  82613. /**
  82614. * The type of primitives to render. All valid values correspond to WebGL enums
  82615. */
  82616. mode?: MeshPrimitiveMode;
  82617. /**
  82618. * 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
  82619. */
  82620. targets?: {
  82621. [name: string]: number;
  82622. }[];
  82623. }
  82624. /**
  82625. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82626. */
  82627. interface IMesh extends IChildRootProperty {
  82628. /**
  82629. * An array of primitives, each defining geometry to be rendered with a material
  82630. */
  82631. primitives: IMeshPrimitive[];
  82632. /**
  82633. * Array of weights to be applied to the Morph Targets
  82634. */
  82635. weights?: number[];
  82636. }
  82637. /**
  82638. * A node in the node hierarchy
  82639. */
  82640. interface INode extends IChildRootProperty {
  82641. /**
  82642. * The index of the camera referenced by this node
  82643. */
  82644. camera?: number;
  82645. /**
  82646. * The indices of this node's children
  82647. */
  82648. children?: number[];
  82649. /**
  82650. * The index of the skin referenced by this node
  82651. */
  82652. skin?: number;
  82653. /**
  82654. * A floating-point 4x4 transformation matrix stored in column-major order
  82655. */
  82656. matrix?: number[];
  82657. /**
  82658. * The index of the mesh in this node
  82659. */
  82660. mesh?: number;
  82661. /**
  82662. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82663. */
  82664. rotation?: number[];
  82665. /**
  82666. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82667. */
  82668. scale?: number[];
  82669. /**
  82670. * The node's translation along the x, y, and z axes
  82671. */
  82672. translation?: number[];
  82673. /**
  82674. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82675. */
  82676. weights?: number[];
  82677. }
  82678. /**
  82679. * Texture sampler properties for filtering and wrapping modes
  82680. */
  82681. interface ISampler extends IChildRootProperty {
  82682. /**
  82683. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82684. */
  82685. magFilter?: TextureMagFilter;
  82686. /**
  82687. * Minification filter. All valid values correspond to WebGL enums
  82688. */
  82689. minFilter?: TextureMinFilter;
  82690. /**
  82691. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82692. */
  82693. wrapS?: TextureWrapMode;
  82694. /**
  82695. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82696. */
  82697. wrapT?: TextureWrapMode;
  82698. }
  82699. /**
  82700. * The root nodes of a scene
  82701. */
  82702. interface IScene extends IChildRootProperty {
  82703. /**
  82704. * The indices of each root node
  82705. */
  82706. nodes: number[];
  82707. }
  82708. /**
  82709. * Joints and matrices defining a skin
  82710. */
  82711. interface ISkin extends IChildRootProperty {
  82712. /**
  82713. * 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
  82714. */
  82715. inverseBindMatrices?: number;
  82716. /**
  82717. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82718. */
  82719. skeleton?: number;
  82720. /**
  82721. * 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)
  82722. */
  82723. joints: number[];
  82724. }
  82725. /**
  82726. * A texture and its sampler
  82727. */
  82728. interface ITexture extends IChildRootProperty {
  82729. /**
  82730. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82731. */
  82732. sampler?: number;
  82733. /**
  82734. * The index of the image used by this texture
  82735. */
  82736. source: number;
  82737. }
  82738. /**
  82739. * Reference to a texture
  82740. */
  82741. interface ITextureInfo extends IProperty {
  82742. /**
  82743. * The index of the texture
  82744. */
  82745. index: number;
  82746. /**
  82747. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82748. */
  82749. texCoord?: number;
  82750. }
  82751. /**
  82752. * The root object for a glTF asset
  82753. */
  82754. interface IGLTF extends IProperty {
  82755. /**
  82756. * An array of accessors. An accessor is a typed view into a bufferView
  82757. */
  82758. accessors?: IAccessor[];
  82759. /**
  82760. * An array of keyframe animations
  82761. */
  82762. animations?: IAnimation[];
  82763. /**
  82764. * Metadata about the glTF asset
  82765. */
  82766. asset: IAsset;
  82767. /**
  82768. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82769. */
  82770. buffers?: IBuffer[];
  82771. /**
  82772. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82773. */
  82774. bufferViews?: IBufferView[];
  82775. /**
  82776. * An array of cameras
  82777. */
  82778. cameras?: ICamera[];
  82779. /**
  82780. * Names of glTF extensions used somewhere in this asset
  82781. */
  82782. extensionsUsed?: string[];
  82783. /**
  82784. * Names of glTF extensions required to properly load this asset
  82785. */
  82786. extensionsRequired?: string[];
  82787. /**
  82788. * An array of images. An image defines data used to create a texture
  82789. */
  82790. images?: IImage[];
  82791. /**
  82792. * An array of materials. A material defines the appearance of a primitive
  82793. */
  82794. materials?: IMaterial[];
  82795. /**
  82796. * An array of meshes. A mesh is a set of primitives to be rendered
  82797. */
  82798. meshes?: IMesh[];
  82799. /**
  82800. * An array of nodes
  82801. */
  82802. nodes?: INode[];
  82803. /**
  82804. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82805. */
  82806. samplers?: ISampler[];
  82807. /**
  82808. * The index of the default scene
  82809. */
  82810. scene?: number;
  82811. /**
  82812. * An array of scenes
  82813. */
  82814. scenes?: IScene[];
  82815. /**
  82816. * An array of skins. A skin is defined by joints and matrices
  82817. */
  82818. skins?: ISkin[];
  82819. /**
  82820. * An array of textures
  82821. */
  82822. textures?: ITexture[];
  82823. }
  82824. /**
  82825. * The glTF validation results
  82826. * @ignore
  82827. */
  82828. interface IGLTFValidationResults {
  82829. info: {
  82830. generator: string;
  82831. hasAnimations: boolean;
  82832. hasDefaultScene: boolean;
  82833. hasMaterials: boolean;
  82834. hasMorphTargets: boolean;
  82835. hasSkins: boolean;
  82836. hasTextures: boolean;
  82837. maxAttributesUsed: number;
  82838. primitivesCount: number
  82839. };
  82840. issues: {
  82841. messages: Array<string>;
  82842. numErrors: number;
  82843. numHints: number;
  82844. numInfos: number;
  82845. numWarnings: number;
  82846. truncated: boolean
  82847. };
  82848. mimeType: string;
  82849. uri: string;
  82850. validatedAt: string;
  82851. validatorVersion: string;
  82852. }
  82853. /**
  82854. * The glTF validation options
  82855. */
  82856. interface IGLTFValidationOptions {
  82857. /** Uri to use */
  82858. uri?: string;
  82859. /** Function used to load external resources */
  82860. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82861. /** Boolean indicating that we need to validate accessor data */
  82862. validateAccessorData?: boolean;
  82863. /** max number of issues allowed */
  82864. maxIssues?: number;
  82865. /** Ignored issues */
  82866. ignoredIssues?: Array<string>;
  82867. /** Value to override severy settings */
  82868. severityOverrides?: Object;
  82869. }
  82870. /**
  82871. * The glTF validator object
  82872. * @ignore
  82873. */
  82874. interface IGLTFValidator {
  82875. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82876. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82877. }
  82878. }
  82879. declare module BABYLON {
  82880. /** @hidden */
  82881. export var cellPixelShader: {
  82882. name: string;
  82883. shader: string;
  82884. };
  82885. }
  82886. declare module BABYLON {
  82887. /** @hidden */
  82888. export var cellVertexShader: {
  82889. name: string;
  82890. shader: string;
  82891. };
  82892. }
  82893. declare module BABYLON {
  82894. export class CellMaterial extends BABYLON.PushMaterial {
  82895. private _diffuseTexture;
  82896. diffuseTexture: BABYLON.BaseTexture;
  82897. diffuseColor: BABYLON.Color3;
  82898. _computeHighLevel: boolean;
  82899. computeHighLevel: boolean;
  82900. private _disableLighting;
  82901. disableLighting: boolean;
  82902. private _maxSimultaneousLights;
  82903. maxSimultaneousLights: number;
  82904. constructor(name: string, scene: BABYLON.Scene);
  82905. needAlphaBlending(): boolean;
  82906. needAlphaTesting(): boolean;
  82907. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82908. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82909. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82910. getAnimatables(): BABYLON.IAnimatable[];
  82911. getActiveTextures(): BABYLON.BaseTexture[];
  82912. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82913. dispose(forceDisposeEffect?: boolean): void;
  82914. getClassName(): string;
  82915. clone(name: string): CellMaterial;
  82916. serialize(): any;
  82917. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82918. }
  82919. }
  82920. declare module BABYLON {
  82921. export class CustomShaderStructure {
  82922. FragmentStore: string;
  82923. VertexStore: string;
  82924. constructor();
  82925. }
  82926. export class ShaderSpecialParts {
  82927. constructor();
  82928. Fragment_Begin: string;
  82929. Fragment_Definitions: string;
  82930. Fragment_MainBegin: string;
  82931. Fragment_Custom_Diffuse: string;
  82932. Fragment_Before_Lights: string;
  82933. Fragment_Before_Fog: string;
  82934. Fragment_Custom_Alpha: string;
  82935. Fragment_Before_FragColor: string;
  82936. Vertex_Begin: string;
  82937. Vertex_Definitions: string;
  82938. Vertex_MainBegin: string;
  82939. Vertex_Before_PositionUpdated: string;
  82940. Vertex_Before_NormalUpdated: string;
  82941. Vertex_After_WorldPosComputed: string;
  82942. Vertex_MainEnd: string;
  82943. }
  82944. export class CustomMaterial extends BABYLON.StandardMaterial {
  82945. static ShaderIndexer: number;
  82946. CustomParts: ShaderSpecialParts;
  82947. _isCreatedShader: boolean;
  82948. _createdShaderName: string;
  82949. _customUniform: string[];
  82950. _newUniforms: string[];
  82951. _newUniformInstances: {
  82952. [name: string]: any;
  82953. };
  82954. _newSamplerInstances: {
  82955. [name: string]: BABYLON.Texture;
  82956. };
  82957. _customAttributes: string[];
  82958. FragmentShader: string;
  82959. VertexShader: string;
  82960. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82961. ReviewUniform(name: string, arr: string[]): string[];
  82962. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82963. constructor(name: string, scene: BABYLON.Scene);
  82964. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82965. AddAttribute(name: string): CustomMaterial;
  82966. Fragment_Begin(shaderPart: string): CustomMaterial;
  82967. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82968. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82969. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82970. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82971. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82972. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82973. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82974. Vertex_Begin(shaderPart: string): CustomMaterial;
  82975. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82976. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82977. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82978. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82979. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82980. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82981. }
  82982. }
  82983. declare module BABYLON {
  82984. export class ShaderAlebdoParts {
  82985. constructor();
  82986. Fragment_Begin: string;
  82987. Fragment_Definitions: string;
  82988. Fragment_MainBegin: string;
  82989. Fragment_Custom_Albedo: string;
  82990. Fragment_Before_Lights: string;
  82991. Fragment_Custom_MetallicRoughness: string;
  82992. Fragment_Custom_MicroSurface: string;
  82993. Fragment_Before_Fog: string;
  82994. Fragment_Custom_Alpha: string;
  82995. Fragment_Before_FragColor: string;
  82996. Vertex_Begin: string;
  82997. Vertex_Definitions: string;
  82998. Vertex_MainBegin: string;
  82999. Vertex_Before_PositionUpdated: string;
  83000. Vertex_Before_NormalUpdated: string;
  83001. Vertex_After_WorldPosComputed: string;
  83002. Vertex_MainEnd: string;
  83003. }
  83004. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  83005. static ShaderIndexer: number;
  83006. CustomParts: ShaderAlebdoParts;
  83007. _isCreatedShader: boolean;
  83008. _createdShaderName: string;
  83009. _customUniform: string[];
  83010. _newUniforms: string[];
  83011. _newUniformInstances: {
  83012. [name: string]: any;
  83013. };
  83014. _newSamplerInstances: {
  83015. [name: string]: BABYLON.Texture;
  83016. };
  83017. _customAttributes: string[];
  83018. FragmentShader: string;
  83019. VertexShader: string;
  83020. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83021. ReviewUniform(name: string, arr: string[]): string[];
  83022. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83023. constructor(name: string, scene: BABYLON.Scene);
  83024. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83025. AddAttribute(name: string): PBRCustomMaterial;
  83026. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83027. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83028. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83029. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83030. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83031. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83032. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83033. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83034. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83035. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83036. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83037. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83038. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83039. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83040. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83041. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83042. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83043. }
  83044. }
  83045. declare module BABYLON {
  83046. /** @hidden */
  83047. export var firePixelShader: {
  83048. name: string;
  83049. shader: string;
  83050. };
  83051. }
  83052. declare module BABYLON {
  83053. /** @hidden */
  83054. export var fireVertexShader: {
  83055. name: string;
  83056. shader: string;
  83057. };
  83058. }
  83059. declare module BABYLON {
  83060. export class FireMaterial extends BABYLON.PushMaterial {
  83061. private _diffuseTexture;
  83062. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83063. private _distortionTexture;
  83064. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83065. private _opacityTexture;
  83066. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83067. diffuseColor: BABYLON.Color3;
  83068. speed: number;
  83069. private _scaledDiffuse;
  83070. private _lastTime;
  83071. constructor(name: string, scene: BABYLON.Scene);
  83072. needAlphaBlending(): boolean;
  83073. needAlphaTesting(): boolean;
  83074. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83075. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83076. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83077. getAnimatables(): BABYLON.IAnimatable[];
  83078. getActiveTextures(): BABYLON.BaseTexture[];
  83079. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83080. getClassName(): string;
  83081. dispose(forceDisposeEffect?: boolean): void;
  83082. clone(name: string): FireMaterial;
  83083. serialize(): any;
  83084. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83085. }
  83086. }
  83087. declare module BABYLON {
  83088. /** @hidden */
  83089. export var furPixelShader: {
  83090. name: string;
  83091. shader: string;
  83092. };
  83093. }
  83094. declare module BABYLON {
  83095. /** @hidden */
  83096. export var furVertexShader: {
  83097. name: string;
  83098. shader: string;
  83099. };
  83100. }
  83101. declare module BABYLON {
  83102. export class FurMaterial extends BABYLON.PushMaterial {
  83103. private _diffuseTexture;
  83104. diffuseTexture: BABYLON.BaseTexture;
  83105. private _heightTexture;
  83106. heightTexture: BABYLON.BaseTexture;
  83107. diffuseColor: BABYLON.Color3;
  83108. furLength: number;
  83109. furAngle: number;
  83110. furColor: BABYLON.Color3;
  83111. furOffset: number;
  83112. furSpacing: number;
  83113. furGravity: BABYLON.Vector3;
  83114. furSpeed: number;
  83115. furDensity: number;
  83116. furOcclusion: number;
  83117. furTexture: BABYLON.DynamicTexture;
  83118. private _disableLighting;
  83119. disableLighting: boolean;
  83120. private _maxSimultaneousLights;
  83121. maxSimultaneousLights: number;
  83122. highLevelFur: boolean;
  83123. _meshes: BABYLON.AbstractMesh[];
  83124. private _furTime;
  83125. constructor(name: string, scene: BABYLON.Scene);
  83126. get furTime(): number;
  83127. set furTime(furTime: number);
  83128. needAlphaBlending(): boolean;
  83129. needAlphaTesting(): boolean;
  83130. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83131. updateFur(): void;
  83132. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83133. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83134. getAnimatables(): BABYLON.IAnimatable[];
  83135. getActiveTextures(): BABYLON.BaseTexture[];
  83136. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83137. dispose(forceDisposeEffect?: boolean): void;
  83138. clone(name: string): FurMaterial;
  83139. serialize(): any;
  83140. getClassName(): string;
  83141. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  83142. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  83143. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  83144. }
  83145. }
  83146. declare module BABYLON {
  83147. /** @hidden */
  83148. export var gradientPixelShader: {
  83149. name: string;
  83150. shader: string;
  83151. };
  83152. }
  83153. declare module BABYLON {
  83154. /** @hidden */
  83155. export var gradientVertexShader: {
  83156. name: string;
  83157. shader: string;
  83158. };
  83159. }
  83160. declare module BABYLON {
  83161. export class GradientMaterial extends BABYLON.PushMaterial {
  83162. private _maxSimultaneousLights;
  83163. maxSimultaneousLights: number;
  83164. topColor: BABYLON.Color3;
  83165. topColorAlpha: number;
  83166. bottomColor: BABYLON.Color3;
  83167. bottomColorAlpha: number;
  83168. offset: number;
  83169. scale: number;
  83170. smoothness: number;
  83171. private _disableLighting;
  83172. disableLighting: boolean;
  83173. constructor(name: string, scene: BABYLON.Scene);
  83174. needAlphaBlending(): boolean;
  83175. needAlphaTesting(): boolean;
  83176. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83177. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83178. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83179. getAnimatables(): BABYLON.IAnimatable[];
  83180. dispose(forceDisposeEffect?: boolean): void;
  83181. clone(name: string): GradientMaterial;
  83182. serialize(): any;
  83183. getClassName(): string;
  83184. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83185. }
  83186. }
  83187. declare module BABYLON {
  83188. /** @hidden */
  83189. export var gridPixelShader: {
  83190. name: string;
  83191. shader: string;
  83192. };
  83193. }
  83194. declare module BABYLON {
  83195. /** @hidden */
  83196. export var gridVertexShader: {
  83197. name: string;
  83198. shader: string;
  83199. };
  83200. }
  83201. declare module BABYLON {
  83202. /**
  83203. * The grid materials allows you to wrap any shape with a grid.
  83204. * Colors are customizable.
  83205. */
  83206. export class GridMaterial extends BABYLON.PushMaterial {
  83207. /**
  83208. * Main color of the grid (e.g. between lines)
  83209. */
  83210. mainColor: BABYLON.Color3;
  83211. /**
  83212. * Color of the grid lines.
  83213. */
  83214. lineColor: BABYLON.Color3;
  83215. /**
  83216. * The scale of the grid compared to unit.
  83217. */
  83218. gridRatio: number;
  83219. /**
  83220. * Allows setting an offset for the grid lines.
  83221. */
  83222. gridOffset: BABYLON.Vector3;
  83223. /**
  83224. * The frequency of thicker lines.
  83225. */
  83226. majorUnitFrequency: number;
  83227. /**
  83228. * The visibility of minor units in the grid.
  83229. */
  83230. minorUnitVisibility: number;
  83231. /**
  83232. * The grid opacity outside of the lines.
  83233. */
  83234. opacity: number;
  83235. /**
  83236. * Determine RBG output is premultiplied by alpha value.
  83237. */
  83238. preMultiplyAlpha: boolean;
  83239. private _opacityTexture;
  83240. opacityTexture: BABYLON.BaseTexture;
  83241. private _gridControl;
  83242. /**
  83243. * constructor
  83244. * @param name The name given to the material in order to identify it afterwards.
  83245. * @param scene The scene the material is used in.
  83246. */
  83247. constructor(name: string, scene: BABYLON.Scene);
  83248. /**
  83249. * Returns wehter or not the grid requires alpha blending.
  83250. */
  83251. needAlphaBlending(): boolean;
  83252. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83253. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83254. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83255. /**
  83256. * Dispose the material and its associated resources.
  83257. * @param forceDisposeEffect will also dispose the used effect when true
  83258. */
  83259. dispose(forceDisposeEffect?: boolean): void;
  83260. clone(name: string): GridMaterial;
  83261. serialize(): any;
  83262. getClassName(): string;
  83263. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83264. }
  83265. }
  83266. declare module BABYLON {
  83267. /** @hidden */
  83268. export var lavaPixelShader: {
  83269. name: string;
  83270. shader: string;
  83271. };
  83272. }
  83273. declare module BABYLON {
  83274. /** @hidden */
  83275. export var lavaVertexShader: {
  83276. name: string;
  83277. shader: string;
  83278. };
  83279. }
  83280. declare module BABYLON {
  83281. export class LavaMaterial extends BABYLON.PushMaterial {
  83282. private _diffuseTexture;
  83283. diffuseTexture: BABYLON.BaseTexture;
  83284. noiseTexture: BABYLON.BaseTexture;
  83285. fogColor: BABYLON.Color3;
  83286. speed: number;
  83287. movingSpeed: number;
  83288. lowFrequencySpeed: number;
  83289. fogDensity: number;
  83290. private _lastTime;
  83291. diffuseColor: BABYLON.Color3;
  83292. private _disableLighting;
  83293. disableLighting: boolean;
  83294. private _unlit;
  83295. unlit: boolean;
  83296. private _maxSimultaneousLights;
  83297. maxSimultaneousLights: number;
  83298. private _scaledDiffuse;
  83299. constructor(name: string, scene: BABYLON.Scene);
  83300. needAlphaBlending(): boolean;
  83301. needAlphaTesting(): boolean;
  83302. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83303. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83304. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83305. getAnimatables(): BABYLON.IAnimatable[];
  83306. getActiveTextures(): BABYLON.BaseTexture[];
  83307. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83308. dispose(forceDisposeEffect?: boolean): void;
  83309. clone(name: string): LavaMaterial;
  83310. serialize(): any;
  83311. getClassName(): string;
  83312. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  83313. }
  83314. }
  83315. declare module BABYLON {
  83316. /** @hidden */
  83317. export var mixPixelShader: {
  83318. name: string;
  83319. shader: string;
  83320. };
  83321. }
  83322. declare module BABYLON {
  83323. /** @hidden */
  83324. export var mixVertexShader: {
  83325. name: string;
  83326. shader: string;
  83327. };
  83328. }
  83329. declare module BABYLON {
  83330. export class MixMaterial extends BABYLON.PushMaterial {
  83331. /**
  83332. * Mix textures
  83333. */
  83334. private _mixTexture1;
  83335. mixTexture1: BABYLON.BaseTexture;
  83336. private _mixTexture2;
  83337. mixTexture2: BABYLON.BaseTexture;
  83338. /**
  83339. * Diffuse textures
  83340. */
  83341. private _diffuseTexture1;
  83342. diffuseTexture1: BABYLON.Texture;
  83343. private _diffuseTexture2;
  83344. diffuseTexture2: BABYLON.Texture;
  83345. private _diffuseTexture3;
  83346. diffuseTexture3: BABYLON.Texture;
  83347. private _diffuseTexture4;
  83348. diffuseTexture4: BABYLON.Texture;
  83349. private _diffuseTexture5;
  83350. diffuseTexture5: BABYLON.Texture;
  83351. private _diffuseTexture6;
  83352. diffuseTexture6: BABYLON.Texture;
  83353. private _diffuseTexture7;
  83354. diffuseTexture7: BABYLON.Texture;
  83355. private _diffuseTexture8;
  83356. diffuseTexture8: BABYLON.Texture;
  83357. /**
  83358. * Uniforms
  83359. */
  83360. diffuseColor: BABYLON.Color3;
  83361. specularColor: BABYLON.Color3;
  83362. specularPower: number;
  83363. private _disableLighting;
  83364. disableLighting: boolean;
  83365. private _maxSimultaneousLights;
  83366. maxSimultaneousLights: number;
  83367. constructor(name: string, scene: BABYLON.Scene);
  83368. needAlphaBlending(): boolean;
  83369. needAlphaTesting(): boolean;
  83370. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83371. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83372. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83373. getAnimatables(): BABYLON.IAnimatable[];
  83374. getActiveTextures(): BABYLON.BaseTexture[];
  83375. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83376. dispose(forceDisposeEffect?: boolean): void;
  83377. clone(name: string): MixMaterial;
  83378. serialize(): any;
  83379. getClassName(): string;
  83380. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  83381. }
  83382. }
  83383. declare module BABYLON {
  83384. /** @hidden */
  83385. export var normalPixelShader: {
  83386. name: string;
  83387. shader: string;
  83388. };
  83389. }
  83390. declare module BABYLON {
  83391. /** @hidden */
  83392. export var normalVertexShader: {
  83393. name: string;
  83394. shader: string;
  83395. };
  83396. }
  83397. declare module BABYLON {
  83398. export class NormalMaterial extends BABYLON.PushMaterial {
  83399. private _diffuseTexture;
  83400. diffuseTexture: BABYLON.BaseTexture;
  83401. diffuseColor: BABYLON.Color3;
  83402. private _disableLighting;
  83403. disableLighting: boolean;
  83404. private _maxSimultaneousLights;
  83405. maxSimultaneousLights: number;
  83406. constructor(name: string, scene: BABYLON.Scene);
  83407. needAlphaBlending(): boolean;
  83408. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83409. needAlphaTesting(): boolean;
  83410. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83411. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83412. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83413. getAnimatables(): BABYLON.IAnimatable[];
  83414. getActiveTextures(): BABYLON.BaseTexture[];
  83415. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83416. dispose(forceDisposeEffect?: boolean): void;
  83417. clone(name: string): NormalMaterial;
  83418. serialize(): any;
  83419. getClassName(): string;
  83420. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  83421. }
  83422. }
  83423. declare module BABYLON {
  83424. /** @hidden */
  83425. export var shadowOnlyPixelShader: {
  83426. name: string;
  83427. shader: string;
  83428. };
  83429. }
  83430. declare module BABYLON {
  83431. /** @hidden */
  83432. export var shadowOnlyVertexShader: {
  83433. name: string;
  83434. shader: string;
  83435. };
  83436. }
  83437. declare module BABYLON {
  83438. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  83439. private _activeLight;
  83440. private _needAlphaBlending;
  83441. constructor(name: string, scene: BABYLON.Scene);
  83442. shadowColor: BABYLON.Color3;
  83443. needAlphaBlending(): boolean;
  83444. needAlphaTesting(): boolean;
  83445. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83446. get activeLight(): BABYLON.IShadowLight;
  83447. set activeLight(light: BABYLON.IShadowLight);
  83448. private _getFirstShadowLightForMesh;
  83449. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83450. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83451. clone(name: string): ShadowOnlyMaterial;
  83452. serialize(): any;
  83453. getClassName(): string;
  83454. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  83455. }
  83456. }
  83457. declare module BABYLON {
  83458. /** @hidden */
  83459. export var simplePixelShader: {
  83460. name: string;
  83461. shader: string;
  83462. };
  83463. }
  83464. declare module BABYLON {
  83465. /** @hidden */
  83466. export var simpleVertexShader: {
  83467. name: string;
  83468. shader: string;
  83469. };
  83470. }
  83471. declare module BABYLON {
  83472. export class SimpleMaterial extends BABYLON.PushMaterial {
  83473. private _diffuseTexture;
  83474. diffuseTexture: BABYLON.BaseTexture;
  83475. diffuseColor: BABYLON.Color3;
  83476. private _disableLighting;
  83477. disableLighting: boolean;
  83478. private _maxSimultaneousLights;
  83479. maxSimultaneousLights: number;
  83480. constructor(name: string, scene: BABYLON.Scene);
  83481. needAlphaBlending(): boolean;
  83482. needAlphaTesting(): boolean;
  83483. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83484. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83485. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83486. getAnimatables(): BABYLON.IAnimatable[];
  83487. getActiveTextures(): BABYLON.BaseTexture[];
  83488. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83489. dispose(forceDisposeEffect?: boolean): void;
  83490. clone(name: string): SimpleMaterial;
  83491. serialize(): any;
  83492. getClassName(): string;
  83493. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  83494. }
  83495. }
  83496. declare module BABYLON {
  83497. /** @hidden */
  83498. export var skyPixelShader: {
  83499. name: string;
  83500. shader: string;
  83501. };
  83502. }
  83503. declare module BABYLON {
  83504. /** @hidden */
  83505. export var skyVertexShader: {
  83506. name: string;
  83507. shader: string;
  83508. };
  83509. }
  83510. declare module BABYLON {
  83511. /**
  83512. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83513. * @see https://doc.babylonjs.com/extensions/sky
  83514. */
  83515. export class SkyMaterial extends BABYLON.PushMaterial {
  83516. /**
  83517. * Defines the overall luminance of sky in interval ]0, 1[.
  83518. */
  83519. luminance: number;
  83520. /**
  83521. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83522. */
  83523. turbidity: number;
  83524. /**
  83525. * Defines the sky appearance (light intensity).
  83526. */
  83527. rayleigh: number;
  83528. /**
  83529. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83530. */
  83531. mieCoefficient: number;
  83532. /**
  83533. * Defines the amount of haze particles following the Mie scattering theory.
  83534. */
  83535. mieDirectionalG: number;
  83536. /**
  83537. * Defines the distance of the sun according to the active scene camera.
  83538. */
  83539. distance: number;
  83540. /**
  83541. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  83542. * "inclined".
  83543. */
  83544. inclination: number;
  83545. /**
  83546. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  83547. * an object direction and a reference direction.
  83548. */
  83549. azimuth: number;
  83550. /**
  83551. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  83552. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  83553. */
  83554. sunPosition: BABYLON.Vector3;
  83555. /**
  83556. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  83557. * .sunPosition property.
  83558. */
  83559. useSunPosition: boolean;
  83560. /**
  83561. * Defines an offset vector used to get a horizon offset.
  83562. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  83563. */
  83564. cameraOffset: BABYLON.Vector3;
  83565. private _cameraPosition;
  83566. /**
  83567. * Instantiates a new sky material.
  83568. * This material allows to create dynamic and texture free
  83569. * effects for skyboxes by taking care of the atmosphere state.
  83570. * @see https://doc.babylonjs.com/extensions/sky
  83571. * @param name Define the name of the material in the scene
  83572. * @param scene Define the scene the material belong to
  83573. */
  83574. constructor(name: string, scene: BABYLON.Scene);
  83575. /**
  83576. * Specifies if the material will require alpha blending
  83577. * @returns a boolean specifying if alpha blending is needed
  83578. */
  83579. needAlphaBlending(): boolean;
  83580. /**
  83581. * Specifies if this material should be rendered in alpha test mode
  83582. * @returns false as the sky material doesn't need alpha testing.
  83583. */
  83584. needAlphaTesting(): boolean;
  83585. /**
  83586. * Get the texture used for alpha test purpose.
  83587. * @returns null as the sky material has no texture.
  83588. */
  83589. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83590. /**
  83591. * Get if the submesh is ready to be used and all its information available.
  83592. * Child classes can use it to update shaders
  83593. * @param mesh defines the mesh to check
  83594. * @param subMesh defines which submesh to check
  83595. * @param useInstances specifies that instances should be used
  83596. * @returns a boolean indicating that the submesh is ready or not
  83597. */
  83598. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83599. /**
  83600. * Binds the submesh to this material by preparing the effect and shader to draw
  83601. * @param world defines the world transformation matrix
  83602. * @param mesh defines the mesh containing the submesh
  83603. * @param subMesh defines the submesh to bind the material to
  83604. */
  83605. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83606. /**
  83607. * Get the list of animatables in the material.
  83608. * @returns the list of animatables object used in the material
  83609. */
  83610. getAnimatables(): BABYLON.IAnimatable[];
  83611. /**
  83612. * Disposes the material
  83613. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83614. */
  83615. dispose(forceDisposeEffect?: boolean): void;
  83616. /**
  83617. * Makes a duplicate of the material, and gives it a new name
  83618. * @param name defines the new name for the duplicated material
  83619. * @returns the cloned material
  83620. */
  83621. clone(name: string): SkyMaterial;
  83622. /**
  83623. * Serializes this material in a JSON representation
  83624. * @returns the serialized material object
  83625. */
  83626. serialize(): any;
  83627. /**
  83628. * Gets the current class name of the material e.g. "SkyMaterial"
  83629. * Mainly use in serialization.
  83630. * @returns the class name
  83631. */
  83632. getClassName(): string;
  83633. /**
  83634. * Creates a sky material from parsed material data
  83635. * @param source defines the JSON representation of the material
  83636. * @param scene defines the hosting scene
  83637. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83638. * @returns a new sky material
  83639. */
  83640. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83641. }
  83642. }
  83643. declare module BABYLON {
  83644. /** @hidden */
  83645. export var terrainPixelShader: {
  83646. name: string;
  83647. shader: string;
  83648. };
  83649. }
  83650. declare module BABYLON {
  83651. /** @hidden */
  83652. export var terrainVertexShader: {
  83653. name: string;
  83654. shader: string;
  83655. };
  83656. }
  83657. declare module BABYLON {
  83658. export class TerrainMaterial extends BABYLON.PushMaterial {
  83659. private _mixTexture;
  83660. mixTexture: BABYLON.BaseTexture;
  83661. private _diffuseTexture1;
  83662. diffuseTexture1: BABYLON.Texture;
  83663. private _diffuseTexture2;
  83664. diffuseTexture2: BABYLON.Texture;
  83665. private _diffuseTexture3;
  83666. diffuseTexture3: BABYLON.Texture;
  83667. private _bumpTexture1;
  83668. bumpTexture1: BABYLON.Texture;
  83669. private _bumpTexture2;
  83670. bumpTexture2: BABYLON.Texture;
  83671. private _bumpTexture3;
  83672. bumpTexture3: BABYLON.Texture;
  83673. diffuseColor: BABYLON.Color3;
  83674. specularColor: BABYLON.Color3;
  83675. specularPower: number;
  83676. private _disableLighting;
  83677. disableLighting: boolean;
  83678. private _maxSimultaneousLights;
  83679. maxSimultaneousLights: number;
  83680. constructor(name: string, scene: BABYLON.Scene);
  83681. needAlphaBlending(): boolean;
  83682. needAlphaTesting(): boolean;
  83683. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83684. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83685. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83686. getAnimatables(): BABYLON.IAnimatable[];
  83687. getActiveTextures(): BABYLON.BaseTexture[];
  83688. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83689. dispose(forceDisposeEffect?: boolean): void;
  83690. clone(name: string): TerrainMaterial;
  83691. serialize(): any;
  83692. getClassName(): string;
  83693. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83694. }
  83695. }
  83696. declare module BABYLON {
  83697. /** @hidden */
  83698. export var triplanarPixelShader: {
  83699. name: string;
  83700. shader: string;
  83701. };
  83702. }
  83703. declare module BABYLON {
  83704. /** @hidden */
  83705. export var triplanarVertexShader: {
  83706. name: string;
  83707. shader: string;
  83708. };
  83709. }
  83710. declare module BABYLON {
  83711. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83712. mixTexture: BABYLON.BaseTexture;
  83713. private _diffuseTextureX;
  83714. diffuseTextureX: BABYLON.BaseTexture;
  83715. private _diffuseTextureY;
  83716. diffuseTextureY: BABYLON.BaseTexture;
  83717. private _diffuseTextureZ;
  83718. diffuseTextureZ: BABYLON.BaseTexture;
  83719. private _normalTextureX;
  83720. normalTextureX: BABYLON.BaseTexture;
  83721. private _normalTextureY;
  83722. normalTextureY: BABYLON.BaseTexture;
  83723. private _normalTextureZ;
  83724. normalTextureZ: BABYLON.BaseTexture;
  83725. tileSize: number;
  83726. diffuseColor: BABYLON.Color3;
  83727. specularColor: BABYLON.Color3;
  83728. specularPower: number;
  83729. private _disableLighting;
  83730. disableLighting: boolean;
  83731. private _maxSimultaneousLights;
  83732. maxSimultaneousLights: number;
  83733. constructor(name: string, scene: BABYLON.Scene);
  83734. needAlphaBlending(): boolean;
  83735. needAlphaTesting(): boolean;
  83736. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83737. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83738. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83739. getAnimatables(): BABYLON.IAnimatable[];
  83740. getActiveTextures(): BABYLON.BaseTexture[];
  83741. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83742. dispose(forceDisposeEffect?: boolean): void;
  83743. clone(name: string): TriPlanarMaterial;
  83744. serialize(): any;
  83745. getClassName(): string;
  83746. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83747. }
  83748. }
  83749. declare module BABYLON {
  83750. /** @hidden */
  83751. export var waterPixelShader: {
  83752. name: string;
  83753. shader: string;
  83754. };
  83755. }
  83756. declare module BABYLON {
  83757. /** @hidden */
  83758. export var waterVertexShader: {
  83759. name: string;
  83760. shader: string;
  83761. };
  83762. }
  83763. declare module BABYLON {
  83764. export class WaterMaterial extends BABYLON.PushMaterial {
  83765. renderTargetSize: BABYLON.Vector2;
  83766. private _bumpTexture;
  83767. bumpTexture: BABYLON.BaseTexture;
  83768. diffuseColor: BABYLON.Color3;
  83769. specularColor: BABYLON.Color3;
  83770. specularPower: number;
  83771. private _disableLighting;
  83772. disableLighting: boolean;
  83773. private _maxSimultaneousLights;
  83774. maxSimultaneousLights: number;
  83775. /**
  83776. * @param {number}: Represents the wind force
  83777. */
  83778. windForce: number;
  83779. /**
  83780. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83781. */
  83782. windDirection: BABYLON.Vector2;
  83783. /**
  83784. * @param {number}: Wave height, represents the height of the waves
  83785. */
  83786. waveHeight: number;
  83787. /**
  83788. * @param {number}: Bump height, represents the bump height related to the bump map
  83789. */
  83790. bumpHeight: number;
  83791. /**
  83792. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83793. */
  83794. private _bumpSuperimpose;
  83795. bumpSuperimpose: boolean;
  83796. /**
  83797. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83798. */
  83799. private _fresnelSeparate;
  83800. fresnelSeparate: boolean;
  83801. /**
  83802. * @param {boolean}: bump Waves modify the reflection.
  83803. */
  83804. private _bumpAffectsReflection;
  83805. bumpAffectsReflection: boolean;
  83806. /**
  83807. * @param {number}: The water color blended with the refraction (near)
  83808. */
  83809. waterColor: BABYLON.Color3;
  83810. /**
  83811. * @param {number}: The blend factor related to the water color
  83812. */
  83813. colorBlendFactor: number;
  83814. /**
  83815. * @param {number}: The water color blended with the reflection (far)
  83816. */
  83817. waterColor2: BABYLON.Color3;
  83818. /**
  83819. * @param {number}: The blend factor related to the water color (reflection, far)
  83820. */
  83821. colorBlendFactor2: number;
  83822. /**
  83823. * @param {number}: Represents the maximum length of a wave
  83824. */
  83825. waveLength: number;
  83826. /**
  83827. * @param {number}: Defines the waves speed
  83828. */
  83829. waveSpeed: number;
  83830. /**
  83831. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83832. * will avoid calculating useless pixels in the pixel shader of the water material.
  83833. */
  83834. disableClipPlane: boolean;
  83835. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83836. private _mesh;
  83837. private _refractionRTT;
  83838. private _reflectionRTT;
  83839. private _reflectionTransform;
  83840. private _lastTime;
  83841. private _lastDeltaTime;
  83842. private _useLogarithmicDepth;
  83843. private _waitingRenderList;
  83844. private _imageProcessingConfiguration;
  83845. private _imageProcessingObserver;
  83846. /**
  83847. * Gets a boolean indicating that current material needs to register RTT
  83848. */
  83849. get hasRenderTargetTextures(): boolean;
  83850. /**
  83851. * Constructor
  83852. */
  83853. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83854. get useLogarithmicDepth(): boolean;
  83855. set useLogarithmicDepth(value: boolean);
  83856. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83857. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83858. addToRenderList(node: any): void;
  83859. enableRenderTargets(enable: boolean): void;
  83860. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83861. get renderTargetsEnabled(): boolean;
  83862. needAlphaBlending(): boolean;
  83863. needAlphaTesting(): boolean;
  83864. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83865. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83866. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83867. private _createRenderTargets;
  83868. getAnimatables(): BABYLON.IAnimatable[];
  83869. getActiveTextures(): BABYLON.BaseTexture[];
  83870. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83871. dispose(forceDisposeEffect?: boolean): void;
  83872. clone(name: string): WaterMaterial;
  83873. serialize(): any;
  83874. getClassName(): string;
  83875. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83876. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83877. }
  83878. }
  83879. declare module BABYLON {
  83880. /** @hidden */
  83881. export var asciiartPixelShader: {
  83882. name: string;
  83883. shader: string;
  83884. };
  83885. }
  83886. declare module BABYLON {
  83887. /**
  83888. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83889. *
  83890. * It basically takes care rendering the font front the given font size to a texture.
  83891. * This is used later on in the postprocess.
  83892. */
  83893. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83894. private _font;
  83895. private _text;
  83896. private _charSize;
  83897. /**
  83898. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83899. */
  83900. get charSize(): number;
  83901. /**
  83902. * Create a new instance of the Ascii Art FontTexture class
  83903. * @param name the name of the texture
  83904. * @param font the font to use, use the W3C CSS notation
  83905. * @param text the caracter set to use in the rendering.
  83906. * @param scene the scene that owns the texture
  83907. */
  83908. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83909. /**
  83910. * Gets the max char width of a font.
  83911. * @param font the font to use, use the W3C CSS notation
  83912. * @return the max char width
  83913. */
  83914. private getFontWidth;
  83915. /**
  83916. * Gets the max char height of a font.
  83917. * @param font the font to use, use the W3C CSS notation
  83918. * @return the max char height
  83919. */
  83920. private getFontHeight;
  83921. /**
  83922. * Clones the current AsciiArtTexture.
  83923. * @return the clone of the texture.
  83924. */
  83925. clone(): AsciiArtFontTexture;
  83926. /**
  83927. * Parses a json object representing the texture and returns an instance of it.
  83928. * @param source the source JSON representation
  83929. * @param scene the scene to create the texture for
  83930. * @return the parsed texture
  83931. */
  83932. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83933. }
  83934. /**
  83935. * Option available in the Ascii Art Post Process.
  83936. */
  83937. export interface IAsciiArtPostProcessOptions {
  83938. /**
  83939. * The font to use following the w3c font definition.
  83940. */
  83941. font?: string;
  83942. /**
  83943. * The character set to use in the postprocess.
  83944. */
  83945. characterSet?: string;
  83946. /**
  83947. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83948. * This number is defined between 0 and 1;
  83949. */
  83950. mixToTile?: number;
  83951. /**
  83952. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83953. * This number is defined between 0 and 1;
  83954. */
  83955. mixToNormal?: number;
  83956. }
  83957. /**
  83958. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83959. *
  83960. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83961. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83962. */
  83963. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83964. /**
  83965. * The font texture used to render the char in the post process.
  83966. */
  83967. private _asciiArtFontTexture;
  83968. /**
  83969. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83970. * This number is defined between 0 and 1;
  83971. */
  83972. mixToTile: number;
  83973. /**
  83974. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83975. * This number is defined between 0 and 1;
  83976. */
  83977. mixToNormal: number;
  83978. /**
  83979. * Instantiates a new Ascii Art Post Process.
  83980. * @param name the name to give to the postprocess
  83981. * @camera the camera to apply the post process to.
  83982. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83983. */
  83984. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83985. }
  83986. }
  83987. declare module BABYLON {
  83988. /** @hidden */
  83989. export var digitalrainPixelShader: {
  83990. name: string;
  83991. shader: string;
  83992. };
  83993. }
  83994. declare module BABYLON {
  83995. /**
  83996. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  83997. *
  83998. * It basically takes care rendering the font front the given font size to a texture.
  83999. * This is used later on in the postprocess.
  84000. */
  84001. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  84002. private _font;
  84003. private _text;
  84004. private _charSize;
  84005. /**
  84006. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84007. */
  84008. get charSize(): number;
  84009. /**
  84010. * Create a new instance of the Digital Rain FontTexture class
  84011. * @param name the name of the texture
  84012. * @param font the font to use, use the W3C CSS notation
  84013. * @param text the caracter set to use in the rendering.
  84014. * @param scene the scene that owns the texture
  84015. */
  84016. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84017. /**
  84018. * Gets the max char width of a font.
  84019. * @param font the font to use, use the W3C CSS notation
  84020. * @return the max char width
  84021. */
  84022. private getFontWidth;
  84023. /**
  84024. * Gets the max char height of a font.
  84025. * @param font the font to use, use the W3C CSS notation
  84026. * @return the max char height
  84027. */
  84028. private getFontHeight;
  84029. /**
  84030. * Clones the current DigitalRainFontTexture.
  84031. * @return the clone of the texture.
  84032. */
  84033. clone(): DigitalRainFontTexture;
  84034. /**
  84035. * Parses a json object representing the texture and returns an instance of it.
  84036. * @param source the source JSON representation
  84037. * @param scene the scene to create the texture for
  84038. * @return the parsed texture
  84039. */
  84040. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84041. }
  84042. /**
  84043. * Option available in the Digital Rain Post Process.
  84044. */
  84045. export interface IDigitalRainPostProcessOptions {
  84046. /**
  84047. * The font to use following the w3c font definition.
  84048. */
  84049. font?: string;
  84050. /**
  84051. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84052. * This number is defined between 0 and 1;
  84053. */
  84054. mixToTile?: number;
  84055. /**
  84056. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84057. * This number is defined between 0 and 1;
  84058. */
  84059. mixToNormal?: number;
  84060. }
  84061. /**
  84062. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84063. *
  84064. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84065. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84066. */
  84067. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84068. /**
  84069. * The font texture used to render the char in the post process.
  84070. */
  84071. private _digitalRainFontTexture;
  84072. /**
  84073. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84074. * This number is defined between 0 and 1;
  84075. */
  84076. mixToTile: number;
  84077. /**
  84078. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84079. * This number is defined between 0 and 1;
  84080. */
  84081. mixToNormal: number;
  84082. /**
  84083. * Instantiates a new Digital Rain Post Process.
  84084. * @param name the name to give to the postprocess
  84085. * @camera the camera to apply the post process to.
  84086. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84087. */
  84088. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84089. }
  84090. }
  84091. declare module BABYLON {
  84092. /** @hidden */
  84093. export var brickProceduralTexturePixelShader: {
  84094. name: string;
  84095. shader: string;
  84096. };
  84097. }
  84098. declare module BABYLON {
  84099. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  84100. private _numberOfBricksHeight;
  84101. private _numberOfBricksWidth;
  84102. private _jointColor;
  84103. private _brickColor;
  84104. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84105. updateShaderUniforms(): void;
  84106. get numberOfBricksHeight(): number;
  84107. set numberOfBricksHeight(value: number);
  84108. get numberOfBricksWidth(): number;
  84109. set numberOfBricksWidth(value: number);
  84110. get jointColor(): BABYLON.Color3;
  84111. set jointColor(value: BABYLON.Color3);
  84112. get brickColor(): BABYLON.Color3;
  84113. set brickColor(value: BABYLON.Color3);
  84114. /**
  84115. * Serializes this brick procedural texture
  84116. * @returns a serialized brick procedural texture object
  84117. */
  84118. serialize(): any;
  84119. /**
  84120. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  84121. * @param parsedTexture defines parsed texture data
  84122. * @param scene defines the current scene
  84123. * @param rootUrl defines the root URL containing brick procedural texture information
  84124. * @returns a parsed Brick Procedural BABYLON.Texture
  84125. */
  84126. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  84127. }
  84128. }
  84129. declare module BABYLON {
  84130. /** @hidden */
  84131. export var cloudProceduralTexturePixelShader: {
  84132. name: string;
  84133. shader: string;
  84134. };
  84135. }
  84136. declare module BABYLON {
  84137. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  84138. private _skyColor;
  84139. private _cloudColor;
  84140. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84141. updateShaderUniforms(): void;
  84142. get skyColor(): BABYLON.Color4;
  84143. set skyColor(value: BABYLON.Color4);
  84144. get cloudColor(): BABYLON.Color4;
  84145. set cloudColor(value: BABYLON.Color4);
  84146. /**
  84147. * Serializes this cloud procedural texture
  84148. * @returns a serialized cloud procedural texture object
  84149. */
  84150. serialize(): any;
  84151. /**
  84152. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  84153. * @param parsedTexture defines parsed texture data
  84154. * @param scene defines the current scene
  84155. * @param rootUrl defines the root URL containing cloud procedural texture information
  84156. * @returns a parsed Cloud Procedural BABYLON.Texture
  84157. */
  84158. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  84159. }
  84160. }
  84161. declare module BABYLON {
  84162. /** @hidden */
  84163. export var fireProceduralTexturePixelShader: {
  84164. name: string;
  84165. shader: string;
  84166. };
  84167. }
  84168. declare module BABYLON {
  84169. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  84170. private _time;
  84171. private _speed;
  84172. private _autoGenerateTime;
  84173. private _fireColors;
  84174. private _alphaThreshold;
  84175. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84176. updateShaderUniforms(): void;
  84177. render(useCameraPostProcess?: boolean): void;
  84178. static get PurpleFireColors(): BABYLON.Color3[];
  84179. static get GreenFireColors(): BABYLON.Color3[];
  84180. static get RedFireColors(): BABYLON.Color3[];
  84181. static get BlueFireColors(): BABYLON.Color3[];
  84182. get autoGenerateTime(): boolean;
  84183. set autoGenerateTime(value: boolean);
  84184. get fireColors(): BABYLON.Color3[];
  84185. set fireColors(value: BABYLON.Color3[]);
  84186. get time(): number;
  84187. set time(value: number);
  84188. get speed(): BABYLON.Vector2;
  84189. set speed(value: BABYLON.Vector2);
  84190. get alphaThreshold(): number;
  84191. set alphaThreshold(value: number);
  84192. /**
  84193. * Serializes this fire procedural texture
  84194. * @returns a serialized fire procedural texture object
  84195. */
  84196. serialize(): any;
  84197. /**
  84198. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84199. * @param parsedTexture defines parsed texture data
  84200. * @param scene defines the current scene
  84201. * @param rootUrl defines the root URL containing fire procedural texture information
  84202. * @returns a parsed Fire Procedural BABYLON.Texture
  84203. */
  84204. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84205. }
  84206. }
  84207. declare module BABYLON {
  84208. /** @hidden */
  84209. export var grassProceduralTexturePixelShader: {
  84210. name: string;
  84211. shader: string;
  84212. };
  84213. }
  84214. declare module BABYLON {
  84215. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84216. private _grassColors;
  84217. private _groundColor;
  84218. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84219. updateShaderUniforms(): void;
  84220. get grassColors(): BABYLON.Color3[];
  84221. set grassColors(value: BABYLON.Color3[]);
  84222. get groundColor(): BABYLON.Color3;
  84223. set groundColor(value: BABYLON.Color3);
  84224. /**
  84225. * Serializes this grass procedural texture
  84226. * @returns a serialized grass procedural texture object
  84227. */
  84228. serialize(): any;
  84229. /**
  84230. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84231. * @param parsedTexture defines parsed texture data
  84232. * @param scene defines the current scene
  84233. * @param rootUrl defines the root URL containing grass procedural texture information
  84234. * @returns a parsed Grass Procedural BABYLON.Texture
  84235. */
  84236. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84237. }
  84238. }
  84239. declare module BABYLON {
  84240. /** @hidden */
  84241. export var marbleProceduralTexturePixelShader: {
  84242. name: string;
  84243. shader: string;
  84244. };
  84245. }
  84246. declare module BABYLON {
  84247. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84248. private _numberOfTilesHeight;
  84249. private _numberOfTilesWidth;
  84250. private _amplitude;
  84251. private _jointColor;
  84252. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84253. updateShaderUniforms(): void;
  84254. get numberOfTilesHeight(): number;
  84255. set numberOfTilesHeight(value: number);
  84256. get amplitude(): number;
  84257. set amplitude(value: number);
  84258. get numberOfTilesWidth(): number;
  84259. set numberOfTilesWidth(value: number);
  84260. get jointColor(): BABYLON.Color3;
  84261. set jointColor(value: BABYLON.Color3);
  84262. /**
  84263. * Serializes this marble procedural texture
  84264. * @returns a serialized marble procedural texture object
  84265. */
  84266. serialize(): any;
  84267. /**
  84268. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  84269. * @param parsedTexture defines parsed texture data
  84270. * @param scene defines the current scene
  84271. * @param rootUrl defines the root URL containing marble procedural texture information
  84272. * @returns a parsed Marble Procedural BABYLON.Texture
  84273. */
  84274. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  84275. }
  84276. }
  84277. declare module BABYLON {
  84278. /** @hidden */
  84279. export var normalMapProceduralTexturePixelShader: {
  84280. name: string;
  84281. shader: string;
  84282. };
  84283. }
  84284. declare module BABYLON {
  84285. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  84286. private _baseTexture;
  84287. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84288. updateShaderUniforms(): void;
  84289. render(useCameraPostProcess?: boolean): void;
  84290. resize(size: any, generateMipMaps: any): void;
  84291. get baseTexture(): BABYLON.Texture;
  84292. set baseTexture(texture: BABYLON.Texture);
  84293. /**
  84294. * Serializes this normal map procedural texture
  84295. * @returns a serialized normal map procedural texture object
  84296. */
  84297. serialize(): any;
  84298. /**
  84299. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  84300. * @param parsedTexture defines parsed texture data
  84301. * @param scene defines the current scene
  84302. * @param rootUrl defines the root URL containing normal map procedural texture information
  84303. * @returns a parsed Normal Map Procedural BABYLON.Texture
  84304. */
  84305. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  84306. }
  84307. }
  84308. declare module BABYLON {
  84309. /** @hidden */
  84310. export var perlinNoiseProceduralTexturePixelShader: {
  84311. name: string;
  84312. shader: string;
  84313. };
  84314. }
  84315. declare module BABYLON {
  84316. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  84317. time: number;
  84318. timeScale: number;
  84319. translationSpeed: number;
  84320. private _currentTranslation;
  84321. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84322. updateShaderUniforms(): void;
  84323. render(useCameraPostProcess?: boolean): void;
  84324. resize(size: any, generateMipMaps: any): void;
  84325. /**
  84326. * Serializes this perlin noise procedural texture
  84327. * @returns a serialized perlin noise procedural texture object
  84328. */
  84329. serialize(): any;
  84330. /**
  84331. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  84332. * @param parsedTexture defines parsed texture data
  84333. * @param scene defines the current scene
  84334. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  84335. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  84336. */
  84337. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  84338. }
  84339. }
  84340. declare module BABYLON {
  84341. /** @hidden */
  84342. export var roadProceduralTexturePixelShader: {
  84343. name: string;
  84344. shader: string;
  84345. };
  84346. }
  84347. declare module BABYLON {
  84348. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  84349. private _roadColor;
  84350. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84351. updateShaderUniforms(): void;
  84352. get roadColor(): BABYLON.Color3;
  84353. set roadColor(value: BABYLON.Color3);
  84354. /**
  84355. * Serializes this road procedural texture
  84356. * @returns a serialized road procedural texture object
  84357. */
  84358. serialize(): any;
  84359. /**
  84360. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  84361. * @param parsedTexture defines parsed texture data
  84362. * @param scene defines the current scene
  84363. * @param rootUrl defines the root URL containing road procedural texture information
  84364. * @returns a parsed Road Procedural BABYLON.Texture
  84365. */
  84366. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  84367. }
  84368. }
  84369. declare module BABYLON {
  84370. /** @hidden */
  84371. export var starfieldProceduralTexturePixelShader: {
  84372. name: string;
  84373. shader: string;
  84374. };
  84375. }
  84376. declare module BABYLON {
  84377. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  84378. private _time;
  84379. private _alpha;
  84380. private _beta;
  84381. private _zoom;
  84382. private _formuparam;
  84383. private _stepsize;
  84384. private _tile;
  84385. private _brightness;
  84386. private _darkmatter;
  84387. private _distfading;
  84388. private _saturation;
  84389. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84390. updateShaderUniforms(): void;
  84391. get time(): number;
  84392. set time(value: number);
  84393. get alpha(): number;
  84394. set alpha(value: number);
  84395. get beta(): number;
  84396. set beta(value: number);
  84397. get formuparam(): number;
  84398. set formuparam(value: number);
  84399. get stepsize(): number;
  84400. set stepsize(value: number);
  84401. get zoom(): number;
  84402. set zoom(value: number);
  84403. get tile(): number;
  84404. set tile(value: number);
  84405. get brightness(): number;
  84406. set brightness(value: number);
  84407. get darkmatter(): number;
  84408. set darkmatter(value: number);
  84409. get distfading(): number;
  84410. set distfading(value: number);
  84411. get saturation(): number;
  84412. set saturation(value: number);
  84413. /**
  84414. * Serializes this starfield procedural texture
  84415. * @returns a serialized starfield procedural texture object
  84416. */
  84417. serialize(): any;
  84418. /**
  84419. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  84420. * @param parsedTexture defines parsed texture data
  84421. * @param scene defines the current scene
  84422. * @param rootUrl defines the root URL containing startfield procedural texture information
  84423. * @returns a parsed Starfield Procedural BABYLON.Texture
  84424. */
  84425. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  84426. }
  84427. }
  84428. declare module BABYLON {
  84429. /** @hidden */
  84430. export var woodProceduralTexturePixelShader: {
  84431. name: string;
  84432. shader: string;
  84433. };
  84434. }
  84435. declare module BABYLON {
  84436. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  84437. private _ampScale;
  84438. private _woodColor;
  84439. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84440. updateShaderUniforms(): void;
  84441. get ampScale(): number;
  84442. set ampScale(value: number);
  84443. get woodColor(): BABYLON.Color3;
  84444. set woodColor(value: BABYLON.Color3);
  84445. /**
  84446. * Serializes this wood procedural texture
  84447. * @returns a serialized wood procedural texture object
  84448. */
  84449. serialize(): any;
  84450. /**
  84451. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  84452. * @param parsedTexture defines parsed texture data
  84453. * @param scene defines the current scene
  84454. * @param rootUrl defines the root URL containing wood procedural texture information
  84455. * @returns a parsed Wood Procedural BABYLON.Texture
  84456. */
  84457. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  84458. }
  84459. }