documentation.d.ts 3.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579
  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: 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. private static _UpReadOnly;
  2412. private static _ZeroReadOnly;
  2413. /** @hidden */
  2414. _x: number;
  2415. /** @hidden */
  2416. _y: number;
  2417. /** @hidden */
  2418. _z: number;
  2419. /** @hidden */
  2420. _isDirty: boolean;
  2421. /** Gets or sets the x coordinate */
  2422. get x(): number;
  2423. set x(value: number);
  2424. /** Gets or sets the y coordinate */
  2425. get y(): number;
  2426. set y(value: number);
  2427. /** Gets or sets the z coordinate */
  2428. get z(): number;
  2429. set z(value: number);
  2430. /**
  2431. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2432. * @param x defines the first coordinates (on X axis)
  2433. * @param y defines the second coordinates (on Y axis)
  2434. * @param z defines the third coordinates (on Z axis)
  2435. */
  2436. constructor(x?: number, y?: number, z?: number);
  2437. /**
  2438. * Creates a string representation of the Vector3
  2439. * @returns a string with the Vector3 coordinates.
  2440. */
  2441. toString(): string;
  2442. /**
  2443. * Gets the class name
  2444. * @returns the string "Vector3"
  2445. */
  2446. getClassName(): string;
  2447. /**
  2448. * Creates the Vector3 hash code
  2449. * @returns a number which tends to be unique between Vector3 instances
  2450. */
  2451. getHashCode(): number;
  2452. /**
  2453. * Creates an array containing three elements : the coordinates of the Vector3
  2454. * @returns a new array of numbers
  2455. */
  2456. asArray(): number[];
  2457. /**
  2458. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2459. * @param array defines the destination array
  2460. * @param index defines the offset in the destination array
  2461. * @returns the current Vector3
  2462. */
  2463. toArray(array: FloatArray, index?: number): Vector3;
  2464. /**
  2465. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2466. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2467. */
  2468. toQuaternion(): Quaternion;
  2469. /**
  2470. * Adds the given vector to the current Vector3
  2471. * @param otherVector defines the second operand
  2472. * @returns the current updated Vector3
  2473. */
  2474. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2475. /**
  2476. * Adds the given coordinates to the current Vector3
  2477. * @param x defines the x coordinate of the operand
  2478. * @param y defines the y coordinate of the operand
  2479. * @param z defines the z coordinate of the operand
  2480. * @returns the current updated Vector3
  2481. */
  2482. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2483. /**
  2484. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2485. * @param otherVector defines the second operand
  2486. * @returns the resulting Vector3
  2487. */
  2488. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2489. /**
  2490. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2491. * @param otherVector defines the second operand
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the current Vector3
  2494. */
  2495. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2496. /**
  2497. * Subtract the given vector from the current Vector3
  2498. * @param otherVector defines the second operand
  2499. * @returns the current updated Vector3
  2500. */
  2501. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2502. /**
  2503. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2504. * @param otherVector defines the second operand
  2505. * @returns the resulting Vector3
  2506. */
  2507. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2508. /**
  2509. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2510. * @param otherVector defines the second operand
  2511. * @param result defines the Vector3 object where to store the result
  2512. * @returns the current Vector3
  2513. */
  2514. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2515. /**
  2516. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2517. * @param x defines the x coordinate of the operand
  2518. * @param y defines the y coordinate of the operand
  2519. * @param z defines the z coordinate of the operand
  2520. * @returns the resulting Vector3
  2521. */
  2522. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2523. /**
  2524. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2525. * @param x defines the x coordinate of the operand
  2526. * @param y defines the y coordinate of the operand
  2527. * @param z defines the z coordinate of the operand
  2528. * @param result defines the Vector3 object where to store the result
  2529. * @returns the current Vector3
  2530. */
  2531. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2532. /**
  2533. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2534. * @returns a new Vector3
  2535. */
  2536. negate(): Vector3;
  2537. /**
  2538. * Negate this vector in place
  2539. * @returns this
  2540. */
  2541. negateInPlace(): Vector3;
  2542. /**
  2543. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2544. * @param result defines the Vector3 object where to store the result
  2545. * @returns the current Vector3
  2546. */
  2547. negateToRef(result: Vector3): Vector3;
  2548. /**
  2549. * Multiplies the Vector3 coordinates by the float "scale"
  2550. * @param scale defines the multiplier factor
  2551. * @returns the current updated Vector3
  2552. */
  2553. scaleInPlace(scale: number): Vector3;
  2554. /**
  2555. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2556. * @param scale defines the multiplier factor
  2557. * @returns a new Vector3
  2558. */
  2559. scale(scale: number): Vector3;
  2560. /**
  2561. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2562. * @param scale defines the multiplier factor
  2563. * @param result defines the Vector3 object where to store the result
  2564. * @returns the current Vector3
  2565. */
  2566. scaleToRef(scale: number, result: Vector3): Vector3;
  2567. /**
  2568. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2569. * @param scale defines the scale factor
  2570. * @param result defines the Vector3 object where to store the result
  2571. * @returns the unmodified current Vector3
  2572. */
  2573. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2574. /**
  2575. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2576. * @param origin defines the origin of the projection ray
  2577. * @param plane defines the plane to project to
  2578. * @returns the projected vector3
  2579. */
  2580. projectOnPlane(plane: Plane, origin: 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. * @param result defines the Vector3 where to store the result
  2586. */
  2587. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2588. /**
  2589. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2590. * @param otherVector defines the second operand
  2591. * @returns true if both vectors are equals
  2592. */
  2593. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2594. /**
  2595. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2596. * @param otherVector defines the second operand
  2597. * @param epsilon defines the minimal distance to define values as equals
  2598. * @returns true if both vectors are distant less than epsilon
  2599. */
  2600. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2601. /**
  2602. * Returns true if the current Vector3 coordinates equals the given floats
  2603. * @param x defines the x coordinate of the operand
  2604. * @param y defines the y coordinate of the operand
  2605. * @param z defines the z coordinate of the operand
  2606. * @returns true if both vectors are equals
  2607. */
  2608. equalsToFloats(x: number, y: number, z: number): boolean;
  2609. /**
  2610. * Multiplies the current Vector3 coordinates by the given ones
  2611. * @param otherVector defines the second operand
  2612. * @returns the current updated Vector3
  2613. */
  2614. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2615. /**
  2616. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2617. * @param otherVector defines the second operand
  2618. * @returns the new Vector3
  2619. */
  2620. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2621. /**
  2622. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2623. * @param otherVector defines the second operand
  2624. * @param result defines the Vector3 object where to store the result
  2625. * @returns the current Vector3
  2626. */
  2627. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2628. /**
  2629. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2630. * @param x defines the x coordinate of the operand
  2631. * @param y defines the y coordinate of the operand
  2632. * @param z defines the z coordinate of the operand
  2633. * @returns the new Vector3
  2634. */
  2635. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2636. /**
  2637. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2638. * @param otherVector defines the second operand
  2639. * @returns the new Vector3
  2640. */
  2641. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2642. /**
  2643. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2644. * @param otherVector defines the second operand
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2649. /**
  2650. * Divides the current Vector3 coordinates by the given ones.
  2651. * @param otherVector defines the second operand
  2652. * @returns the current updated Vector3
  2653. */
  2654. divideInPlace(otherVector: Vector3): Vector3;
  2655. /**
  2656. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2657. * @param other defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2663. * @param other defines the second operand
  2664. * @returns the current updated Vector3
  2665. */
  2666. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2677. * @param x defines the x coordinate of the operand
  2678. * @param y defines the y coordinate of the operand
  2679. * @param z defines the z coordinate of the operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2683. /**
  2684. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2685. * Check if is non uniform within a certain amount of decimal places to account for this
  2686. * @param epsilon the amount the values can differ
  2687. * @returns if the the vector is non uniform to a certain number of decimal places
  2688. */
  2689. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2690. /**
  2691. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2692. */
  2693. get isNonUniform(): boolean;
  2694. /**
  2695. * Gets a new Vector3 from current Vector3 floored values
  2696. * @returns a new Vector3
  2697. */
  2698. floor(): Vector3;
  2699. /**
  2700. * Gets a new Vector3 from current Vector3 floored values
  2701. * @returns a new Vector3
  2702. */
  2703. fract(): Vector3;
  2704. /**
  2705. * Gets the length of the Vector3
  2706. * @returns the length of the Vector3
  2707. */
  2708. length(): number;
  2709. /**
  2710. * Gets the squared length of the Vector3
  2711. * @returns squared length of the Vector3
  2712. */
  2713. lengthSquared(): number;
  2714. /**
  2715. * Normalize the current Vector3.
  2716. * Please note that this is an in place operation.
  2717. * @returns the current updated Vector3
  2718. */
  2719. normalize(): Vector3;
  2720. /**
  2721. * Reorders the x y z properties of the vector in place
  2722. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2723. * @returns the current updated vector
  2724. */
  2725. reorderInPlace(order: string): this;
  2726. /**
  2727. * Rotates the vector around 0,0,0 by a quaternion
  2728. * @param quaternion the rotation quaternion
  2729. * @param result vector to store the result
  2730. * @returns the resulting vector
  2731. */
  2732. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2733. /**
  2734. * Rotates a vector around a given point
  2735. * @param quaternion the rotation quaternion
  2736. * @param point the point to rotate around
  2737. * @param result vector to store the result
  2738. * @returns the resulting vector
  2739. */
  2740. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2741. /**
  2742. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2743. * The cross product is then orthogonal to both current and "other"
  2744. * @param other defines the right operand
  2745. * @returns the cross product
  2746. */
  2747. cross(other: Vector3): Vector3;
  2748. /**
  2749. * Normalize the current Vector3 with the given input length.
  2750. * Please note that this is an in place operation.
  2751. * @param len the length of the vector
  2752. * @returns the current updated Vector3
  2753. */
  2754. normalizeFromLength(len: number): Vector3;
  2755. /**
  2756. * Normalize the current Vector3 to a new vector
  2757. * @returns the new Vector3
  2758. */
  2759. normalizeToNew(): Vector3;
  2760. /**
  2761. * Normalize the current Vector3 to the reference
  2762. * @param reference define the Vector3 to update
  2763. * @returns the updated Vector3
  2764. */
  2765. normalizeToRef(reference: Vector3): Vector3;
  2766. /**
  2767. * Creates a new Vector3 copied from the current Vector3
  2768. * @returns the new Vector3
  2769. */
  2770. clone(): Vector3;
  2771. /**
  2772. * Copies the given vector coordinates to the current Vector3 ones
  2773. * @param source defines the source Vector3
  2774. * @returns the current updated Vector3
  2775. */
  2776. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2777. /**
  2778. * Copies the given floats to the current Vector3 coordinates
  2779. * @param x defines the x coordinate of the operand
  2780. * @param y defines the y coordinate of the operand
  2781. * @param z defines the z coordinate of the operand
  2782. * @returns the current updated Vector3
  2783. */
  2784. copyFromFloats(x: number, y: number, z: number): Vector3;
  2785. /**
  2786. * Copies the given floats to the current Vector3 coordinates
  2787. * @param x defines the x coordinate of the operand
  2788. * @param y defines the y coordinate of the operand
  2789. * @param z defines the z coordinate of the operand
  2790. * @returns the current updated Vector3
  2791. */
  2792. set(x: number, y: number, z: number): Vector3;
  2793. /**
  2794. * Copies the given float to the current Vector3 coordinates
  2795. * @param v defines the x, y and z coordinates of the operand
  2796. * @returns the current updated Vector3
  2797. */
  2798. setAll(v: number): Vector3;
  2799. /**
  2800. * Get the clip factor between two vectors
  2801. * @param vector0 defines the first operand
  2802. * @param vector1 defines the second operand
  2803. * @param axis defines the axis to use
  2804. * @param size defines the size along the axis
  2805. * @returns the clip factor
  2806. */
  2807. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2808. /**
  2809. * Get angle between two vectors
  2810. * @param vector0 angle between vector0 and vector1
  2811. * @param vector1 angle between vector0 and vector1
  2812. * @param normal direction of the normal
  2813. * @return the angle between vector0 and vector1
  2814. */
  2815. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2816. /**
  2817. * Returns a new Vector3 set from the index "offset" of the given array
  2818. * @param array defines the source array
  2819. * @param offset defines the offset in the source array
  2820. * @returns the new Vector3
  2821. */
  2822. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2823. /**
  2824. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2825. * @param array defines the source array
  2826. * @param offset defines the offset in the source array
  2827. * @returns the new Vector3
  2828. * @deprecated Please use FromArray instead.
  2829. */
  2830. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2831. /**
  2832. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2833. * @param array defines the source array
  2834. * @param offset defines the offset in the source array
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2838. /**
  2839. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  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. * @deprecated Please use FromArrayToRef instead.
  2844. */
  2845. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2846. /**
  2847. * Sets the given vector "result" with the given floats.
  2848. * @param x defines the x coordinate of the source
  2849. * @param y defines the y coordinate of the source
  2850. * @param z defines the z coordinate of the source
  2851. * @param result defines the Vector3 where to store the result
  2852. */
  2853. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2854. /**
  2855. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2856. * @returns a new empty Vector3
  2857. */
  2858. static Zero(): Vector3;
  2859. /**
  2860. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2861. * @returns a new unit Vector3
  2862. */
  2863. static One(): Vector3;
  2864. /**
  2865. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2866. * @returns a new up Vector3
  2867. */
  2868. static Up(): Vector3;
  2869. /**
  2870. * Gets a up Vector3 that must not be updated
  2871. */
  2872. static get UpReadOnly(): DeepImmutable<Vector3>;
  2873. /**
  2874. * Gets a zero Vector3 that must not be updated
  2875. */
  2876. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2877. /**
  2878. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2879. * @returns a new down Vector3
  2880. */
  2881. static Down(): Vector3;
  2882. /**
  2883. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2884. * @param rightHandedSystem is the scene right-handed (negative z)
  2885. * @returns a new forward Vector3
  2886. */
  2887. static Forward(rightHandedSystem?: boolean): Vector3;
  2888. /**
  2889. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2890. * @param rightHandedSystem is the scene right-handed (negative-z)
  2891. * @returns a new forward Vector3
  2892. */
  2893. static Backward(rightHandedSystem?: boolean): Vector3;
  2894. /**
  2895. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2896. * @returns a new right Vector3
  2897. */
  2898. static Right(): Vector3;
  2899. /**
  2900. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2901. * @returns a new left Vector3
  2902. */
  2903. static Left(): Vector3;
  2904. /**
  2905. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2906. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2907. * @param vector defines the Vector3 to transform
  2908. * @param transformation defines the transformation matrix
  2909. * @returns the transformed Vector3
  2910. */
  2911. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2912. /**
  2913. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2914. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2915. * @param vector defines the Vector3 to transform
  2916. * @param transformation defines the transformation matrix
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2920. /**
  2921. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2922. * This method computes tranformed coordinates only, not transformed direction vectors
  2923. * @param x define the x coordinate of the source vector
  2924. * @param y define the y coordinate of the source vector
  2925. * @param z define the z coordinate of the source vector
  2926. * @param transformation defines the transformation matrix
  2927. * @param result defines the Vector3 where to store the result
  2928. */
  2929. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2930. /**
  2931. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2932. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2933. * @param vector defines the Vector3 to transform
  2934. * @param transformation defines the transformation matrix
  2935. * @returns the new Vector3
  2936. */
  2937. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2938. /**
  2939. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2940. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2941. * @param vector defines the Vector3 to transform
  2942. * @param transformation defines the transformation matrix
  2943. * @param result defines the Vector3 where to store the result
  2944. */
  2945. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2946. /**
  2947. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2948. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2949. * @param x define the x coordinate of the source vector
  2950. * @param y define the y coordinate of the source vector
  2951. * @param z define the z coordinate of the source vector
  2952. * @param transformation defines the transformation matrix
  2953. * @param result defines the Vector3 where to store the result
  2954. */
  2955. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2956. /**
  2957. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2958. * @param value1 defines the first control point
  2959. * @param value2 defines the second control point
  2960. * @param value3 defines the third control point
  2961. * @param value4 defines the fourth control point
  2962. * @param amount defines the amount on the spline to use
  2963. * @returns the new Vector3
  2964. */
  2965. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2966. /**
  2967. * 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"
  2968. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2969. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2970. * @param value defines the current value
  2971. * @param min defines the lower range value
  2972. * @param max defines the upper range value
  2973. * @returns the new Vector3
  2974. */
  2975. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2976. /**
  2977. * 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"
  2978. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2979. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2980. * @param value defines the current value
  2981. * @param min defines the lower range value
  2982. * @param max defines the upper range value
  2983. * @param result defines the Vector3 where to store the result
  2984. */
  2985. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2986. /**
  2987. * Checks if a given vector is inside a specific range
  2988. * @param v defines the vector to test
  2989. * @param min defines the minimum range
  2990. * @param max defines the maximum range
  2991. */
  2992. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2993. /**
  2994. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2995. * @param value1 defines the first control point
  2996. * @param tangent1 defines the first tangent vector
  2997. * @param value2 defines the second control point
  2998. * @param tangent2 defines the second tangent vector
  2999. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3000. * @returns the new Vector3
  3001. */
  3002. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3003. /**
  3004. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3005. * @param start defines the start value
  3006. * @param end defines the end value
  3007. * @param amount max defines amount between both (between 0 and 1)
  3008. * @returns the new Vector3
  3009. */
  3010. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3011. /**
  3012. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3013. * @param start defines the start value
  3014. * @param end defines the end value
  3015. * @param amount max defines amount between both (between 0 and 1)
  3016. * @param result defines the Vector3 where to store the result
  3017. */
  3018. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3019. /**
  3020. * Returns the dot product (float) between the vectors "left" and "right"
  3021. * @param left defines the left operand
  3022. * @param right defines the right operand
  3023. * @returns the dot product
  3024. */
  3025. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3026. /**
  3027. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3028. * The cross product is then orthogonal to both "left" and "right"
  3029. * @param left defines the left operand
  3030. * @param right defines the right operand
  3031. * @returns the cross product
  3032. */
  3033. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3034. /**
  3035. * Sets the given vector "result" with the cross product of "left" and "right"
  3036. * The cross product is then orthogonal to both "left" and "right"
  3037. * @param left defines the left operand
  3038. * @param right defines the right operand
  3039. * @param result defines the Vector3 where to store the result
  3040. */
  3041. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3042. /**
  3043. * Returns a new Vector3 as the normalization of the given vector
  3044. * @param vector defines the Vector3 to normalize
  3045. * @returns the new Vector3
  3046. */
  3047. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3048. /**
  3049. * Sets the given vector "result" with the normalization of the given first vector
  3050. * @param vector defines the Vector3 to normalize
  3051. * @param result defines the Vector3 where to store the result
  3052. */
  3053. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3054. /**
  3055. * Project a Vector3 onto screen space
  3056. * @param vector defines the Vector3 to project
  3057. * @param world defines the world matrix to use
  3058. * @param transform defines the transform (view x projection) matrix to use
  3059. * @param viewport defines the screen viewport to use
  3060. * @returns the new Vector3
  3061. */
  3062. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3063. /** @hidden */
  3064. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3065. /**
  3066. * Unproject from screen space to object space
  3067. * @param source defines the screen space Vector3 to use
  3068. * @param viewportWidth defines the current width of the viewport
  3069. * @param viewportHeight defines the current height of the viewport
  3070. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3071. * @param transform defines the transform (view x projection) matrix to use
  3072. * @returns the new Vector3
  3073. */
  3074. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3075. /**
  3076. * Unproject from screen space to object space
  3077. * @param source defines the screen space Vector3 to use
  3078. * @param viewportWidth defines the current width of the viewport
  3079. * @param viewportHeight defines the current height of the viewport
  3080. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3081. * @param view defines the view matrix to use
  3082. * @param projection defines the projection matrix to use
  3083. * @returns the new Vector3
  3084. */
  3085. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3086. /**
  3087. * Unproject from screen space to object space
  3088. * @param source defines the screen space Vector3 to use
  3089. * @param viewportWidth defines the current width of the viewport
  3090. * @param viewportHeight defines the current height of the viewport
  3091. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3092. * @param view defines the view matrix to use
  3093. * @param projection defines the projection matrix to use
  3094. * @param result defines the Vector3 where to store the result
  3095. */
  3096. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3097. /**
  3098. * Unproject from screen space to object space
  3099. * @param sourceX defines the screen space x coordinate to use
  3100. * @param sourceY defines the screen space y coordinate to use
  3101. * @param sourceZ defines the screen space z coordinate to use
  3102. * @param viewportWidth defines the current width of the viewport
  3103. * @param viewportHeight defines the current height of the viewport
  3104. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3105. * @param view defines the view matrix to use
  3106. * @param projection defines the projection matrix to use
  3107. * @param result defines the Vector3 where to store the result
  3108. */
  3109. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3110. /**
  3111. * Gets the minimal coordinate values between two Vector3
  3112. * @param left defines the first operand
  3113. * @param right defines the second operand
  3114. * @returns the new Vector3
  3115. */
  3116. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3117. /**
  3118. * Gets the maximal 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 Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3124. /**
  3125. * Returns the distance between the vectors "value1" and "value2"
  3126. * @param value1 defines the first operand
  3127. * @param value2 defines the second operand
  3128. * @returns the distance
  3129. */
  3130. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3131. /**
  3132. * Returns the squared distance between the vectors "value1" and "value2"
  3133. * @param value1 defines the first operand
  3134. * @param value2 defines the second operand
  3135. * @returns the squared distance
  3136. */
  3137. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3138. /**
  3139. * Returns a new Vector3 located at the center between "value1" and "value2"
  3140. * @param value1 defines the first operand
  3141. * @param value2 defines the second operand
  3142. * @returns the new Vector3
  3143. */
  3144. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3145. /**
  3146. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3147. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3148. * to something in order to rotate it from its local system to the given target system
  3149. * Note: axis1, axis2 and axis3 are normalized during this operation
  3150. * @param axis1 defines the first axis
  3151. * @param axis2 defines the second axis
  3152. * @param axis3 defines the third axis
  3153. * @returns a new Vector3
  3154. */
  3155. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3156. /**
  3157. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3158. * @param axis1 defines the first axis
  3159. * @param axis2 defines the second axis
  3160. * @param axis3 defines the third axis
  3161. * @param ref defines the Vector3 where to store the result
  3162. */
  3163. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3164. }
  3165. /**
  3166. * Vector4 class created for EulerAngle class conversion to Quaternion
  3167. */
  3168. export class Vector4 {
  3169. /** x value of the vector */
  3170. x: number;
  3171. /** y value of the vector */
  3172. y: number;
  3173. /** z value of the vector */
  3174. z: number;
  3175. /** w value of the vector */
  3176. w: number;
  3177. /**
  3178. * Creates a Vector4 object from the given floats.
  3179. * @param x x value of the vector
  3180. * @param y y value of the vector
  3181. * @param z z value of the vector
  3182. * @param w w value of the vector
  3183. */
  3184. constructor(
  3185. /** x value of the vector */
  3186. x: number,
  3187. /** y value of the vector */
  3188. y: number,
  3189. /** z value of the vector */
  3190. z: number,
  3191. /** w value of the vector */
  3192. w: number);
  3193. /**
  3194. * Returns the string with the Vector4 coordinates.
  3195. * @returns a string containing all the vector values
  3196. */
  3197. toString(): string;
  3198. /**
  3199. * Returns the string "Vector4".
  3200. * @returns "Vector4"
  3201. */
  3202. getClassName(): string;
  3203. /**
  3204. * Returns the Vector4 hash code.
  3205. * @returns a unique hash code
  3206. */
  3207. getHashCode(): number;
  3208. /**
  3209. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3210. * @returns the resulting array
  3211. */
  3212. asArray(): number[];
  3213. /**
  3214. * Populates the given array from the given index with the Vector4 coordinates.
  3215. * @param array array to populate
  3216. * @param index index of the array to start at (default: 0)
  3217. * @returns the Vector4.
  3218. */
  3219. toArray(array: FloatArray, index?: number): Vector4;
  3220. /**
  3221. * Adds the given vector to the current Vector4.
  3222. * @param otherVector the vector to add
  3223. * @returns the updated Vector4.
  3224. */
  3225. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3226. /**
  3227. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3228. * @param otherVector the vector to add
  3229. * @returns the resulting vector
  3230. */
  3231. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3232. /**
  3233. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3234. * @param otherVector the vector to add
  3235. * @param result the vector to store the result
  3236. * @returns the current Vector4.
  3237. */
  3238. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3239. /**
  3240. * Subtract in place the given vector from the current Vector4.
  3241. * @param otherVector the vector to subtract
  3242. * @returns the updated Vector4.
  3243. */
  3244. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3245. /**
  3246. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3247. * @param otherVector the vector to add
  3248. * @returns the new vector with the result
  3249. */
  3250. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3251. /**
  3252. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3253. * @param otherVector the vector to subtract
  3254. * @param result the vector to store the result
  3255. * @returns the current Vector4.
  3256. */
  3257. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3258. /**
  3259. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3260. */
  3261. /**
  3262. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3263. * @param x value to subtract
  3264. * @param y value to subtract
  3265. * @param z value to subtract
  3266. * @param w value to subtract
  3267. * @returns new vector containing the result
  3268. */
  3269. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3270. /**
  3271. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3272. * @param x value to subtract
  3273. * @param y value to subtract
  3274. * @param z value to subtract
  3275. * @param w value to subtract
  3276. * @param result the vector to store the result in
  3277. * @returns the current Vector4.
  3278. */
  3279. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3280. /**
  3281. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3282. * @returns a new vector with the negated values
  3283. */
  3284. negate(): Vector4;
  3285. /**
  3286. * Negate this vector in place
  3287. * @returns this
  3288. */
  3289. negateInPlace(): Vector4;
  3290. /**
  3291. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3292. * @param result defines the Vector3 object where to store the result
  3293. * @returns the current Vector4
  3294. */
  3295. negateToRef(result: Vector4): Vector4;
  3296. /**
  3297. * Multiplies the current Vector4 coordinates by scale (float).
  3298. * @param scale the number to scale with
  3299. * @returns the updated Vector4.
  3300. */
  3301. scaleInPlace(scale: number): Vector4;
  3302. /**
  3303. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3304. * @param scale the number to scale with
  3305. * @returns a new vector with the result
  3306. */
  3307. scale(scale: number): Vector4;
  3308. /**
  3309. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3310. * @param scale the number to scale with
  3311. * @param result a vector to store the result in
  3312. * @returns the current Vector4.
  3313. */
  3314. scaleToRef(scale: number, result: Vector4): Vector4;
  3315. /**
  3316. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3317. * @param scale defines the scale factor
  3318. * @param result defines the Vector4 object where to store the result
  3319. * @returns the unmodified current Vector4
  3320. */
  3321. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3322. /**
  3323. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3324. * @param otherVector the vector to compare against
  3325. * @returns true if they are equal
  3326. */
  3327. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3328. /**
  3329. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3330. * @param otherVector vector to compare against
  3331. * @param epsilon (Default: very small number)
  3332. * @returns true if they are equal
  3333. */
  3334. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3335. /**
  3336. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3337. * @param x x value to compare against
  3338. * @param y y value to compare against
  3339. * @param z z value to compare against
  3340. * @param w w value to compare against
  3341. * @returns true if equal
  3342. */
  3343. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3344. /**
  3345. * Multiplies in place the current Vector4 by the given one.
  3346. * @param otherVector vector to multiple with
  3347. * @returns the updated Vector4.
  3348. */
  3349. multiplyInPlace(otherVector: Vector4): Vector4;
  3350. /**
  3351. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3352. * @param otherVector vector to multiple with
  3353. * @returns resulting new vector
  3354. */
  3355. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3356. /**
  3357. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3358. * @param otherVector vector to multiple with
  3359. * @param result vector to store the result
  3360. * @returns the current Vector4.
  3361. */
  3362. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3363. /**
  3364. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3365. * @param x x value multiply with
  3366. * @param y y value multiply with
  3367. * @param z z value multiply with
  3368. * @param w w value multiply with
  3369. * @returns resulting new vector
  3370. */
  3371. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3372. /**
  3373. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3374. * @param otherVector vector to devide with
  3375. * @returns resulting new vector
  3376. */
  3377. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3378. /**
  3379. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3380. * @param otherVector vector to devide with
  3381. * @param result vector to store the result
  3382. * @returns the current Vector4.
  3383. */
  3384. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3385. /**
  3386. * Divides the current Vector3 coordinates by the given ones.
  3387. * @param otherVector vector to devide with
  3388. * @returns the updated Vector3.
  3389. */
  3390. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3391. /**
  3392. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3393. * @param other defines the second operand
  3394. * @returns the current updated Vector4
  3395. */
  3396. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3397. /**
  3398. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3399. * @param other defines the second operand
  3400. * @returns the current updated Vector4
  3401. */
  3402. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3403. /**
  3404. * Gets a new Vector4 from current Vector4 floored values
  3405. * @returns a new Vector4
  3406. */
  3407. floor(): Vector4;
  3408. /**
  3409. * Gets a new Vector4 from current Vector3 floored values
  3410. * @returns a new Vector4
  3411. */
  3412. fract(): Vector4;
  3413. /**
  3414. * Returns the Vector4 length (float).
  3415. * @returns the length
  3416. */
  3417. length(): number;
  3418. /**
  3419. * Returns the Vector4 squared length (float).
  3420. * @returns the length squared
  3421. */
  3422. lengthSquared(): number;
  3423. /**
  3424. * Normalizes in place the Vector4.
  3425. * @returns the updated Vector4.
  3426. */
  3427. normalize(): Vector4;
  3428. /**
  3429. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3430. * @returns this converted to a new vector3
  3431. */
  3432. toVector3(): Vector3;
  3433. /**
  3434. * Returns a new Vector4 copied from the current one.
  3435. * @returns the new cloned vector
  3436. */
  3437. clone(): Vector4;
  3438. /**
  3439. * Updates the current Vector4 with the given one coordinates.
  3440. * @param source the source vector to copy from
  3441. * @returns the updated Vector4.
  3442. */
  3443. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the current Vector4 coordinates with the given floats.
  3446. * @param x float to copy from
  3447. * @param y float to copy from
  3448. * @param z float to copy from
  3449. * @param w float to copy from
  3450. * @returns the updated Vector4.
  3451. */
  3452. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3453. /**
  3454. * Updates the current Vector4 coordinates with the given floats.
  3455. * @param x float to set from
  3456. * @param y float to set from
  3457. * @param z float to set from
  3458. * @param w float to set from
  3459. * @returns the updated Vector4.
  3460. */
  3461. set(x: number, y: number, z: number, w: number): Vector4;
  3462. /**
  3463. * Copies the given float to the current Vector3 coordinates
  3464. * @param v defines the x, y, z and w coordinates of the operand
  3465. * @returns the current updated Vector3
  3466. */
  3467. setAll(v: number): Vector4;
  3468. /**
  3469. * Returns a new Vector4 set from the starting index of the given array.
  3470. * @param array the array to pull values from
  3471. * @param offset the offset into the array to start at
  3472. * @returns the new vector
  3473. */
  3474. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3475. /**
  3476. * Updates the given vector "result" 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. * @param result the vector to store the result in
  3480. */
  3481. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3482. /**
  3483. * Updates the given vector "result" from the starting index of the given Float32Array.
  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 FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3489. /**
  3490. * Updates the given vector "result" coordinates from the given floats.
  3491. * @param x float to set from
  3492. * @param y float to set from
  3493. * @param z float to set from
  3494. * @param w float to set from
  3495. * @param result the vector to the floats in
  3496. */
  3497. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3498. /**
  3499. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3500. * @returns the new vector
  3501. */
  3502. static Zero(): Vector4;
  3503. /**
  3504. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3505. * @returns the new vector
  3506. */
  3507. static One(): Vector4;
  3508. /**
  3509. * Returns a new normalized Vector4 from the given one.
  3510. * @param vector the vector to normalize
  3511. * @returns the vector
  3512. */
  3513. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3514. /**
  3515. * Updates the given vector "result" from the normalization of the given one.
  3516. * @param vector the vector to normalize
  3517. * @param result the vector to store the result in
  3518. */
  3519. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3520. /**
  3521. * Returns a vector with the minimum values from the left and right vectors
  3522. * @param left left vector to minimize
  3523. * @param right right vector to minimize
  3524. * @returns a new vector with the minimum of the left and right vector values
  3525. */
  3526. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3527. /**
  3528. * Returns a vector with the maximum values from the left and right vectors
  3529. * @param left left vector to maximize
  3530. * @param right right vector to maximize
  3531. * @returns a new vector with the maximum of the left and right vector values
  3532. */
  3533. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3534. /**
  3535. * Returns the distance (float) between the vectors "value1" and "value2".
  3536. * @param value1 value to calulate the distance between
  3537. * @param value2 value to calulate the distance between
  3538. * @return the distance between the two vectors
  3539. */
  3540. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3541. /**
  3542. * Returns the squared 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 squared
  3546. */
  3547. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3548. /**
  3549. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3550. * @param value1 value to calulate the center between
  3551. * @param value2 value to calulate the center between
  3552. * @return the center between the two vectors
  3553. */
  3554. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3555. /**
  3556. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3557. * This methods computes transformed normalized direction vectors only.
  3558. * @param vector the vector to transform
  3559. * @param transformation the transformation matrix to apply
  3560. * @returns the new vector
  3561. */
  3562. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3563. /**
  3564. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3565. * This methods computes transformed normalized direction vectors only.
  3566. * @param vector the vector to transform
  3567. * @param transformation the transformation matrix to apply
  3568. * @param result the vector to store the result in
  3569. */
  3570. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3571. /**
  3572. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3573. * This methods computes transformed normalized direction vectors only.
  3574. * @param x value to transform
  3575. * @param y value to transform
  3576. * @param z value to transform
  3577. * @param w value to transform
  3578. * @param transformation the transformation matrix to apply
  3579. * @param result the vector to store the results in
  3580. */
  3581. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3582. /**
  3583. * Creates a new Vector4 from a Vector3
  3584. * @param source defines the source data
  3585. * @param w defines the 4th component (default is 0)
  3586. * @returns a new Vector4
  3587. */
  3588. static FromVector3(source: Vector3, w?: number): Vector4;
  3589. }
  3590. /**
  3591. * Class used to store quaternion data
  3592. * @see https://en.wikipedia.org/wiki/Quaternion
  3593. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3594. */
  3595. export class Quaternion {
  3596. /** @hidden */
  3597. _x: number;
  3598. /** @hidden */
  3599. _y: number;
  3600. /** @hidden */
  3601. _z: number;
  3602. /** @hidden */
  3603. _w: number;
  3604. /** @hidden */
  3605. _isDirty: boolean;
  3606. /** Gets or sets the x coordinate */
  3607. get x(): number;
  3608. set x(value: number);
  3609. /** Gets or sets the y coordinate */
  3610. get y(): number;
  3611. set y(value: number);
  3612. /** Gets or sets the z coordinate */
  3613. get z(): number;
  3614. set z(value: number);
  3615. /** Gets or sets the w coordinate */
  3616. get w(): number;
  3617. set w(value: number);
  3618. /**
  3619. * Creates a new Quaternion from the given floats
  3620. * @param x defines the first component (0 by default)
  3621. * @param y defines the second component (0 by default)
  3622. * @param z defines the third component (0 by default)
  3623. * @param w defines the fourth component (1.0 by default)
  3624. */
  3625. constructor(x?: number, y?: number, z?: number, w?: number);
  3626. /**
  3627. * Gets a string representation for the current quaternion
  3628. * @returns a string with the Quaternion coordinates
  3629. */
  3630. toString(): string;
  3631. /**
  3632. * Gets the class name of the quaternion
  3633. * @returns the string "Quaternion"
  3634. */
  3635. getClassName(): string;
  3636. /**
  3637. * Gets a hash code for this quaternion
  3638. * @returns the quaternion hash code
  3639. */
  3640. getHashCode(): number;
  3641. /**
  3642. * Copy the quaternion to an array
  3643. * @returns a new array populated with 4 elements from the quaternion coordinates
  3644. */
  3645. asArray(): number[];
  3646. /**
  3647. * Check if two quaternions are equals
  3648. * @param otherQuaternion defines the second operand
  3649. * @return true if the current quaternion and the given one coordinates are strictly equals
  3650. */
  3651. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3652. /**
  3653. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3654. * @param otherQuaternion defines the other quaternion
  3655. * @param epsilon defines the minimal distance to consider equality
  3656. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3657. */
  3658. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3659. /**
  3660. * Clone the current quaternion
  3661. * @returns a new quaternion copied from the current one
  3662. */
  3663. clone(): Quaternion;
  3664. /**
  3665. * Copy a quaternion to the current one
  3666. * @param other defines the other quaternion
  3667. * @returns the updated current quaternion
  3668. */
  3669. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3670. /**
  3671. * Updates the current quaternion with the given float coordinates
  3672. * @param x defines the x coordinate
  3673. * @param y defines the y coordinate
  3674. * @param z defines the z coordinate
  3675. * @param w defines the w coordinate
  3676. * @returns the updated current quaternion
  3677. */
  3678. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3679. /**
  3680. * Updates the current quaternion from the given float coordinates
  3681. * @param x defines the x coordinate
  3682. * @param y defines the y coordinate
  3683. * @param z defines the z coordinate
  3684. * @param w defines the w coordinate
  3685. * @returns the updated current quaternion
  3686. */
  3687. set(x: number, y: number, z: number, w: number): Quaternion;
  3688. /**
  3689. * Adds two quaternions
  3690. * @param other defines the second operand
  3691. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3692. */
  3693. add(other: DeepImmutable<Quaternion>): Quaternion;
  3694. /**
  3695. * Add a quaternion to the current one
  3696. * @param other defines the quaternion to add
  3697. * @returns the current quaternion
  3698. */
  3699. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3700. /**
  3701. * Subtract two quaternions
  3702. * @param other defines the second operand
  3703. * @returns a new quaternion as the subtraction result of the given one from the current one
  3704. */
  3705. subtract(other: Quaternion): Quaternion;
  3706. /**
  3707. * Multiplies the current quaternion by a scale factor
  3708. * @param value defines the scale factor
  3709. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3710. */
  3711. scale(value: number): Quaternion;
  3712. /**
  3713. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3714. * @param scale defines the scale factor
  3715. * @param result defines the Quaternion object where to store the result
  3716. * @returns the unmodified current quaternion
  3717. */
  3718. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3719. /**
  3720. * Multiplies in place the current quaternion by a scale factor
  3721. * @param value defines the scale factor
  3722. * @returns the current modified quaternion
  3723. */
  3724. scaleInPlace(value: number): Quaternion;
  3725. /**
  3726. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3727. * @param scale defines the scale factor
  3728. * @param result defines the Quaternion object where to store the result
  3729. * @returns the unmodified current quaternion
  3730. */
  3731. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3732. /**
  3733. * Multiplies two quaternions
  3734. * @param q1 defines the second operand
  3735. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3736. */
  3737. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3738. /**
  3739. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3740. * @param q1 defines the second operand
  3741. * @param result defines the target quaternion
  3742. * @returns the current quaternion
  3743. */
  3744. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3745. /**
  3746. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3747. * @param q1 defines the second operand
  3748. * @returns the currentupdated quaternion
  3749. */
  3750. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3751. /**
  3752. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3753. * @param ref defines the target quaternion
  3754. * @returns the current quaternion
  3755. */
  3756. conjugateToRef(ref: Quaternion): Quaternion;
  3757. /**
  3758. * Conjugates in place (1-q) the current quaternion
  3759. * @returns the current updated quaternion
  3760. */
  3761. conjugateInPlace(): Quaternion;
  3762. /**
  3763. * Conjugates in place (1-q) the current quaternion
  3764. * @returns a new quaternion
  3765. */
  3766. conjugate(): Quaternion;
  3767. /**
  3768. * Gets length of current quaternion
  3769. * @returns the quaternion length (float)
  3770. */
  3771. length(): number;
  3772. /**
  3773. * Normalize in place the current quaternion
  3774. * @returns the current updated quaternion
  3775. */
  3776. normalize(): Quaternion;
  3777. /**
  3778. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3779. * @param order is a reserved parameter and is ignore for now
  3780. * @returns a new Vector3 containing the Euler angles
  3781. */
  3782. toEulerAngles(order?: string): Vector3;
  3783. /**
  3784. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3785. * @param result defines the vector which will be filled with the Euler angles
  3786. * @param order is a reserved parameter and is ignore for now
  3787. * @returns the current unchanged quaternion
  3788. */
  3789. toEulerAnglesToRef(result: Vector3): Quaternion;
  3790. /**
  3791. * Updates the given rotation matrix with the current quaternion values
  3792. * @param result defines the target matrix
  3793. * @returns the current unchanged quaternion
  3794. */
  3795. toRotationMatrix(result: Matrix): Quaternion;
  3796. /**
  3797. * Updates the current quaternion from the given rotation matrix values
  3798. * @param matrix defines the source matrix
  3799. * @returns the current updated quaternion
  3800. */
  3801. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3802. /**
  3803. * Creates a new quaternion from a rotation matrix
  3804. * @param matrix defines the source matrix
  3805. * @returns a new quaternion created from the given rotation matrix values
  3806. */
  3807. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3808. /**
  3809. * Updates the given quaternion with the given rotation matrix values
  3810. * @param matrix defines the source matrix
  3811. * @param result defines the target quaternion
  3812. */
  3813. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3814. /**
  3815. * Returns the dot product (float) between the quaternions "left" and "right"
  3816. * @param left defines the left operand
  3817. * @param right defines the right operand
  3818. * @returns the dot product
  3819. */
  3820. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3821. /**
  3822. * Checks if the two quaternions are close to each other
  3823. * @param quat0 defines the first quaternion to check
  3824. * @param quat1 defines the second quaternion to check
  3825. * @returns true if the two quaternions are close to each other
  3826. */
  3827. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3828. /**
  3829. * Creates an empty quaternion
  3830. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3831. */
  3832. static Zero(): Quaternion;
  3833. /**
  3834. * Inverse a given quaternion
  3835. * @param q defines the source quaternion
  3836. * @returns a new quaternion as the inverted current quaternion
  3837. */
  3838. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3839. /**
  3840. * Inverse a given quaternion
  3841. * @param q defines the source quaternion
  3842. * @param result the quaternion the result will be stored in
  3843. * @returns the result quaternion
  3844. */
  3845. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3846. /**
  3847. * Creates an identity quaternion
  3848. * @returns the identity quaternion
  3849. */
  3850. static Identity(): Quaternion;
  3851. /**
  3852. * Gets a boolean indicating if the given quaternion is identity
  3853. * @param quaternion defines the quaternion to check
  3854. * @returns true if the quaternion is identity
  3855. */
  3856. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3857. /**
  3858. * Creates a quaternion from a rotation around an axis
  3859. * @param axis defines the axis to use
  3860. * @param angle defines the angle to use
  3861. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3862. */
  3863. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3864. /**
  3865. * Creates a rotation around an axis and stores it into the given quaternion
  3866. * @param axis defines the axis to use
  3867. * @param angle defines the angle to use
  3868. * @param result defines the target quaternion
  3869. * @returns the target quaternion
  3870. */
  3871. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3872. /**
  3873. * Creates a new quaternion from data stored into an array
  3874. * @param array defines the data source
  3875. * @param offset defines the offset in the source array where the data starts
  3876. * @returns a new quaternion
  3877. */
  3878. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3879. /**
  3880. * Updates the given quaternion "result" from the starting index of the given array.
  3881. * @param array the array to pull values from
  3882. * @param offset the offset into the array to start at
  3883. * @param result the quaternion to store the result in
  3884. */
  3885. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3886. /**
  3887. * Create a quaternion from Euler rotation angles
  3888. * @param x Pitch
  3889. * @param y Yaw
  3890. * @param z Roll
  3891. * @returns the new Quaternion
  3892. */
  3893. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3894. /**
  3895. * Updates a quaternion from Euler rotation angles
  3896. * @param x Pitch
  3897. * @param y Yaw
  3898. * @param z Roll
  3899. * @param result the quaternion to store the result
  3900. * @returns the updated quaternion
  3901. */
  3902. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3903. /**
  3904. * Create a quaternion from Euler rotation vector
  3905. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3906. * @returns the new Quaternion
  3907. */
  3908. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3909. /**
  3910. * Updates a quaternion from Euler rotation vector
  3911. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3912. * @param result the quaternion to store the result
  3913. * @returns the updated quaternion
  3914. */
  3915. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3916. /**
  3917. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3918. * @param yaw defines the rotation around Y axis
  3919. * @param pitch defines the rotation around X axis
  3920. * @param roll defines the rotation around Z axis
  3921. * @returns the new quaternion
  3922. */
  3923. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3924. /**
  3925. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3926. * @param yaw defines the rotation around Y axis
  3927. * @param pitch defines the rotation around X axis
  3928. * @param roll defines the rotation around Z axis
  3929. * @param result defines the target quaternion
  3930. */
  3931. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3932. /**
  3933. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3934. * @param alpha defines the rotation around first axis
  3935. * @param beta defines the rotation around second axis
  3936. * @param gamma defines the rotation around third axis
  3937. * @returns the new quaternion
  3938. */
  3939. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3940. /**
  3941. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3942. * @param alpha defines the rotation around first axis
  3943. * @param beta defines the rotation around second axis
  3944. * @param gamma defines the rotation around third axis
  3945. * @param result defines the target quaternion
  3946. */
  3947. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3948. /**
  3949. * 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)
  3950. * @param axis1 defines the first axis
  3951. * @param axis2 defines the second axis
  3952. * @param axis3 defines the third axis
  3953. * @returns the new quaternion
  3954. */
  3955. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3956. /**
  3957. * 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
  3958. * @param axis1 defines the first axis
  3959. * @param axis2 defines the second axis
  3960. * @param axis3 defines the third axis
  3961. * @param ref defines the target quaternion
  3962. */
  3963. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3964. /**
  3965. * Interpolates between two quaternions
  3966. * @param left defines first quaternion
  3967. * @param right defines second quaternion
  3968. * @param amount defines the gradient to use
  3969. * @returns the new interpolated quaternion
  3970. */
  3971. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3972. /**
  3973. * Interpolates between two quaternions and stores it into a target quaternion
  3974. * @param left defines first quaternion
  3975. * @param right defines second quaternion
  3976. * @param amount defines the gradient to use
  3977. * @param result defines the target quaternion
  3978. */
  3979. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3980. /**
  3981. * Interpolate between two quaternions using Hermite interpolation
  3982. * @param value1 defines first quaternion
  3983. * @param tangent1 defines the incoming tangent
  3984. * @param value2 defines second quaternion
  3985. * @param tangent2 defines the outgoing tangent
  3986. * @param amount defines the target quaternion
  3987. * @returns the new interpolated quaternion
  3988. */
  3989. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3990. }
  3991. /**
  3992. * Class used to store matrix data (4x4)
  3993. */
  3994. export class Matrix {
  3995. private static _updateFlagSeed;
  3996. private static _identityReadOnly;
  3997. private _isIdentity;
  3998. private _isIdentityDirty;
  3999. private _isIdentity3x2;
  4000. private _isIdentity3x2Dirty;
  4001. /**
  4002. * Gets the update flag of the matrix which is an unique number for the matrix.
  4003. * It will be incremented every time the matrix data change.
  4004. * You can use it to speed the comparison between two versions of the same matrix.
  4005. */
  4006. updateFlag: number;
  4007. private readonly _m;
  4008. /**
  4009. * Gets the internal data of the matrix
  4010. */
  4011. get m(): DeepImmutable<Float32Array>;
  4012. /** @hidden */
  4013. _markAsUpdated(): void;
  4014. /** @hidden */
  4015. private _updateIdentityStatus;
  4016. /**
  4017. * Creates an empty matrix (filled with zeros)
  4018. */
  4019. constructor();
  4020. /**
  4021. * Check if the current matrix is identity
  4022. * @returns true is the matrix is the identity matrix
  4023. */
  4024. isIdentity(): boolean;
  4025. /**
  4026. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4027. * @returns true is the matrix is the identity matrix
  4028. */
  4029. isIdentityAs3x2(): boolean;
  4030. /**
  4031. * Gets the determinant of the matrix
  4032. * @returns the matrix determinant
  4033. */
  4034. determinant(): number;
  4035. /**
  4036. * Returns the matrix as a Float32Array
  4037. * @returns the matrix underlying array
  4038. */
  4039. toArray(): DeepImmutable<Float32Array>;
  4040. /**
  4041. * Returns the matrix as a Float32Array
  4042. * @returns the matrix underlying array.
  4043. */
  4044. asArray(): DeepImmutable<Float32Array>;
  4045. /**
  4046. * Inverts the current matrix in place
  4047. * @returns the current inverted matrix
  4048. */
  4049. invert(): Matrix;
  4050. /**
  4051. * Sets all the matrix elements to zero
  4052. * @returns the current matrix
  4053. */
  4054. reset(): Matrix;
  4055. /**
  4056. * Adds the current matrix with a second one
  4057. * @param other defines the matrix to add
  4058. * @returns a new matrix as the addition of the current matrix and the given one
  4059. */
  4060. add(other: DeepImmutable<Matrix>): Matrix;
  4061. /**
  4062. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4063. * @param other defines the matrix to add
  4064. * @param result defines the target matrix
  4065. * @returns the current matrix
  4066. */
  4067. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4068. /**
  4069. * Adds in place the given matrix to the current matrix
  4070. * @param other defines the second operand
  4071. * @returns the current updated matrix
  4072. */
  4073. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4074. /**
  4075. * Sets the given matrix to the current inverted Matrix
  4076. * @param other defines the target matrix
  4077. * @returns the unmodified current matrix
  4078. */
  4079. invertToRef(other: Matrix): Matrix;
  4080. /**
  4081. * add a value at the specified position in the current Matrix
  4082. * @param index the index of the value within the matrix. between 0 and 15.
  4083. * @param value the value to be added
  4084. * @returns the current updated matrix
  4085. */
  4086. addAtIndex(index: number, value: number): Matrix;
  4087. /**
  4088. * mutiply the specified position in the current Matrix by a value
  4089. * @param index the index of the value within the matrix. between 0 and 15.
  4090. * @param value the value to be added
  4091. * @returns the current updated matrix
  4092. */
  4093. multiplyAtIndex(index: number, value: number): Matrix;
  4094. /**
  4095. * Inserts the translation vector (using 3 floats) in the current matrix
  4096. * @param x defines the 1st component of the translation
  4097. * @param y defines the 2nd component of the translation
  4098. * @param z defines the 3rd component of the translation
  4099. * @returns the current updated matrix
  4100. */
  4101. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4102. /**
  4103. * Adds the translation vector (using 3 floats) in the current matrix
  4104. * @param x defines the 1st component of the translation
  4105. * @param y defines the 2nd component of the translation
  4106. * @param z defines the 3rd component of the translation
  4107. * @returns the current updated matrix
  4108. */
  4109. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4110. /**
  4111. * Inserts the translation vector in the current matrix
  4112. * @param vector3 defines the translation to insert
  4113. * @returns the current updated matrix
  4114. */
  4115. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4116. /**
  4117. * Gets the translation value of the current matrix
  4118. * @returns a new Vector3 as the extracted translation from the matrix
  4119. */
  4120. getTranslation(): Vector3;
  4121. /**
  4122. * Fill a Vector3 with the extracted translation from the matrix
  4123. * @param result defines the Vector3 where to store the translation
  4124. * @returns the current matrix
  4125. */
  4126. getTranslationToRef(result: Vector3): Matrix;
  4127. /**
  4128. * Remove rotation and scaling part from the matrix
  4129. * @returns the updated matrix
  4130. */
  4131. removeRotationAndScaling(): Matrix;
  4132. /**
  4133. * Multiply two matrices
  4134. * @param other defines the second operand
  4135. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4136. */
  4137. multiply(other: DeepImmutable<Matrix>): Matrix;
  4138. /**
  4139. * Copy the current matrix from the given one
  4140. * @param other defines the source matrix
  4141. * @returns the current updated matrix
  4142. */
  4143. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4144. /**
  4145. * Populates the given array from the starting index with the current matrix values
  4146. * @param array defines the target array
  4147. * @param offset defines the offset in the target array where to start storing values
  4148. * @returns the current matrix
  4149. */
  4150. copyToArray(array: Float32Array, offset?: number): Matrix;
  4151. /**
  4152. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4153. * @param other defines the second operand
  4154. * @param result defines the matrix where to store the multiplication
  4155. * @returns the current matrix
  4156. */
  4157. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4158. /**
  4159. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4160. * @param other defines the second operand
  4161. * @param result defines the array where to store the multiplication
  4162. * @param offset defines the offset in the target array where to start storing values
  4163. * @returns the current matrix
  4164. */
  4165. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4166. /**
  4167. * Check equality between this matrix and a second one
  4168. * @param value defines the second matrix to compare
  4169. * @returns true is the current matrix and the given one values are strictly equal
  4170. */
  4171. equals(value: DeepImmutable<Matrix>): boolean;
  4172. /**
  4173. * Clone the current matrix
  4174. * @returns a new matrix from the current matrix
  4175. */
  4176. clone(): Matrix;
  4177. /**
  4178. * Returns the name of the current matrix class
  4179. * @returns the string "Matrix"
  4180. */
  4181. getClassName(): string;
  4182. /**
  4183. * Gets the hash code of the current matrix
  4184. * @returns the hash code
  4185. */
  4186. getHashCode(): number;
  4187. /**
  4188. * Decomposes the current Matrix into a translation, rotation and scaling components
  4189. * @param scale defines the scale vector3 given as a reference to update
  4190. * @param rotation defines the rotation quaternion given as a reference to update
  4191. * @param translation defines the translation vector3 given as a reference to update
  4192. * @returns true if operation was successful
  4193. */
  4194. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4195. /**
  4196. * Gets specific row of the matrix
  4197. * @param index defines the number of the row to get
  4198. * @returns the index-th row of the current matrix as a new Vector4
  4199. */
  4200. getRow(index: number): Nullable<Vector4>;
  4201. /**
  4202. * Sets the index-th row of the current matrix to the vector4 values
  4203. * @param index defines the number of the row to set
  4204. * @param row defines the target vector4
  4205. * @returns the updated current matrix
  4206. */
  4207. setRow(index: number, row: Vector4): Matrix;
  4208. /**
  4209. * Compute the transpose of the matrix
  4210. * @returns the new transposed matrix
  4211. */
  4212. transpose(): Matrix;
  4213. /**
  4214. * Compute the transpose of the matrix and store it in a given matrix
  4215. * @param result defines the target matrix
  4216. * @returns the current matrix
  4217. */
  4218. transposeToRef(result: Matrix): Matrix;
  4219. /**
  4220. * Sets the index-th row of the current matrix with the given 4 x float values
  4221. * @param index defines the row index
  4222. * @param x defines the x component to set
  4223. * @param y defines the y component to set
  4224. * @param z defines the z component to set
  4225. * @param w defines the w component to set
  4226. * @returns the updated current matrix
  4227. */
  4228. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4229. /**
  4230. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4231. * @param scale defines the scale factor
  4232. * @returns a new matrix
  4233. */
  4234. scale(scale: number): Matrix;
  4235. /**
  4236. * Scale the current matrix values by a factor to a given result matrix
  4237. * @param scale defines the scale factor
  4238. * @param result defines the matrix to store the result
  4239. * @returns the current matrix
  4240. */
  4241. scaleToRef(scale: number, result: Matrix): Matrix;
  4242. /**
  4243. * Scale the current matrix values by a factor and add the result to a given matrix
  4244. * @param scale defines the scale factor
  4245. * @param result defines the Matrix to store the result
  4246. * @returns the current matrix
  4247. */
  4248. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4249. /**
  4250. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4251. * @param ref matrix to store the result
  4252. */
  4253. toNormalMatrix(ref: Matrix): void;
  4254. /**
  4255. * Gets only rotation part of the current matrix
  4256. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4257. */
  4258. getRotationMatrix(): Matrix;
  4259. /**
  4260. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4261. * @param result defines the target matrix to store data to
  4262. * @returns the current matrix
  4263. */
  4264. getRotationMatrixToRef(result: Matrix): Matrix;
  4265. /**
  4266. * Toggles model matrix from being right handed to left handed in place and vice versa
  4267. */
  4268. toggleModelMatrixHandInPlace(): void;
  4269. /**
  4270. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4271. */
  4272. toggleProjectionMatrixHandInPlace(): void;
  4273. /**
  4274. * Creates a matrix from an array
  4275. * @param array defines the source array
  4276. * @param offset defines an offset in the source array
  4277. * @returns a new Matrix set from the starting index of the given array
  4278. */
  4279. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4280. /**
  4281. * Copy the content of an array into a given matrix
  4282. * @param array defines the source array
  4283. * @param offset defines an offset in the source array
  4284. * @param result defines the target matrix
  4285. */
  4286. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4287. /**
  4288. * Stores an array into a matrix after having multiplied each component by a given factor
  4289. * @param array defines the source array
  4290. * @param offset defines the offset in the source array
  4291. * @param scale defines the scaling factor
  4292. * @param result defines the target matrix
  4293. */
  4294. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4295. /**
  4296. * Gets an identity matrix that must not be updated
  4297. */
  4298. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4299. /**
  4300. * Stores a list of values (16) inside a given matrix
  4301. * @param initialM11 defines 1st value of 1st row
  4302. * @param initialM12 defines 2nd value of 1st row
  4303. * @param initialM13 defines 3rd value of 1st row
  4304. * @param initialM14 defines 4th value of 1st row
  4305. * @param initialM21 defines 1st value of 2nd row
  4306. * @param initialM22 defines 2nd value of 2nd row
  4307. * @param initialM23 defines 3rd value of 2nd row
  4308. * @param initialM24 defines 4th value of 2nd row
  4309. * @param initialM31 defines 1st value of 3rd row
  4310. * @param initialM32 defines 2nd value of 3rd row
  4311. * @param initialM33 defines 3rd value of 3rd row
  4312. * @param initialM34 defines 4th value of 3rd row
  4313. * @param initialM41 defines 1st value of 4th row
  4314. * @param initialM42 defines 2nd value of 4th row
  4315. * @param initialM43 defines 3rd value of 4th row
  4316. * @param initialM44 defines 4th value of 4th row
  4317. * @param result defines the target matrix
  4318. */
  4319. 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;
  4320. /**
  4321. * Creates new matrix from a list of values (16)
  4322. * @param initialM11 defines 1st value of 1st row
  4323. * @param initialM12 defines 2nd value of 1st row
  4324. * @param initialM13 defines 3rd value of 1st row
  4325. * @param initialM14 defines 4th value of 1st row
  4326. * @param initialM21 defines 1st value of 2nd row
  4327. * @param initialM22 defines 2nd value of 2nd row
  4328. * @param initialM23 defines 3rd value of 2nd row
  4329. * @param initialM24 defines 4th value of 2nd row
  4330. * @param initialM31 defines 1st value of 3rd row
  4331. * @param initialM32 defines 2nd value of 3rd row
  4332. * @param initialM33 defines 3rd value of 3rd row
  4333. * @param initialM34 defines 4th value of 3rd row
  4334. * @param initialM41 defines 1st value of 4th row
  4335. * @param initialM42 defines 2nd value of 4th row
  4336. * @param initialM43 defines 3rd value of 4th row
  4337. * @param initialM44 defines 4th value of 4th row
  4338. * @returns the new matrix
  4339. */
  4340. 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;
  4341. /**
  4342. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4343. * @param scale defines the scale vector3
  4344. * @param rotation defines the rotation quaternion
  4345. * @param translation defines the translation vector3
  4346. * @returns a new matrix
  4347. */
  4348. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4349. /**
  4350. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4351. * @param scale defines the scale vector3
  4352. * @param rotation defines the rotation quaternion
  4353. * @param translation defines the translation vector3
  4354. * @param result defines the target matrix
  4355. */
  4356. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4357. /**
  4358. * Creates a new identity matrix
  4359. * @returns a new identity matrix
  4360. */
  4361. static Identity(): Matrix;
  4362. /**
  4363. * Creates a new identity matrix and stores the result in a given matrix
  4364. * @param result defines the target matrix
  4365. */
  4366. static IdentityToRef(result: Matrix): void;
  4367. /**
  4368. * Creates a new zero matrix
  4369. * @returns a new zero matrix
  4370. */
  4371. static Zero(): Matrix;
  4372. /**
  4373. * Creates a new rotation matrix for "angle" radians around the X axis
  4374. * @param angle defines the angle (in radians) to use
  4375. * @return the new matrix
  4376. */
  4377. static RotationX(angle: number): Matrix;
  4378. /**
  4379. * Creates a new matrix as the invert of a given matrix
  4380. * @param source defines the source matrix
  4381. * @returns the new matrix
  4382. */
  4383. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4384. /**
  4385. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4386. * @param angle defines the angle (in radians) to use
  4387. * @param result defines the target matrix
  4388. */
  4389. static RotationXToRef(angle: number, result: Matrix): void;
  4390. /**
  4391. * Creates a new rotation matrix for "angle" radians around the Y axis
  4392. * @param angle defines the angle (in radians) to use
  4393. * @return the new matrix
  4394. */
  4395. static RotationY(angle: number): Matrix;
  4396. /**
  4397. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4398. * @param angle defines the angle (in radians) to use
  4399. * @param result defines the target matrix
  4400. */
  4401. static RotationYToRef(angle: number, result: Matrix): void;
  4402. /**
  4403. * Creates a new rotation matrix for "angle" radians around the Z axis
  4404. * @param angle defines the angle (in radians) to use
  4405. * @return the new matrix
  4406. */
  4407. static RotationZ(angle: number): Matrix;
  4408. /**
  4409. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4410. * @param angle defines the angle (in radians) to use
  4411. * @param result defines the target matrix
  4412. */
  4413. static RotationZToRef(angle: number, result: Matrix): void;
  4414. /**
  4415. * Creates a new rotation matrix for "angle" radians around the given axis
  4416. * @param axis defines the axis to use
  4417. * @param angle defines the angle (in radians) to use
  4418. * @return the new matrix
  4419. */
  4420. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4421. /**
  4422. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4423. * @param axis defines the axis to use
  4424. * @param angle defines the angle (in radians) to use
  4425. * @param result defines the target matrix
  4426. */
  4427. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4428. /**
  4429. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4430. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4431. * @param from defines the vector to align
  4432. * @param to defines the vector to align to
  4433. * @param result defines the target matrix
  4434. */
  4435. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4436. /**
  4437. * Creates a rotation matrix
  4438. * @param yaw defines the yaw angle in radians (Y axis)
  4439. * @param pitch defines the pitch angle in radians (X axis)
  4440. * @param roll defines the roll angle in radians (X axis)
  4441. * @returns the new rotation matrix
  4442. */
  4443. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4444. /**
  4445. * Creates a rotation matrix and stores it in a given matrix
  4446. * @param yaw defines the yaw angle in radians (Y axis)
  4447. * @param pitch defines the pitch angle in radians (X axis)
  4448. * @param roll defines the roll angle in radians (X axis)
  4449. * @param result defines the target matrix
  4450. */
  4451. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4452. /**
  4453. * Creates a scaling matrix
  4454. * @param x defines the scale factor on X axis
  4455. * @param y defines the scale factor on Y axis
  4456. * @param z defines the scale factor on Z axis
  4457. * @returns the new matrix
  4458. */
  4459. static Scaling(x: number, y: number, z: number): Matrix;
  4460. /**
  4461. * Creates a scaling matrix and stores it in a given matrix
  4462. * @param x defines the scale factor on X axis
  4463. * @param y defines the scale factor on Y axis
  4464. * @param z defines the scale factor on Z axis
  4465. * @param result defines the target matrix
  4466. */
  4467. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4468. /**
  4469. * Creates a translation matrix
  4470. * @param x defines the translation on X axis
  4471. * @param y defines the translation on Y axis
  4472. * @param z defines the translationon Z axis
  4473. * @returns the new matrix
  4474. */
  4475. static Translation(x: number, y: number, z: number): Matrix;
  4476. /**
  4477. * Creates a translation matrix and stores it in a given matrix
  4478. * @param x defines the translation on X axis
  4479. * @param y defines the translation on Y axis
  4480. * @param z defines the translationon Z axis
  4481. * @param result defines the target matrix
  4482. */
  4483. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4484. /**
  4485. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4486. * @param startValue defines the start value
  4487. * @param endValue defines the end value
  4488. * @param gradient defines the gradient factor
  4489. * @returns the new matrix
  4490. */
  4491. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4492. /**
  4493. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4494. * @param startValue defines the start value
  4495. * @param endValue defines the end value
  4496. * @param gradient defines the gradient factor
  4497. * @param result defines the Matrix object where to store data
  4498. */
  4499. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4500. /**
  4501. * Builds a new matrix whose values are computed by:
  4502. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4503. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4504. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4505. * @param startValue defines the first matrix
  4506. * @param endValue defines the second matrix
  4507. * @param gradient defines the gradient between the two matrices
  4508. * @returns the new matrix
  4509. */
  4510. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4511. /**
  4512. * Update a matrix to values which are computed by:
  4513. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4514. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4515. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4516. * @param startValue defines the first matrix
  4517. * @param endValue defines the second matrix
  4518. * @param gradient defines the gradient between the two matrices
  4519. * @param result defines the target matrix
  4520. */
  4521. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4522. /**
  4523. * 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"
  4524. * This function works in left handed mode
  4525. * @param eye defines the final position of the entity
  4526. * @param target defines where the entity should look at
  4527. * @param up defines the up vector for the entity
  4528. * @returns the new matrix
  4529. */
  4530. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4531. /**
  4532. * 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".
  4533. * This function works in left handed mode
  4534. * @param eye defines the final position of the entity
  4535. * @param target defines where the entity should look at
  4536. * @param up defines the up vector for the entity
  4537. * @param result defines the target matrix
  4538. */
  4539. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4540. /**
  4541. * 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"
  4542. * This function works in right handed mode
  4543. * @param eye defines the final position of the entity
  4544. * @param target defines where the entity should look at
  4545. * @param up defines the up vector for the entity
  4546. * @returns the new matrix
  4547. */
  4548. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4549. /**
  4550. * 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".
  4551. * This function works in right handed mode
  4552. * @param eye defines the final position of the entity
  4553. * @param target defines where the entity should look at
  4554. * @param up defines the up vector for the entity
  4555. * @param result defines the target matrix
  4556. */
  4557. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4558. /**
  4559. * Create a left-handed orthographic projection matrix
  4560. * @param width defines the viewport width
  4561. * @param height defines the viewport height
  4562. * @param znear defines the near clip plane
  4563. * @param zfar defines the far clip plane
  4564. * @returns a new matrix as a left-handed orthographic projection matrix
  4565. */
  4566. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4567. /**
  4568. * Store a left-handed orthographic projection to a given matrix
  4569. * @param width defines the viewport width
  4570. * @param height defines the viewport height
  4571. * @param znear defines the near clip plane
  4572. * @param zfar defines the far clip plane
  4573. * @param result defines the target matrix
  4574. */
  4575. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4576. /**
  4577. * Create a left-handed orthographic projection matrix
  4578. * @param left defines the viewport left coordinate
  4579. * @param right defines the viewport right coordinate
  4580. * @param bottom defines the viewport bottom coordinate
  4581. * @param top defines the viewport top coordinate
  4582. * @param znear defines the near clip plane
  4583. * @param zfar defines the far clip plane
  4584. * @returns a new matrix as a left-handed orthographic projection matrix
  4585. */
  4586. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4587. /**
  4588. * Stores a left-handed orthographic projection into a given matrix
  4589. * @param left defines the viewport left coordinate
  4590. * @param right defines the viewport right coordinate
  4591. * @param bottom defines the viewport bottom coordinate
  4592. * @param top defines the viewport top coordinate
  4593. * @param znear defines the near clip plane
  4594. * @param zfar defines the far clip plane
  4595. * @param result defines the target matrix
  4596. */
  4597. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4598. /**
  4599. * Creates a right-handed orthographic projection matrix
  4600. * @param left defines the viewport left coordinate
  4601. * @param right defines the viewport right coordinate
  4602. * @param bottom defines the viewport bottom coordinate
  4603. * @param top defines the viewport top coordinate
  4604. * @param znear defines the near clip plane
  4605. * @param zfar defines the far clip plane
  4606. * @returns a new matrix as a right-handed orthographic projection matrix
  4607. */
  4608. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4609. /**
  4610. * Stores a right-handed orthographic projection into a given matrix
  4611. * @param left defines the viewport left coordinate
  4612. * @param right defines the viewport right coordinate
  4613. * @param bottom defines the viewport bottom coordinate
  4614. * @param top defines the viewport top coordinate
  4615. * @param znear defines the near clip plane
  4616. * @param zfar defines the far clip plane
  4617. * @param result defines the target matrix
  4618. */
  4619. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4620. /**
  4621. * Creates a left-handed perspective projection matrix
  4622. * @param width defines the viewport width
  4623. * @param height defines the viewport height
  4624. * @param znear defines the near clip plane
  4625. * @param zfar defines the far clip plane
  4626. * @returns a new matrix as a left-handed perspective projection matrix
  4627. */
  4628. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4629. /**
  4630. * Creates a left-handed perspective projection matrix
  4631. * @param fov defines the horizontal field of view
  4632. * @param aspect defines the aspect ratio
  4633. * @param znear defines the near clip plane
  4634. * @param zfar defines the far clip plane
  4635. * @returns a new matrix as a left-handed perspective projection matrix
  4636. */
  4637. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4638. /**
  4639. * Stores a left-handed perspective projection into a given matrix
  4640. * @param fov defines the horizontal field of view
  4641. * @param aspect defines the aspect ratio
  4642. * @param znear defines the near clip plane
  4643. * @param zfar defines the far clip plane
  4644. * @param result defines the target matrix
  4645. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4646. */
  4647. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4648. /**
  4649. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4650. * @param fov defines the horizontal field of view
  4651. * @param aspect defines the aspect ratio
  4652. * @param znear defines the near clip plane
  4653. * @param zfar not used as infinity is used as far clip
  4654. * @param result defines the target matrix
  4655. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4656. */
  4657. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4658. /**
  4659. * Creates a right-handed perspective projection matrix
  4660. * @param fov defines the horizontal field of view
  4661. * @param aspect defines the aspect ratio
  4662. * @param znear defines the near clip plane
  4663. * @param zfar defines the far clip plane
  4664. * @returns a new matrix as a right-handed perspective projection matrix
  4665. */
  4666. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4667. /**
  4668. * Stores a right-handed perspective projection into a given matrix
  4669. * @param fov defines the horizontal field of view
  4670. * @param aspect defines the aspect ratio
  4671. * @param znear defines the near clip plane
  4672. * @param zfar defines the far clip plane
  4673. * @param result defines the target matrix
  4674. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4675. */
  4676. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4677. /**
  4678. * Stores a right-handed perspective projection into a given matrix
  4679. * @param fov defines the horizontal field of view
  4680. * @param aspect defines the aspect ratio
  4681. * @param znear defines the near clip plane
  4682. * @param zfar not used as infinity is used as far clip
  4683. * @param result defines the target matrix
  4684. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4685. */
  4686. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4687. /**
  4688. * Stores a perspective projection for WebVR info a given matrix
  4689. * @param fov defines the field of view
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @param result defines the target matrix
  4693. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4694. */
  4695. static PerspectiveFovWebVRToRef(fov: {
  4696. upDegrees: number;
  4697. downDegrees: number;
  4698. leftDegrees: number;
  4699. rightDegrees: number;
  4700. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4701. /**
  4702. * Computes a complete transformation matrix
  4703. * @param viewport defines the viewport to use
  4704. * @param world defines the world matrix
  4705. * @param view defines the view matrix
  4706. * @param projection defines the projection matrix
  4707. * @param zmin defines the near clip plane
  4708. * @param zmax defines the far clip plane
  4709. * @returns the transformation matrix
  4710. */
  4711. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4712. /**
  4713. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4714. * @param matrix defines the matrix to use
  4715. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4716. */
  4717. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4718. /**
  4719. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4720. * @param matrix defines the matrix to use
  4721. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4722. */
  4723. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4724. /**
  4725. * Compute the transpose of a given matrix
  4726. * @param matrix defines the matrix to transpose
  4727. * @returns the new matrix
  4728. */
  4729. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4730. /**
  4731. * Compute the transpose of a matrix and store it in a target matrix
  4732. * @param matrix defines the matrix to transpose
  4733. * @param result defines the target matrix
  4734. */
  4735. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4736. /**
  4737. * Computes a reflection matrix from a plane
  4738. * @param plane defines the reflection plane
  4739. * @returns a new matrix
  4740. */
  4741. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4742. /**
  4743. * Computes a reflection matrix from a plane
  4744. * @param plane defines the reflection plane
  4745. * @param result defines the target matrix
  4746. */
  4747. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4748. /**
  4749. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4750. * @param xaxis defines the value of the 1st axis
  4751. * @param yaxis defines the value of the 2nd axis
  4752. * @param zaxis defines the value of the 3rd axis
  4753. * @param result defines the target matrix
  4754. */
  4755. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4756. /**
  4757. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4758. * @param quat defines the quaternion to use
  4759. * @param result defines the target matrix
  4760. */
  4761. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4762. }
  4763. /**
  4764. * @hidden
  4765. */
  4766. export class TmpVectors {
  4767. static Vector2: Vector2[];
  4768. static Vector3: Vector3[];
  4769. static Vector4: Vector4[];
  4770. static Quaternion: Quaternion[];
  4771. static Matrix: Matrix[];
  4772. }
  4773. }
  4774. declare module BABYLON {
  4775. /**
  4776. * Defines potential orientation for back face culling
  4777. */
  4778. export enum Orientation {
  4779. /**
  4780. * Clockwise
  4781. */
  4782. CW = 0,
  4783. /** Counter clockwise */
  4784. CCW = 1
  4785. }
  4786. /** Class used to represent a Bezier curve */
  4787. export class BezierCurve {
  4788. /**
  4789. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4790. * @param t defines the time
  4791. * @param x1 defines the left coordinate on X axis
  4792. * @param y1 defines the left coordinate on Y axis
  4793. * @param x2 defines the right coordinate on X axis
  4794. * @param y2 defines the right coordinate on Y axis
  4795. * @returns the interpolated value
  4796. */
  4797. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4798. }
  4799. /**
  4800. * Defines angle representation
  4801. */
  4802. export class Angle {
  4803. private _radians;
  4804. /**
  4805. * Creates an Angle object of "radians" radians (float).
  4806. * @param radians the angle in radians
  4807. */
  4808. constructor(radians: number);
  4809. /**
  4810. * Get value in degrees
  4811. * @returns the Angle value in degrees (float)
  4812. */
  4813. degrees(): number;
  4814. /**
  4815. * Get value in radians
  4816. * @returns the Angle value in radians (float)
  4817. */
  4818. radians(): number;
  4819. /**
  4820. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4821. * @param a defines first vector
  4822. * @param b defines second vector
  4823. * @returns a new Angle
  4824. */
  4825. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4826. /**
  4827. * Gets a new Angle object from the given float in radians
  4828. * @param radians defines the angle value in radians
  4829. * @returns a new Angle
  4830. */
  4831. static FromRadians(radians: number): Angle;
  4832. /**
  4833. * Gets a new Angle object from the given float in degrees
  4834. * @param degrees defines the angle value in degrees
  4835. * @returns a new Angle
  4836. */
  4837. static FromDegrees(degrees: number): Angle;
  4838. }
  4839. /**
  4840. * This represents an arc in a 2d space.
  4841. */
  4842. export class Arc2 {
  4843. /** Defines the start point of the arc */
  4844. startPoint: Vector2;
  4845. /** Defines the mid point of the arc */
  4846. midPoint: Vector2;
  4847. /** Defines the end point of the arc */
  4848. endPoint: Vector2;
  4849. /**
  4850. * Defines the center point of the arc.
  4851. */
  4852. centerPoint: Vector2;
  4853. /**
  4854. * Defines the radius of the arc.
  4855. */
  4856. radius: number;
  4857. /**
  4858. * Defines the angle of the arc (from mid point to end point).
  4859. */
  4860. angle: Angle;
  4861. /**
  4862. * Defines the start angle of the arc (from start point to middle point).
  4863. */
  4864. startAngle: Angle;
  4865. /**
  4866. * Defines the orientation of the arc (clock wise/counter clock wise).
  4867. */
  4868. orientation: Orientation;
  4869. /**
  4870. * Creates an Arc object from the three given points : start, middle and end.
  4871. * @param startPoint Defines the start point of the arc
  4872. * @param midPoint Defines the midlle point of the arc
  4873. * @param endPoint Defines the end point of the arc
  4874. */
  4875. constructor(
  4876. /** Defines the start point of the arc */
  4877. startPoint: Vector2,
  4878. /** Defines the mid point of the arc */
  4879. midPoint: Vector2,
  4880. /** Defines the end point of the arc */
  4881. endPoint: Vector2);
  4882. }
  4883. /**
  4884. * Represents a 2D path made up of multiple 2D points
  4885. */
  4886. export class Path2 {
  4887. private _points;
  4888. private _length;
  4889. /**
  4890. * If the path start and end point are the same
  4891. */
  4892. closed: boolean;
  4893. /**
  4894. * Creates a Path2 object from the starting 2D coordinates x and y.
  4895. * @param x the starting points x value
  4896. * @param y the starting points y value
  4897. */
  4898. constructor(x: number, y: number);
  4899. /**
  4900. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4901. * @param x the added points x value
  4902. * @param y the added points y value
  4903. * @returns the updated Path2.
  4904. */
  4905. addLineTo(x: number, y: number): Path2;
  4906. /**
  4907. * 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.
  4908. * @param midX middle point x value
  4909. * @param midY middle point y value
  4910. * @param endX end point x value
  4911. * @param endY end point y value
  4912. * @param numberOfSegments (default: 36)
  4913. * @returns the updated Path2.
  4914. */
  4915. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4916. /**
  4917. * Closes the Path2.
  4918. * @returns the Path2.
  4919. */
  4920. close(): Path2;
  4921. /**
  4922. * Gets the sum of the distance between each sequential point in the path
  4923. * @returns the Path2 total length (float).
  4924. */
  4925. length(): number;
  4926. /**
  4927. * Gets the points which construct the path
  4928. * @returns the Path2 internal array of points.
  4929. */
  4930. getPoints(): Vector2[];
  4931. /**
  4932. * Retreives the point at the distance aways from the starting point
  4933. * @param normalizedLengthPosition the length along the path to retreive the point from
  4934. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4935. */
  4936. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4937. /**
  4938. * Creates a new path starting from an x and y position
  4939. * @param x starting x value
  4940. * @param y starting y value
  4941. * @returns a new Path2 starting at the coordinates (x, y).
  4942. */
  4943. static StartingAt(x: number, y: number): Path2;
  4944. }
  4945. /**
  4946. * Represents a 3D path made up of multiple 3D points
  4947. */
  4948. export class Path3D {
  4949. /**
  4950. * an array of Vector3, the curve axis of the Path3D
  4951. */
  4952. path: Vector3[];
  4953. private _curve;
  4954. private _distances;
  4955. private _tangents;
  4956. private _normals;
  4957. private _binormals;
  4958. private _raw;
  4959. private _alignTangentsWithPath;
  4960. private readonly _pointAtData;
  4961. /**
  4962. * new Path3D(path, normal, raw)
  4963. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4964. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4965. * @param path an array of Vector3, the curve axis of the Path3D
  4966. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4967. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4968. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4969. */
  4970. constructor(
  4971. /**
  4972. * an array of Vector3, the curve axis of the Path3D
  4973. */
  4974. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4975. /**
  4976. * Returns the Path3D array of successive Vector3 designing its curve.
  4977. * @returns the Path3D array of successive Vector3 designing its curve.
  4978. */
  4979. getCurve(): Vector3[];
  4980. /**
  4981. * Returns the Path3D array of successive Vector3 designing its curve.
  4982. * @returns the Path3D array of successive Vector3 designing its curve.
  4983. */
  4984. getPoints(): Vector3[];
  4985. /**
  4986. * @returns the computed length (float) of the path.
  4987. */
  4988. length(): number;
  4989. /**
  4990. * Returns an array populated with tangent vectors on each Path3D curve point.
  4991. * @returns an array populated with tangent vectors on each Path3D curve point.
  4992. */
  4993. getTangents(): Vector3[];
  4994. /**
  4995. * Returns an array populated with normal vectors on each Path3D curve point.
  4996. * @returns an array populated with normal vectors on each Path3D curve point.
  4997. */
  4998. getNormals(): Vector3[];
  4999. /**
  5000. * Returns an array populated with binormal vectors on each Path3D curve point.
  5001. * @returns an array populated with binormal vectors on each Path3D curve point.
  5002. */
  5003. getBinormals(): Vector3[];
  5004. /**
  5005. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5006. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5007. */
  5008. getDistances(): number[];
  5009. /**
  5010. * Returns an interpolated point along this path
  5011. * @param position the position of the point along this path, from 0.0 to 1.0
  5012. * @returns a new Vector3 as the point
  5013. */
  5014. getPointAt(position: number): Vector3;
  5015. /**
  5016. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5017. * @param position the position of the point along this path, from 0.0 to 1.0
  5018. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5019. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5020. */
  5021. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5022. /**
  5023. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5024. * @param position the position of the point along this path, from 0.0 to 1.0
  5025. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5026. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5027. */
  5028. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5029. /**
  5030. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5031. * @param position the position of the point along this path, from 0.0 to 1.0
  5032. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5033. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5034. */
  5035. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5036. /**
  5037. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5038. * @param position the position of the point along this path, from 0.0 to 1.0
  5039. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5040. */
  5041. getDistanceAt(position: number): number;
  5042. /**
  5043. * Returns the array index of the previous point of an interpolated point along this path
  5044. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5045. * @returns the array index
  5046. */
  5047. getPreviousPointIndexAt(position: number): number;
  5048. /**
  5049. * 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)
  5050. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5051. * @returns the sub position
  5052. */
  5053. getSubPositionAt(position: number): number;
  5054. /**
  5055. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5056. * @param target the vector of which to get the closest position to
  5057. * @returns the position of the closest virtual point on this path to the target vector
  5058. */
  5059. getClosestPositionTo(target: Vector3): number;
  5060. /**
  5061. * Returns a sub path (slice) of this path
  5062. * @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
  5063. * @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
  5064. * @returns a sub path (slice) of this path
  5065. */
  5066. slice(start?: number, end?: number): Path3D;
  5067. /**
  5068. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5069. * @param path path which all values are copied into the curves points
  5070. * @param firstNormal which should be projected onto the curve
  5071. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5072. * @returns the same object updated.
  5073. */
  5074. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5075. private _compute;
  5076. private _getFirstNonNullVector;
  5077. private _getLastNonNullVector;
  5078. private _normalVector;
  5079. /**
  5080. * Updates the point at data for an interpolated point along this curve
  5081. * @param position the position of the point along this curve, from 0.0 to 1.0
  5082. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5083. * @returns the (updated) point at data
  5084. */
  5085. private _updatePointAtData;
  5086. /**
  5087. * Updates the point at data from the specified parameters
  5088. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5089. * @param point the interpolated point
  5090. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5091. */
  5092. private _setPointAtData;
  5093. /**
  5094. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5095. */
  5096. private _updateInterpolationMatrix;
  5097. }
  5098. /**
  5099. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5100. * A Curve3 is designed from a series of successive Vector3.
  5101. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5102. */
  5103. export class Curve3 {
  5104. private _points;
  5105. private _length;
  5106. /**
  5107. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5108. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5109. * @param v1 (Vector3) the control point
  5110. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5111. * @param nbPoints (integer) the wanted number of points in the curve
  5112. * @returns the created Curve3
  5113. */
  5114. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5115. /**
  5116. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5117. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5118. * @param v1 (Vector3) the first control point
  5119. * @param v2 (Vector3) the second control point
  5120. * @param v3 (Vector3) the end point of the Cubic Bezier
  5121. * @param nbPoints (integer) the wanted number of points in the curve
  5122. * @returns the created Curve3
  5123. */
  5124. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5125. /**
  5126. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5127. * @param p1 (Vector3) the origin point of the Hermite Spline
  5128. * @param t1 (Vector3) the tangent vector at the origin point
  5129. * @param p2 (Vector3) the end point of the Hermite Spline
  5130. * @param t2 (Vector3) the tangent vector at the end point
  5131. * @param nbPoints (integer) the wanted number of points in the curve
  5132. * @returns the created Curve3
  5133. */
  5134. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5135. /**
  5136. * Returns a Curve3 object along a CatmullRom Spline curve :
  5137. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5138. * @param nbPoints (integer) the wanted number of points between each curve control points
  5139. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5140. * @returns the created Curve3
  5141. */
  5142. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5143. /**
  5144. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5145. * A Curve3 is designed from a series of successive Vector3.
  5146. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5147. * @param points points which make up the curve
  5148. */
  5149. constructor(points: Vector3[]);
  5150. /**
  5151. * @returns the Curve3 stored array of successive Vector3
  5152. */
  5153. getPoints(): Vector3[];
  5154. /**
  5155. * @returns the computed length (float) of the curve.
  5156. */
  5157. length(): number;
  5158. /**
  5159. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5160. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5161. * curveA and curveB keep unchanged.
  5162. * @param curve the curve to continue from this curve
  5163. * @returns the newly constructed curve
  5164. */
  5165. continue(curve: DeepImmutable<Curve3>): Curve3;
  5166. private _computeLength;
  5167. }
  5168. }
  5169. declare module BABYLON {
  5170. /**
  5171. * This represents the main contract an easing function should follow.
  5172. * Easing functions are used throughout the animation system.
  5173. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5174. */
  5175. export interface IEasingFunction {
  5176. /**
  5177. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5178. * of the easing function.
  5179. * The link below provides some of the most common examples of easing functions.
  5180. * @see https://easings.net/
  5181. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5182. * @returns the corresponding value on the curve defined by the easing function
  5183. */
  5184. ease(gradient: number): number;
  5185. }
  5186. /**
  5187. * Base class used for every default easing function.
  5188. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5189. */
  5190. export class EasingFunction implements IEasingFunction {
  5191. /**
  5192. * Interpolation follows the mathematical formula associated with the easing function.
  5193. */
  5194. static readonly EASINGMODE_EASEIN: number;
  5195. /**
  5196. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5197. */
  5198. static readonly EASINGMODE_EASEOUT: number;
  5199. /**
  5200. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5201. */
  5202. static readonly EASINGMODE_EASEINOUT: number;
  5203. private _easingMode;
  5204. /**
  5205. * Sets the easing mode of the current function.
  5206. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5207. */
  5208. setEasingMode(easingMode: number): void;
  5209. /**
  5210. * Gets the current easing mode.
  5211. * @returns the easing mode
  5212. */
  5213. getEasingMode(): number;
  5214. /**
  5215. * @hidden
  5216. */
  5217. easeInCore(gradient: number): number;
  5218. /**
  5219. * Given an input gradient between 0 and 1, this returns the corresponding value
  5220. * of the easing function.
  5221. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5222. * @returns the corresponding value on the curve defined by the easing function
  5223. */
  5224. ease(gradient: number): number;
  5225. }
  5226. /**
  5227. * Easing function with a circle shape (see link below).
  5228. * @see https://easings.net/#easeInCirc
  5229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5230. */
  5231. export class CircleEase extends EasingFunction implements IEasingFunction {
  5232. /** @hidden */
  5233. easeInCore(gradient: number): number;
  5234. }
  5235. /**
  5236. * Easing function with a ease back shape (see link below).
  5237. * @see https://easings.net/#easeInBack
  5238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5239. */
  5240. export class BackEase extends EasingFunction implements IEasingFunction {
  5241. /** Defines the amplitude of the function */
  5242. amplitude: number;
  5243. /**
  5244. * Instantiates a back ease easing
  5245. * @see https://easings.net/#easeInBack
  5246. * @param amplitude Defines the amplitude of the function
  5247. */
  5248. constructor(
  5249. /** Defines the amplitude of the function */
  5250. amplitude?: number);
  5251. /** @hidden */
  5252. easeInCore(gradient: number): number;
  5253. }
  5254. /**
  5255. * Easing function with a bouncing shape (see link below).
  5256. * @see https://easings.net/#easeInBounce
  5257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5258. */
  5259. export class BounceEase extends EasingFunction implements IEasingFunction {
  5260. /** Defines the number of bounces */
  5261. bounces: number;
  5262. /** Defines the amplitude of the bounce */
  5263. bounciness: number;
  5264. /**
  5265. * Instantiates a bounce easing
  5266. * @see https://easings.net/#easeInBounce
  5267. * @param bounces Defines the number of bounces
  5268. * @param bounciness Defines the amplitude of the bounce
  5269. */
  5270. constructor(
  5271. /** Defines the number of bounces */
  5272. bounces?: number,
  5273. /** Defines the amplitude of the bounce */
  5274. bounciness?: number);
  5275. /** @hidden */
  5276. easeInCore(gradient: number): number;
  5277. }
  5278. /**
  5279. * Easing function with a power of 3 shape (see link below).
  5280. * @see https://easings.net/#easeInCubic
  5281. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5282. */
  5283. export class CubicEase extends EasingFunction implements IEasingFunction {
  5284. /** @hidden */
  5285. easeInCore(gradient: number): number;
  5286. }
  5287. /**
  5288. * Easing function with an elastic shape (see link below).
  5289. * @see https://easings.net/#easeInElastic
  5290. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5291. */
  5292. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5293. /** Defines the number of oscillations*/
  5294. oscillations: number;
  5295. /** Defines the amplitude of the oscillations*/
  5296. springiness: number;
  5297. /**
  5298. * Instantiates an elastic easing function
  5299. * @see https://easings.net/#easeInElastic
  5300. * @param oscillations Defines the number of oscillations
  5301. * @param springiness Defines the amplitude of the oscillations
  5302. */
  5303. constructor(
  5304. /** Defines the number of oscillations*/
  5305. oscillations?: number,
  5306. /** Defines the amplitude of the oscillations*/
  5307. springiness?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with an exponential shape (see link below).
  5313. * @see https://easings.net/#easeInExpo
  5314. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the exponent of the function */
  5318. exponent: number;
  5319. /**
  5320. * Instantiates an exponential easing function
  5321. * @see https://easings.net/#easeInExpo
  5322. * @param exponent Defines the exponent of the function
  5323. */
  5324. constructor(
  5325. /** Defines the exponent of the function */
  5326. exponent?: number);
  5327. /** @hidden */
  5328. easeInCore(gradient: number): number;
  5329. }
  5330. /**
  5331. * Easing function with a power shape (see link below).
  5332. * @see https://easings.net/#easeInQuad
  5333. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5334. */
  5335. export class PowerEase extends EasingFunction implements IEasingFunction {
  5336. /** Defines the power of the function */
  5337. power: number;
  5338. /**
  5339. * Instantiates an power base easing function
  5340. * @see https://easings.net/#easeInQuad
  5341. * @param power Defines the power of the function
  5342. */
  5343. constructor(
  5344. /** Defines the power of the function */
  5345. power?: number);
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a power of 2 shape (see link below).
  5351. * @see https://easings.net/#easeInQuad
  5352. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5355. /** @hidden */
  5356. easeInCore(gradient: number): number;
  5357. }
  5358. /**
  5359. * Easing function with a power of 4 shape (see link below).
  5360. * @see https://easings.net/#easeInQuart
  5361. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5362. */
  5363. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5364. /** @hidden */
  5365. easeInCore(gradient: number): number;
  5366. }
  5367. /**
  5368. * Easing function with a power of 5 shape (see link below).
  5369. * @see https://easings.net/#easeInQuint
  5370. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5371. */
  5372. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5373. /** @hidden */
  5374. easeInCore(gradient: number): number;
  5375. }
  5376. /**
  5377. * Easing function with a sin shape (see link below).
  5378. * @see https://easings.net/#easeInSine
  5379. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5380. */
  5381. export class SineEase extends EasingFunction implements IEasingFunction {
  5382. /** @hidden */
  5383. easeInCore(gradient: number): number;
  5384. }
  5385. /**
  5386. * Easing function with a bezier shape (see link below).
  5387. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5388. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5389. */
  5390. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5391. /** Defines the x component of the start tangent in the bezier curve */
  5392. x1: number;
  5393. /** Defines the y component of the start tangent in the bezier curve */
  5394. y1: number;
  5395. /** Defines the x component of the end tangent in the bezier curve */
  5396. x2: number;
  5397. /** Defines the y component of the end tangent in the bezier curve */
  5398. y2: number;
  5399. /**
  5400. * Instantiates a bezier function
  5401. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5402. * @param x1 Defines the x component of the start tangent in the bezier curve
  5403. * @param y1 Defines the y component of the start tangent in the bezier curve
  5404. * @param x2 Defines the x component of the end tangent in the bezier curve
  5405. * @param y2 Defines the y component of the end tangent in the bezier curve
  5406. */
  5407. constructor(
  5408. /** Defines the x component of the start tangent in the bezier curve */
  5409. x1?: number,
  5410. /** Defines the y component of the start tangent in the bezier curve */
  5411. y1?: number,
  5412. /** Defines the x component of the end tangent in the bezier curve */
  5413. x2?: number,
  5414. /** Defines the y component of the end tangent in the bezier curve */
  5415. y2?: number);
  5416. /** @hidden */
  5417. easeInCore(gradient: number): number;
  5418. }
  5419. }
  5420. declare module BABYLON {
  5421. /**
  5422. * Class used to hold a RBG color
  5423. */
  5424. export class Color3 {
  5425. /**
  5426. * Defines the red component (between 0 and 1, default is 0)
  5427. */
  5428. r: number;
  5429. /**
  5430. * Defines the green component (between 0 and 1, default is 0)
  5431. */
  5432. g: number;
  5433. /**
  5434. * Defines the blue component (between 0 and 1, default is 0)
  5435. */
  5436. b: number;
  5437. /**
  5438. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5439. * @param r defines the red component (between 0 and 1, default is 0)
  5440. * @param g defines the green component (between 0 and 1, default is 0)
  5441. * @param b defines the blue component (between 0 and 1, default is 0)
  5442. */
  5443. constructor(
  5444. /**
  5445. * Defines the red component (between 0 and 1, default is 0)
  5446. */
  5447. r?: number,
  5448. /**
  5449. * Defines the green component (between 0 and 1, default is 0)
  5450. */
  5451. g?: number,
  5452. /**
  5453. * Defines the blue component (between 0 and 1, default is 0)
  5454. */
  5455. b?: number);
  5456. /**
  5457. * Creates a string with the Color3 current values
  5458. * @returns the string representation of the Color3 object
  5459. */
  5460. toString(): string;
  5461. /**
  5462. * Returns the string "Color3"
  5463. * @returns "Color3"
  5464. */
  5465. getClassName(): string;
  5466. /**
  5467. * Compute the Color3 hash code
  5468. * @returns an unique number that can be used to hash Color3 objects
  5469. */
  5470. getHashCode(): number;
  5471. /**
  5472. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5473. * @param array defines the array where to store the r,g,b components
  5474. * @param index defines an optional index in the target array to define where to start storing values
  5475. * @returns the current Color3 object
  5476. */
  5477. toArray(array: FloatArray, index?: number): Color3;
  5478. /**
  5479. * Returns a new Color4 object from the current Color3 and the given alpha
  5480. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5481. * @returns a new Color4 object
  5482. */
  5483. toColor4(alpha?: number): Color4;
  5484. /**
  5485. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5486. * @returns the new array
  5487. */
  5488. asArray(): number[];
  5489. /**
  5490. * Returns the luminance value
  5491. * @returns a float value
  5492. */
  5493. toLuminance(): number;
  5494. /**
  5495. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5496. * @param otherColor defines the second operand
  5497. * @returns the new Color3 object
  5498. */
  5499. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5500. /**
  5501. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5502. * @param otherColor defines the second operand
  5503. * @param result defines the Color3 object where to store the result
  5504. * @returns the current Color3
  5505. */
  5506. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5507. /**
  5508. * Determines equality between Color3 objects
  5509. * @param otherColor defines the second operand
  5510. * @returns true if the rgb values are equal to the given ones
  5511. */
  5512. equals(otherColor: DeepImmutable<Color3>): boolean;
  5513. /**
  5514. * Determines equality between the current Color3 object and a set of r,b,g values
  5515. * @param r defines the red component to check
  5516. * @param g defines the green component to check
  5517. * @param b defines the blue component to check
  5518. * @returns true if the rgb values are equal to the given ones
  5519. */
  5520. equalsFloats(r: number, g: number, b: number): boolean;
  5521. /**
  5522. * Multiplies in place each rgb value by scale
  5523. * @param scale defines the scaling factor
  5524. * @returns the updated Color3
  5525. */
  5526. scale(scale: number): Color3;
  5527. /**
  5528. * Multiplies the rgb values by scale and stores the result into "result"
  5529. * @param scale defines the scaling factor
  5530. * @param result defines the Color3 object where to store the result
  5531. * @returns the unmodified current Color3
  5532. */
  5533. scaleToRef(scale: number, result: Color3): Color3;
  5534. /**
  5535. * Scale the current Color3 values by a factor and add the result to a given Color3
  5536. * @param scale defines the scale factor
  5537. * @param result defines color to store the result into
  5538. * @returns the unmodified current Color3
  5539. */
  5540. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5541. /**
  5542. * Clamps the rgb values by the min and max values and stores the result into "result"
  5543. * @param min defines minimum clamping value (default is 0)
  5544. * @param max defines maximum clamping value (default is 1)
  5545. * @param result defines color to store the result into
  5546. * @returns the original Color3
  5547. */
  5548. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5549. /**
  5550. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5551. * @param otherColor defines the second operand
  5552. * @returns the new Color3
  5553. */
  5554. add(otherColor: DeepImmutable<Color3>): Color3;
  5555. /**
  5556. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5557. * @param otherColor defines the second operand
  5558. * @param result defines Color3 object to store the result into
  5559. * @returns the unmodified current Color3
  5560. */
  5561. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5562. /**
  5563. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5564. * @param otherColor defines the second operand
  5565. * @returns the new Color3
  5566. */
  5567. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5568. /**
  5569. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5570. * @param otherColor defines the second operand
  5571. * @param result defines Color3 object to store the result into
  5572. * @returns the unmodified current Color3
  5573. */
  5574. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5575. /**
  5576. * Copy the current object
  5577. * @returns a new Color3 copied the current one
  5578. */
  5579. clone(): Color3;
  5580. /**
  5581. * Copies the rgb values from the source in the current Color3
  5582. * @param source defines the source Color3 object
  5583. * @returns the updated Color3 object
  5584. */
  5585. copyFrom(source: DeepImmutable<Color3>): Color3;
  5586. /**
  5587. * Updates the Color3 rgb values from the given floats
  5588. * @param r defines the red component to read from
  5589. * @param g defines the green component to read from
  5590. * @param b defines the blue component to read from
  5591. * @returns the current Color3 object
  5592. */
  5593. copyFromFloats(r: number, g: number, b: number): Color3;
  5594. /**
  5595. * Updates the Color3 rgb values from the given floats
  5596. * @param r defines the red component to read from
  5597. * @param g defines the green component to read from
  5598. * @param b defines the blue component to read from
  5599. * @returns the current Color3 object
  5600. */
  5601. set(r: number, g: number, b: number): Color3;
  5602. /**
  5603. * Compute the Color3 hexadecimal code as a string
  5604. * @returns a string containing the hexadecimal representation of the Color3 object
  5605. */
  5606. toHexString(): string;
  5607. /**
  5608. * Computes a new Color3 converted from the current one to linear space
  5609. * @returns a new Color3 object
  5610. */
  5611. toLinearSpace(): Color3;
  5612. /**
  5613. * Converts current color in rgb space to HSV values
  5614. * @returns a new color3 representing the HSV values
  5615. */
  5616. toHSV(): Color3;
  5617. /**
  5618. * Converts current color in rgb space to HSV values
  5619. * @param result defines the Color3 where to store the HSV values
  5620. */
  5621. toHSVToRef(result: Color3): void;
  5622. /**
  5623. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5624. * @param convertedColor defines the Color3 object where to store the linear space version
  5625. * @returns the unmodified Color3
  5626. */
  5627. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5628. /**
  5629. * Computes a new Color3 converted from the current one to gamma space
  5630. * @returns a new Color3 object
  5631. */
  5632. toGammaSpace(): Color3;
  5633. /**
  5634. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5635. * @param convertedColor defines the Color3 object where to store the gamma space version
  5636. * @returns the unmodified Color3
  5637. */
  5638. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5639. private static _BlackReadOnly;
  5640. /**
  5641. * Convert Hue, saturation and value to a Color3 (RGB)
  5642. * @param hue defines the hue
  5643. * @param saturation defines the saturation
  5644. * @param value defines the value
  5645. * @param result defines the Color3 where to store the RGB values
  5646. */
  5647. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5648. /**
  5649. * Creates a new Color3 from the string containing valid hexadecimal values
  5650. * @param hex defines a string containing valid hexadecimal values
  5651. * @returns a new Color3 object
  5652. */
  5653. static FromHexString(hex: string): Color3;
  5654. /**
  5655. * Creates a new Color3 from the starting index of the given array
  5656. * @param array defines the source array
  5657. * @param offset defines an offset in the source array
  5658. * @returns a new Color3 object
  5659. */
  5660. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5661. /**
  5662. * Creates a new Color3 from integer values (< 256)
  5663. * @param r defines the red component to read from (value between 0 and 255)
  5664. * @param g defines the green component to read from (value between 0 and 255)
  5665. * @param b defines the blue component to read from (value between 0 and 255)
  5666. * @returns a new Color3 object
  5667. */
  5668. static FromInts(r: number, g: number, b: number): Color3;
  5669. /**
  5670. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5671. * @param start defines the start Color3 value
  5672. * @param end defines the end Color3 value
  5673. * @param amount defines the gradient value between start and end
  5674. * @returns a new Color3 object
  5675. */
  5676. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5677. /**
  5678. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5679. * @param left defines the start value
  5680. * @param right defines the end value
  5681. * @param amount defines the gradient factor
  5682. * @param result defines the Color3 object where to store the result
  5683. */
  5684. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5685. /**
  5686. * Returns a Color3 value containing a red color
  5687. * @returns a new Color3 object
  5688. */
  5689. static Red(): Color3;
  5690. /**
  5691. * Returns a Color3 value containing a green color
  5692. * @returns a new Color3 object
  5693. */
  5694. static Green(): Color3;
  5695. /**
  5696. * Returns a Color3 value containing a blue color
  5697. * @returns a new Color3 object
  5698. */
  5699. static Blue(): Color3;
  5700. /**
  5701. * Returns a Color3 value containing a black color
  5702. * @returns a new Color3 object
  5703. */
  5704. static Black(): Color3;
  5705. /**
  5706. * Gets a Color3 value containing a black color that must not be updated
  5707. */
  5708. static get BlackReadOnly(): DeepImmutable<Color3>;
  5709. /**
  5710. * Returns a Color3 value containing a white color
  5711. * @returns a new Color3 object
  5712. */
  5713. static White(): Color3;
  5714. /**
  5715. * Returns a Color3 value containing a purple color
  5716. * @returns a new Color3 object
  5717. */
  5718. static Purple(): Color3;
  5719. /**
  5720. * Returns a Color3 value containing a magenta color
  5721. * @returns a new Color3 object
  5722. */
  5723. static Magenta(): Color3;
  5724. /**
  5725. * Returns a Color3 value containing a yellow color
  5726. * @returns a new Color3 object
  5727. */
  5728. static Yellow(): Color3;
  5729. /**
  5730. * Returns a Color3 value containing a gray color
  5731. * @returns a new Color3 object
  5732. */
  5733. static Gray(): Color3;
  5734. /**
  5735. * Returns a Color3 value containing a teal color
  5736. * @returns a new Color3 object
  5737. */
  5738. static Teal(): Color3;
  5739. /**
  5740. * Returns a Color3 value containing a random color
  5741. * @returns a new Color3 object
  5742. */
  5743. static Random(): Color3;
  5744. }
  5745. /**
  5746. * Class used to hold a RBGA color
  5747. */
  5748. export class Color4 {
  5749. /**
  5750. * Defines the red component (between 0 and 1, default is 0)
  5751. */
  5752. r: number;
  5753. /**
  5754. * Defines the green component (between 0 and 1, default is 0)
  5755. */
  5756. g: number;
  5757. /**
  5758. * Defines the blue component (between 0 and 1, default is 0)
  5759. */
  5760. b: number;
  5761. /**
  5762. * Defines the alpha component (between 0 and 1, default is 1)
  5763. */
  5764. a: number;
  5765. /**
  5766. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5767. * @param r defines the red component (between 0 and 1, default is 0)
  5768. * @param g defines the green component (between 0 and 1, default is 0)
  5769. * @param b defines the blue component (between 0 and 1, default is 0)
  5770. * @param a defines the alpha component (between 0 and 1, default is 1)
  5771. */
  5772. constructor(
  5773. /**
  5774. * Defines the red component (between 0 and 1, default is 0)
  5775. */
  5776. r?: number,
  5777. /**
  5778. * Defines the green component (between 0 and 1, default is 0)
  5779. */
  5780. g?: number,
  5781. /**
  5782. * Defines the blue component (between 0 and 1, default is 0)
  5783. */
  5784. b?: number,
  5785. /**
  5786. * Defines the alpha component (between 0 and 1, default is 1)
  5787. */
  5788. a?: number);
  5789. /**
  5790. * Adds in place the given Color4 values to the current Color4 object
  5791. * @param right defines the second operand
  5792. * @returns the current updated Color4 object
  5793. */
  5794. addInPlace(right: DeepImmutable<Color4>): Color4;
  5795. /**
  5796. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5797. * @returns the new array
  5798. */
  5799. asArray(): number[];
  5800. /**
  5801. * Stores from the starting index in the given array the Color4 successive values
  5802. * @param array defines the array where to store the r,g,b components
  5803. * @param index defines an optional index in the target array to define where to start storing values
  5804. * @returns the current Color4 object
  5805. */
  5806. toArray(array: number[], index?: number): Color4;
  5807. /**
  5808. * Determines equality between Color4 objects
  5809. * @param otherColor defines the second operand
  5810. * @returns true if the rgba values are equal to the given ones
  5811. */
  5812. equals(otherColor: DeepImmutable<Color4>): boolean;
  5813. /**
  5814. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5815. * @param right defines the second operand
  5816. * @returns a new Color4 object
  5817. */
  5818. add(right: DeepImmutable<Color4>): Color4;
  5819. /**
  5820. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5821. * @param right defines the second operand
  5822. * @returns a new Color4 object
  5823. */
  5824. subtract(right: DeepImmutable<Color4>): Color4;
  5825. /**
  5826. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5827. * @param right defines the second operand
  5828. * @param result defines the Color4 object where to store the result
  5829. * @returns the current Color4 object
  5830. */
  5831. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5832. /**
  5833. * Creates a new Color4 with the current Color4 values multiplied by scale
  5834. * @param scale defines the scaling factor to apply
  5835. * @returns a new Color4 object
  5836. */
  5837. scale(scale: number): Color4;
  5838. /**
  5839. * Multiplies the current Color4 values by scale and stores the result in "result"
  5840. * @param scale defines the scaling factor to apply
  5841. * @param result defines the Color4 object where to store the result
  5842. * @returns the current unmodified Color4
  5843. */
  5844. scaleToRef(scale: number, result: Color4): Color4;
  5845. /**
  5846. * Scale the current Color4 values by a factor and add the result to a given Color4
  5847. * @param scale defines the scale factor
  5848. * @param result defines the Color4 object where to store the result
  5849. * @returns the unmodified current Color4
  5850. */
  5851. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5852. /**
  5853. * Clamps the rgb values by the min and max values and stores the result into "result"
  5854. * @param min defines minimum clamping value (default is 0)
  5855. * @param max defines maximum clamping value (default is 1)
  5856. * @param result defines color to store the result into.
  5857. * @returns the cuurent Color4
  5858. */
  5859. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5860. /**
  5861. * Multipy an Color4 value by another and return a new Color4 object
  5862. * @param color defines the Color4 value to multiply by
  5863. * @returns a new Color4 object
  5864. */
  5865. multiply(color: Color4): Color4;
  5866. /**
  5867. * Multipy a Color4 value by another and push the result in a reference value
  5868. * @param color defines the Color4 value to multiply by
  5869. * @param result defines the Color4 to fill the result in
  5870. * @returns the result Color4
  5871. */
  5872. multiplyToRef(color: Color4, result: Color4): Color4;
  5873. /**
  5874. * Creates a string with the Color4 current values
  5875. * @returns the string representation of the Color4 object
  5876. */
  5877. toString(): string;
  5878. /**
  5879. * Returns the string "Color4"
  5880. * @returns "Color4"
  5881. */
  5882. getClassName(): string;
  5883. /**
  5884. * Compute the Color4 hash code
  5885. * @returns an unique number that can be used to hash Color4 objects
  5886. */
  5887. getHashCode(): number;
  5888. /**
  5889. * Creates a new Color4 copied from the current one
  5890. * @returns a new Color4 object
  5891. */
  5892. clone(): Color4;
  5893. /**
  5894. * Copies the given Color4 values into the current one
  5895. * @param source defines the source Color4 object
  5896. * @returns the current updated Color4 object
  5897. */
  5898. copyFrom(source: Color4): Color4;
  5899. /**
  5900. * Copies the given float values into the current one
  5901. * @param r defines the red component to read from
  5902. * @param g defines the green component to read from
  5903. * @param b defines the blue component to read from
  5904. * @param a defines the alpha component to read from
  5905. * @returns the current updated Color4 object
  5906. */
  5907. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5908. /**
  5909. * Copies the given float values into the current one
  5910. * @param r defines the red component to read from
  5911. * @param g defines the green component to read from
  5912. * @param b defines the blue component to read from
  5913. * @param a defines the alpha component to read from
  5914. * @returns the current updated Color4 object
  5915. */
  5916. set(r: number, g: number, b: number, a: number): Color4;
  5917. /**
  5918. * Compute the Color4 hexadecimal code as a string
  5919. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5920. * @returns a string containing the hexadecimal representation of the Color4 object
  5921. */
  5922. toHexString(returnAsColor3?: boolean): string;
  5923. /**
  5924. * Computes a new Color4 converted from the current one to linear space
  5925. * @returns a new Color4 object
  5926. */
  5927. toLinearSpace(): Color4;
  5928. /**
  5929. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5930. * @param convertedColor defines the Color4 object where to store the linear space version
  5931. * @returns the unmodified Color4
  5932. */
  5933. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5934. /**
  5935. * Computes a new Color4 converted from the current one to gamma space
  5936. * @returns a new Color4 object
  5937. */
  5938. toGammaSpace(): Color4;
  5939. /**
  5940. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5941. * @param convertedColor defines the Color4 object where to store the gamma space version
  5942. * @returns the unmodified Color4
  5943. */
  5944. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5945. /**
  5946. * Creates a new Color4 from the string containing valid hexadecimal values
  5947. * @param hex defines a string containing valid hexadecimal values
  5948. * @returns a new Color4 object
  5949. */
  5950. static FromHexString(hex: string): Color4;
  5951. /**
  5952. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5953. * @param left defines the start value
  5954. * @param right defines the end value
  5955. * @param amount defines the gradient factor
  5956. * @returns a new Color4 object
  5957. */
  5958. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5959. /**
  5960. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5961. * @param left defines the start value
  5962. * @param right defines the end value
  5963. * @param amount defines the gradient factor
  5964. * @param result defines the Color4 object where to store data
  5965. */
  5966. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5967. /**
  5968. * Creates a new Color4 from a Color3 and an alpha value
  5969. * @param color3 defines the source Color3 to read from
  5970. * @param alpha defines the alpha component (1.0 by default)
  5971. * @returns a new Color4 object
  5972. */
  5973. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5974. /**
  5975. * Creates a new Color4 from the starting index element of the given array
  5976. * @param array defines the source array to read from
  5977. * @param offset defines the offset in the source array
  5978. * @returns a new Color4 object
  5979. */
  5980. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5981. /**
  5982. * Creates a new Color3 from integer values (< 256)
  5983. * @param r defines the red component to read from (value between 0 and 255)
  5984. * @param g defines the green component to read from (value between 0 and 255)
  5985. * @param b defines the blue component to read from (value between 0 and 255)
  5986. * @param a defines the alpha component to read from (value between 0 and 255)
  5987. * @returns a new Color3 object
  5988. */
  5989. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5990. /**
  5991. * Check the content of a given array and convert it to an array containing RGBA data
  5992. * If the original array was already containing count * 4 values then it is returned directly
  5993. * @param colors defines the array to check
  5994. * @param count defines the number of RGBA data to expect
  5995. * @returns an array containing count * 4 values (RGBA)
  5996. */
  5997. static CheckColors4(colors: number[], count: number): number[];
  5998. }
  5999. /**
  6000. * @hidden
  6001. */
  6002. export class TmpColors {
  6003. static Color3: Color3[];
  6004. static Color4: Color4[];
  6005. }
  6006. }
  6007. declare module BABYLON {
  6008. /**
  6009. * Defines an interface which represents an animation key frame
  6010. */
  6011. export interface IAnimationKey {
  6012. /**
  6013. * Frame of the key frame
  6014. */
  6015. frame: number;
  6016. /**
  6017. * Value at the specifies key frame
  6018. */
  6019. value: any;
  6020. /**
  6021. * The input tangent for the cubic hermite spline
  6022. */
  6023. inTangent?: any;
  6024. /**
  6025. * The output tangent for the cubic hermite spline
  6026. */
  6027. outTangent?: any;
  6028. /**
  6029. * The animation interpolation type
  6030. */
  6031. interpolation?: AnimationKeyInterpolation;
  6032. }
  6033. /**
  6034. * Enum for the animation key frame interpolation type
  6035. */
  6036. export enum AnimationKeyInterpolation {
  6037. /**
  6038. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6039. */
  6040. STEP = 1
  6041. }
  6042. }
  6043. declare module BABYLON {
  6044. /**
  6045. * Represents the range of an animation
  6046. */
  6047. export class AnimationRange {
  6048. /**The name of the animation range**/
  6049. name: string;
  6050. /**The starting frame of the animation */
  6051. from: number;
  6052. /**The ending frame of the animation*/
  6053. to: number;
  6054. /**
  6055. * Initializes the range of an animation
  6056. * @param name The name of the animation range
  6057. * @param from The starting frame of the animation
  6058. * @param to The ending frame of the animation
  6059. */
  6060. constructor(
  6061. /**The name of the animation range**/
  6062. name: string,
  6063. /**The starting frame of the animation */
  6064. from: number,
  6065. /**The ending frame of the animation*/
  6066. to: number);
  6067. /**
  6068. * Makes a copy of the animation range
  6069. * @returns A copy of the animation range
  6070. */
  6071. clone(): AnimationRange;
  6072. }
  6073. }
  6074. declare module BABYLON {
  6075. /**
  6076. * Composed of a frame, and an action function
  6077. */
  6078. export class AnimationEvent {
  6079. /** The frame for which the event is triggered **/
  6080. frame: number;
  6081. /** The event to perform when triggered **/
  6082. action: (currentFrame: number) => void;
  6083. /** Specifies if the event should be triggered only once**/
  6084. onlyOnce?: boolean | undefined;
  6085. /**
  6086. * Specifies if the animation event is done
  6087. */
  6088. isDone: boolean;
  6089. /**
  6090. * Initializes the animation event
  6091. * @param frame The frame for which the event is triggered
  6092. * @param action The event to perform when triggered
  6093. * @param onlyOnce Specifies if the event should be triggered only once
  6094. */
  6095. constructor(
  6096. /** The frame for which the event is triggered **/
  6097. frame: number,
  6098. /** The event to perform when triggered **/
  6099. action: (currentFrame: number) => void,
  6100. /** Specifies if the event should be triggered only once**/
  6101. onlyOnce?: boolean | undefined);
  6102. /** @hidden */
  6103. _clone(): AnimationEvent;
  6104. }
  6105. }
  6106. declare module BABYLON {
  6107. /**
  6108. * Interface used to define a behavior
  6109. */
  6110. export interface Behavior<T> {
  6111. /** gets or sets behavior's name */
  6112. name: string;
  6113. /**
  6114. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6115. */
  6116. init(): void;
  6117. /**
  6118. * Called when the behavior is attached to a target
  6119. * @param target defines the target where the behavior is attached to
  6120. */
  6121. attach(target: T): void;
  6122. /**
  6123. * Called when the behavior is detached from its target
  6124. */
  6125. detach(): void;
  6126. }
  6127. /**
  6128. * Interface implemented by classes supporting behaviors
  6129. */
  6130. export interface IBehaviorAware<T> {
  6131. /**
  6132. * Attach a behavior
  6133. * @param behavior defines the behavior to attach
  6134. * @returns the current host
  6135. */
  6136. addBehavior(behavior: Behavior<T>): T;
  6137. /**
  6138. * Remove a behavior from the current object
  6139. * @param behavior defines the behavior to detach
  6140. * @returns the current host
  6141. */
  6142. removeBehavior(behavior: Behavior<T>): T;
  6143. /**
  6144. * Gets a behavior using its name to search
  6145. * @param name defines the name to search
  6146. * @returns the behavior or null if not found
  6147. */
  6148. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6149. }
  6150. }
  6151. declare module BABYLON {
  6152. /**
  6153. * Defines an array and its length.
  6154. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6155. */
  6156. export interface ISmartArrayLike<T> {
  6157. /**
  6158. * The data of the array.
  6159. */
  6160. data: Array<T>;
  6161. /**
  6162. * The active length of the array.
  6163. */
  6164. length: number;
  6165. }
  6166. /**
  6167. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6168. */
  6169. export class SmartArray<T> implements ISmartArrayLike<T> {
  6170. /**
  6171. * The full set of data from the array.
  6172. */
  6173. data: Array<T>;
  6174. /**
  6175. * The active length of the array.
  6176. */
  6177. length: number;
  6178. protected _id: number;
  6179. /**
  6180. * Instantiates a Smart Array.
  6181. * @param capacity defines the default capacity of the array.
  6182. */
  6183. constructor(capacity: number);
  6184. /**
  6185. * Pushes a value at the end of the active data.
  6186. * @param value defines the object to push in the array.
  6187. */
  6188. push(value: T): void;
  6189. /**
  6190. * Iterates over the active data and apply the lambda to them.
  6191. * @param func defines the action to apply on each value.
  6192. */
  6193. forEach(func: (content: T) => void): void;
  6194. /**
  6195. * Sorts the full sets of data.
  6196. * @param compareFn defines the comparison function to apply.
  6197. */
  6198. sort(compareFn: (a: T, b: T) => number): void;
  6199. /**
  6200. * Resets the active data to an empty array.
  6201. */
  6202. reset(): void;
  6203. /**
  6204. * Releases all the data from the array as well as the array.
  6205. */
  6206. dispose(): void;
  6207. /**
  6208. * Concats the active data with a given array.
  6209. * @param array defines the data to concatenate with.
  6210. */
  6211. concat(array: any): void;
  6212. /**
  6213. * Returns the position of a value in the active data.
  6214. * @param value defines the value to find the index for
  6215. * @returns the index if found in the active data otherwise -1
  6216. */
  6217. indexOf(value: T): number;
  6218. /**
  6219. * Returns whether an element is part of the active data.
  6220. * @param value defines the value to look for
  6221. * @returns true if found in the active data otherwise false
  6222. */
  6223. contains(value: T): boolean;
  6224. private static _GlobalId;
  6225. }
  6226. /**
  6227. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6228. * The data in this array can only be present once
  6229. */
  6230. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6231. private _duplicateId;
  6232. /**
  6233. * Pushes a value at the end of the active data.
  6234. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6235. * @param value defines the object to push in the array.
  6236. */
  6237. push(value: T): void;
  6238. /**
  6239. * Pushes a value at the end of the active data.
  6240. * If the data is already present, it won t be added again
  6241. * @param value defines the object to push in the array.
  6242. * @returns true if added false if it was already present
  6243. */
  6244. pushNoDuplicate(value: T): boolean;
  6245. /**
  6246. * Resets the active data to an empty array.
  6247. */
  6248. reset(): void;
  6249. /**
  6250. * Concats the active data with a given array.
  6251. * This ensures no dupplicate will be present in the result.
  6252. * @param array defines the data to concatenate with.
  6253. */
  6254. concatWithNoDuplicate(array: any): void;
  6255. }
  6256. }
  6257. declare module BABYLON {
  6258. /**
  6259. * @ignore
  6260. * This is a list of all the different input types that are available in the application.
  6261. * Fo instance: ArcRotateCameraGamepadInput...
  6262. */
  6263. export var CameraInputTypes: {};
  6264. /**
  6265. * This is the contract to implement in order to create a new input class.
  6266. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6267. */
  6268. export interface ICameraInput<TCamera extends Camera> {
  6269. /**
  6270. * Defines the camera the input is attached to.
  6271. */
  6272. camera: Nullable<TCamera>;
  6273. /**
  6274. * Gets the class name of the current intput.
  6275. * @returns the class name
  6276. */
  6277. getClassName(): string;
  6278. /**
  6279. * Get the friendly name associated with the input class.
  6280. * @returns the input friendly name
  6281. */
  6282. getSimpleName(): string;
  6283. /**
  6284. * Attach the input controls to a specific dom element to get the input from.
  6285. * @param element Defines the element the controls should be listened from
  6286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6287. */
  6288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6289. /**
  6290. * Detach the current controls from the specified dom element.
  6291. * @param element Defines the element to stop listening the inputs from
  6292. */
  6293. detachControl(element: Nullable<HTMLElement>): void;
  6294. /**
  6295. * Update the current camera state depending on the inputs that have been used this frame.
  6296. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6297. */
  6298. checkInputs?: () => void;
  6299. }
  6300. /**
  6301. * Represents a map of input types to input instance or input index to input instance.
  6302. */
  6303. export interface CameraInputsMap<TCamera extends Camera> {
  6304. /**
  6305. * Accessor to the input by input type.
  6306. */
  6307. [name: string]: ICameraInput<TCamera>;
  6308. /**
  6309. * Accessor to the input by input index.
  6310. */
  6311. [idx: number]: ICameraInput<TCamera>;
  6312. }
  6313. /**
  6314. * This represents the input manager used within a camera.
  6315. * It helps dealing with all the different kind of input attached to a camera.
  6316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6317. */
  6318. export class CameraInputsManager<TCamera extends Camera> {
  6319. /**
  6320. * Defines the list of inputs attahed to the camera.
  6321. */
  6322. attached: CameraInputsMap<TCamera>;
  6323. /**
  6324. * Defines the dom element the camera is collecting inputs from.
  6325. * This is null if the controls have not been attached.
  6326. */
  6327. attachedElement: Nullable<HTMLElement>;
  6328. /**
  6329. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6330. */
  6331. noPreventDefault: boolean;
  6332. /**
  6333. * Defined the camera the input manager belongs to.
  6334. */
  6335. camera: TCamera;
  6336. /**
  6337. * Update the current camera state depending on the inputs that have been used this frame.
  6338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6339. */
  6340. checkInputs: () => void;
  6341. /**
  6342. * Instantiate a new Camera Input Manager.
  6343. * @param camera Defines the camera the input manager blongs to
  6344. */
  6345. constructor(camera: TCamera);
  6346. /**
  6347. * Add an input method to a camera
  6348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6349. * @param input camera input method
  6350. */
  6351. add(input: ICameraInput<TCamera>): void;
  6352. /**
  6353. * Remove a specific input method from a camera
  6354. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6355. * @param inputToRemove camera input method
  6356. */
  6357. remove(inputToRemove: ICameraInput<TCamera>): void;
  6358. /**
  6359. * Remove a specific input type from a camera
  6360. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6361. * @param inputType the type of the input to remove
  6362. */
  6363. removeByType(inputType: string): void;
  6364. private _addCheckInputs;
  6365. /**
  6366. * Attach the input controls to the currently attached dom element to listen the events from.
  6367. * @param input Defines the input to attach
  6368. */
  6369. attachInput(input: ICameraInput<TCamera>): void;
  6370. /**
  6371. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6372. * @param element Defines the dom element to collect the events from
  6373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6374. */
  6375. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6376. /**
  6377. * Detach the current manager inputs controls from a specific dom element.
  6378. * @param element Defines the dom element to collect the events from
  6379. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6380. */
  6381. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6382. /**
  6383. * Rebuild the dynamic inputCheck function from the current list of
  6384. * defined inputs in the manager.
  6385. */
  6386. rebuildInputCheck(): void;
  6387. /**
  6388. * Remove all attached input methods from a camera
  6389. */
  6390. clear(): void;
  6391. /**
  6392. * Serialize the current input manager attached to a camera.
  6393. * This ensures than once parsed,
  6394. * the input associated to the camera will be identical to the current ones
  6395. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6396. */
  6397. serialize(serializedCamera: any): void;
  6398. /**
  6399. * Parses an input manager serialized JSON to restore the previous list of inputs
  6400. * and states associated to a camera.
  6401. * @param parsedCamera Defines the JSON to parse
  6402. */
  6403. parse(parsedCamera: any): void;
  6404. }
  6405. }
  6406. declare module BABYLON {
  6407. /**
  6408. * Class used to store data that will be store in GPU memory
  6409. */
  6410. export class Buffer {
  6411. private _engine;
  6412. private _buffer;
  6413. /** @hidden */
  6414. _data: Nullable<DataArray>;
  6415. private _updatable;
  6416. private _instanced;
  6417. private _divisor;
  6418. /**
  6419. * Gets the byte stride.
  6420. */
  6421. readonly byteStride: number;
  6422. /**
  6423. * Constructor
  6424. * @param engine the engine
  6425. * @param data the data to use for this buffer
  6426. * @param updatable whether the data is updatable
  6427. * @param stride the stride (optional)
  6428. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6429. * @param instanced whether the buffer is instanced (optional)
  6430. * @param useBytes set to true if the stride in in bytes (optional)
  6431. * @param divisor sets an optional divisor for instances (1 by default)
  6432. */
  6433. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6434. /**
  6435. * Create a new VertexBuffer based on the current buffer
  6436. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6437. * @param offset defines offset in the buffer (0 by default)
  6438. * @param size defines the size in floats of attributes (position is 3 for instance)
  6439. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6440. * @param instanced defines if the vertex buffer contains indexed data
  6441. * @param useBytes defines if the offset and stride are in bytes *
  6442. * @param divisor sets an optional divisor for instances (1 by default)
  6443. * @returns the new vertex buffer
  6444. */
  6445. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6446. /**
  6447. * Gets a boolean indicating if the Buffer is updatable?
  6448. * @returns true if the buffer is updatable
  6449. */
  6450. isUpdatable(): boolean;
  6451. /**
  6452. * Gets current buffer's data
  6453. * @returns a DataArray or null
  6454. */
  6455. getData(): Nullable<DataArray>;
  6456. /**
  6457. * Gets underlying native buffer
  6458. * @returns underlying native buffer
  6459. */
  6460. getBuffer(): Nullable<DataBuffer>;
  6461. /**
  6462. * Gets the stride in float32 units (i.e. byte stride / 4).
  6463. * May not be an integer if the byte stride is not divisible by 4.
  6464. * @returns the stride in float32 units
  6465. * @deprecated Please use byteStride instead.
  6466. */
  6467. getStrideSize(): number;
  6468. /**
  6469. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6470. * @param data defines the data to store
  6471. */
  6472. create(data?: Nullable<DataArray>): void;
  6473. /** @hidden */
  6474. _rebuild(): void;
  6475. /**
  6476. * Update current buffer data
  6477. * @param data defines the data to store
  6478. */
  6479. update(data: DataArray): void;
  6480. /**
  6481. * Updates the data directly.
  6482. * @param data the new data
  6483. * @param offset the new offset
  6484. * @param vertexCount the vertex count (optional)
  6485. * @param useBytes set to true if the offset is in bytes
  6486. */
  6487. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6488. /**
  6489. * Release all resources
  6490. */
  6491. dispose(): void;
  6492. }
  6493. /**
  6494. * Specialized buffer used to store vertex data
  6495. */
  6496. export class VertexBuffer {
  6497. /** @hidden */
  6498. _buffer: Buffer;
  6499. private _kind;
  6500. private _size;
  6501. private _ownsBuffer;
  6502. private _instanced;
  6503. private _instanceDivisor;
  6504. /**
  6505. * The byte type.
  6506. */
  6507. static readonly BYTE: number;
  6508. /**
  6509. * The unsigned byte type.
  6510. */
  6511. static readonly UNSIGNED_BYTE: number;
  6512. /**
  6513. * The short type.
  6514. */
  6515. static readonly SHORT: number;
  6516. /**
  6517. * The unsigned short type.
  6518. */
  6519. static readonly UNSIGNED_SHORT: number;
  6520. /**
  6521. * The integer type.
  6522. */
  6523. static readonly INT: number;
  6524. /**
  6525. * The unsigned integer type.
  6526. */
  6527. static readonly UNSIGNED_INT: number;
  6528. /**
  6529. * The float type.
  6530. */
  6531. static readonly FLOAT: number;
  6532. /**
  6533. * Gets or sets the instance divisor when in instanced mode
  6534. */
  6535. get instanceDivisor(): number;
  6536. set instanceDivisor(value: number);
  6537. /**
  6538. * Gets the byte stride.
  6539. */
  6540. readonly byteStride: number;
  6541. /**
  6542. * Gets the byte offset.
  6543. */
  6544. readonly byteOffset: number;
  6545. /**
  6546. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6547. */
  6548. readonly normalized: boolean;
  6549. /**
  6550. * Gets the data type of each component in the array.
  6551. */
  6552. readonly type: number;
  6553. /**
  6554. * Constructor
  6555. * @param engine the engine
  6556. * @param data the data to use for this vertex buffer
  6557. * @param kind the vertex buffer kind
  6558. * @param updatable whether the data is updatable
  6559. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6560. * @param stride the stride (optional)
  6561. * @param instanced whether the buffer is instanced (optional)
  6562. * @param offset the offset of the data (optional)
  6563. * @param size the number of components (optional)
  6564. * @param type the type of the component (optional)
  6565. * @param normalized whether the data contains normalized data (optional)
  6566. * @param useBytes set to true if stride and offset are in bytes (optional)
  6567. * @param divisor defines the instance divisor to use (1 by default)
  6568. */
  6569. 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);
  6570. /** @hidden */
  6571. _rebuild(): void;
  6572. /**
  6573. * Returns the kind of the VertexBuffer (string)
  6574. * @returns a string
  6575. */
  6576. getKind(): string;
  6577. /**
  6578. * Gets a boolean indicating if the VertexBuffer is updatable?
  6579. * @returns true if the buffer is updatable
  6580. */
  6581. isUpdatable(): boolean;
  6582. /**
  6583. * Gets current buffer's data
  6584. * @returns a DataArray or null
  6585. */
  6586. getData(): Nullable<DataArray>;
  6587. /**
  6588. * Gets underlying native buffer
  6589. * @returns underlying native buffer
  6590. */
  6591. getBuffer(): Nullable<DataBuffer>;
  6592. /**
  6593. * Gets the stride in float32 units (i.e. byte stride / 4).
  6594. * May not be an integer if the byte stride is not divisible by 4.
  6595. * @returns the stride in float32 units
  6596. * @deprecated Please use byteStride instead.
  6597. */
  6598. getStrideSize(): number;
  6599. /**
  6600. * Returns the offset as a multiple of the type byte length.
  6601. * @returns the offset in bytes
  6602. * @deprecated Please use byteOffset instead.
  6603. */
  6604. getOffset(): number;
  6605. /**
  6606. * Returns the number of components per vertex attribute (integer)
  6607. * @returns the size in float
  6608. */
  6609. getSize(): number;
  6610. /**
  6611. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6612. * @returns true if this buffer is instanced
  6613. */
  6614. getIsInstanced(): boolean;
  6615. /**
  6616. * Returns the instancing divisor, zero for non-instanced (integer).
  6617. * @returns a number
  6618. */
  6619. getInstanceDivisor(): number;
  6620. /**
  6621. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6622. * @param data defines the data to store
  6623. */
  6624. create(data?: DataArray): void;
  6625. /**
  6626. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6627. * This function will create a new buffer if the current one is not updatable
  6628. * @param data defines the data to store
  6629. */
  6630. update(data: DataArray): void;
  6631. /**
  6632. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6633. * Returns the directly updated WebGLBuffer.
  6634. * @param data the new data
  6635. * @param offset the new offset
  6636. * @param useBytes set to true if the offset is in bytes
  6637. */
  6638. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6639. /**
  6640. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6641. */
  6642. dispose(): void;
  6643. /**
  6644. * Enumerates each value of this vertex buffer as numbers.
  6645. * @param count the number of values to enumerate
  6646. * @param callback the callback function called for each value
  6647. */
  6648. forEach(count: number, callback: (value: number, index: number) => void): void;
  6649. /**
  6650. * Positions
  6651. */
  6652. static readonly PositionKind: string;
  6653. /**
  6654. * Normals
  6655. */
  6656. static readonly NormalKind: string;
  6657. /**
  6658. * Tangents
  6659. */
  6660. static readonly TangentKind: string;
  6661. /**
  6662. * Texture coordinates
  6663. */
  6664. static readonly UVKind: string;
  6665. /**
  6666. * Texture coordinates 2
  6667. */
  6668. static readonly UV2Kind: string;
  6669. /**
  6670. * Texture coordinates 3
  6671. */
  6672. static readonly UV3Kind: string;
  6673. /**
  6674. * Texture coordinates 4
  6675. */
  6676. static readonly UV4Kind: string;
  6677. /**
  6678. * Texture coordinates 5
  6679. */
  6680. static readonly UV5Kind: string;
  6681. /**
  6682. * Texture coordinates 6
  6683. */
  6684. static readonly UV6Kind: string;
  6685. /**
  6686. * Colors
  6687. */
  6688. static readonly ColorKind: string;
  6689. /**
  6690. * Matrix indices (for bones)
  6691. */
  6692. static readonly MatricesIndicesKind: string;
  6693. /**
  6694. * Matrix weights (for bones)
  6695. */
  6696. static readonly MatricesWeightsKind: string;
  6697. /**
  6698. * Additional matrix indices (for bones)
  6699. */
  6700. static readonly MatricesIndicesExtraKind: string;
  6701. /**
  6702. * Additional matrix weights (for bones)
  6703. */
  6704. static readonly MatricesWeightsExtraKind: string;
  6705. /**
  6706. * Deduces the stride given a kind.
  6707. * @param kind The kind string to deduce
  6708. * @returns The deduced stride
  6709. */
  6710. static DeduceStride(kind: string): number;
  6711. /**
  6712. * Gets the byte length of the given type.
  6713. * @param type the type
  6714. * @returns the number of bytes
  6715. */
  6716. static GetTypeByteLength(type: number): number;
  6717. /**
  6718. * Enumerates each value of the given parameters as numbers.
  6719. * @param data the data to enumerate
  6720. * @param byteOffset the byte offset of the data
  6721. * @param byteStride the byte stride of the data
  6722. * @param componentCount the number of components per element
  6723. * @param componentType the type of the component
  6724. * @param count the number of values to enumerate
  6725. * @param normalized whether the data is normalized
  6726. * @param callback the callback function called for each value
  6727. */
  6728. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6729. private static _GetFloatValue;
  6730. }
  6731. }
  6732. declare module BABYLON {
  6733. /**
  6734. * @hidden
  6735. */
  6736. export class IntersectionInfo {
  6737. bu: Nullable<number>;
  6738. bv: Nullable<number>;
  6739. distance: number;
  6740. faceId: number;
  6741. subMeshId: number;
  6742. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6743. }
  6744. }
  6745. declare module BABYLON {
  6746. /**
  6747. * Class used to store bounding sphere information
  6748. */
  6749. export class BoundingSphere {
  6750. /**
  6751. * Gets the center of the bounding sphere in local space
  6752. */
  6753. readonly center: Vector3;
  6754. /**
  6755. * Radius of the bounding sphere in local space
  6756. */
  6757. radius: number;
  6758. /**
  6759. * Gets the center of the bounding sphere in world space
  6760. */
  6761. readonly centerWorld: Vector3;
  6762. /**
  6763. * Radius of the bounding sphere in world space
  6764. */
  6765. radiusWorld: number;
  6766. /**
  6767. * Gets the minimum vector in local space
  6768. */
  6769. readonly minimum: Vector3;
  6770. /**
  6771. * Gets the maximum vector in local space
  6772. */
  6773. readonly maximum: Vector3;
  6774. private _worldMatrix;
  6775. private static readonly TmpVector3;
  6776. /**
  6777. * Creates a new bounding sphere
  6778. * @param min defines the minimum vector (in local space)
  6779. * @param max defines the maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6783. /**
  6784. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6785. * @param min defines the new minimum vector (in local space)
  6786. * @param max defines the new maximum vector (in local space)
  6787. * @param worldMatrix defines the new world matrix
  6788. */
  6789. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6790. /**
  6791. * Scale the current bounding sphere by applying a scale factor
  6792. * @param factor defines the scale factor to apply
  6793. * @returns the current bounding box
  6794. */
  6795. scale(factor: number): BoundingSphere;
  6796. /**
  6797. * Gets the world matrix of the bounding box
  6798. * @returns a matrix
  6799. */
  6800. getWorldMatrix(): DeepImmutable<Matrix>;
  6801. /** @hidden */
  6802. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6803. /**
  6804. * Tests if the bounding sphere is intersecting the frustum planes
  6805. * @param frustumPlanes defines the frustum planes to test
  6806. * @returns true if there is an intersection
  6807. */
  6808. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6809. /**
  6810. * Tests if the bounding sphere center is in between the frustum planes.
  6811. * Used for optimistic fast inclusion.
  6812. * @param frustumPlanes defines the frustum planes to test
  6813. * @returns true if the sphere center is in between the frustum planes
  6814. */
  6815. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6816. /**
  6817. * Tests if a point is inside the bounding sphere
  6818. * @param point defines the point to test
  6819. * @returns true if the point is inside the bounding sphere
  6820. */
  6821. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6822. /**
  6823. * Checks if two sphere intersct
  6824. * @param sphere0 sphere 0
  6825. * @param sphere1 sphere 1
  6826. * @returns true if the speres intersect
  6827. */
  6828. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6829. }
  6830. }
  6831. declare module BABYLON {
  6832. /**
  6833. * Class used to store bounding box information
  6834. */
  6835. export class BoundingBox implements ICullable {
  6836. /**
  6837. * Gets the 8 vectors representing the bounding box in local space
  6838. */
  6839. readonly vectors: Vector3[];
  6840. /**
  6841. * Gets the center of the bounding box in local space
  6842. */
  6843. readonly center: Vector3;
  6844. /**
  6845. * Gets the center of the bounding box in world space
  6846. */
  6847. readonly centerWorld: Vector3;
  6848. /**
  6849. * Gets the extend size in local space
  6850. */
  6851. readonly extendSize: Vector3;
  6852. /**
  6853. * Gets the extend size in world space
  6854. */
  6855. readonly extendSizeWorld: Vector3;
  6856. /**
  6857. * Gets the OBB (object bounding box) directions
  6858. */
  6859. readonly directions: Vector3[];
  6860. /**
  6861. * Gets the 8 vectors representing the bounding box in world space
  6862. */
  6863. readonly vectorsWorld: Vector3[];
  6864. /**
  6865. * Gets the minimum vector in world space
  6866. */
  6867. readonly minimumWorld: Vector3;
  6868. /**
  6869. * Gets the maximum vector in world space
  6870. */
  6871. readonly maximumWorld: Vector3;
  6872. /**
  6873. * Gets the minimum vector in local space
  6874. */
  6875. readonly minimum: Vector3;
  6876. /**
  6877. * Gets the maximum vector in local space
  6878. */
  6879. readonly maximum: Vector3;
  6880. private _worldMatrix;
  6881. private static readonly TmpVector3;
  6882. /**
  6883. * @hidden
  6884. */
  6885. _tag: number;
  6886. /**
  6887. * Creates a new bounding box
  6888. * @param min defines the minimum vector (in local space)
  6889. * @param max defines the maximum vector (in local space)
  6890. * @param worldMatrix defines the new world matrix
  6891. */
  6892. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6893. /**
  6894. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6895. * @param min defines the new minimum vector (in local space)
  6896. * @param max defines the new maximum vector (in local space)
  6897. * @param worldMatrix defines the new world matrix
  6898. */
  6899. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6900. /**
  6901. * Scale the current bounding box by applying a scale factor
  6902. * @param factor defines the scale factor to apply
  6903. * @returns the current bounding box
  6904. */
  6905. scale(factor: number): BoundingBox;
  6906. /**
  6907. * Gets the world matrix of the bounding box
  6908. * @returns a matrix
  6909. */
  6910. getWorldMatrix(): DeepImmutable<Matrix>;
  6911. /** @hidden */
  6912. _update(world: DeepImmutable<Matrix>): void;
  6913. /**
  6914. * Tests if the bounding box is intersecting the frustum planes
  6915. * @param frustumPlanes defines the frustum planes to test
  6916. * @returns true if there is an intersection
  6917. */
  6918. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6919. /**
  6920. * Tests if the bounding box is entirely inside the frustum planes
  6921. * @param frustumPlanes defines the frustum planes to test
  6922. * @returns true if there is an inclusion
  6923. */
  6924. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6925. /**
  6926. * Tests if a point is inside the bounding box
  6927. * @param point defines the point to test
  6928. * @returns true if the point is inside the bounding box
  6929. */
  6930. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6931. /**
  6932. * Tests if the bounding box intersects with a bounding sphere
  6933. * @param sphere defines the sphere to test
  6934. * @returns true if there is an intersection
  6935. */
  6936. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6937. /**
  6938. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6939. * @param min defines the min vector to use
  6940. * @param max defines the max vector to use
  6941. * @returns true if there is an intersection
  6942. */
  6943. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6944. /**
  6945. * Tests if two bounding boxes are intersections
  6946. * @param box0 defines the first box to test
  6947. * @param box1 defines the second box to test
  6948. * @returns true if there is an intersection
  6949. */
  6950. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6951. /**
  6952. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6953. * @param minPoint defines the minimum vector of the bounding box
  6954. * @param maxPoint defines the maximum vector of the bounding box
  6955. * @param sphereCenter defines the sphere center
  6956. * @param sphereRadius defines the sphere radius
  6957. * @returns true if there is an intersection
  6958. */
  6959. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6960. /**
  6961. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6962. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6963. * @param frustumPlanes defines the frustum planes to test
  6964. * @return true if there is an inclusion
  6965. */
  6966. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6967. /**
  6968. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6969. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6970. * @param frustumPlanes defines the frustum planes to test
  6971. * @return true if there is an intersection
  6972. */
  6973. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6974. }
  6975. }
  6976. declare module BABYLON {
  6977. /** @hidden */
  6978. export class Collider {
  6979. /** Define if a collision was found */
  6980. collisionFound: boolean;
  6981. /**
  6982. * Define last intersection point in local space
  6983. */
  6984. intersectionPoint: Vector3;
  6985. /**
  6986. * Define last collided mesh
  6987. */
  6988. collidedMesh: Nullable<AbstractMesh>;
  6989. private _collisionPoint;
  6990. private _planeIntersectionPoint;
  6991. private _tempVector;
  6992. private _tempVector2;
  6993. private _tempVector3;
  6994. private _tempVector4;
  6995. private _edge;
  6996. private _baseToVertex;
  6997. private _destinationPoint;
  6998. private _slidePlaneNormal;
  6999. private _displacementVector;
  7000. /** @hidden */
  7001. _radius: Vector3;
  7002. /** @hidden */
  7003. _retry: number;
  7004. private _velocity;
  7005. private _basePoint;
  7006. private _epsilon;
  7007. /** @hidden */
  7008. _velocityWorldLength: number;
  7009. /** @hidden */
  7010. _basePointWorld: Vector3;
  7011. private _velocityWorld;
  7012. private _normalizedVelocity;
  7013. /** @hidden */
  7014. _initialVelocity: Vector3;
  7015. /** @hidden */
  7016. _initialPosition: Vector3;
  7017. private _nearestDistance;
  7018. private _collisionMask;
  7019. get collisionMask(): number;
  7020. set collisionMask(mask: number);
  7021. /**
  7022. * Gets the plane normal used to compute the sliding response (in local space)
  7023. */
  7024. get slidePlaneNormal(): Vector3;
  7025. /** @hidden */
  7026. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7027. /** @hidden */
  7028. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7029. /** @hidden */
  7030. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7031. /** @hidden */
  7032. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7033. /** @hidden */
  7034. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7035. /** @hidden */
  7036. _getResponse(pos: Vector3, vel: Vector3): void;
  7037. }
  7038. }
  7039. declare module BABYLON {
  7040. /**
  7041. * Interface for cullable objects
  7042. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7043. */
  7044. export interface ICullable {
  7045. /**
  7046. * Checks if the object or part of the object is in the frustum
  7047. * @param frustumPlanes Camera near/planes
  7048. * @returns true if the object is in frustum otherwise false
  7049. */
  7050. isInFrustum(frustumPlanes: Plane[]): boolean;
  7051. /**
  7052. * Checks if a cullable object (mesh...) is in the camera frustum
  7053. * Unlike isInFrustum this cheks the full bounding box
  7054. * @param frustumPlanes Camera near/planes
  7055. * @returns true if the object is in frustum otherwise false
  7056. */
  7057. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7058. }
  7059. /**
  7060. * Info for a bounding data of a mesh
  7061. */
  7062. export class BoundingInfo implements ICullable {
  7063. /**
  7064. * Bounding box for the mesh
  7065. */
  7066. readonly boundingBox: BoundingBox;
  7067. /**
  7068. * Bounding sphere for the mesh
  7069. */
  7070. readonly boundingSphere: BoundingSphere;
  7071. private _isLocked;
  7072. private static readonly TmpVector3;
  7073. /**
  7074. * Constructs bounding info
  7075. * @param minimum min vector of the bounding box/sphere
  7076. * @param maximum max vector of the bounding box/sphere
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7080. /**
  7081. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7082. * @param min defines the new minimum vector (in local space)
  7083. * @param max defines the new maximum vector (in local space)
  7084. * @param worldMatrix defines the new world matrix
  7085. */
  7086. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7087. /**
  7088. * min vector of the bounding box/sphere
  7089. */
  7090. get minimum(): Vector3;
  7091. /**
  7092. * max vector of the bounding box/sphere
  7093. */
  7094. get maximum(): Vector3;
  7095. /**
  7096. * If the info is locked and won't be updated to avoid perf overhead
  7097. */
  7098. get isLocked(): boolean;
  7099. set isLocked(value: boolean);
  7100. /**
  7101. * Updates the bounding sphere and box
  7102. * @param world world matrix to be used to update
  7103. */
  7104. update(world: DeepImmutable<Matrix>): void;
  7105. /**
  7106. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7107. * @param center New center of the bounding info
  7108. * @param extend New extend of the bounding info
  7109. * @returns the current bounding info
  7110. */
  7111. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7112. /**
  7113. * Scale the current bounding info by applying a scale factor
  7114. * @param factor defines the scale factor to apply
  7115. * @returns the current bounding info
  7116. */
  7117. scale(factor: number): BoundingInfo;
  7118. /**
  7119. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7120. * @param frustumPlanes defines the frustum to test
  7121. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7122. * @returns true if the bounding info is in the frustum planes
  7123. */
  7124. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7125. /**
  7126. * Gets the world distance between the min and max points of the bounding box
  7127. */
  7128. get diagonalLength(): number;
  7129. /**
  7130. * Checks if a cullable object (mesh...) is in the camera frustum
  7131. * Unlike isInFrustum this cheks the full bounding box
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7136. /** @hidden */
  7137. _checkCollision(collider: Collider): boolean;
  7138. /**
  7139. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7140. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7141. * @param point the point to check intersection with
  7142. * @returns if the point intersects
  7143. */
  7144. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7145. /**
  7146. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7147. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7148. * @param boundingInfo the bounding info to check intersection with
  7149. * @param precise if the intersection should be done using OBB
  7150. * @returns if the bounding info intersects
  7151. */
  7152. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7153. }
  7154. }
  7155. declare module BABYLON {
  7156. /**
  7157. * Extracts minimum and maximum values from a list of indexed positions
  7158. * @param positions defines the positions to use
  7159. * @param indices defines the indices to the positions
  7160. * @param indexStart defines the start index
  7161. * @param indexCount defines the end index
  7162. * @param bias defines bias value to add to the result
  7163. * @return minimum and maximum values
  7164. */
  7165. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7166. minimum: Vector3;
  7167. maximum: Vector3;
  7168. };
  7169. /**
  7170. * Extracts minimum and maximum values from a list of positions
  7171. * @param positions defines the positions to use
  7172. * @param start defines the start index in the positions array
  7173. * @param count defines the number of positions to handle
  7174. * @param bias defines bias value to add to the result
  7175. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7176. * @return minimum and maximum values
  7177. */
  7178. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7179. minimum: Vector3;
  7180. maximum: Vector3;
  7181. };
  7182. }
  7183. declare module BABYLON {
  7184. /** @hidden */
  7185. export class WebGLDataBuffer extends DataBuffer {
  7186. private _buffer;
  7187. constructor(resource: WebGLBuffer);
  7188. get underlyingResource(): any;
  7189. }
  7190. }
  7191. declare module BABYLON {
  7192. /** @hidden */
  7193. export class WebGLPipelineContext implements IPipelineContext {
  7194. engine: ThinEngine;
  7195. program: Nullable<WebGLProgram>;
  7196. context?: WebGLRenderingContext;
  7197. vertexShader?: WebGLShader;
  7198. fragmentShader?: WebGLShader;
  7199. isParallelCompiled: boolean;
  7200. onCompiled?: () => void;
  7201. transformFeedback?: WebGLTransformFeedback | null;
  7202. vertexCompilationError: Nullable<string>;
  7203. fragmentCompilationError: Nullable<string>;
  7204. programLinkError: Nullable<string>;
  7205. programValidationError: Nullable<string>;
  7206. get isAsync(): boolean;
  7207. get isReady(): boolean;
  7208. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7209. _getVertexShaderCode(): string | null;
  7210. _getFragmentShaderCode(): string | null;
  7211. }
  7212. }
  7213. declare module BABYLON {
  7214. interface ThinEngine {
  7215. /**
  7216. * Create an uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Create a dynamic uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param elements defines the content of the uniform buffer
  7226. * @returns the webGL uniform buffer
  7227. */
  7228. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7229. /**
  7230. * Update an existing uniform buffer
  7231. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7232. * @param uniformBuffer defines the target uniform buffer
  7233. * @param elements defines the content to update
  7234. * @param offset defines the offset in the uniform buffer where update should start
  7235. * @param count defines the size of the data to update
  7236. */
  7237. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7238. /**
  7239. * Bind an uniform buffer to the current webGL context
  7240. * @param buffer defines the buffer to bind
  7241. */
  7242. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7243. /**
  7244. * Bind a buffer to the current webGL context at a given location
  7245. * @param buffer defines the buffer to bind
  7246. * @param location defines the index where to bind the buffer
  7247. */
  7248. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7249. /**
  7250. * Bind a specific block at a given index in a specific shader program
  7251. * @param pipelineContext defines the pipeline context to use
  7252. * @param blockName defines the block name
  7253. * @param index defines the index where to bind the block
  7254. */
  7255. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7256. }
  7257. }
  7258. declare module BABYLON {
  7259. /**
  7260. * Uniform buffer objects.
  7261. *
  7262. * Handles blocks of uniform on the GPU.
  7263. *
  7264. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7265. *
  7266. * For more information, please refer to :
  7267. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7268. */
  7269. export class UniformBuffer {
  7270. private _engine;
  7271. private _buffer;
  7272. private _data;
  7273. private _bufferData;
  7274. private _dynamic?;
  7275. private _uniformLocations;
  7276. private _uniformSizes;
  7277. private _uniformLocationPointer;
  7278. private _needSync;
  7279. private _noUBO;
  7280. private _currentEffect;
  7281. /** @hidden */
  7282. _alreadyBound: boolean;
  7283. private static _MAX_UNIFORM_SIZE;
  7284. private static _tempBuffer;
  7285. /**
  7286. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7291. /**
  7292. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7297. /**
  7298. * Lambda to Update a single float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat: (name: string, x: number) => void;
  7303. /**
  7304. * Lambda to Update a vec2 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a vec3 of float in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7315. /**
  7316. * Lambda to Update a vec4 of float in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7321. /**
  7322. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateMatrix: (name: string, mat: Matrix) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateVector3: (name: string, vector: Vector3) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateVector4: (name: string, vector: Vector4) => void;
  7339. /**
  7340. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7345. /**
  7346. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7351. /**
  7352. * Instantiates a new Uniform buffer objects.
  7353. *
  7354. * Handles blocks of uniform on the GPU.
  7355. *
  7356. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7357. *
  7358. * For more information, please refer to :
  7359. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7360. * @param engine Define the engine the buffer is associated with
  7361. * @param data Define the data contained in the buffer
  7362. * @param dynamic Define if the buffer is updatable
  7363. */
  7364. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7365. /**
  7366. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7367. * or just falling back on setUniformXXX calls.
  7368. */
  7369. get useUbo(): boolean;
  7370. /**
  7371. * Indicates if the WebGL underlying uniform buffer is in sync
  7372. * with the javascript cache data.
  7373. */
  7374. get isSync(): boolean;
  7375. /**
  7376. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7377. * Also, a dynamic UniformBuffer will disable cache verification and always
  7378. * update the underlying WebGL uniform buffer to the GPU.
  7379. * @returns if Dynamic, otherwise false
  7380. */
  7381. isDynamic(): boolean;
  7382. /**
  7383. * The data cache on JS side.
  7384. * @returns the underlying data as a float array
  7385. */
  7386. getData(): Float32Array;
  7387. /**
  7388. * The underlying WebGL Uniform buffer.
  7389. * @returns the webgl buffer
  7390. */
  7391. getBuffer(): Nullable<DataBuffer>;
  7392. /**
  7393. * std140 layout specifies how to align data within an UBO structure.
  7394. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7395. * for specs.
  7396. */
  7397. private _fillAlignment;
  7398. /**
  7399. * Adds an uniform in the buffer.
  7400. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7401. * for the layout to be correct !
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param size Data size, or data directly.
  7404. */
  7405. addUniform(name: string, size: number | number[]): void;
  7406. /**
  7407. * Adds a Matrix 4x4 to the uniform buffer.
  7408. * @param name Name of the uniform, as used in the uniform block in the shader.
  7409. * @param mat A 4x4 matrix.
  7410. */
  7411. addMatrix(name: string, mat: Matrix): void;
  7412. /**
  7413. * Adds a vec2 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param x Define the x component value of the vec2
  7416. * @param y Define the y component value of the vec2
  7417. */
  7418. addFloat2(name: string, x: number, y: number): void;
  7419. /**
  7420. * Adds a vec3 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. * @param x Define the x component value of the vec3
  7423. * @param y Define the y component value of the vec3
  7424. * @param z Define the z component value of the vec3
  7425. */
  7426. addFloat3(name: string, x: number, y: number, z: number): void;
  7427. /**
  7428. * Adds a vec3 to the uniform buffer.
  7429. * @param name Name of the uniform, as used in the uniform block in the shader.
  7430. * @param color Define the vec3 from a Color
  7431. */
  7432. addColor3(name: string, color: Color3): void;
  7433. /**
  7434. * Adds a vec4 to the uniform buffer.
  7435. * @param name Name of the uniform, as used in the uniform block in the shader.
  7436. * @param color Define the rgb components from a Color
  7437. * @param alpha Define the a component of the vec4
  7438. */
  7439. addColor4(name: string, color: Color3, alpha: number): void;
  7440. /**
  7441. * Adds a vec3 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param vector Define the vec3 components from a Vector
  7444. */
  7445. addVector3(name: string, vector: Vector3): void;
  7446. /**
  7447. * Adds a Matrix 3x3 to the uniform buffer.
  7448. * @param name Name of the uniform, as used in the uniform block in the shader.
  7449. */
  7450. addMatrix3x3(name: string): void;
  7451. /**
  7452. * Adds a Matrix 2x2 to the uniform buffer.
  7453. * @param name Name of the uniform, as used in the uniform block in the shader.
  7454. */
  7455. addMatrix2x2(name: string): void;
  7456. /**
  7457. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7458. */
  7459. create(): void;
  7460. /** @hidden */
  7461. _rebuild(): void;
  7462. /**
  7463. * Updates the WebGL Uniform Buffer on the GPU.
  7464. * If the `dynamic` flag is set to true, no cache comparison is done.
  7465. * Otherwise, the buffer will be updated only if the cache differs.
  7466. */
  7467. update(): void;
  7468. /**
  7469. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7470. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7471. * @param data Define the flattened data
  7472. * @param size Define the size of the data.
  7473. */
  7474. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7475. private _valueCache;
  7476. private _cacheMatrix;
  7477. private _updateMatrix3x3ForUniform;
  7478. private _updateMatrix3x3ForEffect;
  7479. private _updateMatrix2x2ForEffect;
  7480. private _updateMatrix2x2ForUniform;
  7481. private _updateFloatForEffect;
  7482. private _updateFloatForUniform;
  7483. private _updateFloat2ForEffect;
  7484. private _updateFloat2ForUniform;
  7485. private _updateFloat3ForEffect;
  7486. private _updateFloat3ForUniform;
  7487. private _updateFloat4ForEffect;
  7488. private _updateFloat4ForUniform;
  7489. private _updateMatrixForEffect;
  7490. private _updateMatrixForUniform;
  7491. private _updateVector3ForEffect;
  7492. private _updateVector3ForUniform;
  7493. private _updateVector4ForEffect;
  7494. private _updateVector4ForUniform;
  7495. private _updateColor3ForEffect;
  7496. private _updateColor3ForUniform;
  7497. private _updateColor4ForEffect;
  7498. private _updateColor4ForUniform;
  7499. /**
  7500. * Sets a sampler uniform on the effect.
  7501. * @param name Define the name of the sampler.
  7502. * @param texture Define the texture to set in the sampler
  7503. */
  7504. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7505. /**
  7506. * Directly updates the value of the uniform in the cache AND on the GPU.
  7507. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7508. * @param data Define the flattened data
  7509. */
  7510. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7511. /**
  7512. * Binds this uniform buffer to an effect.
  7513. * @param effect Define the effect to bind the buffer to
  7514. * @param name Name of the uniform block in the shader.
  7515. */
  7516. bindToEffect(effect: Effect, name: string): void;
  7517. /**
  7518. * Disposes the uniform buffer.
  7519. */
  7520. dispose(): void;
  7521. }
  7522. }
  7523. declare module BABYLON {
  7524. /**
  7525. * Enum that determines the text-wrapping mode to use.
  7526. */
  7527. export enum InspectableType {
  7528. /**
  7529. * Checkbox for booleans
  7530. */
  7531. Checkbox = 0,
  7532. /**
  7533. * Sliders for numbers
  7534. */
  7535. Slider = 1,
  7536. /**
  7537. * Vector3
  7538. */
  7539. Vector3 = 2,
  7540. /**
  7541. * Quaternions
  7542. */
  7543. Quaternion = 3,
  7544. /**
  7545. * Color3
  7546. */
  7547. Color3 = 4,
  7548. /**
  7549. * String
  7550. */
  7551. String = 5
  7552. }
  7553. /**
  7554. * Interface used to define custom inspectable properties.
  7555. * This interface is used by the inspector to display custom property grids
  7556. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7557. */
  7558. export interface IInspectable {
  7559. /**
  7560. * Gets the label to display
  7561. */
  7562. label: string;
  7563. /**
  7564. * Gets the name of the property to edit
  7565. */
  7566. propertyName: string;
  7567. /**
  7568. * Gets the type of the editor to use
  7569. */
  7570. type: InspectableType;
  7571. /**
  7572. * Gets the minimum value of the property when using in "slider" mode
  7573. */
  7574. min?: number;
  7575. /**
  7576. * Gets the maximum value of the property when using in "slider" mode
  7577. */
  7578. max?: number;
  7579. /**
  7580. * Gets the setp to use when using in "slider" mode
  7581. */
  7582. step?: number;
  7583. }
  7584. }
  7585. declare module BABYLON {
  7586. /**
  7587. * Class used to provide helper for timing
  7588. */
  7589. export class TimingTools {
  7590. /**
  7591. * Polyfill for setImmediate
  7592. * @param action defines the action to execute after the current execution block
  7593. */
  7594. static SetImmediate(action: () => void): void;
  7595. }
  7596. }
  7597. declare module BABYLON {
  7598. /**
  7599. * Class used to enable instatition of objects by class name
  7600. */
  7601. export class InstantiationTools {
  7602. /**
  7603. * Use this object to register external classes like custom textures or material
  7604. * to allow the laoders to instantiate them
  7605. */
  7606. static RegisteredExternalClasses: {
  7607. [key: string]: Object;
  7608. };
  7609. /**
  7610. * Tries to instantiate a new object from a given class name
  7611. * @param className defines the class name to instantiate
  7612. * @returns the new object or null if the system was not able to do the instantiation
  7613. */
  7614. static Instantiate(className: string): any;
  7615. }
  7616. }
  7617. declare module BABYLON {
  7618. /**
  7619. * Define options used to create a depth texture
  7620. */
  7621. export class DepthTextureCreationOptions {
  7622. /** Specifies whether or not a stencil should be allocated in the texture */
  7623. generateStencil?: boolean;
  7624. /** Specifies whether or not bilinear filtering is enable on the texture */
  7625. bilinearFiltering?: boolean;
  7626. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7627. comparisonFunction?: number;
  7628. /** Specifies if the created texture is a cube texture */
  7629. isCube?: boolean;
  7630. }
  7631. }
  7632. declare module BABYLON {
  7633. interface ThinEngine {
  7634. /**
  7635. * Creates a depth stencil cube texture.
  7636. * This is only available in WebGL 2.
  7637. * @param size The size of face edge in the cube texture.
  7638. * @param options The options defining the cube texture.
  7639. * @returns The cube texture
  7640. */
  7641. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7642. /**
  7643. * Creates a cube texture
  7644. * @param rootUrl defines the url where the files to load is located
  7645. * @param scene defines the current scene
  7646. * @param files defines the list of files to load (1 per face)
  7647. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7648. * @param onLoad defines an optional callback raised when the texture is loaded
  7649. * @param onError defines an optional callback raised if there is an issue to load the texture
  7650. * @param format defines the format of the data
  7651. * @param forcedExtension defines the extension to use to pick the right loader
  7652. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7653. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7654. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7655. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7656. * @returns the cube texture as an InternalTexture
  7657. */
  7658. 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;
  7659. /**
  7660. * Creates a cube texture
  7661. * @param rootUrl defines the url where the files to load is located
  7662. * @param scene defines the current scene
  7663. * @param files defines the list of files to load (1 per face)
  7664. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7665. * @param onLoad defines an optional callback raised when the texture is loaded
  7666. * @param onError defines an optional callback raised if there is an issue to load the texture
  7667. * @param format defines the format of the data
  7668. * @param forcedExtension defines the extension to use to pick the right loader
  7669. * @returns the cube texture as an InternalTexture
  7670. */
  7671. 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;
  7672. /**
  7673. * Creates a cube texture
  7674. * @param rootUrl defines the url where the files to load is located
  7675. * @param scene defines the current scene
  7676. * @param files defines the list of files to load (1 per face)
  7677. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7678. * @param onLoad defines an optional callback raised when the texture is loaded
  7679. * @param onError defines an optional callback raised if there is an issue to load the texture
  7680. * @param format defines the format of the data
  7681. * @param forcedExtension defines the extension to use to pick the right loader
  7682. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7683. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7684. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7685. * @returns the cube texture as an InternalTexture
  7686. */
  7687. 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;
  7688. /** @hidden */
  7689. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7690. /** @hidden */
  7691. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7692. /** @hidden */
  7693. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7694. /** @hidden */
  7695. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7696. /**
  7697. * @hidden
  7698. */
  7699. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Class for creating a cube texture
  7705. */
  7706. export class CubeTexture extends BaseTexture {
  7707. private _delayedOnLoad;
  7708. /**
  7709. * Observable triggered once the texture has been loaded.
  7710. */
  7711. onLoadObservable: Observable<CubeTexture>;
  7712. /**
  7713. * The url of the texture
  7714. */
  7715. url: string;
  7716. /**
  7717. * Gets or sets the center of the bounding box associated with the cube texture.
  7718. * It must define where the camera used to render the texture was set
  7719. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7720. */
  7721. boundingBoxPosition: Vector3;
  7722. private _boundingBoxSize;
  7723. /**
  7724. * Gets or sets the size of the bounding box associated with the cube texture
  7725. * When defined, the cubemap will switch to local mode
  7726. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7727. * @example https://www.babylonjs-playground.com/#RNASML
  7728. */
  7729. set boundingBoxSize(value: Vector3);
  7730. /**
  7731. * Returns the bounding box size
  7732. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7733. */
  7734. get boundingBoxSize(): Vector3;
  7735. protected _rotationY: number;
  7736. /**
  7737. * Sets texture matrix rotation angle around Y axis in radians.
  7738. */
  7739. set rotationY(value: number);
  7740. /**
  7741. * Gets texture matrix rotation angle around Y axis radians.
  7742. */
  7743. get rotationY(): number;
  7744. /**
  7745. * Are mip maps generated for this texture or not.
  7746. */
  7747. get noMipmap(): boolean;
  7748. private _noMipmap;
  7749. private _files;
  7750. protected _forcedExtension: Nullable<string>;
  7751. private _extensions;
  7752. private _textureMatrix;
  7753. private _format;
  7754. private _createPolynomials;
  7755. /**
  7756. * Creates a cube texture from an array of image urls
  7757. * @param files defines an array of image urls
  7758. * @param scene defines the hosting scene
  7759. * @param noMipmap specifies if mip maps are not used
  7760. * @returns a cube texture
  7761. */
  7762. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7763. /**
  7764. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7765. * @param url defines the url of the prefiltered texture
  7766. * @param scene defines the scene the texture is attached to
  7767. * @param forcedExtension defines the extension of the file if different from the url
  7768. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7769. * @return the prefiltered texture
  7770. */
  7771. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7772. /**
  7773. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7774. * as prefiltered data.
  7775. * @param rootUrl defines the url of the texture or the root name of the six images
  7776. * @param null defines the scene or engine the texture is attached to
  7777. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7778. * @param noMipmap defines if mipmaps should be created or not
  7779. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7780. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7781. * @param onError defines a callback triggered in case of error during load
  7782. * @param format defines the internal format to use for the texture once loaded
  7783. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7784. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7785. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7786. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7787. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7788. * @return the cube texture
  7789. */
  7790. 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);
  7791. /**
  7792. * Get the current class name of the texture useful for serialization or dynamic coding.
  7793. * @returns "CubeTexture"
  7794. */
  7795. getClassName(): string;
  7796. /**
  7797. * Update the url (and optional buffer) of this texture if url was null during construction.
  7798. * @param url the url of the texture
  7799. * @param forcedExtension defines the extension to use
  7800. * @param onLoad callback called when the texture is loaded (defaults to null)
  7801. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7802. */
  7803. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7804. /**
  7805. * Delays loading of the cube texture
  7806. * @param forcedExtension defines the extension to use
  7807. */
  7808. delayLoad(forcedExtension?: string): void;
  7809. /**
  7810. * Returns the reflection texture matrix
  7811. * @returns the reflection texture matrix
  7812. */
  7813. getReflectionTextureMatrix(): Matrix;
  7814. /**
  7815. * Sets the reflection texture matrix
  7816. * @param value Reflection texture matrix
  7817. */
  7818. setReflectionTextureMatrix(value: Matrix): void;
  7819. /**
  7820. * Parses text to create a cube texture
  7821. * @param parsedTexture define the serialized text to read from
  7822. * @param scene defines the hosting scene
  7823. * @param rootUrl defines the root url of the cube texture
  7824. * @returns a cube texture
  7825. */
  7826. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7827. /**
  7828. * Makes a clone, or deep copy, of the cube texture
  7829. * @returns a new cube texture
  7830. */
  7831. clone(): CubeTexture;
  7832. }
  7833. }
  7834. declare module BABYLON {
  7835. /**
  7836. * Manages the defines for the Material
  7837. */
  7838. export class MaterialDefines {
  7839. /** @hidden */
  7840. protected _keys: string[];
  7841. private _isDirty;
  7842. /** @hidden */
  7843. _renderId: number;
  7844. /** @hidden */
  7845. _areLightsDirty: boolean;
  7846. /** @hidden */
  7847. _areLightsDisposed: boolean;
  7848. /** @hidden */
  7849. _areAttributesDirty: boolean;
  7850. /** @hidden */
  7851. _areTexturesDirty: boolean;
  7852. /** @hidden */
  7853. _areFresnelDirty: boolean;
  7854. /** @hidden */
  7855. _areMiscDirty: boolean;
  7856. /** @hidden */
  7857. _areImageProcessingDirty: boolean;
  7858. /** @hidden */
  7859. _normals: boolean;
  7860. /** @hidden */
  7861. _uvs: boolean;
  7862. /** @hidden */
  7863. _needNormals: boolean;
  7864. /** @hidden */
  7865. _needUVs: boolean;
  7866. [id: string]: any;
  7867. /**
  7868. * Specifies if the material needs to be re-calculated
  7869. */
  7870. get isDirty(): boolean;
  7871. /**
  7872. * Marks the material to indicate that it has been re-calculated
  7873. */
  7874. markAsProcessed(): void;
  7875. /**
  7876. * Marks the material to indicate that it needs to be re-calculated
  7877. */
  7878. markAsUnprocessed(): void;
  7879. /**
  7880. * Marks the material to indicate all of its defines need to be re-calculated
  7881. */
  7882. markAllAsDirty(): void;
  7883. /**
  7884. * Marks the material to indicate that image processing needs to be re-calculated
  7885. */
  7886. markAsImageProcessingDirty(): void;
  7887. /**
  7888. * Marks the material to indicate the lights need to be re-calculated
  7889. * @param disposed Defines whether the light is dirty due to dispose or not
  7890. */
  7891. markAsLightDirty(disposed?: boolean): void;
  7892. /**
  7893. * Marks the attribute state as changed
  7894. */
  7895. markAsAttributesDirty(): void;
  7896. /**
  7897. * Marks the texture state as changed
  7898. */
  7899. markAsTexturesDirty(): void;
  7900. /**
  7901. * Marks the fresnel state as changed
  7902. */
  7903. markAsFresnelDirty(): void;
  7904. /**
  7905. * Marks the misc state as changed
  7906. */
  7907. markAsMiscDirty(): void;
  7908. /**
  7909. * Rebuilds the material defines
  7910. */
  7911. rebuild(): void;
  7912. /**
  7913. * Specifies if two material defines are equal
  7914. * @param other - A material define instance to compare to
  7915. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7916. */
  7917. isEqual(other: MaterialDefines): boolean;
  7918. /**
  7919. * Clones this instance's defines to another instance
  7920. * @param other - material defines to clone values to
  7921. */
  7922. cloneTo(other: MaterialDefines): void;
  7923. /**
  7924. * Resets the material define values
  7925. */
  7926. reset(): void;
  7927. /**
  7928. * Converts the material define values to a string
  7929. * @returns - String of material define information
  7930. */
  7931. toString(): string;
  7932. }
  7933. }
  7934. declare module BABYLON {
  7935. /**
  7936. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7937. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7938. * 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;
  7939. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7940. */
  7941. export class ColorCurves {
  7942. private _dirty;
  7943. private _tempColor;
  7944. private _globalCurve;
  7945. private _highlightsCurve;
  7946. private _midtonesCurve;
  7947. private _shadowsCurve;
  7948. private _positiveCurve;
  7949. private _negativeCurve;
  7950. private _globalHue;
  7951. private _globalDensity;
  7952. private _globalSaturation;
  7953. private _globalExposure;
  7954. /**
  7955. * Gets the global Hue value.
  7956. * 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).
  7957. */
  7958. get globalHue(): number;
  7959. /**
  7960. * Sets the global Hue value.
  7961. * 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).
  7962. */
  7963. set globalHue(value: number);
  7964. /**
  7965. * Gets the global Density value.
  7966. * 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.
  7967. * Values less than zero provide a filter of opposite hue.
  7968. */
  7969. get globalDensity(): number;
  7970. /**
  7971. * Sets the global Density value.
  7972. * 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.
  7973. * Values less than zero provide a filter of opposite hue.
  7974. */
  7975. set globalDensity(value: number);
  7976. /**
  7977. * Gets the global Saturation value.
  7978. * 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.
  7979. */
  7980. get globalSaturation(): number;
  7981. /**
  7982. * Sets the global Saturation value.
  7983. * 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.
  7984. */
  7985. set globalSaturation(value: number);
  7986. /**
  7987. * Gets the global Exposure value.
  7988. * 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.
  7989. */
  7990. get globalExposure(): number;
  7991. /**
  7992. * Sets the global Exposure value.
  7993. * 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.
  7994. */
  7995. set globalExposure(value: number);
  7996. private _highlightsHue;
  7997. private _highlightsDensity;
  7998. private _highlightsSaturation;
  7999. private _highlightsExposure;
  8000. /**
  8001. * Gets the highlights Hue value.
  8002. * 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).
  8003. */
  8004. get highlightsHue(): number;
  8005. /**
  8006. * Sets the highlights Hue value.
  8007. * 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).
  8008. */
  8009. set highlightsHue(value: number);
  8010. /**
  8011. * Gets the highlights Density value.
  8012. * 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.
  8013. * Values less than zero provide a filter of opposite hue.
  8014. */
  8015. get highlightsDensity(): number;
  8016. /**
  8017. * Sets the highlights Density value.
  8018. * 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.
  8019. * Values less than zero provide a filter of opposite hue.
  8020. */
  8021. set highlightsDensity(value: number);
  8022. /**
  8023. * Gets the highlights Saturation value.
  8024. * 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.
  8025. */
  8026. get highlightsSaturation(): number;
  8027. /**
  8028. * Sets the highlights Saturation value.
  8029. * 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.
  8030. */
  8031. set highlightsSaturation(value: number);
  8032. /**
  8033. * Gets the highlights Exposure value.
  8034. * 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.
  8035. */
  8036. get highlightsExposure(): number;
  8037. /**
  8038. * Sets the highlights Exposure value.
  8039. * 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.
  8040. */
  8041. set highlightsExposure(value: number);
  8042. private _midtonesHue;
  8043. private _midtonesDensity;
  8044. private _midtonesSaturation;
  8045. private _midtonesExposure;
  8046. /**
  8047. * Gets the midtones Hue value.
  8048. * 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).
  8049. */
  8050. get midtonesHue(): number;
  8051. /**
  8052. * Sets the midtones Hue value.
  8053. * 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).
  8054. */
  8055. set midtonesHue(value: number);
  8056. /**
  8057. * Gets the midtones Density value.
  8058. * 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.
  8059. * Values less than zero provide a filter of opposite hue.
  8060. */
  8061. get midtonesDensity(): number;
  8062. /**
  8063. * Sets the midtones Density value.
  8064. * 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.
  8065. * Values less than zero provide a filter of opposite hue.
  8066. */
  8067. set midtonesDensity(value: number);
  8068. /**
  8069. * Gets the midtones Saturation value.
  8070. * 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.
  8071. */
  8072. get midtonesSaturation(): number;
  8073. /**
  8074. * Sets the midtones Saturation value.
  8075. * 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.
  8076. */
  8077. set midtonesSaturation(value: number);
  8078. /**
  8079. * Gets the midtones Exposure value.
  8080. * 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.
  8081. */
  8082. get midtonesExposure(): number;
  8083. /**
  8084. * Sets the midtones Exposure value.
  8085. * 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.
  8086. */
  8087. set midtonesExposure(value: number);
  8088. private _shadowsHue;
  8089. private _shadowsDensity;
  8090. private _shadowsSaturation;
  8091. private _shadowsExposure;
  8092. /**
  8093. * Gets the shadows Hue value.
  8094. * 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).
  8095. */
  8096. get shadowsHue(): number;
  8097. /**
  8098. * Sets the shadows Hue value.
  8099. * 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).
  8100. */
  8101. set shadowsHue(value: number);
  8102. /**
  8103. * Gets the shadows Density value.
  8104. * 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.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. get shadowsDensity(): number;
  8108. /**
  8109. * Sets the shadows Density value.
  8110. * 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.
  8111. * Values less than zero provide a filter of opposite hue.
  8112. */
  8113. set shadowsDensity(value: number);
  8114. /**
  8115. * Gets the shadows Saturation value.
  8116. * 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.
  8117. */
  8118. get shadowsSaturation(): number;
  8119. /**
  8120. * Sets the shadows Saturation value.
  8121. * 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.
  8122. */
  8123. set shadowsSaturation(value: number);
  8124. /**
  8125. * Gets the shadows Exposure value.
  8126. * 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.
  8127. */
  8128. get shadowsExposure(): number;
  8129. /**
  8130. * Sets the shadows Exposure value.
  8131. * 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.
  8132. */
  8133. set shadowsExposure(value: number);
  8134. /**
  8135. * Returns the class name
  8136. * @returns The class name
  8137. */
  8138. getClassName(): string;
  8139. /**
  8140. * Binds the color curves to the shader.
  8141. * @param colorCurves The color curve to bind
  8142. * @param effect The effect to bind to
  8143. * @param positiveUniform The positive uniform shader parameter
  8144. * @param neutralUniform The neutral uniform shader parameter
  8145. * @param negativeUniform The negative uniform shader parameter
  8146. */
  8147. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8148. /**
  8149. * Prepare the list of uniforms associated with the ColorCurves effects.
  8150. * @param uniformsList The list of uniforms used in the effect
  8151. */
  8152. static PrepareUniforms(uniformsList: string[]): void;
  8153. /**
  8154. * Returns color grading data based on a hue, density, saturation and exposure value.
  8155. * @param filterHue The hue of the color filter.
  8156. * @param filterDensity The density of the color filter.
  8157. * @param saturation The saturation.
  8158. * @param exposure The exposure.
  8159. * @param result The result data container.
  8160. */
  8161. private getColorGradingDataToRef;
  8162. /**
  8163. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8164. * @param value The input slider value in range [-100,100].
  8165. * @returns Adjusted value.
  8166. */
  8167. private static applyColorGradingSliderNonlinear;
  8168. /**
  8169. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8170. * @param hue The hue (H) input.
  8171. * @param saturation The saturation (S) input.
  8172. * @param brightness The brightness (B) input.
  8173. * @result An RGBA color represented as Vector4.
  8174. */
  8175. private static fromHSBToRef;
  8176. /**
  8177. * Returns a value clamped between min and max
  8178. * @param value The value to clamp
  8179. * @param min The minimum of value
  8180. * @param max The maximum of value
  8181. * @returns The clamped value.
  8182. */
  8183. private static clamp;
  8184. /**
  8185. * Clones the current color curve instance.
  8186. * @return The cloned curves
  8187. */
  8188. clone(): ColorCurves;
  8189. /**
  8190. * Serializes the current color curve instance to a json representation.
  8191. * @return a JSON representation
  8192. */
  8193. serialize(): any;
  8194. /**
  8195. * Parses the color curve from a json representation.
  8196. * @param source the JSON source to parse
  8197. * @return The parsed curves
  8198. */
  8199. static Parse(source: any): ColorCurves;
  8200. }
  8201. }
  8202. declare module BABYLON {
  8203. /**
  8204. * Interface to follow in your material defines to integrate easily the
  8205. * Image proccessing functions.
  8206. * @hidden
  8207. */
  8208. export interface IImageProcessingConfigurationDefines {
  8209. IMAGEPROCESSING: boolean;
  8210. VIGNETTE: boolean;
  8211. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8212. VIGNETTEBLENDMODEOPAQUE: boolean;
  8213. TONEMAPPING: boolean;
  8214. TONEMAPPING_ACES: boolean;
  8215. CONTRAST: boolean;
  8216. EXPOSURE: boolean;
  8217. COLORCURVES: boolean;
  8218. COLORGRADING: boolean;
  8219. COLORGRADING3D: boolean;
  8220. SAMPLER3DGREENDEPTH: boolean;
  8221. SAMPLER3DBGRMAP: boolean;
  8222. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8223. }
  8224. /**
  8225. * @hidden
  8226. */
  8227. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8228. IMAGEPROCESSING: boolean;
  8229. VIGNETTE: boolean;
  8230. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8231. VIGNETTEBLENDMODEOPAQUE: boolean;
  8232. TONEMAPPING: boolean;
  8233. TONEMAPPING_ACES: boolean;
  8234. CONTRAST: boolean;
  8235. COLORCURVES: boolean;
  8236. COLORGRADING: boolean;
  8237. COLORGRADING3D: boolean;
  8238. SAMPLER3DGREENDEPTH: boolean;
  8239. SAMPLER3DBGRMAP: boolean;
  8240. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8241. EXPOSURE: boolean;
  8242. constructor();
  8243. }
  8244. /**
  8245. * This groups together the common properties used for image processing either in direct forward pass
  8246. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8247. * or not.
  8248. */
  8249. export class ImageProcessingConfiguration {
  8250. /**
  8251. * Default tone mapping applied in BabylonJS.
  8252. */
  8253. static readonly TONEMAPPING_STANDARD: number;
  8254. /**
  8255. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8256. * to other engines rendering to increase portability.
  8257. */
  8258. static readonly TONEMAPPING_ACES: number;
  8259. /**
  8260. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8261. */
  8262. colorCurves: Nullable<ColorCurves>;
  8263. private _colorCurvesEnabled;
  8264. /**
  8265. * Gets wether the color curves effect is enabled.
  8266. */
  8267. get colorCurvesEnabled(): boolean;
  8268. /**
  8269. * Sets wether the color curves effect is enabled.
  8270. */
  8271. set colorCurvesEnabled(value: boolean);
  8272. private _colorGradingTexture;
  8273. /**
  8274. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8275. */
  8276. get colorGradingTexture(): Nullable<BaseTexture>;
  8277. /**
  8278. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8279. */
  8280. set colorGradingTexture(value: Nullable<BaseTexture>);
  8281. private _colorGradingEnabled;
  8282. /**
  8283. * Gets wether the color grading effect is enabled.
  8284. */
  8285. get colorGradingEnabled(): boolean;
  8286. /**
  8287. * Sets wether the color grading effect is enabled.
  8288. */
  8289. set colorGradingEnabled(value: boolean);
  8290. private _colorGradingWithGreenDepth;
  8291. /**
  8292. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8293. */
  8294. get colorGradingWithGreenDepth(): boolean;
  8295. /**
  8296. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8297. */
  8298. set colorGradingWithGreenDepth(value: boolean);
  8299. private _colorGradingBGR;
  8300. /**
  8301. * Gets wether the color grading texture contains BGR values.
  8302. */
  8303. get colorGradingBGR(): boolean;
  8304. /**
  8305. * Sets wether the color grading texture contains BGR values.
  8306. */
  8307. set colorGradingBGR(value: boolean);
  8308. /** @hidden */
  8309. _exposure: number;
  8310. /**
  8311. * Gets the Exposure used in the effect.
  8312. */
  8313. get exposure(): number;
  8314. /**
  8315. * Sets the Exposure used in the effect.
  8316. */
  8317. set exposure(value: number);
  8318. private _toneMappingEnabled;
  8319. /**
  8320. * Gets wether the tone mapping effect is enabled.
  8321. */
  8322. get toneMappingEnabled(): boolean;
  8323. /**
  8324. * Sets wether the tone mapping effect is enabled.
  8325. */
  8326. set toneMappingEnabled(value: boolean);
  8327. private _toneMappingType;
  8328. /**
  8329. * Gets the type of tone mapping effect.
  8330. */
  8331. get toneMappingType(): number;
  8332. /**
  8333. * Sets the type of tone mapping effect used in BabylonJS.
  8334. */
  8335. set toneMappingType(value: number);
  8336. protected _contrast: number;
  8337. /**
  8338. * Gets the contrast used in the effect.
  8339. */
  8340. get contrast(): number;
  8341. /**
  8342. * Sets the contrast used in the effect.
  8343. */
  8344. set contrast(value: number);
  8345. /**
  8346. * Vignette stretch size.
  8347. */
  8348. vignetteStretch: number;
  8349. /**
  8350. * Vignette centre X Offset.
  8351. */
  8352. vignetteCentreX: number;
  8353. /**
  8354. * Vignette centre Y Offset.
  8355. */
  8356. vignetteCentreY: number;
  8357. /**
  8358. * Vignette weight or intensity of the vignette effect.
  8359. */
  8360. vignetteWeight: number;
  8361. /**
  8362. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8363. * if vignetteEnabled is set to true.
  8364. */
  8365. vignetteColor: Color4;
  8366. /**
  8367. * Camera field of view used by the Vignette effect.
  8368. */
  8369. vignetteCameraFov: number;
  8370. private _vignetteBlendMode;
  8371. /**
  8372. * Gets the vignette blend mode allowing different kind of effect.
  8373. */
  8374. get vignetteBlendMode(): number;
  8375. /**
  8376. * Sets the vignette blend mode allowing different kind of effect.
  8377. */
  8378. set vignetteBlendMode(value: number);
  8379. private _vignetteEnabled;
  8380. /**
  8381. * Gets wether the vignette effect is enabled.
  8382. */
  8383. get vignetteEnabled(): boolean;
  8384. /**
  8385. * Sets wether the vignette effect is enabled.
  8386. */
  8387. set vignetteEnabled(value: boolean);
  8388. private _applyByPostProcess;
  8389. /**
  8390. * Gets wether the image processing is applied through a post process or not.
  8391. */
  8392. get applyByPostProcess(): boolean;
  8393. /**
  8394. * Sets wether the image processing is applied through a post process or not.
  8395. */
  8396. set applyByPostProcess(value: boolean);
  8397. private _isEnabled;
  8398. /**
  8399. * Gets wether the image processing is enabled or not.
  8400. */
  8401. get isEnabled(): boolean;
  8402. /**
  8403. * Sets wether the image processing is enabled or not.
  8404. */
  8405. set isEnabled(value: boolean);
  8406. /**
  8407. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8408. */
  8409. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8410. /**
  8411. * Method called each time the image processing information changes requires to recompile the effect.
  8412. */
  8413. protected _updateParameters(): void;
  8414. /**
  8415. * Gets the current class name.
  8416. * @return "ImageProcessingConfiguration"
  8417. */
  8418. getClassName(): string;
  8419. /**
  8420. * Prepare the list of uniforms associated with the Image Processing effects.
  8421. * @param uniforms The list of uniforms used in the effect
  8422. * @param defines the list of defines currently in use
  8423. */
  8424. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8425. /**
  8426. * Prepare the list of samplers associated with the Image Processing effects.
  8427. * @param samplersList The list of uniforms used in the effect
  8428. * @param defines the list of defines currently in use
  8429. */
  8430. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8431. /**
  8432. * Prepare the list of defines associated to the shader.
  8433. * @param defines the list of defines to complete
  8434. * @param forPostProcess Define if we are currently in post process mode or not
  8435. */
  8436. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8437. /**
  8438. * Returns true if all the image processing information are ready.
  8439. * @returns True if ready, otherwise, false
  8440. */
  8441. isReady(): boolean;
  8442. /**
  8443. * Binds the image processing to the shader.
  8444. * @param effect The effect to bind to
  8445. * @param overrideAspectRatio Override the aspect ratio of the effect
  8446. */
  8447. bind(effect: Effect, overrideAspectRatio?: number): void;
  8448. /**
  8449. * Clones the current image processing instance.
  8450. * @return The cloned image processing
  8451. */
  8452. clone(): ImageProcessingConfiguration;
  8453. /**
  8454. * Serializes the current image processing instance to a json representation.
  8455. * @return a JSON representation
  8456. */
  8457. serialize(): any;
  8458. /**
  8459. * Parses the image processing from a json representation.
  8460. * @param source the JSON source to parse
  8461. * @return The parsed image processing
  8462. */
  8463. static Parse(source: any): ImageProcessingConfiguration;
  8464. private static _VIGNETTEMODE_MULTIPLY;
  8465. private static _VIGNETTEMODE_OPAQUE;
  8466. /**
  8467. * Used to apply the vignette as a mix with the pixel color.
  8468. */
  8469. static get VIGNETTEMODE_MULTIPLY(): number;
  8470. /**
  8471. * Used to apply the vignette as a replacement of the pixel color.
  8472. */
  8473. static get VIGNETTEMODE_OPAQUE(): number;
  8474. }
  8475. }
  8476. declare module BABYLON {
  8477. /** @hidden */
  8478. export var postprocessVertexShader: {
  8479. name: string;
  8480. shader: string;
  8481. };
  8482. }
  8483. declare module BABYLON {
  8484. interface ThinEngine {
  8485. /**
  8486. * Creates a new render target texture
  8487. * @param size defines the size of the texture
  8488. * @param options defines the options used to create the texture
  8489. * @returns a new render target texture stored in an InternalTexture
  8490. */
  8491. createRenderTargetTexture(size: number | {
  8492. width: number;
  8493. height: number;
  8494. layers?: number;
  8495. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8496. /**
  8497. * Creates a depth stencil texture.
  8498. * This is only available in WebGL 2 or with the depth texture extension available.
  8499. * @param size The size of face edge in the texture.
  8500. * @param options The options defining the texture.
  8501. * @returns The texture
  8502. */
  8503. createDepthStencilTexture(size: number | {
  8504. width: number;
  8505. height: number;
  8506. layers?: number;
  8507. }, options: DepthTextureCreationOptions): InternalTexture;
  8508. /** @hidden */
  8509. _createDepthStencilTexture(size: number | {
  8510. width: number;
  8511. height: number;
  8512. layers?: number;
  8513. }, options: DepthTextureCreationOptions): InternalTexture;
  8514. }
  8515. }
  8516. declare module BABYLON {
  8517. /**
  8518. * Defines the kind of connection point for node based material
  8519. */
  8520. export enum NodeMaterialBlockConnectionPointTypes {
  8521. /** Float */
  8522. Float = 1,
  8523. /** Int */
  8524. Int = 2,
  8525. /** Vector2 */
  8526. Vector2 = 4,
  8527. /** Vector3 */
  8528. Vector3 = 8,
  8529. /** Vector4 */
  8530. Vector4 = 16,
  8531. /** Color3 */
  8532. Color3 = 32,
  8533. /** Color4 */
  8534. Color4 = 64,
  8535. /** Matrix */
  8536. Matrix = 128,
  8537. /** Custom object */
  8538. Object = 256,
  8539. /** Detect type based on connection */
  8540. AutoDetect = 1024,
  8541. /** Output type that will be defined by input type */
  8542. BasedOnInput = 2048
  8543. }
  8544. }
  8545. declare module BABYLON {
  8546. /**
  8547. * Enum used to define the target of a block
  8548. */
  8549. export enum NodeMaterialBlockTargets {
  8550. /** Vertex shader */
  8551. Vertex = 1,
  8552. /** Fragment shader */
  8553. Fragment = 2,
  8554. /** Neutral */
  8555. Neutral = 4,
  8556. /** Vertex and Fragment */
  8557. VertexAndFragment = 3
  8558. }
  8559. }
  8560. declare module BABYLON {
  8561. /**
  8562. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8563. */
  8564. export enum NodeMaterialBlockConnectionPointMode {
  8565. /** Value is an uniform */
  8566. Uniform = 0,
  8567. /** Value is a mesh attribute */
  8568. Attribute = 1,
  8569. /** Value is a varying between vertex and fragment shaders */
  8570. Varying = 2,
  8571. /** Mode is undefined */
  8572. Undefined = 3
  8573. }
  8574. }
  8575. declare module BABYLON {
  8576. /**
  8577. * Enum used to define system values e.g. values automatically provided by the system
  8578. */
  8579. export enum NodeMaterialSystemValues {
  8580. /** World */
  8581. World = 1,
  8582. /** View */
  8583. View = 2,
  8584. /** Projection */
  8585. Projection = 3,
  8586. /** ViewProjection */
  8587. ViewProjection = 4,
  8588. /** WorldView */
  8589. WorldView = 5,
  8590. /** WorldViewProjection */
  8591. WorldViewProjection = 6,
  8592. /** CameraPosition */
  8593. CameraPosition = 7,
  8594. /** Fog Color */
  8595. FogColor = 8,
  8596. /** Delta time */
  8597. DeltaTime = 9
  8598. }
  8599. }
  8600. declare module BABYLON {
  8601. /** Defines supported spaces */
  8602. export enum Space {
  8603. /** Local (object) space */
  8604. LOCAL = 0,
  8605. /** World space */
  8606. WORLD = 1,
  8607. /** Bone space */
  8608. BONE = 2
  8609. }
  8610. /** Defines the 3 main axes */
  8611. export class Axis {
  8612. /** X axis */
  8613. static X: Vector3;
  8614. /** Y axis */
  8615. static Y: Vector3;
  8616. /** Z axis */
  8617. static Z: Vector3;
  8618. }
  8619. }
  8620. declare module BABYLON {
  8621. /**
  8622. * Represents a camera frustum
  8623. */
  8624. export class Frustum {
  8625. /**
  8626. * Gets the planes representing the frustum
  8627. * @param transform matrix to be applied to the returned planes
  8628. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8629. */
  8630. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8631. /**
  8632. * Gets the near frustum plane transformed by the transform matrix
  8633. * @param transform transformation matrix to be applied to the resulting frustum plane
  8634. * @param frustumPlane the resuling frustum plane
  8635. */
  8636. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8637. /**
  8638. * Gets the far frustum plane transformed by the transform matrix
  8639. * @param transform transformation matrix to be applied to the resulting frustum plane
  8640. * @param frustumPlane the resuling frustum plane
  8641. */
  8642. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8643. /**
  8644. * Gets the left frustum plane transformed by the transform matrix
  8645. * @param transform transformation matrix to be applied to the resulting frustum plane
  8646. * @param frustumPlane the resuling frustum plane
  8647. */
  8648. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8649. /**
  8650. * Gets the right frustum plane transformed by the transform matrix
  8651. * @param transform transformation matrix to be applied to the resulting frustum plane
  8652. * @param frustumPlane the resuling frustum plane
  8653. */
  8654. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8655. /**
  8656. * Gets the top frustum plane transformed by the transform matrix
  8657. * @param transform transformation matrix to be applied to the resulting frustum plane
  8658. * @param frustumPlane the resuling frustum plane
  8659. */
  8660. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8661. /**
  8662. * Gets the bottom frustum plane transformed by the transform matrix
  8663. * @param transform transformation matrix to be applied to the resulting frustum plane
  8664. * @param frustumPlane the resuling frustum plane
  8665. */
  8666. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8667. /**
  8668. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8669. * @param transform transformation matrix to be applied to the resulting frustum planes
  8670. * @param frustumPlanes the resuling frustum planes
  8671. */
  8672. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8673. }
  8674. }
  8675. declare module BABYLON {
  8676. /**
  8677. * Interface for the size containing width and height
  8678. */
  8679. export interface ISize {
  8680. /**
  8681. * Width
  8682. */
  8683. width: number;
  8684. /**
  8685. * Heighht
  8686. */
  8687. height: number;
  8688. }
  8689. /**
  8690. * Size containing widht and height
  8691. */
  8692. export class Size implements ISize {
  8693. /**
  8694. * Width
  8695. */
  8696. width: number;
  8697. /**
  8698. * Height
  8699. */
  8700. height: number;
  8701. /**
  8702. * Creates a Size object from the given width and height (floats).
  8703. * @param width width of the new size
  8704. * @param height height of the new size
  8705. */
  8706. constructor(width: number, height: number);
  8707. /**
  8708. * Returns a string with the Size width and height
  8709. * @returns a string with the Size width and height
  8710. */
  8711. toString(): string;
  8712. /**
  8713. * "Size"
  8714. * @returns the string "Size"
  8715. */
  8716. getClassName(): string;
  8717. /**
  8718. * Returns the Size hash code.
  8719. * @returns a hash code for a unique width and height
  8720. */
  8721. getHashCode(): number;
  8722. /**
  8723. * Updates the current size from the given one.
  8724. * @param src the given size
  8725. */
  8726. copyFrom(src: Size): void;
  8727. /**
  8728. * Updates in place the current Size from the given floats.
  8729. * @param width width of the new size
  8730. * @param height height of the new size
  8731. * @returns the updated Size.
  8732. */
  8733. copyFromFloats(width: number, height: number): Size;
  8734. /**
  8735. * Updates in place the current Size from the given floats.
  8736. * @param width width to set
  8737. * @param height height to set
  8738. * @returns the updated Size.
  8739. */
  8740. set(width: number, height: number): Size;
  8741. /**
  8742. * Multiplies the width and height by numbers
  8743. * @param w factor to multiple the width by
  8744. * @param h factor to multiple the height by
  8745. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8746. */
  8747. multiplyByFloats(w: number, h: number): Size;
  8748. /**
  8749. * Clones the size
  8750. * @returns a new Size copied from the given one.
  8751. */
  8752. clone(): Size;
  8753. /**
  8754. * True if the current Size and the given one width and height are strictly equal.
  8755. * @param other the other size to compare against
  8756. * @returns True if the current Size and the given one width and height are strictly equal.
  8757. */
  8758. equals(other: Size): boolean;
  8759. /**
  8760. * The surface of the Size : width * height (float).
  8761. */
  8762. get surface(): number;
  8763. /**
  8764. * Create a new size of zero
  8765. * @returns a new Size set to (0.0, 0.0)
  8766. */
  8767. static Zero(): Size;
  8768. /**
  8769. * Sums the width and height of two sizes
  8770. * @param otherSize size to add to this size
  8771. * @returns a new Size set as the addition result of the current Size and the given one.
  8772. */
  8773. add(otherSize: Size): Size;
  8774. /**
  8775. * Subtracts the width and height of two
  8776. * @param otherSize size to subtract to this size
  8777. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8778. */
  8779. subtract(otherSize: Size): Size;
  8780. /**
  8781. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8782. * @param start starting size to lerp between
  8783. * @param end end size to lerp between
  8784. * @param amount amount to lerp between the start and end values
  8785. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8786. */
  8787. static Lerp(start: Size, end: Size, amount: number): Size;
  8788. }
  8789. }
  8790. declare module BABYLON {
  8791. /**
  8792. * Contains position and normal vectors for a vertex
  8793. */
  8794. export class PositionNormalVertex {
  8795. /** the position of the vertex (defaut: 0,0,0) */
  8796. position: Vector3;
  8797. /** the normal of the vertex (defaut: 0,1,0) */
  8798. normal: Vector3;
  8799. /**
  8800. * Creates a PositionNormalVertex
  8801. * @param position the position of the vertex (defaut: 0,0,0)
  8802. * @param normal the normal of the vertex (defaut: 0,1,0)
  8803. */
  8804. constructor(
  8805. /** the position of the vertex (defaut: 0,0,0) */
  8806. position?: Vector3,
  8807. /** the normal of the vertex (defaut: 0,1,0) */
  8808. normal?: Vector3);
  8809. /**
  8810. * Clones the PositionNormalVertex
  8811. * @returns the cloned PositionNormalVertex
  8812. */
  8813. clone(): PositionNormalVertex;
  8814. }
  8815. /**
  8816. * Contains position, normal and uv vectors for a vertex
  8817. */
  8818. export class PositionNormalTextureVertex {
  8819. /** the position of the vertex (defaut: 0,0,0) */
  8820. position: Vector3;
  8821. /** the normal of the vertex (defaut: 0,1,0) */
  8822. normal: Vector3;
  8823. /** the uv of the vertex (default: 0,0) */
  8824. uv: Vector2;
  8825. /**
  8826. * Creates a PositionNormalTextureVertex
  8827. * @param position the position of the vertex (defaut: 0,0,0)
  8828. * @param normal the normal of the vertex (defaut: 0,1,0)
  8829. * @param uv the uv of the vertex (default: 0,0)
  8830. */
  8831. constructor(
  8832. /** the position of the vertex (defaut: 0,0,0) */
  8833. position?: Vector3,
  8834. /** the normal of the vertex (defaut: 0,1,0) */
  8835. normal?: Vector3,
  8836. /** the uv of the vertex (default: 0,0) */
  8837. uv?: Vector2);
  8838. /**
  8839. * Clones the PositionNormalTextureVertex
  8840. * @returns the cloned PositionNormalTextureVertex
  8841. */
  8842. clone(): PositionNormalTextureVertex;
  8843. }
  8844. }
  8845. declare module BABYLON {
  8846. /**
  8847. * Enum defining the type of animations supported by InputBlock
  8848. */
  8849. export enum AnimatedInputBlockTypes {
  8850. /** No animation */
  8851. None = 0,
  8852. /** Time based animation. Will only work for floats */
  8853. Time = 1
  8854. }
  8855. }
  8856. declare module BABYLON {
  8857. /**
  8858. * Interface describing all the common properties and methods a shadow light needs to implement.
  8859. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8860. * as well as binding the different shadow properties to the effects.
  8861. */
  8862. export interface IShadowLight extends Light {
  8863. /**
  8864. * The light id in the scene (used in scene.findLighById for instance)
  8865. */
  8866. id: string;
  8867. /**
  8868. * The position the shdow will be casted from.
  8869. */
  8870. position: Vector3;
  8871. /**
  8872. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8873. */
  8874. direction: Vector3;
  8875. /**
  8876. * The transformed position. Position of the light in world space taking parenting in account.
  8877. */
  8878. transformedPosition: Vector3;
  8879. /**
  8880. * The transformed direction. Direction of the light in world space taking parenting in account.
  8881. */
  8882. transformedDirection: Vector3;
  8883. /**
  8884. * The friendly name of the light in the scene.
  8885. */
  8886. name: string;
  8887. /**
  8888. * Defines the shadow projection clipping minimum z value.
  8889. */
  8890. shadowMinZ: number;
  8891. /**
  8892. * Defines the shadow projection clipping maximum z value.
  8893. */
  8894. shadowMaxZ: number;
  8895. /**
  8896. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8897. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8898. */
  8899. computeTransformedInformation(): boolean;
  8900. /**
  8901. * Gets the scene the light belongs to.
  8902. * @returns The scene
  8903. */
  8904. getScene(): Scene;
  8905. /**
  8906. * Callback defining a custom Projection Matrix Builder.
  8907. * This can be used to override the default projection matrix computation.
  8908. */
  8909. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8910. /**
  8911. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8912. * @param matrix The materix to updated with the projection information
  8913. * @param viewMatrix The transform matrix of the light
  8914. * @param renderList The list of mesh to render in the map
  8915. * @returns The current light
  8916. */
  8917. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8918. /**
  8919. * Gets the current depth scale used in ESM.
  8920. * @returns The scale
  8921. */
  8922. getDepthScale(): number;
  8923. /**
  8924. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8925. * @returns true if a cube texture needs to be use
  8926. */
  8927. needCube(): boolean;
  8928. /**
  8929. * Detects if the projection matrix requires to be recomputed this frame.
  8930. * @returns true if it requires to be recomputed otherwise, false.
  8931. */
  8932. needProjectionMatrixCompute(): boolean;
  8933. /**
  8934. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8935. */
  8936. forceProjectionMatrixCompute(): void;
  8937. /**
  8938. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8939. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8940. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8941. */
  8942. getShadowDirection(faceIndex?: number): Vector3;
  8943. /**
  8944. * Gets the minZ used for shadow according to both the scene and the light.
  8945. * @param activeCamera The camera we are returning the min for
  8946. * @returns the depth min z
  8947. */
  8948. getDepthMinZ(activeCamera: Camera): number;
  8949. /**
  8950. * Gets the maxZ used for shadow according to both the scene and the light.
  8951. * @param activeCamera The camera we are returning the max for
  8952. * @returns the depth max z
  8953. */
  8954. getDepthMaxZ(activeCamera: Camera): number;
  8955. }
  8956. /**
  8957. * Base implementation IShadowLight
  8958. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8959. */
  8960. export abstract class ShadowLight extends Light implements IShadowLight {
  8961. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8962. protected _position: Vector3;
  8963. protected _setPosition(value: Vector3): void;
  8964. /**
  8965. * Sets the position the shadow will be casted from. Also use as the light position for both
  8966. * point and spot lights.
  8967. */
  8968. get position(): Vector3;
  8969. /**
  8970. * Sets the position the shadow will be casted from. Also use as the light position for both
  8971. * point and spot lights.
  8972. */
  8973. set position(value: Vector3);
  8974. protected _direction: Vector3;
  8975. protected _setDirection(value: Vector3): void;
  8976. /**
  8977. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8978. * Also use as the light direction on spot and directional lights.
  8979. */
  8980. get direction(): Vector3;
  8981. /**
  8982. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8983. * Also use as the light direction on spot and directional lights.
  8984. */
  8985. set direction(value: Vector3);
  8986. protected _shadowMinZ: number;
  8987. /**
  8988. * Gets the shadow projection clipping minimum z value.
  8989. */
  8990. get shadowMinZ(): number;
  8991. /**
  8992. * Sets the shadow projection clipping minimum z value.
  8993. */
  8994. set shadowMinZ(value: number);
  8995. protected _shadowMaxZ: number;
  8996. /**
  8997. * Sets the shadow projection clipping maximum z value.
  8998. */
  8999. get shadowMaxZ(): number;
  9000. /**
  9001. * Gets the shadow projection clipping maximum z value.
  9002. */
  9003. set shadowMaxZ(value: number);
  9004. /**
  9005. * Callback defining a custom Projection Matrix Builder.
  9006. * This can be used to override the default projection matrix computation.
  9007. */
  9008. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9009. /**
  9010. * The transformed position. Position of the light in world space taking parenting in account.
  9011. */
  9012. transformedPosition: Vector3;
  9013. /**
  9014. * The transformed direction. Direction of the light in world space taking parenting in account.
  9015. */
  9016. transformedDirection: Vector3;
  9017. private _needProjectionMatrixCompute;
  9018. /**
  9019. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9020. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9021. */
  9022. computeTransformedInformation(): boolean;
  9023. /**
  9024. * Return the depth scale used for the shadow map.
  9025. * @returns the depth scale.
  9026. */
  9027. getDepthScale(): number;
  9028. /**
  9029. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9030. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9031. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9032. */
  9033. getShadowDirection(faceIndex?: number): Vector3;
  9034. /**
  9035. * Returns the ShadowLight absolute position in the World.
  9036. * @returns the position vector in world space
  9037. */
  9038. getAbsolutePosition(): Vector3;
  9039. /**
  9040. * Sets the ShadowLight direction toward the passed target.
  9041. * @param target The point to target in local space
  9042. * @returns the updated ShadowLight direction
  9043. */
  9044. setDirectionToTarget(target: Vector3): Vector3;
  9045. /**
  9046. * Returns the light rotation in euler definition.
  9047. * @returns the x y z rotation in local space.
  9048. */
  9049. getRotation(): Vector3;
  9050. /**
  9051. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9052. * @returns true if a cube texture needs to be use
  9053. */
  9054. needCube(): boolean;
  9055. /**
  9056. * Detects if the projection matrix requires to be recomputed this frame.
  9057. * @returns true if it requires to be recomputed otherwise, false.
  9058. */
  9059. needProjectionMatrixCompute(): boolean;
  9060. /**
  9061. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9062. */
  9063. forceProjectionMatrixCompute(): void;
  9064. /** @hidden */
  9065. _initCache(): void;
  9066. /** @hidden */
  9067. _isSynchronized(): boolean;
  9068. /**
  9069. * Computes the world matrix of the node
  9070. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9071. * @returns the world matrix
  9072. */
  9073. computeWorldMatrix(force?: boolean): Matrix;
  9074. /**
  9075. * Gets the minZ used for shadow according to both the scene and the light.
  9076. * @param activeCamera The camera we are returning the min for
  9077. * @returns the depth min z
  9078. */
  9079. getDepthMinZ(activeCamera: Camera): number;
  9080. /**
  9081. * Gets the maxZ used for shadow according to both the scene and the light.
  9082. * @param activeCamera The camera we are returning the max for
  9083. * @returns the depth max z
  9084. */
  9085. getDepthMaxZ(activeCamera: Camera): number;
  9086. /**
  9087. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9088. * @param matrix The materix to updated with the projection information
  9089. * @param viewMatrix The transform matrix of the light
  9090. * @param renderList The list of mesh to render in the map
  9091. * @returns The current light
  9092. */
  9093. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9094. }
  9095. }
  9096. declare module BABYLON {
  9097. /** @hidden */
  9098. export var packingFunctions: {
  9099. name: string;
  9100. shader: string;
  9101. };
  9102. }
  9103. declare module BABYLON {
  9104. /** @hidden */
  9105. export var bayerDitherFunctions: {
  9106. name: string;
  9107. shader: string;
  9108. };
  9109. }
  9110. declare module BABYLON {
  9111. /** @hidden */
  9112. export var shadowMapFragmentDeclaration: {
  9113. name: string;
  9114. shader: string;
  9115. };
  9116. }
  9117. declare module BABYLON {
  9118. /** @hidden */
  9119. export var clipPlaneFragmentDeclaration: {
  9120. name: string;
  9121. shader: string;
  9122. };
  9123. }
  9124. declare module BABYLON {
  9125. /** @hidden */
  9126. export var clipPlaneFragment: {
  9127. name: string;
  9128. shader: string;
  9129. };
  9130. }
  9131. declare module BABYLON {
  9132. /** @hidden */
  9133. export var shadowMapFragment: {
  9134. name: string;
  9135. shader: string;
  9136. };
  9137. }
  9138. declare module BABYLON {
  9139. /** @hidden */
  9140. export var shadowMapPixelShader: {
  9141. name: string;
  9142. shader: string;
  9143. };
  9144. }
  9145. declare module BABYLON {
  9146. /** @hidden */
  9147. export var bonesDeclaration: {
  9148. name: string;
  9149. shader: string;
  9150. };
  9151. }
  9152. declare module BABYLON {
  9153. /** @hidden */
  9154. export var morphTargetsVertexGlobalDeclaration: {
  9155. name: string;
  9156. shader: string;
  9157. };
  9158. }
  9159. declare module BABYLON {
  9160. /** @hidden */
  9161. export var morphTargetsVertexDeclaration: {
  9162. name: string;
  9163. shader: string;
  9164. };
  9165. }
  9166. declare module BABYLON {
  9167. /** @hidden */
  9168. export var instancesDeclaration: {
  9169. name: string;
  9170. shader: string;
  9171. };
  9172. }
  9173. declare module BABYLON {
  9174. /** @hidden */
  9175. export var helperFunctions: {
  9176. name: string;
  9177. shader: string;
  9178. };
  9179. }
  9180. declare module BABYLON {
  9181. /** @hidden */
  9182. export var shadowMapVertexDeclaration: {
  9183. name: string;
  9184. shader: string;
  9185. };
  9186. }
  9187. declare module BABYLON {
  9188. /** @hidden */
  9189. export var clipPlaneVertexDeclaration: {
  9190. name: string;
  9191. shader: string;
  9192. };
  9193. }
  9194. declare module BABYLON {
  9195. /** @hidden */
  9196. export var morphTargetsVertex: {
  9197. name: string;
  9198. shader: string;
  9199. };
  9200. }
  9201. declare module BABYLON {
  9202. /** @hidden */
  9203. export var instancesVertex: {
  9204. name: string;
  9205. shader: string;
  9206. };
  9207. }
  9208. declare module BABYLON {
  9209. /** @hidden */
  9210. export var bonesVertex: {
  9211. name: string;
  9212. shader: string;
  9213. };
  9214. }
  9215. declare module BABYLON {
  9216. /** @hidden */
  9217. export var shadowMapVertexNormalBias: {
  9218. name: string;
  9219. shader: string;
  9220. };
  9221. }
  9222. declare module BABYLON {
  9223. /** @hidden */
  9224. export var shadowMapVertexMetric: {
  9225. name: string;
  9226. shader: string;
  9227. };
  9228. }
  9229. declare module BABYLON {
  9230. /** @hidden */
  9231. export var clipPlaneVertex: {
  9232. name: string;
  9233. shader: string;
  9234. };
  9235. }
  9236. declare module BABYLON {
  9237. /** @hidden */
  9238. export var shadowMapVertexShader: {
  9239. name: string;
  9240. shader: string;
  9241. };
  9242. }
  9243. declare module BABYLON {
  9244. /** @hidden */
  9245. export var depthBoxBlurPixelShader: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module BABYLON {
  9251. /** @hidden */
  9252. export var shadowMapFragmentSoftTransparentShadow: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module BABYLON {
  9258. /**
  9259. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9260. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9261. */
  9262. export class EffectFallbacks implements IEffectFallbacks {
  9263. private _defines;
  9264. private _currentRank;
  9265. private _maxRank;
  9266. private _mesh;
  9267. /**
  9268. * Removes the fallback from the bound mesh.
  9269. */
  9270. unBindMesh(): void;
  9271. /**
  9272. * Adds a fallback on the specified property.
  9273. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9274. * @param define The name of the define in the shader
  9275. */
  9276. addFallback(rank: number, define: string): void;
  9277. /**
  9278. * Sets the mesh to use CPU skinning when needing to fallback.
  9279. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9280. * @param mesh The mesh to use the fallbacks.
  9281. */
  9282. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9283. /**
  9284. * Checks to see if more fallbacks are still availible.
  9285. */
  9286. get hasMoreFallbacks(): boolean;
  9287. /**
  9288. * Removes the defines that should be removed when falling back.
  9289. * @param currentDefines defines the current define statements for the shader.
  9290. * @param effect defines the current effect we try to compile
  9291. * @returns The resulting defines with defines of the current rank removed.
  9292. */
  9293. reduce(currentDefines: string, effect: Effect): string;
  9294. }
  9295. }
  9296. declare module BABYLON {
  9297. /**
  9298. * Interface used to define Action
  9299. */
  9300. export interface IAction {
  9301. /**
  9302. * Trigger for the action
  9303. */
  9304. trigger: number;
  9305. /** Options of the trigger */
  9306. triggerOptions: any;
  9307. /**
  9308. * Gets the trigger parameters
  9309. * @returns the trigger parameters
  9310. */
  9311. getTriggerParameter(): any;
  9312. /**
  9313. * Internal only - executes current action event
  9314. * @hidden
  9315. */
  9316. _executeCurrent(evt?: ActionEvent): void;
  9317. /**
  9318. * Serialize placeholder for child classes
  9319. * @param parent of child
  9320. * @returns the serialized object
  9321. */
  9322. serialize(parent: any): any;
  9323. /**
  9324. * Internal only
  9325. * @hidden
  9326. */
  9327. _prepare(): void;
  9328. /**
  9329. * Internal only - manager for action
  9330. * @hidden
  9331. */
  9332. _actionManager: AbstractActionManager;
  9333. /**
  9334. * Adds action to chain of actions, may be a DoNothingAction
  9335. * @param action defines the next action to execute
  9336. * @returns The action passed in
  9337. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9338. */
  9339. then(action: IAction): IAction;
  9340. }
  9341. /**
  9342. * The action to be carried out following a trigger
  9343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9344. */
  9345. export class Action implements IAction {
  9346. /** the trigger, with or without parameters, for the action */
  9347. triggerOptions: any;
  9348. /**
  9349. * Trigger for the action
  9350. */
  9351. trigger: number;
  9352. /**
  9353. * Internal only - manager for action
  9354. * @hidden
  9355. */
  9356. _actionManager: ActionManager;
  9357. private _nextActiveAction;
  9358. private _child;
  9359. private _condition?;
  9360. private _triggerParameter;
  9361. /**
  9362. * An event triggered prior to action being executed.
  9363. */
  9364. onBeforeExecuteObservable: Observable<Action>;
  9365. /**
  9366. * Creates a new Action
  9367. * @param triggerOptions the trigger, with or without parameters, for the action
  9368. * @param condition an optional determinant of action
  9369. */
  9370. constructor(
  9371. /** the trigger, with or without parameters, for the action */
  9372. triggerOptions: any, condition?: Condition);
  9373. /**
  9374. * Internal only
  9375. * @hidden
  9376. */
  9377. _prepare(): void;
  9378. /**
  9379. * Gets the trigger parameters
  9380. * @returns the trigger parameters
  9381. */
  9382. getTriggerParameter(): any;
  9383. /**
  9384. * Internal only - executes current action event
  9385. * @hidden
  9386. */
  9387. _executeCurrent(evt?: ActionEvent): void;
  9388. /**
  9389. * Execute placeholder for child classes
  9390. * @param evt optional action event
  9391. */
  9392. execute(evt?: ActionEvent): void;
  9393. /**
  9394. * Skips to next active action
  9395. */
  9396. skipToNextActiveAction(): void;
  9397. /**
  9398. * Adds action to chain of actions, may be a DoNothingAction
  9399. * @param action defines the next action to execute
  9400. * @returns The action passed in
  9401. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9402. */
  9403. then(action: Action): Action;
  9404. /**
  9405. * Internal only
  9406. * @hidden
  9407. */
  9408. _getProperty(propertyPath: string): string;
  9409. /**
  9410. * Internal only
  9411. * @hidden
  9412. */
  9413. _getEffectiveTarget(target: any, propertyPath: string): any;
  9414. /**
  9415. * Serialize placeholder for child classes
  9416. * @param parent of child
  9417. * @returns the serialized object
  9418. */
  9419. serialize(parent: any): any;
  9420. /**
  9421. * Internal only called by serialize
  9422. * @hidden
  9423. */
  9424. protected _serialize(serializedAction: any, parent?: any): any;
  9425. /**
  9426. * Internal only
  9427. * @hidden
  9428. */
  9429. static _SerializeValueAsString: (value: any) => string;
  9430. /**
  9431. * Internal only
  9432. * @hidden
  9433. */
  9434. static _GetTargetProperty: (target: Node | Scene) => {
  9435. name: string;
  9436. targetType: string;
  9437. value: string;
  9438. };
  9439. }
  9440. }
  9441. declare module BABYLON {
  9442. /**
  9443. * A Condition applied to an Action
  9444. */
  9445. export class Condition {
  9446. /**
  9447. * Internal only - manager for action
  9448. * @hidden
  9449. */
  9450. _actionManager: ActionManager;
  9451. /**
  9452. * Internal only
  9453. * @hidden
  9454. */
  9455. _evaluationId: number;
  9456. /**
  9457. * Internal only
  9458. * @hidden
  9459. */
  9460. _currentResult: boolean;
  9461. /**
  9462. * Creates a new Condition
  9463. * @param actionManager the manager of the action the condition is applied to
  9464. */
  9465. constructor(actionManager: ActionManager);
  9466. /**
  9467. * Check if the current condition is valid
  9468. * @returns a boolean
  9469. */
  9470. isValid(): boolean;
  9471. /**
  9472. * Internal only
  9473. * @hidden
  9474. */
  9475. _getProperty(propertyPath: string): string;
  9476. /**
  9477. * Internal only
  9478. * @hidden
  9479. */
  9480. _getEffectiveTarget(target: any, propertyPath: string): any;
  9481. /**
  9482. * Serialize placeholder for child classes
  9483. * @returns the serialized object
  9484. */
  9485. serialize(): any;
  9486. /**
  9487. * Internal only
  9488. * @hidden
  9489. */
  9490. protected _serialize(serializedCondition: any): any;
  9491. }
  9492. /**
  9493. * Defines specific conditional operators as extensions of Condition
  9494. */
  9495. export class ValueCondition extends Condition {
  9496. /** path to specify the property of the target the conditional operator uses */
  9497. propertyPath: string;
  9498. /** the value compared by the conditional operator against the current value of the property */
  9499. value: any;
  9500. /** the conditional operator, default ValueCondition.IsEqual */
  9501. operator: number;
  9502. /**
  9503. * Internal only
  9504. * @hidden
  9505. */
  9506. private static _IsEqual;
  9507. /**
  9508. * Internal only
  9509. * @hidden
  9510. */
  9511. private static _IsDifferent;
  9512. /**
  9513. * Internal only
  9514. * @hidden
  9515. */
  9516. private static _IsGreater;
  9517. /**
  9518. * Internal only
  9519. * @hidden
  9520. */
  9521. private static _IsLesser;
  9522. /**
  9523. * returns the number for IsEqual
  9524. */
  9525. static get IsEqual(): number;
  9526. /**
  9527. * Returns the number for IsDifferent
  9528. */
  9529. static get IsDifferent(): number;
  9530. /**
  9531. * Returns the number for IsGreater
  9532. */
  9533. static get IsGreater(): number;
  9534. /**
  9535. * Returns the number for IsLesser
  9536. */
  9537. static get IsLesser(): number;
  9538. /**
  9539. * Internal only The action manager for the condition
  9540. * @hidden
  9541. */
  9542. _actionManager: ActionManager;
  9543. /**
  9544. * Internal only
  9545. * @hidden
  9546. */
  9547. private _target;
  9548. /**
  9549. * Internal only
  9550. * @hidden
  9551. */
  9552. private _effectiveTarget;
  9553. /**
  9554. * Internal only
  9555. * @hidden
  9556. */
  9557. private _property;
  9558. /**
  9559. * Creates a new ValueCondition
  9560. * @param actionManager manager for the action the condition applies to
  9561. * @param target for the action
  9562. * @param propertyPath path to specify the property of the target the conditional operator uses
  9563. * @param value the value compared by the conditional operator against the current value of the property
  9564. * @param operator the conditional operator, default ValueCondition.IsEqual
  9565. */
  9566. constructor(actionManager: ActionManager, target: any,
  9567. /** path to specify the property of the target the conditional operator uses */
  9568. propertyPath: string,
  9569. /** the value compared by the conditional operator against the current value of the property */
  9570. value: any,
  9571. /** the conditional operator, default ValueCondition.IsEqual */
  9572. operator?: number);
  9573. /**
  9574. * Compares the given value with the property value for the specified conditional operator
  9575. * @returns the result of the comparison
  9576. */
  9577. isValid(): boolean;
  9578. /**
  9579. * Serialize the ValueCondition into a JSON compatible object
  9580. * @returns serialization object
  9581. */
  9582. serialize(): any;
  9583. /**
  9584. * Gets the name of the conditional operator for the ValueCondition
  9585. * @param operator the conditional operator
  9586. * @returns the name
  9587. */
  9588. static GetOperatorName(operator: number): string;
  9589. }
  9590. /**
  9591. * Defines a predicate condition as an extension of Condition
  9592. */
  9593. export class PredicateCondition extends Condition {
  9594. /** defines the predicate function used to validate the condition */
  9595. predicate: () => boolean;
  9596. /**
  9597. * Internal only - manager for action
  9598. * @hidden
  9599. */
  9600. _actionManager: ActionManager;
  9601. /**
  9602. * Creates a new PredicateCondition
  9603. * @param actionManager manager for the action the condition applies to
  9604. * @param predicate defines the predicate function used to validate the condition
  9605. */
  9606. constructor(actionManager: ActionManager,
  9607. /** defines the predicate function used to validate the condition */
  9608. predicate: () => boolean);
  9609. /**
  9610. * @returns the validity of the predicate condition
  9611. */
  9612. isValid(): boolean;
  9613. }
  9614. /**
  9615. * Defines a state condition as an extension of Condition
  9616. */
  9617. export class StateCondition extends Condition {
  9618. /** Value to compare with target state */
  9619. value: string;
  9620. /**
  9621. * Internal only - manager for action
  9622. * @hidden
  9623. */
  9624. _actionManager: ActionManager;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. private _target;
  9630. /**
  9631. * Creates a new StateCondition
  9632. * @param actionManager manager for the action the condition applies to
  9633. * @param target of the condition
  9634. * @param value to compare with target state
  9635. */
  9636. constructor(actionManager: ActionManager, target: any,
  9637. /** Value to compare with target state */
  9638. value: string);
  9639. /**
  9640. * Gets a boolean indicating if the current condition is met
  9641. * @returns the validity of the state
  9642. */
  9643. isValid(): boolean;
  9644. /**
  9645. * Serialize the StateCondition into a JSON compatible object
  9646. * @returns serialization object
  9647. */
  9648. serialize(): any;
  9649. }
  9650. }
  9651. declare module BABYLON {
  9652. /**
  9653. * This defines an action responsible to toggle a boolean once triggered.
  9654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9655. */
  9656. export class SwitchBooleanAction extends Action {
  9657. /**
  9658. * The path to the boolean property in the target object
  9659. */
  9660. propertyPath: string;
  9661. private _target;
  9662. private _effectiveTarget;
  9663. private _property;
  9664. /**
  9665. * Instantiate the action
  9666. * @param triggerOptions defines the trigger options
  9667. * @param target defines the object containing the boolean
  9668. * @param propertyPath defines the path to the boolean property in the target object
  9669. * @param condition defines the trigger related conditions
  9670. */
  9671. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9672. /** @hidden */
  9673. _prepare(): void;
  9674. /**
  9675. * Execute the action toggle the boolean value.
  9676. */
  9677. execute(): void;
  9678. /**
  9679. * Serializes the actions and its related information.
  9680. * @param parent defines the object to serialize in
  9681. * @returns the serialized object
  9682. */
  9683. serialize(parent: any): any;
  9684. }
  9685. /**
  9686. * This defines an action responsible to set a the state field of the target
  9687. * to a desired value once triggered.
  9688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9689. */
  9690. export class SetStateAction extends Action {
  9691. /**
  9692. * The value to store in the state field.
  9693. */
  9694. value: string;
  9695. private _target;
  9696. /**
  9697. * Instantiate the action
  9698. * @param triggerOptions defines the trigger options
  9699. * @param target defines the object containing the state property
  9700. * @param value defines the value to store in the state field
  9701. * @param condition defines the trigger related conditions
  9702. */
  9703. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9704. /**
  9705. * Execute the action and store the value on the target state property.
  9706. */
  9707. execute(): void;
  9708. /**
  9709. * Serializes the actions and its related information.
  9710. * @param parent defines the object to serialize in
  9711. * @returns the serialized object
  9712. */
  9713. serialize(parent: any): any;
  9714. }
  9715. /**
  9716. * This defines an action responsible to set a property of the target
  9717. * to a desired value once triggered.
  9718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9719. */
  9720. export class SetValueAction extends Action {
  9721. /**
  9722. * The path of the property to set in the target.
  9723. */
  9724. propertyPath: string;
  9725. /**
  9726. * The value to set in the property
  9727. */
  9728. value: any;
  9729. private _target;
  9730. private _effectiveTarget;
  9731. private _property;
  9732. /**
  9733. * Instantiate the action
  9734. * @param triggerOptions defines the trigger options
  9735. * @param target defines the object containing the property
  9736. * @param propertyPath defines the path of the property to set in the target
  9737. * @param value defines the value to set in the property
  9738. * @param condition defines the trigger related conditions
  9739. */
  9740. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9741. /** @hidden */
  9742. _prepare(): void;
  9743. /**
  9744. * Execute the action and set the targetted property to the desired value.
  9745. */
  9746. execute(): void;
  9747. /**
  9748. * Serializes the actions and its related information.
  9749. * @param parent defines the object to serialize in
  9750. * @returns the serialized object
  9751. */
  9752. serialize(parent: any): any;
  9753. }
  9754. /**
  9755. * This defines an action responsible to increment the target value
  9756. * to a desired value once triggered.
  9757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9758. */
  9759. export class IncrementValueAction extends Action {
  9760. /**
  9761. * The path of the property to increment in the target.
  9762. */
  9763. propertyPath: string;
  9764. /**
  9765. * The value we should increment the property by.
  9766. */
  9767. value: any;
  9768. private _target;
  9769. private _effectiveTarget;
  9770. private _property;
  9771. /**
  9772. * Instantiate the action
  9773. * @param triggerOptions defines the trigger options
  9774. * @param target defines the object containing the property
  9775. * @param propertyPath defines the path of the property to increment in the target
  9776. * @param value defines the value value we should increment the property by
  9777. * @param condition defines the trigger related conditions
  9778. */
  9779. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9780. /** @hidden */
  9781. _prepare(): void;
  9782. /**
  9783. * Execute the action and increment the target of the value amount.
  9784. */
  9785. execute(): void;
  9786. /**
  9787. * Serializes the actions and its related information.
  9788. * @param parent defines the object to serialize in
  9789. * @returns the serialized object
  9790. */
  9791. serialize(parent: any): any;
  9792. }
  9793. /**
  9794. * This defines an action responsible to start an animation once triggered.
  9795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9796. */
  9797. export class PlayAnimationAction extends Action {
  9798. /**
  9799. * Where the animation should start (animation frame)
  9800. */
  9801. from: number;
  9802. /**
  9803. * Where the animation should stop (animation frame)
  9804. */
  9805. to: number;
  9806. /**
  9807. * Define if the animation should loop or stop after the first play.
  9808. */
  9809. loop?: boolean;
  9810. private _target;
  9811. /**
  9812. * Instantiate the action
  9813. * @param triggerOptions defines the trigger options
  9814. * @param target defines the target animation or animation name
  9815. * @param from defines from where the animation should start (animation frame)
  9816. * @param end defines where the animation should stop (animation frame)
  9817. * @param loop defines if the animation should loop or stop after the first play
  9818. * @param condition defines the trigger related conditions
  9819. */
  9820. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9821. /** @hidden */
  9822. _prepare(): void;
  9823. /**
  9824. * Execute the action and play the animation.
  9825. */
  9826. execute(): void;
  9827. /**
  9828. * Serializes the actions and its related information.
  9829. * @param parent defines the object to serialize in
  9830. * @returns the serialized object
  9831. */
  9832. serialize(parent: any): any;
  9833. }
  9834. /**
  9835. * This defines an action responsible to stop an animation once triggered.
  9836. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9837. */
  9838. export class StopAnimationAction extends Action {
  9839. private _target;
  9840. /**
  9841. * Instantiate the action
  9842. * @param triggerOptions defines the trigger options
  9843. * @param target defines the target animation or animation name
  9844. * @param condition defines the trigger related conditions
  9845. */
  9846. constructor(triggerOptions: any, target: any, condition?: Condition);
  9847. /** @hidden */
  9848. _prepare(): void;
  9849. /**
  9850. * Execute the action and stop the animation.
  9851. */
  9852. execute(): void;
  9853. /**
  9854. * Serializes the actions and its related information.
  9855. * @param parent defines the object to serialize in
  9856. * @returns the serialized object
  9857. */
  9858. serialize(parent: any): any;
  9859. }
  9860. /**
  9861. * This defines an action responsible that does nothing once triggered.
  9862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9863. */
  9864. export class DoNothingAction extends Action {
  9865. /**
  9866. * Instantiate the action
  9867. * @param triggerOptions defines the trigger options
  9868. * @param condition defines the trigger related conditions
  9869. */
  9870. constructor(triggerOptions?: any, condition?: Condition);
  9871. /**
  9872. * Execute the action and do nothing.
  9873. */
  9874. execute(): void;
  9875. /**
  9876. * Serializes the actions and its related information.
  9877. * @param parent defines the object to serialize in
  9878. * @returns the serialized object
  9879. */
  9880. serialize(parent: any): any;
  9881. }
  9882. /**
  9883. * This defines an action responsible to trigger several actions once triggered.
  9884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9885. */
  9886. export class CombineAction extends Action {
  9887. /**
  9888. * The list of aggregated animations to run.
  9889. */
  9890. children: Action[];
  9891. /**
  9892. * Instantiate the action
  9893. * @param triggerOptions defines the trigger options
  9894. * @param children defines the list of aggregated animations to run
  9895. * @param condition defines the trigger related conditions
  9896. */
  9897. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9898. /** @hidden */
  9899. _prepare(): void;
  9900. /**
  9901. * Execute the action and executes all the aggregated actions.
  9902. */
  9903. execute(evt: ActionEvent): void;
  9904. /**
  9905. * Serializes the actions and its related information.
  9906. * @param parent defines the object to serialize in
  9907. * @returns the serialized object
  9908. */
  9909. serialize(parent: any): any;
  9910. }
  9911. /**
  9912. * This defines an action responsible to run code (external event) once triggered.
  9913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9914. */
  9915. export class ExecuteCodeAction extends Action {
  9916. /**
  9917. * The callback function to run.
  9918. */
  9919. func: (evt: ActionEvent) => void;
  9920. /**
  9921. * Instantiate the action
  9922. * @param triggerOptions defines the trigger options
  9923. * @param func defines the callback function to run
  9924. * @param condition defines the trigger related conditions
  9925. */
  9926. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9927. /**
  9928. * Execute the action and run the attached code.
  9929. */
  9930. execute(evt: ActionEvent): void;
  9931. }
  9932. /**
  9933. * This defines an action responsible to set the parent property of the target once triggered.
  9934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9935. */
  9936. export class SetParentAction extends Action {
  9937. private _parent;
  9938. private _target;
  9939. /**
  9940. * Instantiate the action
  9941. * @param triggerOptions defines the trigger options
  9942. * @param target defines the target containing the parent property
  9943. * @param parent defines from where the animation should start (animation frame)
  9944. * @param condition defines the trigger related conditions
  9945. */
  9946. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9947. /** @hidden */
  9948. _prepare(): void;
  9949. /**
  9950. * Execute the action and set the parent property.
  9951. */
  9952. execute(): void;
  9953. /**
  9954. * Serializes the actions and its related information.
  9955. * @param parent defines the object to serialize in
  9956. * @returns the serialized object
  9957. */
  9958. serialize(parent: any): any;
  9959. }
  9960. }
  9961. declare module BABYLON {
  9962. /**
  9963. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9964. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  9966. */
  9967. export class ActionManager extends AbstractActionManager {
  9968. /**
  9969. * Nothing
  9970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9971. */
  9972. static readonly NothingTrigger: number;
  9973. /**
  9974. * On pick
  9975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9976. */
  9977. static readonly OnPickTrigger: number;
  9978. /**
  9979. * On left pick
  9980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9981. */
  9982. static readonly OnLeftPickTrigger: number;
  9983. /**
  9984. * On right pick
  9985. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9986. */
  9987. static readonly OnRightPickTrigger: number;
  9988. /**
  9989. * On center pick
  9990. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9991. */
  9992. static readonly OnCenterPickTrigger: number;
  9993. /**
  9994. * On pick down
  9995. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9996. */
  9997. static readonly OnPickDownTrigger: number;
  9998. /**
  9999. * On double pick
  10000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10001. */
  10002. static readonly OnDoublePickTrigger: number;
  10003. /**
  10004. * On pick up
  10005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10006. */
  10007. static readonly OnPickUpTrigger: number;
  10008. /**
  10009. * On pick out.
  10010. * This trigger will only be raised if you also declared a OnPickDown
  10011. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10012. */
  10013. static readonly OnPickOutTrigger: number;
  10014. /**
  10015. * On long press
  10016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10017. */
  10018. static readonly OnLongPressTrigger: number;
  10019. /**
  10020. * On pointer over
  10021. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10022. */
  10023. static readonly OnPointerOverTrigger: number;
  10024. /**
  10025. * On pointer out
  10026. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10027. */
  10028. static readonly OnPointerOutTrigger: number;
  10029. /**
  10030. * On every frame
  10031. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10032. */
  10033. static readonly OnEveryFrameTrigger: number;
  10034. /**
  10035. * On intersection enter
  10036. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10037. */
  10038. static readonly OnIntersectionEnterTrigger: number;
  10039. /**
  10040. * On intersection exit
  10041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10042. */
  10043. static readonly OnIntersectionExitTrigger: number;
  10044. /**
  10045. * On key down
  10046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10047. */
  10048. static readonly OnKeyDownTrigger: number;
  10049. /**
  10050. * On key up
  10051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10052. */
  10053. static readonly OnKeyUpTrigger: number;
  10054. private _scene;
  10055. /**
  10056. * Creates a new action manager
  10057. * @param scene defines the hosting scene
  10058. */
  10059. constructor(scene: Scene);
  10060. /**
  10061. * Releases all associated resources
  10062. */
  10063. dispose(): void;
  10064. /**
  10065. * Gets hosting scene
  10066. * @returns the hosting scene
  10067. */
  10068. getScene(): Scene;
  10069. /**
  10070. * Does this action manager handles actions of any of the given triggers
  10071. * @param triggers defines the triggers to be tested
  10072. * @return a boolean indicating whether one (or more) of the triggers is handled
  10073. */
  10074. hasSpecificTriggers(triggers: number[]): boolean;
  10075. /**
  10076. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10077. * speed.
  10078. * @param triggerA defines the trigger to be tested
  10079. * @param triggerB defines the trigger to be tested
  10080. * @return a boolean indicating whether one (or more) of the triggers is handled
  10081. */
  10082. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10083. /**
  10084. * Does this action manager handles actions of a given trigger
  10085. * @param trigger defines the trigger to be tested
  10086. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10087. * @return whether the trigger is handled
  10088. */
  10089. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10090. /**
  10091. * Does this action manager has pointer triggers
  10092. */
  10093. get hasPointerTriggers(): boolean;
  10094. /**
  10095. * Does this action manager has pick triggers
  10096. */
  10097. get hasPickTriggers(): boolean;
  10098. /**
  10099. * Registers an action to this action manager
  10100. * @param action defines the action to be registered
  10101. * @return the action amended (prepared) after registration
  10102. */
  10103. registerAction(action: IAction): Nullable<IAction>;
  10104. /**
  10105. * Unregisters an action to this action manager
  10106. * @param action defines the action to be unregistered
  10107. * @return a boolean indicating whether the action has been unregistered
  10108. */
  10109. unregisterAction(action: IAction): Boolean;
  10110. /**
  10111. * Process a specific trigger
  10112. * @param trigger defines the trigger to process
  10113. * @param evt defines the event details to be processed
  10114. */
  10115. processTrigger(trigger: number, evt?: IActionEvent): void;
  10116. /** @hidden */
  10117. _getEffectiveTarget(target: any, propertyPath: string): any;
  10118. /** @hidden */
  10119. _getProperty(propertyPath: string): string;
  10120. /**
  10121. * Serialize this manager to a JSON object
  10122. * @param name defines the property name to store this manager
  10123. * @returns a JSON representation of this manager
  10124. */
  10125. serialize(name: string): any;
  10126. /**
  10127. * Creates a new ActionManager from a JSON data
  10128. * @param parsedActions defines the JSON data to read from
  10129. * @param object defines the hosting mesh
  10130. * @param scene defines the hosting scene
  10131. */
  10132. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10133. /**
  10134. * Get a trigger name by index
  10135. * @param trigger defines the trigger index
  10136. * @returns a trigger name
  10137. */
  10138. static GetTriggerName(trigger: number): string;
  10139. }
  10140. }
  10141. declare module BABYLON {
  10142. /**
  10143. * Class used to represent a sprite
  10144. * @see http://doc.babylonjs.com/babylon101/sprites
  10145. */
  10146. export class Sprite implements IAnimatable {
  10147. /** defines the name */
  10148. name: string;
  10149. /** Gets or sets the current world position */
  10150. position: Vector3;
  10151. /** Gets or sets the main color */
  10152. color: Color4;
  10153. /** Gets or sets the width */
  10154. width: number;
  10155. /** Gets or sets the height */
  10156. height: number;
  10157. /** Gets or sets rotation angle */
  10158. angle: number;
  10159. /** Gets or sets the cell index in the sprite sheet */
  10160. cellIndex: number;
  10161. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10162. cellRef: string;
  10163. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10164. invertU: boolean;
  10165. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10166. invertV: boolean;
  10167. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10168. disposeWhenFinishedAnimating: boolean;
  10169. /** Gets the list of attached animations */
  10170. animations: Nullable<Array<Animation>>;
  10171. /** Gets or sets a boolean indicating if the sprite can be picked */
  10172. isPickable: boolean;
  10173. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10174. useAlphaForPicking: boolean;
  10175. /** @hidden */
  10176. _xOffset: number;
  10177. /** @hidden */
  10178. _yOffset: number;
  10179. /** @hidden */
  10180. _xSize: number;
  10181. /** @hidden */
  10182. _ySize: number;
  10183. /**
  10184. * Gets or sets the associated action manager
  10185. */
  10186. actionManager: Nullable<ActionManager>;
  10187. /**
  10188. * An event triggered when the control has been disposed
  10189. */
  10190. onDisposeObservable: Observable<Sprite>;
  10191. private _animationStarted;
  10192. private _loopAnimation;
  10193. private _fromIndex;
  10194. private _toIndex;
  10195. private _delay;
  10196. private _direction;
  10197. private _manager;
  10198. private _time;
  10199. private _onAnimationEnd;
  10200. /**
  10201. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10202. */
  10203. isVisible: boolean;
  10204. /**
  10205. * Gets or sets the sprite size
  10206. */
  10207. get size(): number;
  10208. set size(value: number);
  10209. /**
  10210. * Returns a boolean indicating if the animation is started
  10211. */
  10212. get animationStarted(): boolean;
  10213. /**
  10214. * Gets or sets the unique id of the sprite
  10215. */
  10216. uniqueId: number;
  10217. /**
  10218. * Gets the manager of this sprite
  10219. */
  10220. get manager(): ISpriteManager;
  10221. /**
  10222. * Creates a new Sprite
  10223. * @param name defines the name
  10224. * @param manager defines the manager
  10225. */
  10226. constructor(
  10227. /** defines the name */
  10228. name: string, manager: ISpriteManager);
  10229. /**
  10230. * Returns the string "Sprite"
  10231. * @returns "Sprite"
  10232. */
  10233. getClassName(): string;
  10234. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10235. get fromIndex(): number;
  10236. set fromIndex(value: number);
  10237. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10238. get toIndex(): number;
  10239. set toIndex(value: number);
  10240. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10241. get loopAnimation(): boolean;
  10242. set loopAnimation(value: boolean);
  10243. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10244. get delay(): number;
  10245. set delay(value: number);
  10246. /**
  10247. * Starts an animation
  10248. * @param from defines the initial key
  10249. * @param to defines the end key
  10250. * @param loop defines if the animation must loop
  10251. * @param delay defines the start delay (in ms)
  10252. * @param onAnimationEnd defines a callback to call when animation ends
  10253. */
  10254. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10255. /** Stops current animation (if any) */
  10256. stopAnimation(): void;
  10257. /** @hidden */
  10258. _animate(deltaTime: number): void;
  10259. /** Release associated resources */
  10260. dispose(): void;
  10261. /**
  10262. * Serializes the sprite to a JSON object
  10263. * @returns the JSON object
  10264. */
  10265. serialize(): any;
  10266. /**
  10267. * Parses a JSON object to create a new sprite
  10268. * @param parsedSprite The JSON object to parse
  10269. * @param manager defines the hosting manager
  10270. * @returns the new sprite
  10271. */
  10272. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10273. }
  10274. }
  10275. declare module BABYLON {
  10276. /**
  10277. * Information about the result of picking within a scene
  10278. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10279. */
  10280. export class PickingInfo {
  10281. /** @hidden */
  10282. _pickingUnavailable: boolean;
  10283. /**
  10284. * If the pick collided with an object
  10285. */
  10286. hit: boolean;
  10287. /**
  10288. * Distance away where the pick collided
  10289. */
  10290. distance: number;
  10291. /**
  10292. * The location of pick collision
  10293. */
  10294. pickedPoint: Nullable<Vector3>;
  10295. /**
  10296. * The mesh corresponding the the pick collision
  10297. */
  10298. pickedMesh: Nullable<AbstractMesh>;
  10299. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10300. bu: number;
  10301. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10302. bv: number;
  10303. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10304. faceId: number;
  10305. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10306. subMeshFaceId: number;
  10307. /** Id of the the submesh that was picked */
  10308. subMeshId: number;
  10309. /** If a sprite was picked, this will be the sprite the pick collided with */
  10310. pickedSprite: Nullable<Sprite>;
  10311. /**
  10312. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10313. */
  10314. originMesh: Nullable<AbstractMesh>;
  10315. /**
  10316. * The ray that was used to perform the picking.
  10317. */
  10318. ray: Nullable<Ray>;
  10319. /**
  10320. * Gets the normal correspodning to the face the pick collided with
  10321. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10322. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10323. * @returns The normal correspodning to the face the pick collided with
  10324. */
  10325. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10326. /**
  10327. * Gets the texture coordinates of where the pick occured
  10328. * @returns the vector containing the coordnates of the texture
  10329. */
  10330. getTextureCoordinates(): Nullable<Vector2>;
  10331. }
  10332. }
  10333. declare module BABYLON {
  10334. /**
  10335. * Class representing a ray with position and direction
  10336. */
  10337. export class Ray {
  10338. /** origin point */
  10339. origin: Vector3;
  10340. /** direction */
  10341. direction: Vector3;
  10342. /** length of the ray */
  10343. length: number;
  10344. private static readonly TmpVector3;
  10345. private _tmpRay;
  10346. /**
  10347. * Creates a new ray
  10348. * @param origin origin point
  10349. * @param direction direction
  10350. * @param length length of the ray
  10351. */
  10352. constructor(
  10353. /** origin point */
  10354. origin: Vector3,
  10355. /** direction */
  10356. direction: Vector3,
  10357. /** length of the ray */
  10358. length?: number);
  10359. /**
  10360. * Checks if the ray intersects a box
  10361. * This does not account for the ray lenght by design to improve perfs.
  10362. * @param minimum bound of the box
  10363. * @param maximum bound of the box
  10364. * @param intersectionTreshold extra extend to be added to the box in all direction
  10365. * @returns if the box was hit
  10366. */
  10367. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10368. /**
  10369. * Checks if the ray intersects a box
  10370. * This does not account for the ray lenght by design to improve perfs.
  10371. * @param box the bounding box to check
  10372. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10373. * @returns if the box was hit
  10374. */
  10375. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10376. /**
  10377. * If the ray hits a sphere
  10378. * @param sphere the bounding sphere to check
  10379. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10380. * @returns true if it hits the sphere
  10381. */
  10382. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10383. /**
  10384. * If the ray hits a triange
  10385. * @param vertex0 triangle vertex
  10386. * @param vertex1 triangle vertex
  10387. * @param vertex2 triangle vertex
  10388. * @returns intersection information if hit
  10389. */
  10390. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10391. /**
  10392. * Checks if ray intersects a plane
  10393. * @param plane the plane to check
  10394. * @returns the distance away it was hit
  10395. */
  10396. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10397. /**
  10398. * Calculate the intercept of a ray on a given axis
  10399. * @param axis to check 'x' | 'y' | 'z'
  10400. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10401. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10402. */
  10403. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10404. /**
  10405. * Checks if ray intersects a mesh
  10406. * @param mesh the mesh to check
  10407. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10408. * @returns picking info of the intersecton
  10409. */
  10410. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10411. /**
  10412. * Checks if ray intersects a mesh
  10413. * @param meshes the meshes to check
  10414. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10415. * @param results array to store result in
  10416. * @returns Array of picking infos
  10417. */
  10418. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10419. private _comparePickingInfo;
  10420. private static smallnum;
  10421. private static rayl;
  10422. /**
  10423. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10424. * @param sega the first point of the segment to test the intersection against
  10425. * @param segb the second point of the segment to test the intersection against
  10426. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10427. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10428. */
  10429. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10430. /**
  10431. * Update the ray from viewport position
  10432. * @param x position
  10433. * @param y y position
  10434. * @param viewportWidth viewport width
  10435. * @param viewportHeight viewport height
  10436. * @param world world matrix
  10437. * @param view view matrix
  10438. * @param projection projection matrix
  10439. * @returns this ray updated
  10440. */
  10441. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10442. /**
  10443. * Creates a ray with origin and direction of 0,0,0
  10444. * @returns the new ray
  10445. */
  10446. static Zero(): Ray;
  10447. /**
  10448. * Creates a new ray from screen space and viewport
  10449. * @param x position
  10450. * @param y y position
  10451. * @param viewportWidth viewport width
  10452. * @param viewportHeight viewport height
  10453. * @param world world matrix
  10454. * @param view view matrix
  10455. * @param projection projection matrix
  10456. * @returns new ray
  10457. */
  10458. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10459. /**
  10460. * 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
  10461. * transformed to the given world matrix.
  10462. * @param origin The origin point
  10463. * @param end The end point
  10464. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10465. * @returns the new ray
  10466. */
  10467. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10468. /**
  10469. * Transforms a ray by a matrix
  10470. * @param ray ray to transform
  10471. * @param matrix matrix to apply
  10472. * @returns the resulting new ray
  10473. */
  10474. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10475. /**
  10476. * Transforms a ray by a matrix
  10477. * @param ray ray to transform
  10478. * @param matrix matrix to apply
  10479. * @param result ray to store result in
  10480. */
  10481. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10482. /**
  10483. * Unproject a ray from screen space to object space
  10484. * @param sourceX defines the screen space x coordinate to use
  10485. * @param sourceY defines the screen space y coordinate to use
  10486. * @param viewportWidth defines the current width of the viewport
  10487. * @param viewportHeight defines the current height of the viewport
  10488. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10489. * @param view defines the view matrix to use
  10490. * @param projection defines the projection matrix to use
  10491. */
  10492. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10493. }
  10494. /**
  10495. * Type used to define predicate used to select faces when a mesh intersection is detected
  10496. */
  10497. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10498. interface Scene {
  10499. /** @hidden */
  10500. _tempPickingRay: Nullable<Ray>;
  10501. /** @hidden */
  10502. _cachedRayForTransform: Ray;
  10503. /** @hidden */
  10504. _pickWithRayInverseMatrix: Matrix;
  10505. /** @hidden */
  10506. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10507. /** @hidden */
  10508. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10509. }
  10510. }
  10511. declare module BABYLON {
  10512. /**
  10513. * Groups all the scene component constants in one place to ease maintenance.
  10514. * @hidden
  10515. */
  10516. export class SceneComponentConstants {
  10517. static readonly NAME_EFFECTLAYER: string;
  10518. static readonly NAME_LAYER: string;
  10519. static readonly NAME_LENSFLARESYSTEM: string;
  10520. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10521. static readonly NAME_PARTICLESYSTEM: string;
  10522. static readonly NAME_GAMEPAD: string;
  10523. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10524. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10525. static readonly NAME_DEPTHRENDERER: string;
  10526. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10527. static readonly NAME_SPRITE: string;
  10528. static readonly NAME_OUTLINERENDERER: string;
  10529. static readonly NAME_PROCEDURALTEXTURE: string;
  10530. static readonly NAME_SHADOWGENERATOR: string;
  10531. static readonly NAME_OCTREE: string;
  10532. static readonly NAME_PHYSICSENGINE: string;
  10533. static readonly NAME_AUDIO: string;
  10534. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10535. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10536. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10537. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10538. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10539. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10540. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10541. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10542. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10543. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10544. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10545. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10546. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10547. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10548. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10549. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10550. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10551. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10552. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10553. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10554. static readonly STEP_AFTERRENDER_AUDIO: number;
  10555. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10556. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10557. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10558. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10559. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10560. static readonly STEP_POINTERMOVE_SPRITE: number;
  10561. static readonly STEP_POINTERDOWN_SPRITE: number;
  10562. static readonly STEP_POINTERUP_SPRITE: number;
  10563. }
  10564. /**
  10565. * This represents a scene component.
  10566. *
  10567. * This is used to decouple the dependency the scene is having on the different workloads like
  10568. * layers, post processes...
  10569. */
  10570. export interface ISceneComponent {
  10571. /**
  10572. * The name of the component. Each component must have a unique name.
  10573. */
  10574. name: string;
  10575. /**
  10576. * The scene the component belongs to.
  10577. */
  10578. scene: Scene;
  10579. /**
  10580. * Register the component to one instance of a scene.
  10581. */
  10582. register(): void;
  10583. /**
  10584. * Rebuilds the elements related to this component in case of
  10585. * context lost for instance.
  10586. */
  10587. rebuild(): void;
  10588. /**
  10589. * Disposes the component and the associated ressources.
  10590. */
  10591. dispose(): void;
  10592. }
  10593. /**
  10594. * This represents a SERIALIZABLE scene component.
  10595. *
  10596. * This extends Scene Component to add Serialization methods on top.
  10597. */
  10598. export interface ISceneSerializableComponent extends ISceneComponent {
  10599. /**
  10600. * Adds all the elements from the container to the scene
  10601. * @param container the container holding the elements
  10602. */
  10603. addFromContainer(container: AbstractScene): void;
  10604. /**
  10605. * Removes all the elements in the container from the scene
  10606. * @param container contains the elements to remove
  10607. * @param dispose if the removed element should be disposed (default: false)
  10608. */
  10609. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10610. /**
  10611. * Serializes the component data to the specified json object
  10612. * @param serializationObject The object to serialize to
  10613. */
  10614. serialize(serializationObject: any): void;
  10615. }
  10616. /**
  10617. * Strong typing of a Mesh related stage step action
  10618. */
  10619. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10620. /**
  10621. * Strong typing of a Evaluate Sub Mesh related stage step action
  10622. */
  10623. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10624. /**
  10625. * Strong typing of a Active Mesh related stage step action
  10626. */
  10627. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10628. /**
  10629. * Strong typing of a Camera related stage step action
  10630. */
  10631. export type CameraStageAction = (camera: Camera) => void;
  10632. /**
  10633. * Strong typing of a Camera Frame buffer related stage step action
  10634. */
  10635. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10636. /**
  10637. * Strong typing of a Render Target related stage step action
  10638. */
  10639. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10640. /**
  10641. * Strong typing of a RenderingGroup related stage step action
  10642. */
  10643. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10644. /**
  10645. * Strong typing of a Mesh Render related stage step action
  10646. */
  10647. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10648. /**
  10649. * Strong typing of a simple stage step action
  10650. */
  10651. export type SimpleStageAction = () => void;
  10652. /**
  10653. * Strong typing of a render target action.
  10654. */
  10655. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10656. /**
  10657. * Strong typing of a pointer move action.
  10658. */
  10659. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10660. /**
  10661. * Strong typing of a pointer up/down action.
  10662. */
  10663. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10664. /**
  10665. * Representation of a stage in the scene (Basically a list of ordered steps)
  10666. * @hidden
  10667. */
  10668. export class Stage<T extends Function> extends Array<{
  10669. index: number;
  10670. component: ISceneComponent;
  10671. action: T;
  10672. }> {
  10673. /**
  10674. * Hide ctor from the rest of the world.
  10675. * @param items The items to add.
  10676. */
  10677. private constructor();
  10678. /**
  10679. * Creates a new Stage.
  10680. * @returns A new instance of a Stage
  10681. */
  10682. static Create<T extends Function>(): Stage<T>;
  10683. /**
  10684. * Registers a step in an ordered way in the targeted stage.
  10685. * @param index Defines the position to register the step in
  10686. * @param component Defines the component attached to the step
  10687. * @param action Defines the action to launch during the step
  10688. */
  10689. registerStep(index: number, component: ISceneComponent, action: T): void;
  10690. /**
  10691. * Clears all the steps from the stage.
  10692. */
  10693. clear(): void;
  10694. }
  10695. }
  10696. declare module BABYLON {
  10697. interface Scene {
  10698. /** @hidden */
  10699. _pointerOverSprite: Nullable<Sprite>;
  10700. /** @hidden */
  10701. _pickedDownSprite: Nullable<Sprite>;
  10702. /** @hidden */
  10703. _tempSpritePickingRay: Nullable<Ray>;
  10704. /**
  10705. * All of the sprite managers added to this scene
  10706. * @see http://doc.babylonjs.com/babylon101/sprites
  10707. */
  10708. spriteManagers: Array<ISpriteManager>;
  10709. /**
  10710. * An event triggered when sprites rendering is about to start
  10711. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10712. */
  10713. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10714. /**
  10715. * An event triggered when sprites rendering is done
  10716. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10717. */
  10718. onAfterSpritesRenderingObservable: Observable<Scene>;
  10719. /** @hidden */
  10720. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10721. /** Launch a ray to try to pick a sprite in the scene
  10722. * @param x position on screen
  10723. * @param y position on screen
  10724. * @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
  10725. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10726. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10727. * @returns a PickingInfo
  10728. */
  10729. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10730. /** Use the given ray to pick a sprite in the scene
  10731. * @param ray The ray (in world space) to use to pick meshes
  10732. * @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
  10733. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10734. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10735. * @returns a PickingInfo
  10736. */
  10737. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10738. /** @hidden */
  10739. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10740. /** Launch a ray to try to pick sprites in the scene
  10741. * @param x position on screen
  10742. * @param y position on screen
  10743. * @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
  10744. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10745. * @returns a PickingInfo array
  10746. */
  10747. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10748. /** Use the given ray to pick sprites in the scene
  10749. * @param ray The ray (in world space) to use to pick meshes
  10750. * @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
  10751. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10752. * @returns a PickingInfo array
  10753. */
  10754. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10755. /**
  10756. * Force the sprite under the pointer
  10757. * @param sprite defines the sprite to use
  10758. */
  10759. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10760. /**
  10761. * Gets the sprite under the pointer
  10762. * @returns a Sprite or null if no sprite is under the pointer
  10763. */
  10764. getPointerOverSprite(): Nullable<Sprite>;
  10765. }
  10766. /**
  10767. * Defines the sprite scene component responsible to manage sprites
  10768. * in a given scene.
  10769. */
  10770. export class SpriteSceneComponent implements ISceneComponent {
  10771. /**
  10772. * The component name helpfull to identify the component in the list of scene components.
  10773. */
  10774. readonly name: string;
  10775. /**
  10776. * The scene the component belongs to.
  10777. */
  10778. scene: Scene;
  10779. /** @hidden */
  10780. private _spritePredicate;
  10781. /**
  10782. * Creates a new instance of the component for the given scene
  10783. * @param scene Defines the scene to register the component in
  10784. */
  10785. constructor(scene: Scene);
  10786. /**
  10787. * Registers the component in a given scene
  10788. */
  10789. register(): void;
  10790. /**
  10791. * Rebuilds the elements related to this component in case of
  10792. * context lost for instance.
  10793. */
  10794. rebuild(): void;
  10795. /**
  10796. * Disposes the component and the associated ressources.
  10797. */
  10798. dispose(): void;
  10799. private _pickSpriteButKeepRay;
  10800. private _pointerMove;
  10801. private _pointerDown;
  10802. private _pointerUp;
  10803. }
  10804. }
  10805. declare module BABYLON {
  10806. /** @hidden */
  10807. export var fogFragmentDeclaration: {
  10808. name: string;
  10809. shader: string;
  10810. };
  10811. }
  10812. declare module BABYLON {
  10813. /** @hidden */
  10814. export var fogFragment: {
  10815. name: string;
  10816. shader: string;
  10817. };
  10818. }
  10819. declare module BABYLON {
  10820. /** @hidden */
  10821. export var spritesPixelShader: {
  10822. name: string;
  10823. shader: string;
  10824. };
  10825. }
  10826. declare module BABYLON {
  10827. /** @hidden */
  10828. export var fogVertexDeclaration: {
  10829. name: string;
  10830. shader: string;
  10831. };
  10832. }
  10833. declare module BABYLON {
  10834. /** @hidden */
  10835. export var spritesVertexShader: {
  10836. name: string;
  10837. shader: string;
  10838. };
  10839. }
  10840. declare module BABYLON {
  10841. /**
  10842. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10843. */
  10844. export interface ISpriteManager extends IDisposable {
  10845. /**
  10846. * Gets manager's name
  10847. */
  10848. name: string;
  10849. /**
  10850. * Restricts the camera to viewing objects with the same layerMask.
  10851. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10852. */
  10853. layerMask: number;
  10854. /**
  10855. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10856. */
  10857. isPickable: boolean;
  10858. /**
  10859. * Gets the hosting scene
  10860. */
  10861. scene: Scene;
  10862. /**
  10863. * Specifies the rendering group id for this mesh (0 by default)
  10864. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10865. */
  10866. renderingGroupId: number;
  10867. /**
  10868. * Defines the list of sprites managed by the manager.
  10869. */
  10870. sprites: Array<Sprite>;
  10871. /**
  10872. * Gets or sets the spritesheet texture
  10873. */
  10874. texture: Texture;
  10875. /** Defines the default width of a cell in the spritesheet */
  10876. cellWidth: number;
  10877. /** Defines the default height of a cell in the spritesheet */
  10878. cellHeight: number;
  10879. /**
  10880. * Tests the intersection of a sprite with a specific ray.
  10881. * @param ray The ray we are sending to test the collision
  10882. * @param camera The camera space we are sending rays in
  10883. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10884. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10885. * @returns picking info or null.
  10886. */
  10887. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10888. /**
  10889. * Intersects the sprites with a ray
  10890. * @param ray defines the ray to intersect with
  10891. * @param camera defines the current active camera
  10892. * @param predicate defines a predicate used to select candidate sprites
  10893. * @returns null if no hit or a PickingInfo array
  10894. */
  10895. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10896. /**
  10897. * Renders the list of sprites on screen.
  10898. */
  10899. render(): void;
  10900. }
  10901. /**
  10902. * Class used to manage multiple sprites on the same spritesheet
  10903. * @see http://doc.babylonjs.com/babylon101/sprites
  10904. */
  10905. export class SpriteManager implements ISpriteManager {
  10906. /** defines the manager's name */
  10907. name: string;
  10908. /** Define the Url to load snippets */
  10909. static SnippetUrl: string;
  10910. /** Snippet ID if the manager was created from the snippet server */
  10911. snippetId: string;
  10912. /** Gets the list of sprites */
  10913. sprites: Sprite[];
  10914. /** Gets or sets the rendering group id (0 by default) */
  10915. renderingGroupId: number;
  10916. /** Gets or sets camera layer mask */
  10917. layerMask: number;
  10918. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10919. fogEnabled: boolean;
  10920. /** Gets or sets a boolean indicating if the sprites are pickable */
  10921. isPickable: boolean;
  10922. /** Defines the default width of a cell in the spritesheet */
  10923. cellWidth: number;
  10924. /** Defines the default height of a cell in the spritesheet */
  10925. cellHeight: number;
  10926. /** Associative array from JSON sprite data file */
  10927. private _cellData;
  10928. /** Array of sprite names from JSON sprite data file */
  10929. private _spriteMap;
  10930. /** True when packed cell data from JSON file is ready*/
  10931. private _packedAndReady;
  10932. private _textureContent;
  10933. /**
  10934. * An event triggered when the manager is disposed.
  10935. */
  10936. onDisposeObservable: Observable<SpriteManager>;
  10937. private _onDisposeObserver;
  10938. /**
  10939. * Callback called when the manager is disposed
  10940. */
  10941. set onDispose(callback: () => void);
  10942. private _capacity;
  10943. private _fromPacked;
  10944. private _spriteTexture;
  10945. private _epsilon;
  10946. private _scene;
  10947. private _vertexData;
  10948. private _buffer;
  10949. private _vertexBuffers;
  10950. private _indexBuffer;
  10951. private _effectBase;
  10952. private _effectFog;
  10953. /**
  10954. * Gets or sets the unique id of the sprite
  10955. */
  10956. uniqueId: number;
  10957. /**
  10958. * Gets the array of sprites
  10959. */
  10960. get children(): Sprite[];
  10961. /**
  10962. * Gets the hosting scene
  10963. */
  10964. get scene(): Scene;
  10965. /**
  10966. * Gets the capacity of the manager
  10967. */
  10968. get capacity(): number;
  10969. /**
  10970. * Gets or sets the spritesheet texture
  10971. */
  10972. get texture(): Texture;
  10973. set texture(value: Texture);
  10974. private _blendMode;
  10975. /**
  10976. * Blend mode use to render the particle, it can be any of
  10977. * the static Constants.ALPHA_x properties provided in this class.
  10978. * Default value is Constants.ALPHA_COMBINE
  10979. */
  10980. get blendMode(): number;
  10981. set blendMode(blendMode: number);
  10982. /** Disables writing to the depth buffer when rendering the sprites.
  10983. * It can be handy to disable depth writing when using textures without alpha channel
  10984. * and setting some specific blend modes.
  10985. */
  10986. disableDepthWrite: boolean;
  10987. /**
  10988. * Creates a new sprite manager
  10989. * @param name defines the manager's name
  10990. * @param imgUrl defines the sprite sheet url
  10991. * @param capacity defines the maximum allowed number of sprites
  10992. * @param cellSize defines the size of a sprite cell
  10993. * @param scene defines the hosting scene
  10994. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10995. * @param samplingMode defines the smapling mode to use with spritesheet
  10996. * @param fromPacked set to false; do not alter
  10997. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10998. */
  10999. constructor(
  11000. /** defines the manager's name */
  11001. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11002. /**
  11003. * Returns the string "SpriteManager"
  11004. * @returns "SpriteManager"
  11005. */
  11006. getClassName(): string;
  11007. private _makePacked;
  11008. private _appendSpriteVertex;
  11009. private _checkTextureAlpha;
  11010. /**
  11011. * Intersects the sprites with a ray
  11012. * @param ray defines the ray to intersect with
  11013. * @param camera defines the current active camera
  11014. * @param predicate defines a predicate used to select candidate sprites
  11015. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11016. * @returns null if no hit or a PickingInfo
  11017. */
  11018. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11019. /**
  11020. * Intersects the sprites with a ray
  11021. * @param ray defines the ray to intersect with
  11022. * @param camera defines the current active camera
  11023. * @param predicate defines a predicate used to select candidate sprites
  11024. * @returns null if no hit or a PickingInfo array
  11025. */
  11026. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11027. /**
  11028. * Render all child sprites
  11029. */
  11030. render(): void;
  11031. /**
  11032. * Release associated resources
  11033. */
  11034. dispose(): void;
  11035. /**
  11036. * Serializes the sprite manager to a JSON object
  11037. * @param serializeTexture defines if the texture must be serialized as well
  11038. * @returns the JSON object
  11039. */
  11040. serialize(serializeTexture?: boolean): any;
  11041. /**
  11042. * Parses a JSON object to create a new sprite manager.
  11043. * @param parsedManager The JSON object to parse
  11044. * @param scene The scene to create the sprite managerin
  11045. * @param rootUrl The root url to use to load external dependencies like texture
  11046. * @returns the new sprite manager
  11047. */
  11048. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11049. /**
  11050. * Creates a sprite manager from a snippet saved in a remote file
  11051. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11052. * @param url defines the url to load from
  11053. * @param scene defines the hosting scene
  11054. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11055. * @returns a promise that will resolve to the new sprite manager
  11056. */
  11057. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11058. /**
  11059. * Creates a sprite manager from a snippet saved by the sprite editor
  11060. * @param snippetId defines the snippet to load
  11061. * @param scene defines the hosting scene
  11062. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11063. * @returns a promise that will resolve to the new sprite manager
  11064. */
  11065. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11066. }
  11067. }
  11068. declare module BABYLON {
  11069. /** Interface used by value gradients (color, factor, ...) */
  11070. export interface IValueGradient {
  11071. /**
  11072. * Gets or sets the gradient value (between 0 and 1)
  11073. */
  11074. gradient: number;
  11075. }
  11076. /** Class used to store color4 gradient */
  11077. export class ColorGradient implements IValueGradient {
  11078. /**
  11079. * Gets or sets the gradient value (between 0 and 1)
  11080. */
  11081. gradient: number;
  11082. /**
  11083. * Gets or sets first associated color
  11084. */
  11085. color1: Color4;
  11086. /**
  11087. * Gets or sets second associated color
  11088. */
  11089. color2?: Color4 | undefined;
  11090. /**
  11091. * Creates a new color4 gradient
  11092. * @param gradient gets or sets the gradient value (between 0 and 1)
  11093. * @param color1 gets or sets first associated color
  11094. * @param color2 gets or sets first second color
  11095. */
  11096. constructor(
  11097. /**
  11098. * Gets or sets the gradient value (between 0 and 1)
  11099. */
  11100. gradient: number,
  11101. /**
  11102. * Gets or sets first associated color
  11103. */
  11104. color1: Color4,
  11105. /**
  11106. * Gets or sets second associated color
  11107. */
  11108. color2?: Color4 | undefined);
  11109. /**
  11110. * Will get a color picked randomly between color1 and color2.
  11111. * If color2 is undefined then color1 will be used
  11112. * @param result defines the target Color4 to store the result in
  11113. */
  11114. getColorToRef(result: Color4): void;
  11115. }
  11116. /** Class used to store color 3 gradient */
  11117. export class Color3Gradient implements IValueGradient {
  11118. /**
  11119. * Gets or sets the gradient value (between 0 and 1)
  11120. */
  11121. gradient: number;
  11122. /**
  11123. * Gets or sets the associated color
  11124. */
  11125. color: Color3;
  11126. /**
  11127. * Creates a new color3 gradient
  11128. * @param gradient gets or sets the gradient value (between 0 and 1)
  11129. * @param color gets or sets associated color
  11130. */
  11131. constructor(
  11132. /**
  11133. * Gets or sets the gradient value (between 0 and 1)
  11134. */
  11135. gradient: number,
  11136. /**
  11137. * Gets or sets the associated color
  11138. */
  11139. color: Color3);
  11140. }
  11141. /** Class used to store factor gradient */
  11142. export class FactorGradient implements IValueGradient {
  11143. /**
  11144. * Gets or sets the gradient value (between 0 and 1)
  11145. */
  11146. gradient: number;
  11147. /**
  11148. * Gets or sets first associated factor
  11149. */
  11150. factor1: number;
  11151. /**
  11152. * Gets or sets second associated factor
  11153. */
  11154. factor2?: number | undefined;
  11155. /**
  11156. * Creates a new factor gradient
  11157. * @param gradient gets or sets the gradient value (between 0 and 1)
  11158. * @param factor1 gets or sets first associated factor
  11159. * @param factor2 gets or sets second associated factor
  11160. */
  11161. constructor(
  11162. /**
  11163. * Gets or sets the gradient value (between 0 and 1)
  11164. */
  11165. gradient: number,
  11166. /**
  11167. * Gets or sets first associated factor
  11168. */
  11169. factor1: number,
  11170. /**
  11171. * Gets or sets second associated factor
  11172. */
  11173. factor2?: number | undefined);
  11174. /**
  11175. * Will get a number picked randomly between factor1 and factor2.
  11176. * If factor2 is undefined then factor1 will be used
  11177. * @returns the picked number
  11178. */
  11179. getFactor(): number;
  11180. }
  11181. /**
  11182. * Helper used to simplify some generic gradient tasks
  11183. */
  11184. export class GradientHelper {
  11185. /**
  11186. * Gets the current gradient from an array of IValueGradient
  11187. * @param ratio defines the current ratio to get
  11188. * @param gradients defines the array of IValueGradient
  11189. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11190. */
  11191. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11192. }
  11193. }
  11194. declare module BABYLON {
  11195. interface ThinEngine {
  11196. /**
  11197. * Creates a dynamic texture
  11198. * @param width defines the width of the texture
  11199. * @param height defines the height of the texture
  11200. * @param generateMipMaps defines if the engine should generate the mip levels
  11201. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11202. * @returns the dynamic texture inside an InternalTexture
  11203. */
  11204. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11205. /**
  11206. * Update the content of a dynamic texture
  11207. * @param texture defines the texture to update
  11208. * @param canvas defines the canvas containing the source
  11209. * @param invertY defines if data must be stored with Y axis inverted
  11210. * @param premulAlpha defines if alpha is stored as premultiplied
  11211. * @param format defines the format of the data
  11212. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11213. */
  11214. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11215. }
  11216. }
  11217. declare module BABYLON {
  11218. /**
  11219. * Helper class used to generate a canvas to manipulate images
  11220. */
  11221. export class CanvasGenerator {
  11222. /**
  11223. * Create a new canvas (or offscreen canvas depending on the context)
  11224. * @param width defines the expected width
  11225. * @param height defines the expected height
  11226. * @return a new canvas or offscreen canvas
  11227. */
  11228. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  11229. }
  11230. }
  11231. declare module BABYLON {
  11232. /**
  11233. * A class extending Texture allowing drawing on a texture
  11234. * @see http://doc.babylonjs.com/how_to/dynamictexture
  11235. */
  11236. export class DynamicTexture extends Texture {
  11237. private _generateMipMaps;
  11238. private _canvas;
  11239. private _context;
  11240. /**
  11241. * Creates a DynamicTexture
  11242. * @param name defines the name of the texture
  11243. * @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
  11244. * @param scene defines the scene where you want the texture
  11245. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  11246. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  11247. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  11248. */
  11249. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  11250. /**
  11251. * Get the current class name of the texture useful for serialization or dynamic coding.
  11252. * @returns "DynamicTexture"
  11253. */
  11254. getClassName(): string;
  11255. /**
  11256. * Gets the current state of canRescale
  11257. */
  11258. get canRescale(): boolean;
  11259. private _recreate;
  11260. /**
  11261. * Scales the texture
  11262. * @param ratio the scale factor to apply to both width and height
  11263. */
  11264. scale(ratio: number): void;
  11265. /**
  11266. * Resizes the texture
  11267. * @param width the new width
  11268. * @param height the new height
  11269. */
  11270. scaleTo(width: number, height: number): void;
  11271. /**
  11272. * Gets the context of the canvas used by the texture
  11273. * @returns the canvas context of the dynamic texture
  11274. */
  11275. getContext(): CanvasRenderingContext2D;
  11276. /**
  11277. * Clears the texture
  11278. */
  11279. clear(): void;
  11280. /**
  11281. * Updates the texture
  11282. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11283. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  11284. */
  11285. update(invertY?: boolean, premulAlpha?: boolean): void;
  11286. /**
  11287. * Draws text onto the texture
  11288. * @param text defines the text to be drawn
  11289. * @param x defines the placement of the text from the left
  11290. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  11291. * @param font defines the font to be used with font-style, font-size, font-name
  11292. * @param color defines the color used for the text
  11293. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  11294. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  11295. * @param update defines whether texture is immediately update (default is true)
  11296. */
  11297. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  11298. /**
  11299. * Clones the texture
  11300. * @returns the clone of the texture.
  11301. */
  11302. clone(): DynamicTexture;
  11303. /**
  11304. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  11305. * @returns a serialized dynamic texture object
  11306. */
  11307. serialize(): any;
  11308. /** @hidden */
  11309. _rebuild(): void;
  11310. }
  11311. }
  11312. declare module BABYLON {
  11313. interface ThinEngine {
  11314. /**
  11315. * Creates a raw texture
  11316. * @param data defines the data to store in the texture
  11317. * @param width defines the width of the texture
  11318. * @param height defines the height of the texture
  11319. * @param format defines the format of the data
  11320. * @param generateMipMaps defines if the engine should generate the mip levels
  11321. * @param invertY defines if data must be stored with Y axis inverted
  11322. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11323. * @param compression defines the compression used (null by default)
  11324. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11325. * @returns the raw texture inside an InternalTexture
  11326. */
  11327. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11328. /**
  11329. * Update a raw texture
  11330. * @param texture defines the texture to update
  11331. * @param data defines the data to store in the texture
  11332. * @param format defines the format of the data
  11333. * @param invertY defines if data must be stored with Y axis inverted
  11334. */
  11335. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11336. /**
  11337. * Update a raw texture
  11338. * @param texture defines the texture to update
  11339. * @param data defines the data to store in the texture
  11340. * @param format defines the format of the data
  11341. * @param invertY defines if data must be stored with Y axis inverted
  11342. * @param compression defines the compression used (null by default)
  11343. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11344. */
  11345. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11346. /**
  11347. * Creates a new raw cube texture
  11348. * @param data defines the array of data to use to create each face
  11349. * @param size defines the size of the textures
  11350. * @param format defines the format of the data
  11351. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11352. * @param generateMipMaps defines if the engine should generate the mip levels
  11353. * @param invertY defines if data must be stored with Y axis inverted
  11354. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11355. * @param compression defines the compression used (null by default)
  11356. * @returns the cube texture as an InternalTexture
  11357. */
  11358. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11359. /**
  11360. * Update a raw cube texture
  11361. * @param texture defines the texture to udpdate
  11362. * @param data defines the data to store
  11363. * @param format defines the data format
  11364. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11365. * @param invertY defines if data must be stored with Y axis inverted
  11366. */
  11367. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11368. /**
  11369. * Update a raw cube texture
  11370. * @param texture defines the texture to udpdate
  11371. * @param data defines the data to store
  11372. * @param format defines the data format
  11373. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11374. * @param invertY defines if data must be stored with Y axis inverted
  11375. * @param compression defines the compression used (null by default)
  11376. */
  11377. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11378. /**
  11379. * Update a raw cube texture
  11380. * @param texture defines the texture to udpdate
  11381. * @param data defines the data to store
  11382. * @param format defines the data format
  11383. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11384. * @param invertY defines if data must be stored with Y axis inverted
  11385. * @param compression defines the compression used (null by default)
  11386. * @param level defines which level of the texture to update
  11387. */
  11388. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11389. /**
  11390. * Creates a new raw cube texture from a specified url
  11391. * @param url defines the url where the data is located
  11392. * @param scene defines the current scene
  11393. * @param size defines the size of the textures
  11394. * @param format defines the format of the data
  11395. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11396. * @param noMipmap defines if the engine should avoid generating the mip levels
  11397. * @param callback defines a callback used to extract texture data from loaded data
  11398. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11399. * @param onLoad defines a callback called when texture is loaded
  11400. * @param onError defines a callback called if there is an error
  11401. * @returns the cube texture as an InternalTexture
  11402. */
  11403. 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;
  11404. /**
  11405. * Creates a new raw cube texture from a specified url
  11406. * @param url defines the url where the data is located
  11407. * @param scene defines the current scene
  11408. * @param size defines the size of the textures
  11409. * @param format defines the format of the data
  11410. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11411. * @param noMipmap defines if the engine should avoid generating the mip levels
  11412. * @param callback defines a callback used to extract texture data from loaded data
  11413. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11414. * @param onLoad defines a callback called when texture is loaded
  11415. * @param onError defines a callback called if there is an error
  11416. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11417. * @param invertY defines if data must be stored with Y axis inverted
  11418. * @returns the cube texture as an InternalTexture
  11419. */
  11420. 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;
  11421. /**
  11422. * Creates a new raw 3D texture
  11423. * @param data defines the data used to create the texture
  11424. * @param width defines the width of the texture
  11425. * @param height defines the height of the texture
  11426. * @param depth defines the depth of the texture
  11427. * @param format defines the format of the texture
  11428. * @param generateMipMaps defines if the engine must generate mip levels
  11429. * @param invertY defines if data must be stored with Y axis inverted
  11430. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11431. * @param compression defines the compressed used (can be null)
  11432. * @param textureType defines the compressed used (can be null)
  11433. * @returns a new raw 3D texture (stored in an InternalTexture)
  11434. */
  11435. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11436. /**
  11437. * Update a raw 3D texture
  11438. * @param texture defines the texture to update
  11439. * @param data defines the data to store
  11440. * @param format defines the data format
  11441. * @param invertY defines if data must be stored with Y axis inverted
  11442. */
  11443. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11444. /**
  11445. * Update a raw 3D texture
  11446. * @param texture defines the texture to update
  11447. * @param data defines the data to store
  11448. * @param format defines the data format
  11449. * @param invertY defines if data must be stored with Y axis inverted
  11450. * @param compression defines the used compression (can be null)
  11451. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11452. */
  11453. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11454. /**
  11455. * Creates a new raw 2D array texture
  11456. * @param data defines the data used to create the texture
  11457. * @param width defines the width of the texture
  11458. * @param height defines the height of the texture
  11459. * @param depth defines the number of layers of the texture
  11460. * @param format defines the format of the texture
  11461. * @param generateMipMaps defines if the engine must generate mip levels
  11462. * @param invertY defines if data must be stored with Y axis inverted
  11463. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11464. * @param compression defines the compressed used (can be null)
  11465. * @param textureType defines the compressed used (can be null)
  11466. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11467. */
  11468. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11469. /**
  11470. * Update a raw 2D array texture
  11471. * @param texture defines the texture to update
  11472. * @param data defines the data to store
  11473. * @param format defines the data format
  11474. * @param invertY defines if data must be stored with Y axis inverted
  11475. */
  11476. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11477. /**
  11478. * Update a raw 2D array texture
  11479. * @param texture defines the texture to update
  11480. * @param data defines the data to store
  11481. * @param format defines the data format
  11482. * @param invertY defines if data must be stored with Y axis inverted
  11483. * @param compression defines the used compression (can be null)
  11484. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11485. */
  11486. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11487. }
  11488. }
  11489. declare module BABYLON {
  11490. /**
  11491. * Raw texture can help creating a texture directly from an array of data.
  11492. * This can be super useful if you either get the data from an uncompressed source or
  11493. * if you wish to create your texture pixel by pixel.
  11494. */
  11495. export class RawTexture extends Texture {
  11496. /**
  11497. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11498. */
  11499. format: number;
  11500. /**
  11501. * Instantiates a new RawTexture.
  11502. * Raw texture can help creating a texture directly from an array of data.
  11503. * This can be super useful if you either get the data from an uncompressed source or
  11504. * if you wish to create your texture pixel by pixel.
  11505. * @param data define the array of data to use to create the texture
  11506. * @param width define the width of the texture
  11507. * @param height define the height of the texture
  11508. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11509. * @param scene define the scene the texture belongs to
  11510. * @param generateMipMaps define whether mip maps should be generated or not
  11511. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11512. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11513. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11514. */
  11515. constructor(data: ArrayBufferView, width: number, height: number,
  11516. /**
  11517. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11518. */
  11519. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11520. /**
  11521. * Updates the texture underlying data.
  11522. * @param data Define the new data of the texture
  11523. */
  11524. update(data: ArrayBufferView): void;
  11525. /**
  11526. * Creates a luminance texture from some data.
  11527. * @param data Define the texture data
  11528. * @param width Define the width of the texture
  11529. * @param height Define the height of the texture
  11530. * @param scene Define the scene the texture belongs to
  11531. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11532. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11533. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11534. * @returns the luminance texture
  11535. */
  11536. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11537. /**
  11538. * Creates a luminance alpha texture from some data.
  11539. * @param data Define the texture data
  11540. * @param width Define the width of the texture
  11541. * @param height Define the height of the texture
  11542. * @param scene Define the scene the texture belongs to
  11543. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11544. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11545. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11546. * @returns the luminance alpha texture
  11547. */
  11548. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11549. /**
  11550. * Creates an alpha texture from some data.
  11551. * @param data Define the texture data
  11552. * @param width Define the width of the texture
  11553. * @param height Define the height of the texture
  11554. * @param scene Define the scene the texture belongs to
  11555. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11556. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11557. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11558. * @returns the alpha texture
  11559. */
  11560. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11561. /**
  11562. * Creates a RGB texture from some data.
  11563. * @param data Define the texture data
  11564. * @param width Define the width of the texture
  11565. * @param height Define the height of the texture
  11566. * @param scene Define the scene the texture belongs to
  11567. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11568. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11569. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11570. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11571. * @returns the RGB alpha texture
  11572. */
  11573. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11574. /**
  11575. * Creates a RGBA texture from some data.
  11576. * @param data Define the texture data
  11577. * @param width Define the width of the texture
  11578. * @param height Define the height of the texture
  11579. * @param scene Define the scene the texture belongs to
  11580. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11581. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11582. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11583. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11584. * @returns the RGBA texture
  11585. */
  11586. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11587. /**
  11588. * Creates a R texture from some data.
  11589. * @param data Define the texture data
  11590. * @param width Define the width of the texture
  11591. * @param height Define the height of the texture
  11592. * @param scene Define the scene the texture belongs to
  11593. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11594. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11595. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11596. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11597. * @returns the R texture
  11598. */
  11599. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11600. }
  11601. }
  11602. declare module BABYLON {
  11603. interface AbstractScene {
  11604. /**
  11605. * The list of procedural textures added to the scene
  11606. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11607. */
  11608. proceduralTextures: Array<ProceduralTexture>;
  11609. }
  11610. /**
  11611. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11612. * in a given scene.
  11613. */
  11614. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11615. /**
  11616. * The component name helpfull to identify the component in the list of scene components.
  11617. */
  11618. readonly name: string;
  11619. /**
  11620. * The scene the component belongs to.
  11621. */
  11622. scene: Scene;
  11623. /**
  11624. * Creates a new instance of the component for the given scene
  11625. * @param scene Defines the scene to register the component in
  11626. */
  11627. constructor(scene: Scene);
  11628. /**
  11629. * Registers the component in a given scene
  11630. */
  11631. register(): void;
  11632. /**
  11633. * Rebuilds the elements related to this component in case of
  11634. * context lost for instance.
  11635. */
  11636. rebuild(): void;
  11637. /**
  11638. * Disposes the component and the associated ressources.
  11639. */
  11640. dispose(): void;
  11641. private _beforeClear;
  11642. }
  11643. }
  11644. declare module BABYLON {
  11645. interface ThinEngine {
  11646. /**
  11647. * Creates a new render target cube texture
  11648. * @param size defines the size of the texture
  11649. * @param options defines the options used to create the texture
  11650. * @returns a new render target cube texture stored in an InternalTexture
  11651. */
  11652. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11653. }
  11654. }
  11655. declare module BABYLON {
  11656. /** @hidden */
  11657. export var proceduralVertexShader: {
  11658. name: string;
  11659. shader: string;
  11660. };
  11661. }
  11662. declare module BABYLON {
  11663. /**
  11664. * 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.
  11665. * This is the base class of any Procedural texture and contains most of the shareable code.
  11666. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11667. */
  11668. export class ProceduralTexture extends Texture {
  11669. isCube: boolean;
  11670. /**
  11671. * Define if the texture is enabled or not (disabled texture will not render)
  11672. */
  11673. isEnabled: boolean;
  11674. /**
  11675. * Define if the texture must be cleared before rendering (default is true)
  11676. */
  11677. autoClear: boolean;
  11678. /**
  11679. * Callback called when the texture is generated
  11680. */
  11681. onGenerated: () => void;
  11682. /**
  11683. * Event raised when the texture is generated
  11684. */
  11685. onGeneratedObservable: Observable<ProceduralTexture>;
  11686. /** @hidden */
  11687. _generateMipMaps: boolean;
  11688. /** @hidden **/
  11689. _effect: Effect;
  11690. /** @hidden */
  11691. _textures: {
  11692. [key: string]: Texture;
  11693. };
  11694. /** @hidden */
  11695. protected _fallbackTexture: Nullable<Texture>;
  11696. private _size;
  11697. private _currentRefreshId;
  11698. private _frameId;
  11699. private _refreshRate;
  11700. private _vertexBuffers;
  11701. private _indexBuffer;
  11702. private _uniforms;
  11703. private _samplers;
  11704. private _fragment;
  11705. private _floats;
  11706. private _ints;
  11707. private _floatsArrays;
  11708. private _colors3;
  11709. private _colors4;
  11710. private _vectors2;
  11711. private _vectors3;
  11712. private _matrices;
  11713. private _fallbackTextureUsed;
  11714. private _fullEngine;
  11715. private _cachedDefines;
  11716. private _contentUpdateId;
  11717. private _contentData;
  11718. /**
  11719. * Instantiates a new procedural texture.
  11720. * 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.
  11721. * This is the base class of any Procedural texture and contains most of the shareable code.
  11722. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11723. * @param name Define the name of the texture
  11724. * @param size Define the size of the texture to create
  11725. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11726. * @param scene Define the scene the texture belongs to
  11727. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11728. * @param generateMipMaps Define if the texture should creates mip maps or not
  11729. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11730. */
  11731. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11732. /**
  11733. * The effect that is created when initializing the post process.
  11734. * @returns The created effect corresponding the the postprocess.
  11735. */
  11736. getEffect(): Effect;
  11737. /**
  11738. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11739. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11740. */
  11741. getContent(): Nullable<ArrayBufferView>;
  11742. private _createIndexBuffer;
  11743. /** @hidden */
  11744. _rebuild(): void;
  11745. /**
  11746. * Resets the texture in order to recreate its associated resources.
  11747. * This can be called in case of context loss
  11748. */
  11749. reset(): void;
  11750. protected _getDefines(): string;
  11751. /**
  11752. * Is the texture ready to be used ? (rendered at least once)
  11753. * @returns true if ready, otherwise, false.
  11754. */
  11755. isReady(): boolean;
  11756. /**
  11757. * Resets the refresh counter of the texture and start bak from scratch.
  11758. * Could be useful to regenerate the texture if it is setup to render only once.
  11759. */
  11760. resetRefreshCounter(): void;
  11761. /**
  11762. * Set the fragment shader to use in order to render the texture.
  11763. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11764. */
  11765. setFragment(fragment: any): void;
  11766. /**
  11767. * Define the refresh rate of the texture or the rendering frequency.
  11768. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11769. */
  11770. get refreshRate(): number;
  11771. set refreshRate(value: number);
  11772. /** @hidden */
  11773. _shouldRender(): boolean;
  11774. /**
  11775. * Get the size the texture is rendering at.
  11776. * @returns the size (texture is always squared)
  11777. */
  11778. getRenderSize(): number;
  11779. /**
  11780. * Resize the texture to new value.
  11781. * @param size Define the new size the texture should have
  11782. * @param generateMipMaps Define whether the new texture should create mip maps
  11783. */
  11784. resize(size: number, generateMipMaps: boolean): void;
  11785. private _checkUniform;
  11786. /**
  11787. * Set a texture in the shader program used to render.
  11788. * @param name Define the name of the uniform samplers as defined in the shader
  11789. * @param texture Define the texture to bind to this sampler
  11790. * @return the texture itself allowing "fluent" like uniform updates
  11791. */
  11792. setTexture(name: string, texture: Texture): ProceduralTexture;
  11793. /**
  11794. * Set a float in the shader.
  11795. * @param name Define the name of the uniform as defined in the shader
  11796. * @param value Define the value to give to the uniform
  11797. * @return the texture itself allowing "fluent" like uniform updates
  11798. */
  11799. setFloat(name: string, value: number): ProceduralTexture;
  11800. /**
  11801. * Set a int in the shader.
  11802. * @param name Define the name of the uniform as defined in the shader
  11803. * @param value Define the value to give to the uniform
  11804. * @return the texture itself allowing "fluent" like uniform updates
  11805. */
  11806. setInt(name: string, value: number): ProceduralTexture;
  11807. /**
  11808. * Set an array of floats in the shader.
  11809. * @param name Define the name of the uniform as defined in the shader
  11810. * @param value Define the value to give to the uniform
  11811. * @return the texture itself allowing "fluent" like uniform updates
  11812. */
  11813. setFloats(name: string, value: number[]): ProceduralTexture;
  11814. /**
  11815. * Set a vec3 in the shader from a Color3.
  11816. * @param name Define the name of the uniform as defined in the shader
  11817. * @param value Define the value to give to the uniform
  11818. * @return the texture itself allowing "fluent" like uniform updates
  11819. */
  11820. setColor3(name: string, value: Color3): ProceduralTexture;
  11821. /**
  11822. * Set a vec4 in the shader from a Color4.
  11823. * @param name Define the name of the uniform as defined in the shader
  11824. * @param value Define the value to give to the uniform
  11825. * @return the texture itself allowing "fluent" like uniform updates
  11826. */
  11827. setColor4(name: string, value: Color4): ProceduralTexture;
  11828. /**
  11829. * Set a vec2 in the shader from a Vector2.
  11830. * @param name Define the name of the uniform as defined in the shader
  11831. * @param value Define the value to give to the uniform
  11832. * @return the texture itself allowing "fluent" like uniform updates
  11833. */
  11834. setVector2(name: string, value: Vector2): ProceduralTexture;
  11835. /**
  11836. * Set a vec3 in the shader from a Vector3.
  11837. * @param name Define the name of the uniform as defined in the shader
  11838. * @param value Define the value to give to the uniform
  11839. * @return the texture itself allowing "fluent" like uniform updates
  11840. */
  11841. setVector3(name: string, value: Vector3): ProceduralTexture;
  11842. /**
  11843. * Set a mat4 in the shader from a MAtrix.
  11844. * @param name Define the name of the uniform as defined in the shader
  11845. * @param value Define the value to give to the uniform
  11846. * @return the texture itself allowing "fluent" like uniform updates
  11847. */
  11848. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11849. /**
  11850. * Render the texture to its associated render target.
  11851. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11852. */
  11853. render(useCameraPostProcess?: boolean): void;
  11854. /**
  11855. * Clone the texture.
  11856. * @returns the cloned texture
  11857. */
  11858. clone(): ProceduralTexture;
  11859. /**
  11860. * Dispose the texture and release its asoociated resources.
  11861. */
  11862. dispose(): void;
  11863. }
  11864. }
  11865. declare module BABYLON {
  11866. /**
  11867. * This represents the base class for particle system in Babylon.
  11868. * 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.
  11869. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11870. * @example https://doc.babylonjs.com/babylon101/particles
  11871. */
  11872. export class BaseParticleSystem {
  11873. /**
  11874. * Source color is added to the destination color without alpha affecting the result
  11875. */
  11876. static BLENDMODE_ONEONE: number;
  11877. /**
  11878. * Blend current color and particle color using particle’s alpha
  11879. */
  11880. static BLENDMODE_STANDARD: number;
  11881. /**
  11882. * Add current color and particle color multiplied by particle’s alpha
  11883. */
  11884. static BLENDMODE_ADD: number;
  11885. /**
  11886. * Multiply current color with particle color
  11887. */
  11888. static BLENDMODE_MULTIPLY: number;
  11889. /**
  11890. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11891. */
  11892. static BLENDMODE_MULTIPLYADD: number;
  11893. /**
  11894. * List of animations used by the particle system.
  11895. */
  11896. animations: Animation[];
  11897. /**
  11898. * Gets or sets the unique id of the particle system
  11899. */
  11900. uniqueId: number;
  11901. /**
  11902. * The id of the Particle system.
  11903. */
  11904. id: string;
  11905. /**
  11906. * The friendly name of the Particle system.
  11907. */
  11908. name: string;
  11909. /**
  11910. * Snippet ID if the particle system was created from the snippet server
  11911. */
  11912. snippetId: string;
  11913. /**
  11914. * The rendering group used by the Particle system to chose when to render.
  11915. */
  11916. renderingGroupId: number;
  11917. /**
  11918. * The emitter represents the Mesh or position we are attaching the particle system to.
  11919. */
  11920. emitter: Nullable<AbstractMesh | Vector3>;
  11921. /**
  11922. * The maximum number of particles to emit per frame
  11923. */
  11924. emitRate: number;
  11925. /**
  11926. * If you want to launch only a few particles at once, that can be done, as well.
  11927. */
  11928. manualEmitCount: number;
  11929. /**
  11930. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11931. */
  11932. updateSpeed: number;
  11933. /**
  11934. * The amount of time the particle system is running (depends of the overall update speed).
  11935. */
  11936. targetStopDuration: number;
  11937. /**
  11938. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11939. */
  11940. disposeOnStop: boolean;
  11941. /**
  11942. * Minimum power of emitting particles.
  11943. */
  11944. minEmitPower: number;
  11945. /**
  11946. * Maximum power of emitting particles.
  11947. */
  11948. maxEmitPower: number;
  11949. /**
  11950. * Minimum life time of emitting particles.
  11951. */
  11952. minLifeTime: number;
  11953. /**
  11954. * Maximum life time of emitting particles.
  11955. */
  11956. maxLifeTime: number;
  11957. /**
  11958. * Minimum Size of emitting particles.
  11959. */
  11960. minSize: number;
  11961. /**
  11962. * Maximum Size of emitting particles.
  11963. */
  11964. maxSize: number;
  11965. /**
  11966. * Minimum scale of emitting particles on X axis.
  11967. */
  11968. minScaleX: number;
  11969. /**
  11970. * Maximum scale of emitting particles on X axis.
  11971. */
  11972. maxScaleX: number;
  11973. /**
  11974. * Minimum scale of emitting particles on Y axis.
  11975. */
  11976. minScaleY: number;
  11977. /**
  11978. * Maximum scale of emitting particles on Y axis.
  11979. */
  11980. maxScaleY: number;
  11981. /**
  11982. * Gets or sets the minimal initial rotation in radians.
  11983. */
  11984. minInitialRotation: number;
  11985. /**
  11986. * Gets or sets the maximal initial rotation in radians.
  11987. */
  11988. maxInitialRotation: number;
  11989. /**
  11990. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11991. */
  11992. minAngularSpeed: number;
  11993. /**
  11994. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11995. */
  11996. maxAngularSpeed: number;
  11997. /**
  11998. * The texture used to render each particle. (this can be a spritesheet)
  11999. */
  12000. particleTexture: Nullable<Texture>;
  12001. /**
  12002. * The layer mask we are rendering the particles through.
  12003. */
  12004. layerMask: number;
  12005. /**
  12006. * This can help using your own shader to render the particle system.
  12007. * The according effect will be created
  12008. */
  12009. customShader: any;
  12010. /**
  12011. * By default particle system starts as soon as they are created. This prevents the
  12012. * automatic start to happen and let you decide when to start emitting particles.
  12013. */
  12014. preventAutoStart: boolean;
  12015. private _noiseTexture;
  12016. /**
  12017. * Gets or sets a texture used to add random noise to particle positions
  12018. */
  12019. get noiseTexture(): Nullable<ProceduralTexture>;
  12020. set noiseTexture(value: Nullable<ProceduralTexture>);
  12021. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12022. noiseStrength: Vector3;
  12023. /**
  12024. * Callback triggered when the particle animation is ending.
  12025. */
  12026. onAnimationEnd: Nullable<() => void>;
  12027. /**
  12028. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12029. */
  12030. blendMode: number;
  12031. /**
  12032. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12033. * to override the particles.
  12034. */
  12035. forceDepthWrite: boolean;
  12036. /** 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 */
  12037. preWarmCycles: number;
  12038. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12039. preWarmStepOffset: number;
  12040. /**
  12041. * 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)
  12042. */
  12043. spriteCellChangeSpeed: number;
  12044. /**
  12045. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12046. */
  12047. startSpriteCellID: number;
  12048. /**
  12049. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12050. */
  12051. endSpriteCellID: number;
  12052. /**
  12053. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12054. */
  12055. spriteCellWidth: number;
  12056. /**
  12057. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12058. */
  12059. spriteCellHeight: number;
  12060. /**
  12061. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12062. */
  12063. spriteRandomStartCell: boolean;
  12064. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12065. translationPivot: Vector2;
  12066. /** @hidden */
  12067. protected _isAnimationSheetEnabled: boolean;
  12068. /**
  12069. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12070. */
  12071. beginAnimationOnStart: boolean;
  12072. /**
  12073. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12074. */
  12075. beginAnimationFrom: number;
  12076. /**
  12077. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12078. */
  12079. beginAnimationTo: number;
  12080. /**
  12081. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12082. */
  12083. beginAnimationLoop: boolean;
  12084. /**
  12085. * Gets or sets a world offset applied to all particles
  12086. */
  12087. worldOffset: Vector3;
  12088. /**
  12089. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12090. */
  12091. get isAnimationSheetEnabled(): boolean;
  12092. set isAnimationSheetEnabled(value: boolean);
  12093. /**
  12094. * Get hosting scene
  12095. * @returns the scene
  12096. */
  12097. getScene(): Scene;
  12098. /**
  12099. * You can use gravity if you want to give an orientation to your particles.
  12100. */
  12101. gravity: Vector3;
  12102. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12103. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12104. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12105. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12106. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12107. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12108. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12109. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12110. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12111. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12112. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12113. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12114. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12115. /**
  12116. * Defines the delay in milliseconds before starting the system (0 by default)
  12117. */
  12118. startDelay: number;
  12119. /**
  12120. * Gets the current list of drag gradients.
  12121. * You must use addDragGradient and removeDragGradient to udpate this list
  12122. * @returns the list of drag gradients
  12123. */
  12124. getDragGradients(): Nullable<Array<FactorGradient>>;
  12125. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12126. limitVelocityDamping: number;
  12127. /**
  12128. * Gets the current list of limit velocity gradients.
  12129. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12130. * @returns the list of limit velocity gradients
  12131. */
  12132. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12133. /**
  12134. * Gets the current list of color gradients.
  12135. * You must use addColorGradient and removeColorGradient to udpate this list
  12136. * @returns the list of color gradients
  12137. */
  12138. getColorGradients(): Nullable<Array<ColorGradient>>;
  12139. /**
  12140. * Gets the current list of size gradients.
  12141. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12142. * @returns the list of size gradients
  12143. */
  12144. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12145. /**
  12146. * Gets the current list of color remap gradients.
  12147. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12148. * @returns the list of color remap gradients
  12149. */
  12150. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12151. /**
  12152. * Gets the current list of alpha remap gradients.
  12153. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12154. * @returns the list of alpha remap gradients
  12155. */
  12156. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12157. /**
  12158. * Gets the current list of life time gradients.
  12159. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12160. * @returns the list of life time gradients
  12161. */
  12162. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12163. /**
  12164. * Gets the current list of angular speed gradients.
  12165. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12166. * @returns the list of angular speed gradients
  12167. */
  12168. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12169. /**
  12170. * Gets the current list of velocity gradients.
  12171. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12172. * @returns the list of velocity gradients
  12173. */
  12174. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12175. /**
  12176. * Gets the current list of start size gradients.
  12177. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12178. * @returns the list of start size gradients
  12179. */
  12180. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12181. /**
  12182. * Gets the current list of emit rate gradients.
  12183. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12184. * @returns the list of emit rate gradients
  12185. */
  12186. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12187. /**
  12188. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12189. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12190. */
  12191. get direction1(): Vector3;
  12192. set direction1(value: Vector3);
  12193. /**
  12194. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12195. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12196. */
  12197. get direction2(): Vector3;
  12198. set direction2(value: Vector3);
  12199. /**
  12200. * 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.
  12201. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12202. */
  12203. get minEmitBox(): Vector3;
  12204. set minEmitBox(value: Vector3);
  12205. /**
  12206. * 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.
  12207. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12208. */
  12209. get maxEmitBox(): Vector3;
  12210. set maxEmitBox(value: Vector3);
  12211. /**
  12212. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12213. */
  12214. color1: Color4;
  12215. /**
  12216. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12217. */
  12218. color2: Color4;
  12219. /**
  12220. * Color the particle will have at the end of its lifetime
  12221. */
  12222. colorDead: Color4;
  12223. /**
  12224. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12225. */
  12226. textureMask: Color4;
  12227. /**
  12228. * The particle emitter type defines the emitter used by the particle system.
  12229. * It can be for example box, sphere, or cone...
  12230. */
  12231. particleEmitterType: IParticleEmitterType;
  12232. /** @hidden */
  12233. _isSubEmitter: boolean;
  12234. /**
  12235. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12236. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12237. */
  12238. billboardMode: number;
  12239. protected _isBillboardBased: boolean;
  12240. /**
  12241. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12242. */
  12243. get isBillboardBased(): boolean;
  12244. set isBillboardBased(value: boolean);
  12245. /**
  12246. * The scene the particle system belongs to.
  12247. */
  12248. protected _scene: Scene;
  12249. /**
  12250. * Local cache of defines for image processing.
  12251. */
  12252. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12253. /**
  12254. * Default configuration related to image processing available in the standard Material.
  12255. */
  12256. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12257. /**
  12258. * Gets the image processing configuration used either in this material.
  12259. */
  12260. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12261. /**
  12262. * Sets the Default image processing configuration used either in the this material.
  12263. *
  12264. * If sets to null, the scene one is in use.
  12265. */
  12266. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12267. /**
  12268. * Attaches a new image processing configuration to the Standard Material.
  12269. * @param configuration
  12270. */
  12271. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12272. /** @hidden */
  12273. protected _reset(): void;
  12274. /** @hidden */
  12275. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12276. /**
  12277. * Instantiates a particle system.
  12278. * 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.
  12279. * @param name The name of the particle system
  12280. */
  12281. constructor(name: string);
  12282. /**
  12283. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12284. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12285. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @returns the emitter
  12287. */
  12288. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12289. /**
  12290. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12291. * @param radius The radius of the hemisphere to emit from
  12292. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12293. * @returns the emitter
  12294. */
  12295. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12296. /**
  12297. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12298. * @param radius The radius of the sphere to emit from
  12299. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12300. * @returns the emitter
  12301. */
  12302. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12303. /**
  12304. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12305. * @param radius The radius of the sphere to emit from
  12306. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12307. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @returns the emitter
  12309. */
  12310. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12311. /**
  12312. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12313. * @param radius The radius of the emission cylinder
  12314. * @param height The height of the emission cylinder
  12315. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12316. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12317. * @returns the emitter
  12318. */
  12319. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12320. /**
  12321. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12322. * @param radius The radius of the cylinder to emit from
  12323. * @param height The height of the emission cylinder
  12324. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12325. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12326. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @returns the emitter
  12328. */
  12329. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12330. /**
  12331. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12332. * @param radius The radius of the cone to emit from
  12333. * @param angle The base angle of the cone
  12334. * @returns the emitter
  12335. */
  12336. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12337. /**
  12338. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12339. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12340. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12342. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @returns the emitter
  12344. */
  12345. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12346. }
  12347. }
  12348. declare module BABYLON {
  12349. /**
  12350. * Type of sub emitter
  12351. */
  12352. export enum SubEmitterType {
  12353. /**
  12354. * Attached to the particle over it's lifetime
  12355. */
  12356. ATTACHED = 0,
  12357. /**
  12358. * Created when the particle dies
  12359. */
  12360. END = 1
  12361. }
  12362. /**
  12363. * Sub emitter class used to emit particles from an existing particle
  12364. */
  12365. export class SubEmitter {
  12366. /**
  12367. * the particle system to be used by the sub emitter
  12368. */
  12369. particleSystem: ParticleSystem;
  12370. /**
  12371. * Type of the submitter (Default: END)
  12372. */
  12373. type: SubEmitterType;
  12374. /**
  12375. * 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)
  12376. * Note: This only is supported when using an emitter of type Mesh
  12377. */
  12378. inheritDirection: boolean;
  12379. /**
  12380. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12381. */
  12382. inheritedVelocityAmount: number;
  12383. /**
  12384. * Creates a sub emitter
  12385. * @param particleSystem the particle system to be used by the sub emitter
  12386. */
  12387. constructor(
  12388. /**
  12389. * the particle system to be used by the sub emitter
  12390. */
  12391. particleSystem: ParticleSystem);
  12392. /**
  12393. * Clones the sub emitter
  12394. * @returns the cloned sub emitter
  12395. */
  12396. clone(): SubEmitter;
  12397. /**
  12398. * Serialize current object to a JSON object
  12399. * @returns the serialized object
  12400. */
  12401. serialize(): any;
  12402. /** @hidden */
  12403. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12404. /**
  12405. * Creates a new SubEmitter from a serialized JSON version
  12406. * @param serializationObject defines the JSON object to read from
  12407. * @param scene defines the hosting scene
  12408. * @param rootUrl defines the rootUrl for data loading
  12409. * @returns a new SubEmitter
  12410. */
  12411. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12412. /** Release associated resources */
  12413. dispose(): void;
  12414. }
  12415. }
  12416. declare module BABYLON {
  12417. /** @hidden */
  12418. export var imageProcessingDeclaration: {
  12419. name: string;
  12420. shader: string;
  12421. };
  12422. }
  12423. declare module BABYLON {
  12424. /** @hidden */
  12425. export var imageProcessingFunctions: {
  12426. name: string;
  12427. shader: string;
  12428. };
  12429. }
  12430. declare module BABYLON {
  12431. /** @hidden */
  12432. export var particlesPixelShader: {
  12433. name: string;
  12434. shader: string;
  12435. };
  12436. }
  12437. declare module BABYLON {
  12438. /** @hidden */
  12439. export var particlesVertexShader: {
  12440. name: string;
  12441. shader: string;
  12442. };
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * This represents a particle system in Babylon.
  12447. * 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.
  12448. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12449. * @example https://doc.babylonjs.com/babylon101/particles
  12450. */
  12451. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12452. /**
  12453. * Billboard mode will only apply to Y axis
  12454. */
  12455. static readonly BILLBOARDMODE_Y: number;
  12456. /**
  12457. * Billboard mode will apply to all axes
  12458. */
  12459. static readonly BILLBOARDMODE_ALL: number;
  12460. /**
  12461. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12462. */
  12463. static readonly BILLBOARDMODE_STRETCHED: number;
  12464. /**
  12465. * This function can be defined to provide custom update for active particles.
  12466. * This function will be called instead of regular update (age, position, color, etc.).
  12467. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12468. */
  12469. updateFunction: (particles: Particle[]) => void;
  12470. private _emitterWorldMatrix;
  12471. /**
  12472. * This function can be defined to specify initial direction for every new particle.
  12473. * It by default use the emitterType defined function
  12474. */
  12475. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12476. /**
  12477. * This function can be defined to specify initial position for every new particle.
  12478. * It by default use the emitterType defined function
  12479. */
  12480. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12481. /**
  12482. * @hidden
  12483. */
  12484. _inheritedVelocityOffset: Vector3;
  12485. /**
  12486. * An event triggered when the system is disposed
  12487. */
  12488. onDisposeObservable: Observable<IParticleSystem>;
  12489. private _onDisposeObserver;
  12490. /**
  12491. * Sets a callback that will be triggered when the system is disposed
  12492. */
  12493. set onDispose(callback: () => void);
  12494. private _particles;
  12495. private _epsilon;
  12496. private _capacity;
  12497. private _stockParticles;
  12498. private _newPartsExcess;
  12499. private _vertexData;
  12500. private _vertexBuffer;
  12501. private _vertexBuffers;
  12502. private _spriteBuffer;
  12503. private _indexBuffer;
  12504. private _effect;
  12505. private _customEffect;
  12506. private _cachedDefines;
  12507. private _scaledColorStep;
  12508. private _colorDiff;
  12509. private _scaledDirection;
  12510. private _scaledGravity;
  12511. private _currentRenderId;
  12512. private _alive;
  12513. private _useInstancing;
  12514. private _started;
  12515. private _stopped;
  12516. private _actualFrame;
  12517. private _scaledUpdateSpeed;
  12518. private _vertexBufferSize;
  12519. /** @hidden */
  12520. _currentEmitRateGradient: Nullable<FactorGradient>;
  12521. /** @hidden */
  12522. _currentEmitRate1: number;
  12523. /** @hidden */
  12524. _currentEmitRate2: number;
  12525. /** @hidden */
  12526. _currentStartSizeGradient: Nullable<FactorGradient>;
  12527. /** @hidden */
  12528. _currentStartSize1: number;
  12529. /** @hidden */
  12530. _currentStartSize2: number;
  12531. private readonly _rawTextureWidth;
  12532. private _rampGradientsTexture;
  12533. private _useRampGradients;
  12534. /** Gets or sets a boolean indicating that ramp gradients must be used
  12535. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12536. */
  12537. get useRampGradients(): boolean;
  12538. set useRampGradients(value: boolean);
  12539. /**
  12540. * 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.
  12541. * 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: [])
  12542. */
  12543. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12544. private _subEmitters;
  12545. /**
  12546. * @hidden
  12547. * If the particle systems emitter should be disposed when the particle system is disposed
  12548. */
  12549. _disposeEmitterOnDispose: boolean;
  12550. /**
  12551. * The current active Sub-systems, this property is used by the root particle system only.
  12552. */
  12553. activeSubSystems: Array<ParticleSystem>;
  12554. /**
  12555. * Specifies if the particles are updated in emitter local space or world space
  12556. */
  12557. isLocal: boolean;
  12558. private _rootParticleSystem;
  12559. /**
  12560. * Gets the current list of active particles
  12561. */
  12562. get particles(): Particle[];
  12563. /**
  12564. * Gets the number of particles active at the same time.
  12565. * @returns The number of active particles.
  12566. */
  12567. getActiveCount(): number;
  12568. /**
  12569. * Returns the string "ParticleSystem"
  12570. * @returns a string containing the class name
  12571. */
  12572. getClassName(): string;
  12573. /**
  12574. * Gets a boolean indicating that the system is stopping
  12575. * @returns true if the system is currently stopping
  12576. */
  12577. isStopping(): boolean;
  12578. /**
  12579. * Gets the custom effect used to render the particles
  12580. * @param blendMode Blend mode for which the effect should be retrieved
  12581. * @returns The effect
  12582. */
  12583. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12584. /**
  12585. * Sets the custom effect used to render the particles
  12586. * @param effect The effect to set
  12587. * @param blendMode Blend mode for which the effect should be set
  12588. */
  12589. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12590. /** @hidden */
  12591. private _onBeforeDrawParticlesObservable;
  12592. /**
  12593. * Observable that will be called just before the particles are drawn
  12594. */
  12595. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12596. /**
  12597. * Gets the name of the particle vertex shader
  12598. */
  12599. get vertexShaderName(): string;
  12600. /**
  12601. * Instantiates a particle system.
  12602. * 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.
  12603. * @param name The name of the particle system
  12604. * @param capacity The max number of particles alive at the same time
  12605. * @param scene The scene the particle system belongs to
  12606. * @param customEffect a custom effect used to change the way particles are rendered by default
  12607. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12608. * @param epsilon Offset used to render the particles
  12609. */
  12610. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12611. private _addFactorGradient;
  12612. private _removeFactorGradient;
  12613. /**
  12614. * Adds a new life time gradient
  12615. * @param gradient defines the gradient to use (between 0 and 1)
  12616. * @param factor defines the life time factor to affect to the specified gradient
  12617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12618. * @returns the current particle system
  12619. */
  12620. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12621. /**
  12622. * Remove a specific life time gradient
  12623. * @param gradient defines the gradient to remove
  12624. * @returns the current particle system
  12625. */
  12626. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12627. /**
  12628. * Adds a new size gradient
  12629. * @param gradient defines the gradient to use (between 0 and 1)
  12630. * @param factor defines the size factor to affect to the specified gradient
  12631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12632. * @returns the current particle system
  12633. */
  12634. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12635. /**
  12636. * Remove a specific size gradient
  12637. * @param gradient defines the gradient to remove
  12638. * @returns the current particle system
  12639. */
  12640. removeSizeGradient(gradient: number): IParticleSystem;
  12641. /**
  12642. * Adds a new color remap gradient
  12643. * @param gradient defines the gradient to use (between 0 and 1)
  12644. * @param min defines the color remap minimal range
  12645. * @param max defines the color remap maximal range
  12646. * @returns the current particle system
  12647. */
  12648. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12649. /**
  12650. * Remove a specific color remap gradient
  12651. * @param gradient defines the gradient to remove
  12652. * @returns the current particle system
  12653. */
  12654. removeColorRemapGradient(gradient: number): IParticleSystem;
  12655. /**
  12656. * Adds a new alpha remap gradient
  12657. * @param gradient defines the gradient to use (between 0 and 1)
  12658. * @param min defines the alpha remap minimal range
  12659. * @param max defines the alpha remap maximal range
  12660. * @returns the current particle system
  12661. */
  12662. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12663. /**
  12664. * Remove a specific alpha remap gradient
  12665. * @param gradient defines the gradient to remove
  12666. * @returns the current particle system
  12667. */
  12668. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12669. /**
  12670. * Adds a new angular speed gradient
  12671. * @param gradient defines the gradient to use (between 0 and 1)
  12672. * @param factor defines the angular speed to affect to the specified gradient
  12673. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12674. * @returns the current particle system
  12675. */
  12676. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12677. /**
  12678. * Remove a specific angular speed gradient
  12679. * @param gradient defines the gradient to remove
  12680. * @returns the current particle system
  12681. */
  12682. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12683. /**
  12684. * Adds a new velocity gradient
  12685. * @param gradient defines the gradient to use (between 0 and 1)
  12686. * @param factor defines the velocity to affect to the specified gradient
  12687. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12688. * @returns the current particle system
  12689. */
  12690. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12691. /**
  12692. * Remove a specific velocity gradient
  12693. * @param gradient defines the gradient to remove
  12694. * @returns the current particle system
  12695. */
  12696. removeVelocityGradient(gradient: number): IParticleSystem;
  12697. /**
  12698. * Adds a new limit velocity gradient
  12699. * @param gradient defines the gradient to use (between 0 and 1)
  12700. * @param factor defines the limit velocity value to affect to the specified gradient
  12701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12702. * @returns the current particle system
  12703. */
  12704. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12705. /**
  12706. * Remove a specific limit velocity gradient
  12707. * @param gradient defines the gradient to remove
  12708. * @returns the current particle system
  12709. */
  12710. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12711. /**
  12712. * Adds a new drag gradient
  12713. * @param gradient defines the gradient to use (between 0 and 1)
  12714. * @param factor defines the drag value to affect to the specified gradient
  12715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12716. * @returns the current particle system
  12717. */
  12718. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12719. /**
  12720. * Remove a specific drag gradient
  12721. * @param gradient defines the gradient to remove
  12722. * @returns the current particle system
  12723. */
  12724. removeDragGradient(gradient: number): IParticleSystem;
  12725. /**
  12726. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12727. * @param gradient defines the gradient to use (between 0 and 1)
  12728. * @param factor defines the emit rate value to affect to the specified gradient
  12729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12730. * @returns the current particle system
  12731. */
  12732. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12733. /**
  12734. * Remove a specific emit rate gradient
  12735. * @param gradient defines the gradient to remove
  12736. * @returns the current particle system
  12737. */
  12738. removeEmitRateGradient(gradient: number): IParticleSystem;
  12739. /**
  12740. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12741. * @param gradient defines the gradient to use (between 0 and 1)
  12742. * @param factor defines the start size value to affect to the specified gradient
  12743. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12744. * @returns the current particle system
  12745. */
  12746. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12747. /**
  12748. * Remove a specific start size gradient
  12749. * @param gradient defines the gradient to remove
  12750. * @returns the current particle system
  12751. */
  12752. removeStartSizeGradient(gradient: number): IParticleSystem;
  12753. private _createRampGradientTexture;
  12754. /**
  12755. * Gets the current list of ramp gradients.
  12756. * You must use addRampGradient and removeRampGradient to udpate this list
  12757. * @returns the list of ramp gradients
  12758. */
  12759. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12760. /** Force the system to rebuild all gradients that need to be resync */
  12761. forceRefreshGradients(): void;
  12762. private _syncRampGradientTexture;
  12763. /**
  12764. * Adds a new ramp gradient used to remap particle colors
  12765. * @param gradient defines the gradient to use (between 0 and 1)
  12766. * @param color defines the color to affect to the specified gradient
  12767. * @returns the current particle system
  12768. */
  12769. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12770. /**
  12771. * Remove a specific ramp gradient
  12772. * @param gradient defines the gradient to remove
  12773. * @returns the current particle system
  12774. */
  12775. removeRampGradient(gradient: number): ParticleSystem;
  12776. /**
  12777. * Adds a new color gradient
  12778. * @param gradient defines the gradient to use (between 0 and 1)
  12779. * @param color1 defines the color to affect to the specified gradient
  12780. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12781. * @returns this particle system
  12782. */
  12783. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12784. /**
  12785. * Remove a specific color gradient
  12786. * @param gradient defines the gradient to remove
  12787. * @returns this particle system
  12788. */
  12789. removeColorGradient(gradient: number): IParticleSystem;
  12790. private _fetchR;
  12791. protected _reset(): void;
  12792. private _resetEffect;
  12793. private _createVertexBuffers;
  12794. private _createIndexBuffer;
  12795. /**
  12796. * Gets the maximum number of particles active at the same time.
  12797. * @returns The max number of active particles.
  12798. */
  12799. getCapacity(): number;
  12800. /**
  12801. * Gets whether there are still active particles in the system.
  12802. * @returns True if it is alive, otherwise false.
  12803. */
  12804. isAlive(): boolean;
  12805. /**
  12806. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12807. * @returns True if it has been started, otherwise false.
  12808. */
  12809. isStarted(): boolean;
  12810. private _prepareSubEmitterInternalArray;
  12811. /**
  12812. * Starts the particle system and begins to emit
  12813. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12814. */
  12815. start(delay?: number): void;
  12816. /**
  12817. * Stops the particle system.
  12818. * @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.
  12819. */
  12820. stop(stopSubEmitters?: boolean): void;
  12821. /**
  12822. * Remove all active particles
  12823. */
  12824. reset(): void;
  12825. /**
  12826. * @hidden (for internal use only)
  12827. */
  12828. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12829. /**
  12830. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12831. * Its lifetime will start back at 0.
  12832. */
  12833. recycleParticle: (particle: Particle) => void;
  12834. private _stopSubEmitters;
  12835. private _createParticle;
  12836. private _removeFromRoot;
  12837. private _emitFromParticle;
  12838. private _update;
  12839. /** @hidden */
  12840. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12841. /** @hidden */
  12842. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12843. /**
  12844. * Fill the defines array according to the current settings of the particle system
  12845. * @param defines Array to be updated
  12846. * @param blendMode blend mode to take into account when updating the array
  12847. */
  12848. fillDefines(defines: Array<string>, blendMode: number): void;
  12849. /**
  12850. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12851. * @param uniforms Uniforms array to fill
  12852. * @param attributes Attributes array to fill
  12853. * @param samplers Samplers array to fill
  12854. */
  12855. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12856. /** @hidden */
  12857. private _getEffect;
  12858. /**
  12859. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12860. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12861. */
  12862. animate(preWarmOnly?: boolean): void;
  12863. private _appendParticleVertices;
  12864. /**
  12865. * Rebuilds the particle system.
  12866. */
  12867. rebuild(): void;
  12868. /**
  12869. * Is this system ready to be used/rendered
  12870. * @return true if the system is ready
  12871. */
  12872. isReady(): boolean;
  12873. private _render;
  12874. /**
  12875. * Renders the particle system in its current state.
  12876. * @returns the current number of particles
  12877. */
  12878. render(): number;
  12879. /**
  12880. * Disposes the particle system and free the associated resources
  12881. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12882. */
  12883. dispose(disposeTexture?: boolean): void;
  12884. /**
  12885. * Clones the particle system.
  12886. * @param name The name of the cloned object
  12887. * @param newEmitter The new emitter to use
  12888. * @returns the cloned particle system
  12889. */
  12890. clone(name: string, newEmitter: any): ParticleSystem;
  12891. /**
  12892. * Serializes the particle system to a JSON object
  12893. * @param serializeTexture defines if the texture must be serialized as well
  12894. * @returns the JSON object
  12895. */
  12896. serialize(serializeTexture?: boolean): any;
  12897. /** @hidden */
  12898. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12899. /** @hidden */
  12900. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12901. /**
  12902. * Parses a JSON object to create a particle system.
  12903. * @param parsedParticleSystem The JSON object to parse
  12904. * @param scene The scene to create the particle system in
  12905. * @param rootUrl The root url to use to load external dependencies like texture
  12906. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12907. * @returns the Parsed particle system
  12908. */
  12909. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12910. }
  12911. }
  12912. declare module BABYLON {
  12913. /**
  12914. * A particle represents one of the element emitted by a particle system.
  12915. * This is mainly define by its coordinates, direction, velocity and age.
  12916. */
  12917. export class Particle {
  12918. /**
  12919. * The particle system the particle belongs to.
  12920. */
  12921. particleSystem: ParticleSystem;
  12922. private static _Count;
  12923. /**
  12924. * Unique ID of the particle
  12925. */
  12926. id: number;
  12927. /**
  12928. * The world position of the particle in the scene.
  12929. */
  12930. position: Vector3;
  12931. /**
  12932. * The world direction of the particle in the scene.
  12933. */
  12934. direction: Vector3;
  12935. /**
  12936. * The color of the particle.
  12937. */
  12938. color: Color4;
  12939. /**
  12940. * The color change of the particle per step.
  12941. */
  12942. colorStep: Color4;
  12943. /**
  12944. * Defines how long will the life of the particle be.
  12945. */
  12946. lifeTime: number;
  12947. /**
  12948. * The current age of the particle.
  12949. */
  12950. age: number;
  12951. /**
  12952. * The current size of the particle.
  12953. */
  12954. size: number;
  12955. /**
  12956. * The current scale of the particle.
  12957. */
  12958. scale: Vector2;
  12959. /**
  12960. * The current angle of the particle.
  12961. */
  12962. angle: number;
  12963. /**
  12964. * Defines how fast is the angle changing.
  12965. */
  12966. angularSpeed: number;
  12967. /**
  12968. * Defines the cell index used by the particle to be rendered from a sprite.
  12969. */
  12970. cellIndex: number;
  12971. /**
  12972. * The information required to support color remapping
  12973. */
  12974. remapData: Vector4;
  12975. /** @hidden */
  12976. _randomCellOffset?: number;
  12977. /** @hidden */
  12978. _initialDirection: Nullable<Vector3>;
  12979. /** @hidden */
  12980. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12981. /** @hidden */
  12982. _initialStartSpriteCellID: number;
  12983. /** @hidden */
  12984. _initialEndSpriteCellID: number;
  12985. /** @hidden */
  12986. _currentColorGradient: Nullable<ColorGradient>;
  12987. /** @hidden */
  12988. _currentColor1: Color4;
  12989. /** @hidden */
  12990. _currentColor2: Color4;
  12991. /** @hidden */
  12992. _currentSizeGradient: Nullable<FactorGradient>;
  12993. /** @hidden */
  12994. _currentSize1: number;
  12995. /** @hidden */
  12996. _currentSize2: number;
  12997. /** @hidden */
  12998. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12999. /** @hidden */
  13000. _currentAngularSpeed1: number;
  13001. /** @hidden */
  13002. _currentAngularSpeed2: number;
  13003. /** @hidden */
  13004. _currentVelocityGradient: Nullable<FactorGradient>;
  13005. /** @hidden */
  13006. _currentVelocity1: number;
  13007. /** @hidden */
  13008. _currentVelocity2: number;
  13009. /** @hidden */
  13010. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13011. /** @hidden */
  13012. _currentLimitVelocity1: number;
  13013. /** @hidden */
  13014. _currentLimitVelocity2: number;
  13015. /** @hidden */
  13016. _currentDragGradient: Nullable<FactorGradient>;
  13017. /** @hidden */
  13018. _currentDrag1: number;
  13019. /** @hidden */
  13020. _currentDrag2: number;
  13021. /** @hidden */
  13022. _randomNoiseCoordinates1: Vector3;
  13023. /** @hidden */
  13024. _randomNoiseCoordinates2: Vector3;
  13025. /** @hidden */
  13026. _localPosition?: Vector3;
  13027. /**
  13028. * Creates a new instance Particle
  13029. * @param particleSystem the particle system the particle belongs to
  13030. */
  13031. constructor(
  13032. /**
  13033. * The particle system the particle belongs to.
  13034. */
  13035. particleSystem: ParticleSystem);
  13036. private updateCellInfoFromSystem;
  13037. /**
  13038. * Defines how the sprite cell index is updated for the particle
  13039. */
  13040. updateCellIndex(): void;
  13041. /** @hidden */
  13042. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13043. /** @hidden */
  13044. _inheritParticleInfoToSubEmitters(): void;
  13045. /** @hidden */
  13046. _reset(): void;
  13047. /**
  13048. * Copy the properties of particle to another one.
  13049. * @param other the particle to copy the information to.
  13050. */
  13051. copyTo(other: Particle): void;
  13052. }
  13053. }
  13054. declare module BABYLON {
  13055. /**
  13056. * Particle emitter represents a volume emitting particles.
  13057. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13058. */
  13059. export interface IParticleEmitterType {
  13060. /**
  13061. * Called by the particle System when the direction is computed for the created particle.
  13062. * @param worldMatrix is the world matrix of the particle system
  13063. * @param directionToUpdate is the direction vector to update with the result
  13064. * @param particle is the particle we are computed the direction for
  13065. * @param isLocal defines if the direction should be set in local space
  13066. */
  13067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13068. /**
  13069. * Called by the particle System when the position is computed for the created particle.
  13070. * @param worldMatrix is the world matrix of the particle system
  13071. * @param positionToUpdate is the position vector to update with the result
  13072. * @param particle is the particle we are computed the position for
  13073. * @param isLocal defines if the position should be set in local space
  13074. */
  13075. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13076. /**
  13077. * Clones the current emitter and returns a copy of it
  13078. * @returns the new emitter
  13079. */
  13080. clone(): IParticleEmitterType;
  13081. /**
  13082. * Called by the GPUParticleSystem to setup the update shader
  13083. * @param effect defines the update shader
  13084. */
  13085. applyToShader(effect: Effect): void;
  13086. /**
  13087. * Returns a string to use to update the GPU particles update shader
  13088. * @returns the effect defines string
  13089. */
  13090. getEffectDefines(): string;
  13091. /**
  13092. * Returns a string representing the class name
  13093. * @returns a string containing the class name
  13094. */
  13095. getClassName(): string;
  13096. /**
  13097. * Serializes the particle system to a JSON object.
  13098. * @returns the JSON object
  13099. */
  13100. serialize(): any;
  13101. /**
  13102. * Parse properties from a JSON object
  13103. * @param serializationObject defines the JSON object
  13104. * @param scene defines the hosting scene
  13105. */
  13106. parse(serializationObject: any, scene: Scene): void;
  13107. }
  13108. }
  13109. declare module BABYLON {
  13110. /**
  13111. * Particle emitter emitting particles from the inside of a box.
  13112. * It emits the particles randomly between 2 given directions.
  13113. */
  13114. export class BoxParticleEmitter implements IParticleEmitterType {
  13115. /**
  13116. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13117. */
  13118. direction1: Vector3;
  13119. /**
  13120. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13121. */
  13122. direction2: Vector3;
  13123. /**
  13124. * 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.
  13125. */
  13126. minEmitBox: Vector3;
  13127. /**
  13128. * 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.
  13129. */
  13130. maxEmitBox: Vector3;
  13131. /**
  13132. * Creates a new instance BoxParticleEmitter
  13133. */
  13134. constructor();
  13135. /**
  13136. * Called by the particle System when the direction is computed for the created particle.
  13137. * @param worldMatrix is the world matrix of the particle system
  13138. * @param directionToUpdate is the direction vector to update with the result
  13139. * @param particle is the particle we are computed the direction for
  13140. * @param isLocal defines if the direction should be set in local space
  13141. */
  13142. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13143. /**
  13144. * Called by the particle System when the position is computed for the created particle.
  13145. * @param worldMatrix is the world matrix of the particle system
  13146. * @param positionToUpdate is the position vector to update with the result
  13147. * @param particle is the particle we are computed the position for
  13148. * @param isLocal defines if the position should be set in local space
  13149. */
  13150. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13151. /**
  13152. * Clones the current emitter and returns a copy of it
  13153. * @returns the new emitter
  13154. */
  13155. clone(): BoxParticleEmitter;
  13156. /**
  13157. * Called by the GPUParticleSystem to setup the update shader
  13158. * @param effect defines the update shader
  13159. */
  13160. applyToShader(effect: Effect): void;
  13161. /**
  13162. * Returns a string to use to update the GPU particles update shader
  13163. * @returns a string containng the defines string
  13164. */
  13165. getEffectDefines(): string;
  13166. /**
  13167. * Returns the string "BoxParticleEmitter"
  13168. * @returns a string containing the class name
  13169. */
  13170. getClassName(): string;
  13171. /**
  13172. * Serializes the particle system to a JSON object.
  13173. * @returns the JSON object
  13174. */
  13175. serialize(): any;
  13176. /**
  13177. * Parse properties from a JSON object
  13178. * @param serializationObject defines the JSON object
  13179. */
  13180. parse(serializationObject: any): void;
  13181. }
  13182. }
  13183. declare module BABYLON {
  13184. /**
  13185. * Particle emitter emitting particles from the inside of a cone.
  13186. * It emits the particles alongside the cone volume from the base to the particle.
  13187. * The emission direction might be randomized.
  13188. */
  13189. export class ConeParticleEmitter implements IParticleEmitterType {
  13190. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13191. directionRandomizer: number;
  13192. private _radius;
  13193. private _angle;
  13194. private _height;
  13195. /**
  13196. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13197. */
  13198. radiusRange: number;
  13199. /**
  13200. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13201. */
  13202. heightRange: number;
  13203. /**
  13204. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13205. */
  13206. emitFromSpawnPointOnly: boolean;
  13207. /**
  13208. * Gets or sets the radius of the emission cone
  13209. */
  13210. get radius(): number;
  13211. set radius(value: number);
  13212. /**
  13213. * Gets or sets the angle of the emission cone
  13214. */
  13215. get angle(): number;
  13216. set angle(value: number);
  13217. private _buildHeight;
  13218. /**
  13219. * Creates a new instance ConeParticleEmitter
  13220. * @param radius the radius of the emission cone (1 by default)
  13221. * @param angle the cone base angle (PI by default)
  13222. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13223. */
  13224. constructor(radius?: number, angle?: number,
  13225. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13226. directionRandomizer?: number);
  13227. /**
  13228. * Called by the particle System when the direction is computed for the created particle.
  13229. * @param worldMatrix is the world matrix of the particle system
  13230. * @param directionToUpdate is the direction vector to update with the result
  13231. * @param particle is the particle we are computed the direction for
  13232. * @param isLocal defines if the direction should be set in local space
  13233. */
  13234. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13235. /**
  13236. * Called by the particle System when the position is computed for the created particle.
  13237. * @param worldMatrix is the world matrix of the particle system
  13238. * @param positionToUpdate is the position vector to update with the result
  13239. * @param particle is the particle we are computed the position for
  13240. * @param isLocal defines if the position should be set in local space
  13241. */
  13242. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13243. /**
  13244. * Clones the current emitter and returns a copy of it
  13245. * @returns the new emitter
  13246. */
  13247. clone(): ConeParticleEmitter;
  13248. /**
  13249. * Called by the GPUParticleSystem to setup the update shader
  13250. * @param effect defines the update shader
  13251. */
  13252. applyToShader(effect: Effect): void;
  13253. /**
  13254. * Returns a string to use to update the GPU particles update shader
  13255. * @returns a string containng the defines string
  13256. */
  13257. getEffectDefines(): string;
  13258. /**
  13259. * Returns the string "ConeParticleEmitter"
  13260. * @returns a string containing the class name
  13261. */
  13262. getClassName(): string;
  13263. /**
  13264. * Serializes the particle system to a JSON object.
  13265. * @returns the JSON object
  13266. */
  13267. serialize(): any;
  13268. /**
  13269. * Parse properties from a JSON object
  13270. * @param serializationObject defines the JSON object
  13271. */
  13272. parse(serializationObject: any): void;
  13273. }
  13274. }
  13275. declare module BABYLON {
  13276. /**
  13277. * Particle emitter emitting particles from the inside of a cylinder.
  13278. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13279. */
  13280. export class CylinderParticleEmitter implements IParticleEmitterType {
  13281. /**
  13282. * The radius of the emission cylinder.
  13283. */
  13284. radius: number;
  13285. /**
  13286. * The height of the emission cylinder.
  13287. */
  13288. height: number;
  13289. /**
  13290. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13291. */
  13292. radiusRange: number;
  13293. /**
  13294. * How much to randomize the particle direction [0-1].
  13295. */
  13296. directionRandomizer: number;
  13297. /**
  13298. * Creates a new instance CylinderParticleEmitter
  13299. * @param radius the radius of the emission cylinder (1 by default)
  13300. * @param height the height of the emission cylinder (1 by default)
  13301. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13302. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13303. */
  13304. constructor(
  13305. /**
  13306. * The radius of the emission cylinder.
  13307. */
  13308. radius?: number,
  13309. /**
  13310. * The height of the emission cylinder.
  13311. */
  13312. height?: number,
  13313. /**
  13314. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13315. */
  13316. radiusRange?: number,
  13317. /**
  13318. * How much to randomize the particle direction [0-1].
  13319. */
  13320. directionRandomizer?: number);
  13321. /**
  13322. * Called by the particle System when the direction is computed for the created particle.
  13323. * @param worldMatrix is the world matrix of the particle system
  13324. * @param directionToUpdate is the direction vector to update with the result
  13325. * @param particle is the particle we are computed the direction for
  13326. * @param isLocal defines if the direction should be set in local space
  13327. */
  13328. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13329. /**
  13330. * Called by the particle System when the position is computed for the created particle.
  13331. * @param worldMatrix is the world matrix of the particle system
  13332. * @param positionToUpdate is the position vector to update with the result
  13333. * @param particle is the particle we are computed the position for
  13334. * @param isLocal defines if the position should be set in local space
  13335. */
  13336. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13337. /**
  13338. * Clones the current emitter and returns a copy of it
  13339. * @returns the new emitter
  13340. */
  13341. clone(): CylinderParticleEmitter;
  13342. /**
  13343. * Called by the GPUParticleSystem to setup the update shader
  13344. * @param effect defines the update shader
  13345. */
  13346. applyToShader(effect: Effect): void;
  13347. /**
  13348. * Returns a string to use to update the GPU particles update shader
  13349. * @returns a string containng the defines string
  13350. */
  13351. getEffectDefines(): string;
  13352. /**
  13353. * Returns the string "CylinderParticleEmitter"
  13354. * @returns a string containing the class name
  13355. */
  13356. getClassName(): string;
  13357. /**
  13358. * Serializes the particle system to a JSON object.
  13359. * @returns the JSON object
  13360. */
  13361. serialize(): any;
  13362. /**
  13363. * Parse properties from a JSON object
  13364. * @param serializationObject defines the JSON object
  13365. */
  13366. parse(serializationObject: any): void;
  13367. }
  13368. /**
  13369. * Particle emitter emitting particles from the inside of a cylinder.
  13370. * It emits the particles randomly between two vectors.
  13371. */
  13372. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13373. /**
  13374. * The min limit of the emission direction.
  13375. */
  13376. direction1: Vector3;
  13377. /**
  13378. * The max limit of the emission direction.
  13379. */
  13380. direction2: Vector3;
  13381. /**
  13382. * Creates a new instance CylinderDirectedParticleEmitter
  13383. * @param radius the radius of the emission cylinder (1 by default)
  13384. * @param height the height of the emission cylinder (1 by default)
  13385. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13386. * @param direction1 the min limit of the emission direction (up vector by default)
  13387. * @param direction2 the max limit of the emission direction (up vector by default)
  13388. */
  13389. constructor(radius?: number, height?: number, radiusRange?: number,
  13390. /**
  13391. * The min limit of the emission direction.
  13392. */
  13393. direction1?: Vector3,
  13394. /**
  13395. * The max limit of the emission direction.
  13396. */
  13397. direction2?: Vector3);
  13398. /**
  13399. * Called by the particle System when the direction is computed for the created particle.
  13400. * @param worldMatrix is the world matrix of the particle system
  13401. * @param directionToUpdate is the direction vector to update with the result
  13402. * @param particle is the particle we are computed the direction for
  13403. */
  13404. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13405. /**
  13406. * Clones the current emitter and returns a copy of it
  13407. * @returns the new emitter
  13408. */
  13409. clone(): CylinderDirectedParticleEmitter;
  13410. /**
  13411. * Called by the GPUParticleSystem to setup the update shader
  13412. * @param effect defines the update shader
  13413. */
  13414. applyToShader(effect: Effect): void;
  13415. /**
  13416. * Returns a string to use to update the GPU particles update shader
  13417. * @returns a string containng the defines string
  13418. */
  13419. getEffectDefines(): string;
  13420. /**
  13421. * Returns the string "CylinderDirectedParticleEmitter"
  13422. * @returns a string containing the class name
  13423. */
  13424. getClassName(): string;
  13425. /**
  13426. * Serializes the particle system to a JSON object.
  13427. * @returns the JSON object
  13428. */
  13429. serialize(): any;
  13430. /**
  13431. * Parse properties from a JSON object
  13432. * @param serializationObject defines the JSON object
  13433. */
  13434. parse(serializationObject: any): void;
  13435. }
  13436. }
  13437. declare module BABYLON {
  13438. /**
  13439. * Particle emitter emitting particles from the inside of a hemisphere.
  13440. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13441. */
  13442. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13443. /**
  13444. * The radius of the emission hemisphere.
  13445. */
  13446. radius: number;
  13447. /**
  13448. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13449. */
  13450. radiusRange: number;
  13451. /**
  13452. * How much to randomize the particle direction [0-1].
  13453. */
  13454. directionRandomizer: number;
  13455. /**
  13456. * Creates a new instance HemisphericParticleEmitter
  13457. * @param radius the radius of the emission hemisphere (1 by default)
  13458. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13459. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13460. */
  13461. constructor(
  13462. /**
  13463. * The radius of the emission hemisphere.
  13464. */
  13465. radius?: number,
  13466. /**
  13467. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13468. */
  13469. radiusRange?: number,
  13470. /**
  13471. * How much to randomize the particle direction [0-1].
  13472. */
  13473. directionRandomizer?: number);
  13474. /**
  13475. * Called by the particle System when the direction is computed for the created particle.
  13476. * @param worldMatrix is the world matrix of the particle system
  13477. * @param directionToUpdate is the direction vector to update with the result
  13478. * @param particle is the particle we are computed the direction for
  13479. * @param isLocal defines if the direction should be set in local space
  13480. */
  13481. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13482. /**
  13483. * Called by the particle System when the position is computed for the created particle.
  13484. * @param worldMatrix is the world matrix of the particle system
  13485. * @param positionToUpdate is the position vector to update with the result
  13486. * @param particle is the particle we are computed the position for
  13487. * @param isLocal defines if the position should be set in local space
  13488. */
  13489. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13490. /**
  13491. * Clones the current emitter and returns a copy of it
  13492. * @returns the new emitter
  13493. */
  13494. clone(): HemisphericParticleEmitter;
  13495. /**
  13496. * Called by the GPUParticleSystem to setup the update shader
  13497. * @param effect defines the update shader
  13498. */
  13499. applyToShader(effect: Effect): void;
  13500. /**
  13501. * Returns a string to use to update the GPU particles update shader
  13502. * @returns a string containng the defines string
  13503. */
  13504. getEffectDefines(): string;
  13505. /**
  13506. * Returns the string "HemisphericParticleEmitter"
  13507. * @returns a string containing the class name
  13508. */
  13509. getClassName(): string;
  13510. /**
  13511. * Serializes the particle system to a JSON object.
  13512. * @returns the JSON object
  13513. */
  13514. serialize(): any;
  13515. /**
  13516. * Parse properties from a JSON object
  13517. * @param serializationObject defines the JSON object
  13518. */
  13519. parse(serializationObject: any): void;
  13520. }
  13521. }
  13522. declare module BABYLON {
  13523. /**
  13524. * Particle emitter emitting particles from a point.
  13525. * It emits the particles randomly between 2 given directions.
  13526. */
  13527. export class PointParticleEmitter implements IParticleEmitterType {
  13528. /**
  13529. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13530. */
  13531. direction1: Vector3;
  13532. /**
  13533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13534. */
  13535. direction2: Vector3;
  13536. /**
  13537. * Creates a new instance PointParticleEmitter
  13538. */
  13539. constructor();
  13540. /**
  13541. * Called by the particle System when the direction is computed for the created particle.
  13542. * @param worldMatrix is the world matrix of the particle system
  13543. * @param directionToUpdate is the direction vector to update with the result
  13544. * @param particle is the particle we are computed the direction for
  13545. * @param isLocal defines if the direction should be set in local space
  13546. */
  13547. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13548. /**
  13549. * Called by the particle System when the position is computed for the created particle.
  13550. * @param worldMatrix is the world matrix of the particle system
  13551. * @param positionToUpdate is the position vector to update with the result
  13552. * @param particle is the particle we are computed the position for
  13553. * @param isLocal defines if the position should be set in local space
  13554. */
  13555. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13556. /**
  13557. * Clones the current emitter and returns a copy of it
  13558. * @returns the new emitter
  13559. */
  13560. clone(): PointParticleEmitter;
  13561. /**
  13562. * Called by the GPUParticleSystem to setup the update shader
  13563. * @param effect defines the update shader
  13564. */
  13565. applyToShader(effect: Effect): void;
  13566. /**
  13567. * Returns a string to use to update the GPU particles update shader
  13568. * @returns a string containng the defines string
  13569. */
  13570. getEffectDefines(): string;
  13571. /**
  13572. * Returns the string "PointParticleEmitter"
  13573. * @returns a string containing the class name
  13574. */
  13575. getClassName(): string;
  13576. /**
  13577. * Serializes the particle system to a JSON object.
  13578. * @returns the JSON object
  13579. */
  13580. serialize(): any;
  13581. /**
  13582. * Parse properties from a JSON object
  13583. * @param serializationObject defines the JSON object
  13584. */
  13585. parse(serializationObject: any): void;
  13586. }
  13587. }
  13588. declare module BABYLON {
  13589. /**
  13590. * Particle emitter emitting particles from the inside of a sphere.
  13591. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13592. */
  13593. export class SphereParticleEmitter implements IParticleEmitterType {
  13594. /**
  13595. * The radius of the emission sphere.
  13596. */
  13597. radius: number;
  13598. /**
  13599. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13600. */
  13601. radiusRange: number;
  13602. /**
  13603. * How much to randomize the particle direction [0-1].
  13604. */
  13605. directionRandomizer: number;
  13606. /**
  13607. * Creates a new instance SphereParticleEmitter
  13608. * @param radius the radius of the emission sphere (1 by default)
  13609. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13610. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13611. */
  13612. constructor(
  13613. /**
  13614. * The radius of the emission sphere.
  13615. */
  13616. radius?: number,
  13617. /**
  13618. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13619. */
  13620. radiusRange?: number,
  13621. /**
  13622. * How much to randomize the particle direction [0-1].
  13623. */
  13624. directionRandomizer?: number);
  13625. /**
  13626. * Called by the particle System when the direction is computed for the created particle.
  13627. * @param worldMatrix is the world matrix of the particle system
  13628. * @param directionToUpdate is the direction vector to update with the result
  13629. * @param particle is the particle we are computed the direction for
  13630. * @param isLocal defines if the direction should be set in local space
  13631. */
  13632. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13633. /**
  13634. * Called by the particle System when the position is computed for the created particle.
  13635. * @param worldMatrix is the world matrix of the particle system
  13636. * @param positionToUpdate is the position vector to update with the result
  13637. * @param particle is the particle we are computed the position for
  13638. * @param isLocal defines if the position should be set in local space
  13639. */
  13640. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13641. /**
  13642. * Clones the current emitter and returns a copy of it
  13643. * @returns the new emitter
  13644. */
  13645. clone(): SphereParticleEmitter;
  13646. /**
  13647. * Called by the GPUParticleSystem to setup the update shader
  13648. * @param effect defines the update shader
  13649. */
  13650. applyToShader(effect: Effect): void;
  13651. /**
  13652. * Returns a string to use to update the GPU particles update shader
  13653. * @returns a string containng the defines string
  13654. */
  13655. getEffectDefines(): string;
  13656. /**
  13657. * Returns the string "SphereParticleEmitter"
  13658. * @returns a string containing the class name
  13659. */
  13660. getClassName(): string;
  13661. /**
  13662. * Serializes the particle system to a JSON object.
  13663. * @returns the JSON object
  13664. */
  13665. serialize(): any;
  13666. /**
  13667. * Parse properties from a JSON object
  13668. * @param serializationObject defines the JSON object
  13669. */
  13670. parse(serializationObject: any): void;
  13671. }
  13672. /**
  13673. * Particle emitter emitting particles from the inside of a sphere.
  13674. * It emits the particles randomly between two vectors.
  13675. */
  13676. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13677. /**
  13678. * The min limit of the emission direction.
  13679. */
  13680. direction1: Vector3;
  13681. /**
  13682. * The max limit of the emission direction.
  13683. */
  13684. direction2: Vector3;
  13685. /**
  13686. * Creates a new instance SphereDirectedParticleEmitter
  13687. * @param radius the radius of the emission sphere (1 by default)
  13688. * @param direction1 the min limit of the emission direction (up vector by default)
  13689. * @param direction2 the max limit of the emission direction (up vector by default)
  13690. */
  13691. constructor(radius?: number,
  13692. /**
  13693. * The min limit of the emission direction.
  13694. */
  13695. direction1?: Vector3,
  13696. /**
  13697. * The max limit of the emission direction.
  13698. */
  13699. direction2?: Vector3);
  13700. /**
  13701. * Called by the particle System when the direction is computed for the created particle.
  13702. * @param worldMatrix is the world matrix of the particle system
  13703. * @param directionToUpdate is the direction vector to update with the result
  13704. * @param particle is the particle we are computed the direction for
  13705. */
  13706. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13707. /**
  13708. * Clones the current emitter and returns a copy of it
  13709. * @returns the new emitter
  13710. */
  13711. clone(): SphereDirectedParticleEmitter;
  13712. /**
  13713. * Called by the GPUParticleSystem to setup the update shader
  13714. * @param effect defines the update shader
  13715. */
  13716. applyToShader(effect: Effect): void;
  13717. /**
  13718. * Returns a string to use to update the GPU particles update shader
  13719. * @returns a string containng the defines string
  13720. */
  13721. getEffectDefines(): string;
  13722. /**
  13723. * Returns the string "SphereDirectedParticleEmitter"
  13724. * @returns a string containing the class name
  13725. */
  13726. getClassName(): string;
  13727. /**
  13728. * Serializes the particle system to a JSON object.
  13729. * @returns the JSON object
  13730. */
  13731. serialize(): any;
  13732. /**
  13733. * Parse properties from a JSON object
  13734. * @param serializationObject defines the JSON object
  13735. */
  13736. parse(serializationObject: any): void;
  13737. }
  13738. }
  13739. declare module BABYLON {
  13740. /**
  13741. * Particle emitter emitting particles from a custom list of positions.
  13742. */
  13743. export class CustomParticleEmitter implements IParticleEmitterType {
  13744. /**
  13745. * Gets or sets the position generator that will create the inital position of each particle.
  13746. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13747. */
  13748. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13749. /**
  13750. * Gets or sets the destination generator that will create the final destination of each particle.
  13751. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13752. */
  13753. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13754. /**
  13755. * Creates a new instance CustomParticleEmitter
  13756. */
  13757. constructor();
  13758. /**
  13759. * Called by the particle System when the direction is computed for the created particle.
  13760. * @param worldMatrix is the world matrix of the particle system
  13761. * @param directionToUpdate is the direction vector to update with the result
  13762. * @param particle is the particle we are computed the direction for
  13763. * @param isLocal defines if the direction should be set in local space
  13764. */
  13765. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13766. /**
  13767. * Called by the particle System when the position is computed for the created particle.
  13768. * @param worldMatrix is the world matrix of the particle system
  13769. * @param positionToUpdate is the position vector to update with the result
  13770. * @param particle is the particle we are computed the position for
  13771. * @param isLocal defines if the position should be set in local space
  13772. */
  13773. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13774. /**
  13775. * Clones the current emitter and returns a copy of it
  13776. * @returns the new emitter
  13777. */
  13778. clone(): CustomParticleEmitter;
  13779. /**
  13780. * Called by the GPUParticleSystem to setup the update shader
  13781. * @param effect defines the update shader
  13782. */
  13783. applyToShader(effect: Effect): void;
  13784. /**
  13785. * Returns a string to use to update the GPU particles update shader
  13786. * @returns a string containng the defines string
  13787. */
  13788. getEffectDefines(): string;
  13789. /**
  13790. * Returns the string "PointParticleEmitter"
  13791. * @returns a string containing the class name
  13792. */
  13793. getClassName(): string;
  13794. /**
  13795. * Serializes the particle system to a JSON object.
  13796. * @returns the JSON object
  13797. */
  13798. serialize(): any;
  13799. /**
  13800. * Parse properties from a JSON object
  13801. * @param serializationObject defines the JSON object
  13802. */
  13803. parse(serializationObject: any): void;
  13804. }
  13805. }
  13806. declare module BABYLON {
  13807. /**
  13808. * Particle emitter emitting particles from the inside of a box.
  13809. * It emits the particles randomly between 2 given directions.
  13810. */
  13811. export class MeshParticleEmitter implements IParticleEmitterType {
  13812. private _indices;
  13813. private _positions;
  13814. private _normals;
  13815. private _storedNormal;
  13816. private _mesh;
  13817. /**
  13818. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13819. */
  13820. direction1: Vector3;
  13821. /**
  13822. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13823. */
  13824. direction2: Vector3;
  13825. /**
  13826. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13827. */
  13828. useMeshNormalsForDirection: boolean;
  13829. /** Defines the mesh to use as source */
  13830. get mesh(): Nullable<AbstractMesh>;
  13831. set mesh(value: Nullable<AbstractMesh>);
  13832. /**
  13833. * Creates a new instance MeshParticleEmitter
  13834. * @param mesh defines the mesh to use as source
  13835. */
  13836. constructor(mesh?: Nullable<AbstractMesh>);
  13837. /**
  13838. * Called by the particle System when the direction is computed for the created particle.
  13839. * @param worldMatrix is the world matrix of the particle system
  13840. * @param directionToUpdate is the direction vector to update with the result
  13841. * @param particle is the particle we are computed the direction for
  13842. * @param isLocal defines if the direction should be set in local space
  13843. */
  13844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13845. /**
  13846. * Called by the particle System when the position is computed for the created particle.
  13847. * @param worldMatrix is the world matrix of the particle system
  13848. * @param positionToUpdate is the position vector to update with the result
  13849. * @param particle is the particle we are computed the position for
  13850. * @param isLocal defines if the position should be set in local space
  13851. */
  13852. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13853. /**
  13854. * Clones the current emitter and returns a copy of it
  13855. * @returns the new emitter
  13856. */
  13857. clone(): MeshParticleEmitter;
  13858. /**
  13859. * Called by the GPUParticleSystem to setup the update shader
  13860. * @param effect defines the update shader
  13861. */
  13862. applyToShader(effect: Effect): void;
  13863. /**
  13864. * Returns a string to use to update the GPU particles update shader
  13865. * @returns a string containng the defines string
  13866. */
  13867. getEffectDefines(): string;
  13868. /**
  13869. * Returns the string "BoxParticleEmitter"
  13870. * @returns a string containing the class name
  13871. */
  13872. getClassName(): string;
  13873. /**
  13874. * Serializes the particle system to a JSON object.
  13875. * @returns the JSON object
  13876. */
  13877. serialize(): any;
  13878. /**
  13879. * Parse properties from a JSON object
  13880. * @param serializationObject defines the JSON object
  13881. * @param scene defines the hosting scene
  13882. */
  13883. parse(serializationObject: any, scene: Scene): void;
  13884. }
  13885. }
  13886. declare module BABYLON {
  13887. /**
  13888. * Interface representing a particle system in Babylon.js.
  13889. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13890. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13891. */
  13892. export interface IParticleSystem {
  13893. /**
  13894. * List of animations used by the particle system.
  13895. */
  13896. animations: Animation[];
  13897. /**
  13898. * The id of the Particle system.
  13899. */
  13900. id: string;
  13901. /**
  13902. * The name of the Particle system.
  13903. */
  13904. name: string;
  13905. /**
  13906. * The emitter represents the Mesh or position we are attaching the particle system to.
  13907. */
  13908. emitter: Nullable<AbstractMesh | Vector3>;
  13909. /**
  13910. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13911. */
  13912. isBillboardBased: boolean;
  13913. /**
  13914. * The rendering group used by the Particle system to chose when to render.
  13915. */
  13916. renderingGroupId: number;
  13917. /**
  13918. * The layer mask we are rendering the particles through.
  13919. */
  13920. layerMask: number;
  13921. /**
  13922. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13923. */
  13924. updateSpeed: number;
  13925. /**
  13926. * The amount of time the particle system is running (depends of the overall update speed).
  13927. */
  13928. targetStopDuration: number;
  13929. /**
  13930. * The texture used to render each particle. (this can be a spritesheet)
  13931. */
  13932. particleTexture: Nullable<Texture>;
  13933. /**
  13934. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13935. */
  13936. blendMode: number;
  13937. /**
  13938. * Minimum life time of emitting particles.
  13939. */
  13940. minLifeTime: number;
  13941. /**
  13942. * Maximum life time of emitting particles.
  13943. */
  13944. maxLifeTime: number;
  13945. /**
  13946. * Minimum Size of emitting particles.
  13947. */
  13948. minSize: number;
  13949. /**
  13950. * Maximum Size of emitting particles.
  13951. */
  13952. maxSize: number;
  13953. /**
  13954. * Minimum scale of emitting particles on X axis.
  13955. */
  13956. minScaleX: number;
  13957. /**
  13958. * Maximum scale of emitting particles on X axis.
  13959. */
  13960. maxScaleX: number;
  13961. /**
  13962. * Minimum scale of emitting particles on Y axis.
  13963. */
  13964. minScaleY: number;
  13965. /**
  13966. * Maximum scale of emitting particles on Y axis.
  13967. */
  13968. maxScaleY: number;
  13969. /**
  13970. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13971. */
  13972. color1: Color4;
  13973. /**
  13974. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13975. */
  13976. color2: Color4;
  13977. /**
  13978. * Color the particle will have at the end of its lifetime.
  13979. */
  13980. colorDead: Color4;
  13981. /**
  13982. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13983. */
  13984. emitRate: number;
  13985. /**
  13986. * You can use gravity if you want to give an orientation to your particles.
  13987. */
  13988. gravity: Vector3;
  13989. /**
  13990. * Minimum power of emitting particles.
  13991. */
  13992. minEmitPower: number;
  13993. /**
  13994. * Maximum power of emitting particles.
  13995. */
  13996. maxEmitPower: number;
  13997. /**
  13998. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13999. */
  14000. minAngularSpeed: number;
  14001. /**
  14002. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14003. */
  14004. maxAngularSpeed: number;
  14005. /**
  14006. * Gets or sets the minimal initial rotation in radians.
  14007. */
  14008. minInitialRotation: number;
  14009. /**
  14010. * Gets or sets the maximal initial rotation in radians.
  14011. */
  14012. maxInitialRotation: number;
  14013. /**
  14014. * The particle emitter type defines the emitter used by the particle system.
  14015. * It can be for example box, sphere, or cone...
  14016. */
  14017. particleEmitterType: Nullable<IParticleEmitterType>;
  14018. /**
  14019. * Defines the delay in milliseconds before starting the system (0 by default)
  14020. */
  14021. startDelay: number;
  14022. /**
  14023. * 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
  14024. */
  14025. preWarmCycles: number;
  14026. /**
  14027. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14028. */
  14029. preWarmStepOffset: number;
  14030. /**
  14031. * 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)
  14032. */
  14033. spriteCellChangeSpeed: number;
  14034. /**
  14035. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14036. */
  14037. startSpriteCellID: number;
  14038. /**
  14039. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14040. */
  14041. endSpriteCellID: number;
  14042. /**
  14043. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14044. */
  14045. spriteCellWidth: number;
  14046. /**
  14047. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14048. */
  14049. spriteCellHeight: number;
  14050. /**
  14051. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14052. */
  14053. spriteRandomStartCell: boolean;
  14054. /**
  14055. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14056. */
  14057. isAnimationSheetEnabled: boolean;
  14058. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14059. translationPivot: Vector2;
  14060. /**
  14061. * Gets or sets a texture used to add random noise to particle positions
  14062. */
  14063. noiseTexture: Nullable<BaseTexture>;
  14064. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14065. noiseStrength: Vector3;
  14066. /**
  14067. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14068. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14069. */
  14070. billboardMode: number;
  14071. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14072. limitVelocityDamping: number;
  14073. /**
  14074. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14075. */
  14076. beginAnimationOnStart: boolean;
  14077. /**
  14078. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14079. */
  14080. beginAnimationFrom: number;
  14081. /**
  14082. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14083. */
  14084. beginAnimationTo: number;
  14085. /**
  14086. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14087. */
  14088. beginAnimationLoop: boolean;
  14089. /**
  14090. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14091. */
  14092. disposeOnStop: boolean;
  14093. /**
  14094. * Specifies if the particles are updated in emitter local space or world space
  14095. */
  14096. isLocal: boolean;
  14097. /** Snippet ID if the particle system was created from the snippet server */
  14098. snippetId: string;
  14099. /**
  14100. * Gets the maximum number of particles active at the same time.
  14101. * @returns The max number of active particles.
  14102. */
  14103. getCapacity(): number;
  14104. /**
  14105. * Gets the number of particles active at the same time.
  14106. * @returns The number of active particles.
  14107. */
  14108. getActiveCount(): number;
  14109. /**
  14110. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14111. * @returns True if it has been started, otherwise false.
  14112. */
  14113. isStarted(): boolean;
  14114. /**
  14115. * Animates the particle system for this frame.
  14116. */
  14117. animate(): void;
  14118. /**
  14119. * Renders the particle system in its current state.
  14120. * @returns the current number of particles
  14121. */
  14122. render(): number;
  14123. /**
  14124. * Dispose the particle system and frees its associated resources.
  14125. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14126. */
  14127. dispose(disposeTexture?: boolean): void;
  14128. /**
  14129. * An event triggered when the system is disposed
  14130. */
  14131. onDisposeObservable: Observable<IParticleSystem>;
  14132. /**
  14133. * Clones the particle system.
  14134. * @param name The name of the cloned object
  14135. * @param newEmitter The new emitter to use
  14136. * @returns the cloned particle system
  14137. */
  14138. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14139. /**
  14140. * Serializes the particle system to a JSON object
  14141. * @param serializeTexture defines if the texture must be serialized as well
  14142. * @returns the JSON object
  14143. */
  14144. serialize(serializeTexture: boolean): any;
  14145. /**
  14146. * Rebuild the particle system
  14147. */
  14148. rebuild(): void;
  14149. /** Force the system to rebuild all gradients that need to be resync */
  14150. forceRefreshGradients(): void;
  14151. /**
  14152. * Starts the particle system and begins to emit
  14153. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14154. */
  14155. start(delay?: number): void;
  14156. /**
  14157. * Stops the particle system.
  14158. */
  14159. stop(): void;
  14160. /**
  14161. * Remove all active particles
  14162. */
  14163. reset(): void;
  14164. /**
  14165. * Gets a boolean indicating that the system is stopping
  14166. * @returns true if the system is currently stopping
  14167. */
  14168. isStopping(): boolean;
  14169. /**
  14170. * Is this system ready to be used/rendered
  14171. * @return true if the system is ready
  14172. */
  14173. isReady(): boolean;
  14174. /**
  14175. * Returns the string "ParticleSystem"
  14176. * @returns a string containing the class name
  14177. */
  14178. getClassName(): string;
  14179. /**
  14180. * Gets the custom effect used to render the particles
  14181. * @param blendMode Blend mode for which the effect should be retrieved
  14182. * @returns The effect
  14183. */
  14184. getCustomEffect(blendMode: number): Nullable<Effect>;
  14185. /**
  14186. * Sets the custom effect used to render the particles
  14187. * @param effect The effect to set
  14188. * @param blendMode Blend mode for which the effect should be set
  14189. */
  14190. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14191. /**
  14192. * Fill the defines array according to the current settings of the particle system
  14193. * @param defines Array to be updated
  14194. * @param blendMode blend mode to take into account when updating the array
  14195. */
  14196. fillDefines(defines: Array<string>, blendMode: number): void;
  14197. /**
  14198. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14199. * @param uniforms Uniforms array to fill
  14200. * @param attributes Attributes array to fill
  14201. * @param samplers Samplers array to fill
  14202. */
  14203. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14204. /**
  14205. * Observable that will be called just before the particles are drawn
  14206. */
  14207. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14208. /**
  14209. * Gets the name of the particle vertex shader
  14210. */
  14211. vertexShaderName: string;
  14212. /**
  14213. * Adds a new color gradient
  14214. * @param gradient defines the gradient to use (between 0 and 1)
  14215. * @param color1 defines the color to affect to the specified gradient
  14216. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14217. * @returns the current particle system
  14218. */
  14219. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14220. /**
  14221. * Remove a specific color gradient
  14222. * @param gradient defines the gradient to remove
  14223. * @returns the current particle system
  14224. */
  14225. removeColorGradient(gradient: number): IParticleSystem;
  14226. /**
  14227. * Adds a new size gradient
  14228. * @param gradient defines the gradient to use (between 0 and 1)
  14229. * @param factor defines the size factor to affect to the specified gradient
  14230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14231. * @returns the current particle system
  14232. */
  14233. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14234. /**
  14235. * Remove a specific size gradient
  14236. * @param gradient defines the gradient to remove
  14237. * @returns the current particle system
  14238. */
  14239. removeSizeGradient(gradient: number): IParticleSystem;
  14240. /**
  14241. * Gets the current list of color gradients.
  14242. * You must use addColorGradient and removeColorGradient to udpate this list
  14243. * @returns the list of color gradients
  14244. */
  14245. getColorGradients(): Nullable<Array<ColorGradient>>;
  14246. /**
  14247. * Gets the current list of size gradients.
  14248. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14249. * @returns the list of size gradients
  14250. */
  14251. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14252. /**
  14253. * Gets the current list of angular speed gradients.
  14254. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14255. * @returns the list of angular speed gradients
  14256. */
  14257. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14258. /**
  14259. * Adds a new angular speed gradient
  14260. * @param gradient defines the gradient to use (between 0 and 1)
  14261. * @param factor defines the angular speed to affect to the specified gradient
  14262. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14263. * @returns the current particle system
  14264. */
  14265. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14266. /**
  14267. * Remove a specific angular speed gradient
  14268. * @param gradient defines the gradient to remove
  14269. * @returns the current particle system
  14270. */
  14271. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14272. /**
  14273. * Gets the current list of velocity gradients.
  14274. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14275. * @returns the list of velocity gradients
  14276. */
  14277. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14278. /**
  14279. * Adds a new velocity gradient
  14280. * @param gradient defines the gradient to use (between 0 and 1)
  14281. * @param factor defines the velocity to affect to the specified gradient
  14282. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14283. * @returns the current particle system
  14284. */
  14285. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14286. /**
  14287. * Remove a specific velocity gradient
  14288. * @param gradient defines the gradient to remove
  14289. * @returns the current particle system
  14290. */
  14291. removeVelocityGradient(gradient: number): IParticleSystem;
  14292. /**
  14293. * Gets the current list of limit velocity gradients.
  14294. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14295. * @returns the list of limit velocity gradients
  14296. */
  14297. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14298. /**
  14299. * Adds a new limit velocity gradient
  14300. * @param gradient defines the gradient to use (between 0 and 1)
  14301. * @param factor defines the limit velocity to affect to the specified gradient
  14302. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14303. * @returns the current particle system
  14304. */
  14305. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14306. /**
  14307. * Remove a specific limit velocity gradient
  14308. * @param gradient defines the gradient to remove
  14309. * @returns the current particle system
  14310. */
  14311. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14312. /**
  14313. * Adds a new drag gradient
  14314. * @param gradient defines the gradient to use (between 0 and 1)
  14315. * @param factor defines the drag to affect to the specified gradient
  14316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14317. * @returns the current particle system
  14318. */
  14319. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14320. /**
  14321. * Remove a specific drag gradient
  14322. * @param gradient defines the gradient to remove
  14323. * @returns the current particle system
  14324. */
  14325. removeDragGradient(gradient: number): IParticleSystem;
  14326. /**
  14327. * Gets the current list of drag gradients.
  14328. * You must use addDragGradient and removeDragGradient to udpate this list
  14329. * @returns the list of drag gradients
  14330. */
  14331. getDragGradients(): Nullable<Array<FactorGradient>>;
  14332. /**
  14333. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14334. * @param gradient defines the gradient to use (between 0 and 1)
  14335. * @param factor defines the emit rate to affect to the specified gradient
  14336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14337. * @returns the current particle system
  14338. */
  14339. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14340. /**
  14341. * Remove a specific emit rate gradient
  14342. * @param gradient defines the gradient to remove
  14343. * @returns the current particle system
  14344. */
  14345. removeEmitRateGradient(gradient: number): IParticleSystem;
  14346. /**
  14347. * Gets the current list of emit rate gradients.
  14348. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14349. * @returns the list of emit rate gradients
  14350. */
  14351. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14352. /**
  14353. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14354. * @param gradient defines the gradient to use (between 0 and 1)
  14355. * @param factor defines the start size to affect to the specified gradient
  14356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14357. * @returns the current particle system
  14358. */
  14359. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14360. /**
  14361. * Remove a specific start size gradient
  14362. * @param gradient defines the gradient to remove
  14363. * @returns the current particle system
  14364. */
  14365. removeStartSizeGradient(gradient: number): IParticleSystem;
  14366. /**
  14367. * Gets the current list of start size gradients.
  14368. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14369. * @returns the list of start size gradients
  14370. */
  14371. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14372. /**
  14373. * Adds a new life time gradient
  14374. * @param gradient defines the gradient to use (between 0 and 1)
  14375. * @param factor defines the life time factor to affect to the specified gradient
  14376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14377. * @returns the current particle system
  14378. */
  14379. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14380. /**
  14381. * Remove a specific life time gradient
  14382. * @param gradient defines the gradient to remove
  14383. * @returns the current particle system
  14384. */
  14385. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14386. /**
  14387. * Gets the current list of life time gradients.
  14388. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14389. * @returns the list of life time gradients
  14390. */
  14391. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14392. /**
  14393. * Gets the current list of color gradients.
  14394. * You must use addColorGradient and removeColorGradient to udpate this list
  14395. * @returns the list of color gradients
  14396. */
  14397. getColorGradients(): Nullable<Array<ColorGradient>>;
  14398. /**
  14399. * Adds a new ramp gradient used to remap particle colors
  14400. * @param gradient defines the gradient to use (between 0 and 1)
  14401. * @param color defines the color to affect to the specified gradient
  14402. * @returns the current particle system
  14403. */
  14404. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14405. /**
  14406. * Gets the current list of ramp gradients.
  14407. * You must use addRampGradient and removeRampGradient to udpate this list
  14408. * @returns the list of ramp gradients
  14409. */
  14410. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14411. /** Gets or sets a boolean indicating that ramp gradients must be used
  14412. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14413. */
  14414. useRampGradients: boolean;
  14415. /**
  14416. * Adds a new color remap gradient
  14417. * @param gradient defines the gradient to use (between 0 and 1)
  14418. * @param min defines the color remap minimal range
  14419. * @param max defines the color remap maximal range
  14420. * @returns the current particle system
  14421. */
  14422. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14423. /**
  14424. * Gets the current list of color remap gradients.
  14425. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14426. * @returns the list of color remap gradients
  14427. */
  14428. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14429. /**
  14430. * Adds a new alpha remap gradient
  14431. * @param gradient defines the gradient to use (between 0 and 1)
  14432. * @param min defines the alpha remap minimal range
  14433. * @param max defines the alpha remap maximal range
  14434. * @returns the current particle system
  14435. */
  14436. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14437. /**
  14438. * Gets the current list of alpha remap gradients.
  14439. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14440. * @returns the list of alpha remap gradients
  14441. */
  14442. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14443. /**
  14444. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14445. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14446. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14447. * @returns the emitter
  14448. */
  14449. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14450. /**
  14451. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14452. * @param radius The radius of the hemisphere to emit from
  14453. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14454. * @returns the emitter
  14455. */
  14456. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14457. /**
  14458. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14459. * @param radius The radius of the sphere to emit from
  14460. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14461. * @returns the emitter
  14462. */
  14463. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14464. /**
  14465. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14466. * @param radius The radius of the sphere to emit from
  14467. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14468. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14469. * @returns the emitter
  14470. */
  14471. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14472. /**
  14473. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14474. * @param radius The radius of the emission cylinder
  14475. * @param height The height of the emission cylinder
  14476. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14477. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14478. * @returns the emitter
  14479. */
  14480. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14481. /**
  14482. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14483. * @param radius The radius of the cylinder to emit from
  14484. * @param height The height of the emission cylinder
  14485. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14486. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14487. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14488. * @returns the emitter
  14489. */
  14490. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14491. /**
  14492. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14493. * @param radius The radius of the cone to emit from
  14494. * @param angle The base angle of the cone
  14495. * @returns the emitter
  14496. */
  14497. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14498. /**
  14499. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14500. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14501. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14502. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14503. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14504. * @returns the emitter
  14505. */
  14506. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14507. /**
  14508. * Get hosting scene
  14509. * @returns the scene
  14510. */
  14511. getScene(): Scene;
  14512. }
  14513. }
  14514. declare module BABYLON {
  14515. /**
  14516. * 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.
  14517. * @see https://doc.babylonjs.com/how_to/transformnode
  14518. */
  14519. export class TransformNode extends Node {
  14520. /**
  14521. * Object will not rotate to face the camera
  14522. */
  14523. static BILLBOARDMODE_NONE: number;
  14524. /**
  14525. * Object will rotate to face the camera but only on the x axis
  14526. */
  14527. static BILLBOARDMODE_X: number;
  14528. /**
  14529. * Object will rotate to face the camera but only on the y axis
  14530. */
  14531. static BILLBOARDMODE_Y: number;
  14532. /**
  14533. * Object will rotate to face the camera but only on the z axis
  14534. */
  14535. static BILLBOARDMODE_Z: number;
  14536. /**
  14537. * Object will rotate to face the camera
  14538. */
  14539. static BILLBOARDMODE_ALL: number;
  14540. /**
  14541. * Object will rotate to face the camera's position instead of orientation
  14542. */
  14543. static BILLBOARDMODE_USE_POSITION: number;
  14544. private static _TmpRotation;
  14545. private static _TmpScaling;
  14546. private static _TmpTranslation;
  14547. private _forward;
  14548. private _forwardInverted;
  14549. private _up;
  14550. private _right;
  14551. private _rightInverted;
  14552. private _position;
  14553. private _rotation;
  14554. private _rotationQuaternion;
  14555. protected _scaling: Vector3;
  14556. protected _isDirty: boolean;
  14557. private _transformToBoneReferal;
  14558. private _isAbsoluteSynced;
  14559. private _billboardMode;
  14560. /**
  14561. * Gets or sets the billboard mode. Default is 0.
  14562. *
  14563. * | Value | Type | Description |
  14564. * | --- | --- | --- |
  14565. * | 0 | BILLBOARDMODE_NONE | |
  14566. * | 1 | BILLBOARDMODE_X | |
  14567. * | 2 | BILLBOARDMODE_Y | |
  14568. * | 4 | BILLBOARDMODE_Z | |
  14569. * | 7 | BILLBOARDMODE_ALL | |
  14570. *
  14571. */
  14572. get billboardMode(): number;
  14573. set billboardMode(value: number);
  14574. private _preserveParentRotationForBillboard;
  14575. /**
  14576. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14577. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14578. */
  14579. get preserveParentRotationForBillboard(): boolean;
  14580. set preserveParentRotationForBillboard(value: boolean);
  14581. /**
  14582. * 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
  14583. */
  14584. scalingDeterminant: number;
  14585. private _infiniteDistance;
  14586. /**
  14587. * Gets or sets the distance of the object to max, often used by skybox
  14588. */
  14589. get infiniteDistance(): boolean;
  14590. set infiniteDistance(value: boolean);
  14591. /**
  14592. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14593. * By default the system will update normals to compensate
  14594. */
  14595. ignoreNonUniformScaling: boolean;
  14596. /**
  14597. * 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
  14598. */
  14599. reIntegrateRotationIntoRotationQuaternion: boolean;
  14600. /** @hidden */
  14601. _poseMatrix: Nullable<Matrix>;
  14602. /** @hidden */
  14603. _localMatrix: Matrix;
  14604. private _usePivotMatrix;
  14605. private _absolutePosition;
  14606. private _absoluteScaling;
  14607. private _absoluteRotationQuaternion;
  14608. private _pivotMatrix;
  14609. private _pivotMatrixInverse;
  14610. protected _postMultiplyPivotMatrix: boolean;
  14611. protected _isWorldMatrixFrozen: boolean;
  14612. /** @hidden */
  14613. _indexInSceneTransformNodesArray: number;
  14614. /**
  14615. * An event triggered after the world matrix is updated
  14616. */
  14617. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14618. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14619. /**
  14620. * Gets a string identifying the name of the class
  14621. * @returns "TransformNode" string
  14622. */
  14623. getClassName(): string;
  14624. /**
  14625. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14626. */
  14627. get position(): Vector3;
  14628. set position(newPosition: Vector3);
  14629. /**
  14630. * 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)).
  14631. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14632. */
  14633. get rotation(): Vector3;
  14634. set rotation(newRotation: Vector3);
  14635. /**
  14636. * 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)).
  14637. */
  14638. get scaling(): Vector3;
  14639. set scaling(newScaling: Vector3);
  14640. /**
  14641. * 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).
  14642. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14643. */
  14644. get rotationQuaternion(): Nullable<Quaternion>;
  14645. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14646. /**
  14647. * The forward direction of that transform in world space.
  14648. */
  14649. get forward(): Vector3;
  14650. /**
  14651. * The up direction of that transform in world space.
  14652. */
  14653. get up(): Vector3;
  14654. /**
  14655. * The right direction of that transform in world space.
  14656. */
  14657. get right(): Vector3;
  14658. /**
  14659. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14660. * @param matrix the matrix to copy the pose from
  14661. * @returns this TransformNode.
  14662. */
  14663. updatePoseMatrix(matrix: Matrix): TransformNode;
  14664. /**
  14665. * Returns the mesh Pose matrix.
  14666. * @returns the pose matrix
  14667. */
  14668. getPoseMatrix(): Matrix;
  14669. /** @hidden */
  14670. _isSynchronized(): boolean;
  14671. /** @hidden */
  14672. _initCache(): void;
  14673. /**
  14674. * Flag the transform node as dirty (Forcing it to update everything)
  14675. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14676. * @returns this transform node
  14677. */
  14678. markAsDirty(property: string): TransformNode;
  14679. /**
  14680. * Returns the current mesh absolute position.
  14681. * Returns a Vector3.
  14682. */
  14683. get absolutePosition(): Vector3;
  14684. /**
  14685. * Returns the current mesh absolute scaling.
  14686. * Returns a Vector3.
  14687. */
  14688. get absoluteScaling(): Vector3;
  14689. /**
  14690. * Returns the current mesh absolute rotation.
  14691. * Returns a Quaternion.
  14692. */
  14693. get absoluteRotationQuaternion(): Quaternion;
  14694. /**
  14695. * Sets a new matrix to apply before all other transformation
  14696. * @param matrix defines the transform matrix
  14697. * @returns the current TransformNode
  14698. */
  14699. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14700. /**
  14701. * Sets a new pivot matrix to the current node
  14702. * @param matrix defines the new pivot matrix to use
  14703. * @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
  14704. * @returns the current TransformNode
  14705. */
  14706. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14707. /**
  14708. * Returns the mesh pivot matrix.
  14709. * Default : Identity.
  14710. * @returns the matrix
  14711. */
  14712. getPivotMatrix(): Matrix;
  14713. /**
  14714. * Instantiate (when possible) or clone that node with its hierarchy
  14715. * @param newParent defines the new parent to use for the instance (or clone)
  14716. * @param options defines options to configure how copy is done
  14717. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14718. * @returns an instance (or a clone) of the current node with its hiearchy
  14719. */
  14720. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14721. doNotInstantiate: boolean;
  14722. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14723. /**
  14724. * Prevents the World matrix to be computed any longer
  14725. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14726. * @returns the TransformNode.
  14727. */
  14728. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14729. /**
  14730. * Allows back the World matrix computation.
  14731. * @returns the TransformNode.
  14732. */
  14733. unfreezeWorldMatrix(): this;
  14734. /**
  14735. * True if the World matrix has been frozen.
  14736. */
  14737. get isWorldMatrixFrozen(): boolean;
  14738. /**
  14739. * Retuns the mesh absolute position in the World.
  14740. * @returns a Vector3.
  14741. */
  14742. getAbsolutePosition(): Vector3;
  14743. /**
  14744. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14745. * @param absolutePosition the absolute position to set
  14746. * @returns the TransformNode.
  14747. */
  14748. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14749. /**
  14750. * Sets the mesh position in its local space.
  14751. * @param vector3 the position to set in localspace
  14752. * @returns the TransformNode.
  14753. */
  14754. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14755. /**
  14756. * Returns the mesh position in the local space from the current World matrix values.
  14757. * @returns a new Vector3.
  14758. */
  14759. getPositionExpressedInLocalSpace(): Vector3;
  14760. /**
  14761. * Translates the mesh along the passed Vector3 in its local space.
  14762. * @param vector3 the distance to translate in localspace
  14763. * @returns the TransformNode.
  14764. */
  14765. locallyTranslate(vector3: Vector3): TransformNode;
  14766. private static _lookAtVectorCache;
  14767. /**
  14768. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14769. * @param targetPoint the position (must be in same space as current mesh) to look at
  14770. * @param yawCor optional yaw (y-axis) correction in radians
  14771. * @param pitchCor optional pitch (x-axis) correction in radians
  14772. * @param rollCor optional roll (z-axis) correction in radians
  14773. * @param space the choosen space of the target
  14774. * @returns the TransformNode.
  14775. */
  14776. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14777. /**
  14778. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14779. * This Vector3 is expressed in the World space.
  14780. * @param localAxis axis to rotate
  14781. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14782. */
  14783. getDirection(localAxis: Vector3): Vector3;
  14784. /**
  14785. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14786. * localAxis is expressed in the mesh local space.
  14787. * result is computed in the Wordl space from the mesh World matrix.
  14788. * @param localAxis axis to rotate
  14789. * @param result the resulting transformnode
  14790. * @returns this TransformNode.
  14791. */
  14792. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14793. /**
  14794. * Sets this transform node rotation to the given local axis.
  14795. * @param localAxis the axis in local space
  14796. * @param yawCor optional yaw (y-axis) correction in radians
  14797. * @param pitchCor optional pitch (x-axis) correction in radians
  14798. * @param rollCor optional roll (z-axis) correction in radians
  14799. * @returns this TransformNode
  14800. */
  14801. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14802. /**
  14803. * Sets a new pivot point to the current node
  14804. * @param point defines the new pivot point to use
  14805. * @param space defines if the point is in world or local space (local by default)
  14806. * @returns the current TransformNode
  14807. */
  14808. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14809. /**
  14810. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14811. * @returns the pivot point
  14812. */
  14813. getPivotPoint(): Vector3;
  14814. /**
  14815. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14816. * @param result the vector3 to store the result
  14817. * @returns this TransformNode.
  14818. */
  14819. getPivotPointToRef(result: Vector3): TransformNode;
  14820. /**
  14821. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14822. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14823. */
  14824. getAbsolutePivotPoint(): Vector3;
  14825. /**
  14826. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14827. * @param result vector3 to store the result
  14828. * @returns this TransformNode.
  14829. */
  14830. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14831. /**
  14832. * Defines the passed node as the parent of the current node.
  14833. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14834. * @see https://doc.babylonjs.com/how_to/parenting
  14835. * @param node the node ot set as the parent
  14836. * @returns this TransformNode.
  14837. */
  14838. setParent(node: Nullable<Node>): TransformNode;
  14839. private _nonUniformScaling;
  14840. /**
  14841. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14842. */
  14843. get nonUniformScaling(): boolean;
  14844. /** @hidden */
  14845. _updateNonUniformScalingState(value: boolean): boolean;
  14846. /**
  14847. * Attach the current TransformNode to another TransformNode associated with a bone
  14848. * @param bone Bone affecting the TransformNode
  14849. * @param affectedTransformNode TransformNode associated with the bone
  14850. * @returns this object
  14851. */
  14852. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14853. /**
  14854. * Detach the transform node if its associated with a bone
  14855. * @returns this object
  14856. */
  14857. detachFromBone(): TransformNode;
  14858. private static _rotationAxisCache;
  14859. /**
  14860. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14861. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14862. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14863. * The passed axis is also normalized.
  14864. * @param axis the axis to rotate around
  14865. * @param amount the amount to rotate in radians
  14866. * @param space Space to rotate in (Default: local)
  14867. * @returns the TransformNode.
  14868. */
  14869. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14870. /**
  14871. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14872. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14873. * The passed axis is also normalized. .
  14874. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14875. * @param point the point to rotate around
  14876. * @param axis the axis to rotate around
  14877. * @param amount the amount to rotate in radians
  14878. * @returns the TransformNode
  14879. */
  14880. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14881. /**
  14882. * Translates the mesh along the axis vector for the passed distance in the given space.
  14883. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14884. * @param axis the axis to translate in
  14885. * @param distance the distance to translate
  14886. * @param space Space to rotate in (Default: local)
  14887. * @returns the TransformNode.
  14888. */
  14889. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14890. /**
  14891. * Adds a rotation step to the mesh current rotation.
  14892. * x, y, z are Euler angles expressed in radians.
  14893. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14894. * This means this rotation is made in the mesh local space only.
  14895. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14896. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14897. * ```javascript
  14898. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14899. * ```
  14900. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14901. * 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.
  14902. * @param x Rotation to add
  14903. * @param y Rotation to add
  14904. * @param z Rotation to add
  14905. * @returns the TransformNode.
  14906. */
  14907. addRotation(x: number, y: number, z: number): TransformNode;
  14908. /**
  14909. * @hidden
  14910. */
  14911. protected _getEffectiveParent(): Nullable<Node>;
  14912. /**
  14913. * Computes the world matrix of the node
  14914. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14915. * @returns the world matrix
  14916. */
  14917. computeWorldMatrix(force?: boolean): Matrix;
  14918. /**
  14919. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14920. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14921. */
  14922. resetLocalMatrix(independentOfChildren?: boolean): void;
  14923. protected _afterComputeWorldMatrix(): void;
  14924. /**
  14925. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14926. * @param func callback function to add
  14927. *
  14928. * @returns the TransformNode.
  14929. */
  14930. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14931. /**
  14932. * Removes a registered callback function.
  14933. * @param func callback function to remove
  14934. * @returns the TransformNode.
  14935. */
  14936. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14937. /**
  14938. * Gets the position of the current mesh in camera space
  14939. * @param camera defines the camera to use
  14940. * @returns a position
  14941. */
  14942. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14943. /**
  14944. * Returns the distance from the mesh to the active camera
  14945. * @param camera defines the camera to use
  14946. * @returns the distance
  14947. */
  14948. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14949. /**
  14950. * Clone the current transform node
  14951. * @param name Name of the new clone
  14952. * @param newParent New parent for the clone
  14953. * @param doNotCloneChildren Do not clone children hierarchy
  14954. * @returns the new transform node
  14955. */
  14956. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14957. /**
  14958. * Serializes the objects information.
  14959. * @param currentSerializationObject defines the object to serialize in
  14960. * @returns the serialized object
  14961. */
  14962. serialize(currentSerializationObject?: any): any;
  14963. /**
  14964. * Returns a new TransformNode object parsed from the source provided.
  14965. * @param parsedTransformNode is the source.
  14966. * @param scene the scne the object belongs to
  14967. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14968. * @returns a new TransformNode object parsed from the source provided.
  14969. */
  14970. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14971. /**
  14972. * Get all child-transformNodes of this node
  14973. * @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
  14974. * @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
  14975. * @returns an array of TransformNode
  14976. */
  14977. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14978. /**
  14979. * Releases resources associated with this transform node.
  14980. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14981. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14982. */
  14983. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14984. /**
  14985. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14986. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14987. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14988. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14989. * @returns the current mesh
  14990. */
  14991. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14992. private _syncAbsoluteScalingAndRotation;
  14993. }
  14994. }
  14995. declare module BABYLON {
  14996. /**
  14997. * Class used to override all child animations of a given target
  14998. */
  14999. export class AnimationPropertiesOverride {
  15000. /**
  15001. * Gets or sets a value indicating if animation blending must be used
  15002. */
  15003. enableBlending: boolean;
  15004. /**
  15005. * Gets or sets the blending speed to use when enableBlending is true
  15006. */
  15007. blendingSpeed: number;
  15008. /**
  15009. * Gets or sets the default loop mode to use
  15010. */
  15011. loopMode: number;
  15012. }
  15013. }
  15014. declare module BABYLON {
  15015. /**
  15016. * Class used to store bone information
  15017. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15018. */
  15019. export class Bone extends Node {
  15020. /**
  15021. * defines the bone name
  15022. */
  15023. name: string;
  15024. private static _tmpVecs;
  15025. private static _tmpQuat;
  15026. private static _tmpMats;
  15027. /**
  15028. * Gets the list of child bones
  15029. */
  15030. children: Bone[];
  15031. /** Gets the animations associated with this bone */
  15032. animations: Animation[];
  15033. /**
  15034. * Gets or sets bone length
  15035. */
  15036. length: number;
  15037. /**
  15038. * @hidden Internal only
  15039. * Set this value to map this bone to a different index in the transform matrices
  15040. * Set this value to -1 to exclude the bone from the transform matrices
  15041. */
  15042. _index: Nullable<number>;
  15043. private _skeleton;
  15044. private _localMatrix;
  15045. private _restPose;
  15046. private _baseMatrix;
  15047. private _absoluteTransform;
  15048. private _invertedAbsoluteTransform;
  15049. private _parent;
  15050. private _scalingDeterminant;
  15051. private _worldTransform;
  15052. private _localScaling;
  15053. private _localRotation;
  15054. private _localPosition;
  15055. private _needToDecompose;
  15056. private _needToCompose;
  15057. /** @hidden */
  15058. _linkedTransformNode: Nullable<TransformNode>;
  15059. /** @hidden */
  15060. _waitingTransformNodeId: Nullable<string>;
  15061. /** @hidden */
  15062. get _matrix(): Matrix;
  15063. /** @hidden */
  15064. set _matrix(value: Matrix);
  15065. /**
  15066. * Create a new bone
  15067. * @param name defines the bone name
  15068. * @param skeleton defines the parent skeleton
  15069. * @param parentBone defines the parent (can be null if the bone is the root)
  15070. * @param localMatrix defines the local matrix
  15071. * @param restPose defines the rest pose matrix
  15072. * @param baseMatrix defines the base matrix
  15073. * @param index defines index of the bone in the hiearchy
  15074. */
  15075. constructor(
  15076. /**
  15077. * defines the bone name
  15078. */
  15079. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15080. /**
  15081. * Gets the current object class name.
  15082. * @return the class name
  15083. */
  15084. getClassName(): string;
  15085. /**
  15086. * Gets the parent skeleton
  15087. * @returns a skeleton
  15088. */
  15089. getSkeleton(): Skeleton;
  15090. /**
  15091. * Gets parent bone
  15092. * @returns a bone or null if the bone is the root of the bone hierarchy
  15093. */
  15094. getParent(): Nullable<Bone>;
  15095. /**
  15096. * Returns an array containing the root bones
  15097. * @returns an array containing the root bones
  15098. */
  15099. getChildren(): Array<Bone>;
  15100. /**
  15101. * Gets the node index in matrix array generated for rendering
  15102. * @returns the node index
  15103. */
  15104. getIndex(): number;
  15105. /**
  15106. * Sets the parent bone
  15107. * @param parent defines the parent (can be null if the bone is the root)
  15108. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15109. */
  15110. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15111. /**
  15112. * Gets the local matrix
  15113. * @returns a matrix
  15114. */
  15115. getLocalMatrix(): Matrix;
  15116. /**
  15117. * Gets the base matrix (initial matrix which remains unchanged)
  15118. * @returns a matrix
  15119. */
  15120. getBaseMatrix(): Matrix;
  15121. /**
  15122. * Gets the rest pose matrix
  15123. * @returns a matrix
  15124. */
  15125. getRestPose(): Matrix;
  15126. /**
  15127. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15128. */
  15129. getWorldMatrix(): Matrix;
  15130. /**
  15131. * Sets the local matrix to rest pose matrix
  15132. */
  15133. returnToRest(): void;
  15134. /**
  15135. * Gets the inverse of the absolute transform matrix.
  15136. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15137. * @returns a matrix
  15138. */
  15139. getInvertedAbsoluteTransform(): Matrix;
  15140. /**
  15141. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15142. * @returns a matrix
  15143. */
  15144. getAbsoluteTransform(): Matrix;
  15145. /**
  15146. * Links with the given transform node.
  15147. * The local matrix of this bone is copied from the transform node every frame.
  15148. * @param transformNode defines the transform node to link to
  15149. */
  15150. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15151. /**
  15152. * Gets the node used to drive the bone's transformation
  15153. * @returns a transform node or null
  15154. */
  15155. getTransformNode(): Nullable<TransformNode>;
  15156. /** Gets or sets current position (in local space) */
  15157. get position(): Vector3;
  15158. set position(newPosition: Vector3);
  15159. /** Gets or sets current rotation (in local space) */
  15160. get rotation(): Vector3;
  15161. set rotation(newRotation: Vector3);
  15162. /** Gets or sets current rotation quaternion (in local space) */
  15163. get rotationQuaternion(): Quaternion;
  15164. set rotationQuaternion(newRotation: Quaternion);
  15165. /** Gets or sets current scaling (in local space) */
  15166. get scaling(): Vector3;
  15167. set scaling(newScaling: Vector3);
  15168. /**
  15169. * Gets the animation properties override
  15170. */
  15171. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15172. private _decompose;
  15173. private _compose;
  15174. /**
  15175. * Update the base and local matrices
  15176. * @param matrix defines the new base or local matrix
  15177. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15178. * @param updateLocalMatrix defines if the local matrix should be updated
  15179. */
  15180. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15181. /** @hidden */
  15182. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15183. /**
  15184. * Flag the bone as dirty (Forcing it to update everything)
  15185. */
  15186. markAsDirty(): void;
  15187. /** @hidden */
  15188. _markAsDirtyAndCompose(): void;
  15189. private _markAsDirtyAndDecompose;
  15190. /**
  15191. * Translate the bone in local or world space
  15192. * @param vec The amount to translate the bone
  15193. * @param space The space that the translation is in
  15194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15195. */
  15196. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15197. /**
  15198. * Set the postion of the bone in local or world space
  15199. * @param position The position to set the bone
  15200. * @param space The space that the position is in
  15201. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15202. */
  15203. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15204. /**
  15205. * Set the absolute position of the bone (world space)
  15206. * @param position The position to set the bone
  15207. * @param mesh The mesh that this bone is attached to
  15208. */
  15209. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15210. /**
  15211. * Scale the bone on the x, y and z axes (in local space)
  15212. * @param x The amount to scale the bone on the x axis
  15213. * @param y The amount to scale the bone on the y axis
  15214. * @param z The amount to scale the bone on the z axis
  15215. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15216. */
  15217. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15218. /**
  15219. * Set the bone scaling in local space
  15220. * @param scale defines the scaling vector
  15221. */
  15222. setScale(scale: Vector3): void;
  15223. /**
  15224. * Gets the current scaling in local space
  15225. * @returns the current scaling vector
  15226. */
  15227. getScale(): Vector3;
  15228. /**
  15229. * Gets the current scaling in local space and stores it in a target vector
  15230. * @param result defines the target vector
  15231. */
  15232. getScaleToRef(result: Vector3): void;
  15233. /**
  15234. * Set the yaw, pitch, and roll of the bone in local or world space
  15235. * @param yaw The rotation of the bone on the y axis
  15236. * @param pitch The rotation of the bone on the x axis
  15237. * @param roll The rotation of the bone on the z axis
  15238. * @param space The space that the axes of rotation are in
  15239. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15240. */
  15241. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15242. /**
  15243. * Add a rotation to the bone on an axis in local or world space
  15244. * @param axis The axis to rotate the bone on
  15245. * @param amount The amount to rotate the bone
  15246. * @param space The space that the axis is in
  15247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15248. */
  15249. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15250. /**
  15251. * Set the rotation of the bone to a particular axis angle in local or world space
  15252. * @param axis The axis to rotate the bone on
  15253. * @param angle The angle that the bone should be rotated to
  15254. * @param space The space that the axis is in
  15255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15256. */
  15257. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15258. /**
  15259. * Set the euler rotation of the bone in local of world space
  15260. * @param rotation The euler rotation that the bone should be set to
  15261. * @param space The space that the rotation is in
  15262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15263. */
  15264. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15265. /**
  15266. * Set the quaternion rotation of the bone in local of world space
  15267. * @param quat The quaternion rotation that the bone should be set to
  15268. * @param space The space that the rotation is in
  15269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15270. */
  15271. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15272. /**
  15273. * Set the rotation matrix of the bone in local of world space
  15274. * @param rotMat The rotation matrix that the bone should be set to
  15275. * @param space The space that the rotation is in
  15276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15277. */
  15278. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15279. private _rotateWithMatrix;
  15280. private _getNegativeRotationToRef;
  15281. /**
  15282. * Get the position of the bone in local or world space
  15283. * @param space The space that the returned position is in
  15284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15285. * @returns The position of the bone
  15286. */
  15287. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15288. /**
  15289. * Copy the position of the bone to a vector3 in local or world space
  15290. * @param space The space that the returned position is in
  15291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15292. * @param result The vector3 to copy the position to
  15293. */
  15294. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15295. /**
  15296. * Get the absolute position of the bone (world space)
  15297. * @param mesh The mesh that this bone is attached to
  15298. * @returns The absolute position of the bone
  15299. */
  15300. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15301. /**
  15302. * Copy the absolute position of the bone (world space) to the result param
  15303. * @param mesh The mesh that this bone is attached to
  15304. * @param result The vector3 to copy the absolute position to
  15305. */
  15306. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15307. /**
  15308. * Compute the absolute transforms of this bone and its children
  15309. */
  15310. computeAbsoluteTransforms(): void;
  15311. /**
  15312. * Get the world direction from an axis that is in the local space of the bone
  15313. * @param localAxis The local direction that is used to compute the world direction
  15314. * @param mesh The mesh that this bone is attached to
  15315. * @returns The world direction
  15316. */
  15317. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15318. /**
  15319. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15320. * @param localAxis The local direction that is used to compute the world direction
  15321. * @param mesh The mesh that this bone is attached to
  15322. * @param result The vector3 that the world direction will be copied to
  15323. */
  15324. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15325. /**
  15326. * Get the euler rotation of the bone in local or world space
  15327. * @param space The space that the rotation should be in
  15328. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15329. * @returns The euler rotation
  15330. */
  15331. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15332. /**
  15333. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15334. * @param space The space that the rotation should be in
  15335. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15336. * @param result The vector3 that the rotation should be copied to
  15337. */
  15338. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15339. /**
  15340. * Get the quaternion rotation of the bone in either local or world space
  15341. * @param space The space that the rotation should be in
  15342. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15343. * @returns The quaternion rotation
  15344. */
  15345. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15346. /**
  15347. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15348. * @param space The space that the rotation should be in
  15349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15350. * @param result The quaternion that the rotation should be copied to
  15351. */
  15352. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15353. /**
  15354. * Get the rotation matrix of the bone in local or world space
  15355. * @param space The space that the rotation should be in
  15356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15357. * @returns The rotation matrix
  15358. */
  15359. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15360. /**
  15361. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15362. * @param space The space that the rotation should be in
  15363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15364. * @param result The quaternion that the rotation should be copied to
  15365. */
  15366. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15367. /**
  15368. * Get the world position of a point that is in the local space of the bone
  15369. * @param position The local position
  15370. * @param mesh The mesh that this bone is attached to
  15371. * @returns The world position
  15372. */
  15373. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15374. /**
  15375. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15376. * @param position The local position
  15377. * @param mesh The mesh that this bone is attached to
  15378. * @param result The vector3 that the world position should be copied to
  15379. */
  15380. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15381. /**
  15382. * Get the local position of a point that is in world space
  15383. * @param position The world position
  15384. * @param mesh The mesh that this bone is attached to
  15385. * @returns The local position
  15386. */
  15387. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15388. /**
  15389. * Get the local position of a point that is in world space and copy it to the result param
  15390. * @param position The world position
  15391. * @param mesh The mesh that this bone is attached to
  15392. * @param result The vector3 that the local position should be copied to
  15393. */
  15394. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15395. }
  15396. }
  15397. declare module BABYLON {
  15398. /**
  15399. * Defines a runtime animation
  15400. */
  15401. export class RuntimeAnimation {
  15402. private _events;
  15403. /**
  15404. * The current frame of the runtime animation
  15405. */
  15406. private _currentFrame;
  15407. /**
  15408. * The animation used by the runtime animation
  15409. */
  15410. private _animation;
  15411. /**
  15412. * The target of the runtime animation
  15413. */
  15414. private _target;
  15415. /**
  15416. * The initiating animatable
  15417. */
  15418. private _host;
  15419. /**
  15420. * The original value of the runtime animation
  15421. */
  15422. private _originalValue;
  15423. /**
  15424. * The original blend value of the runtime animation
  15425. */
  15426. private _originalBlendValue;
  15427. /**
  15428. * The offsets cache of the runtime animation
  15429. */
  15430. private _offsetsCache;
  15431. /**
  15432. * The high limits cache of the runtime animation
  15433. */
  15434. private _highLimitsCache;
  15435. /**
  15436. * Specifies if the runtime animation has been stopped
  15437. */
  15438. private _stopped;
  15439. /**
  15440. * The blending factor of the runtime animation
  15441. */
  15442. private _blendingFactor;
  15443. /**
  15444. * The BabylonJS scene
  15445. */
  15446. private _scene;
  15447. /**
  15448. * The current value of the runtime animation
  15449. */
  15450. private _currentValue;
  15451. /** @hidden */
  15452. _animationState: _IAnimationState;
  15453. /**
  15454. * The active target of the runtime animation
  15455. */
  15456. private _activeTargets;
  15457. private _currentActiveTarget;
  15458. private _directTarget;
  15459. /**
  15460. * The target path of the runtime animation
  15461. */
  15462. private _targetPath;
  15463. /**
  15464. * The weight of the runtime animation
  15465. */
  15466. private _weight;
  15467. /**
  15468. * The ratio offset of the runtime animation
  15469. */
  15470. private _ratioOffset;
  15471. /**
  15472. * The previous delay of the runtime animation
  15473. */
  15474. private _previousDelay;
  15475. /**
  15476. * The previous ratio of the runtime animation
  15477. */
  15478. private _previousRatio;
  15479. private _enableBlending;
  15480. private _keys;
  15481. private _minFrame;
  15482. private _maxFrame;
  15483. private _minValue;
  15484. private _maxValue;
  15485. private _targetIsArray;
  15486. /**
  15487. * Gets the current frame of the runtime animation
  15488. */
  15489. get currentFrame(): number;
  15490. /**
  15491. * Gets the weight of the runtime animation
  15492. */
  15493. get weight(): number;
  15494. /**
  15495. * Gets the current value of the runtime animation
  15496. */
  15497. get currentValue(): any;
  15498. /**
  15499. * Gets the target path of the runtime animation
  15500. */
  15501. get targetPath(): string;
  15502. /**
  15503. * Gets the actual target of the runtime animation
  15504. */
  15505. get target(): any;
  15506. /**
  15507. * Gets the additive state of the runtime animation
  15508. */
  15509. get isAdditive(): boolean;
  15510. /** @hidden */
  15511. _onLoop: () => void;
  15512. /**
  15513. * Create a new RuntimeAnimation object
  15514. * @param target defines the target of the animation
  15515. * @param animation defines the source animation object
  15516. * @param scene defines the hosting scene
  15517. * @param host defines the initiating Animatable
  15518. */
  15519. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15520. private _preparePath;
  15521. /**
  15522. * Gets the animation from the runtime animation
  15523. */
  15524. get animation(): Animation;
  15525. /**
  15526. * Resets the runtime animation to the beginning
  15527. * @param restoreOriginal defines whether to restore the target property to the original value
  15528. */
  15529. reset(restoreOriginal?: boolean): void;
  15530. /**
  15531. * Specifies if the runtime animation is stopped
  15532. * @returns Boolean specifying if the runtime animation is stopped
  15533. */
  15534. isStopped(): boolean;
  15535. /**
  15536. * Disposes of the runtime animation
  15537. */
  15538. dispose(): void;
  15539. /**
  15540. * Apply the interpolated value to the target
  15541. * @param currentValue defines the value computed by the animation
  15542. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15543. */
  15544. setValue(currentValue: any, weight: number): void;
  15545. private _getOriginalValues;
  15546. private _setValue;
  15547. /**
  15548. * Gets the loop pmode of the runtime animation
  15549. * @returns Loop Mode
  15550. */
  15551. private _getCorrectLoopMode;
  15552. /**
  15553. * Move the current animation to a given frame
  15554. * @param frame defines the frame to move to
  15555. */
  15556. goToFrame(frame: number): void;
  15557. /**
  15558. * @hidden Internal use only
  15559. */
  15560. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15561. /**
  15562. * Execute the current animation
  15563. * @param delay defines the delay to add to the current frame
  15564. * @param from defines the lower bound of the animation range
  15565. * @param to defines the upper bound of the animation range
  15566. * @param loop defines if the current animation must loop
  15567. * @param speedRatio defines the current speed ratio
  15568. * @param weight defines the weight of the animation (default is -1 so no weight)
  15569. * @param onLoop optional callback called when animation loops
  15570. * @returns a boolean indicating if the animation is running
  15571. */
  15572. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15573. }
  15574. }
  15575. declare module BABYLON {
  15576. /**
  15577. * Class used to store an actual running animation
  15578. */
  15579. export class Animatable {
  15580. /** defines the target object */
  15581. target: any;
  15582. /** defines the starting frame number (default is 0) */
  15583. fromFrame: number;
  15584. /** defines the ending frame number (default is 100) */
  15585. toFrame: number;
  15586. /** defines if the animation must loop (default is false) */
  15587. loopAnimation: boolean;
  15588. /** defines a callback to call when animation ends if it is not looping */
  15589. onAnimationEnd?: (() => void) | null | undefined;
  15590. /** defines a callback to call when animation loops */
  15591. onAnimationLoop?: (() => void) | null | undefined;
  15592. /** defines whether the animation should be evaluated additively */
  15593. isAdditive: boolean;
  15594. private _localDelayOffset;
  15595. private _pausedDelay;
  15596. private _runtimeAnimations;
  15597. private _paused;
  15598. private _scene;
  15599. private _speedRatio;
  15600. private _weight;
  15601. private _syncRoot;
  15602. /**
  15603. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15604. * This will only apply for non looping animation (default is true)
  15605. */
  15606. disposeOnEnd: boolean;
  15607. /**
  15608. * Gets a boolean indicating if the animation has started
  15609. */
  15610. animationStarted: boolean;
  15611. /**
  15612. * Observer raised when the animation ends
  15613. */
  15614. onAnimationEndObservable: Observable<Animatable>;
  15615. /**
  15616. * Observer raised when the animation loops
  15617. */
  15618. onAnimationLoopObservable: Observable<Animatable>;
  15619. /**
  15620. * Gets the root Animatable used to synchronize and normalize animations
  15621. */
  15622. get syncRoot(): Nullable<Animatable>;
  15623. /**
  15624. * Gets the current frame of the first RuntimeAnimation
  15625. * Used to synchronize Animatables
  15626. */
  15627. get masterFrame(): number;
  15628. /**
  15629. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15630. */
  15631. get weight(): number;
  15632. set weight(value: number);
  15633. /**
  15634. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15635. */
  15636. get speedRatio(): number;
  15637. set speedRatio(value: number);
  15638. /**
  15639. * Creates a new Animatable
  15640. * @param scene defines the hosting scene
  15641. * @param target defines the target object
  15642. * @param fromFrame defines the starting frame number (default is 0)
  15643. * @param toFrame defines the ending frame number (default is 100)
  15644. * @param loopAnimation defines if the animation must loop (default is false)
  15645. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15646. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15647. * @param animations defines a group of animation to add to the new Animatable
  15648. * @param onAnimationLoop defines a callback to call when animation loops
  15649. * @param isAdditive defines whether the animation should be evaluated additively
  15650. */
  15651. constructor(scene: Scene,
  15652. /** defines the target object */
  15653. target: any,
  15654. /** defines the starting frame number (default is 0) */
  15655. fromFrame?: number,
  15656. /** defines the ending frame number (default is 100) */
  15657. toFrame?: number,
  15658. /** defines if the animation must loop (default is false) */
  15659. loopAnimation?: boolean, speedRatio?: number,
  15660. /** defines a callback to call when animation ends if it is not looping */
  15661. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15662. /** defines a callback to call when animation loops */
  15663. onAnimationLoop?: (() => void) | null | undefined,
  15664. /** defines whether the animation should be evaluated additively */
  15665. isAdditive?: boolean);
  15666. /**
  15667. * Synchronize and normalize current Animatable with a source Animatable
  15668. * This is useful when using animation weights and when animations are not of the same length
  15669. * @param root defines the root Animatable to synchronize with
  15670. * @returns the current Animatable
  15671. */
  15672. syncWith(root: Animatable): Animatable;
  15673. /**
  15674. * Gets the list of runtime animations
  15675. * @returns an array of RuntimeAnimation
  15676. */
  15677. getAnimations(): RuntimeAnimation[];
  15678. /**
  15679. * Adds more animations to the current animatable
  15680. * @param target defines the target of the animations
  15681. * @param animations defines the new animations to add
  15682. */
  15683. appendAnimations(target: any, animations: Animation[]): void;
  15684. /**
  15685. * Gets the source animation for a specific property
  15686. * @param property defines the propertyu to look for
  15687. * @returns null or the source animation for the given property
  15688. */
  15689. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15690. /**
  15691. * Gets the runtime animation for a specific property
  15692. * @param property defines the propertyu to look for
  15693. * @returns null or the runtime animation for the given property
  15694. */
  15695. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15696. /**
  15697. * Resets the animatable to its original state
  15698. */
  15699. reset(): void;
  15700. /**
  15701. * Allows the animatable to blend with current running animations
  15702. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15703. * @param blendingSpeed defines the blending speed to use
  15704. */
  15705. enableBlending(blendingSpeed: number): void;
  15706. /**
  15707. * Disable animation blending
  15708. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15709. */
  15710. disableBlending(): void;
  15711. /**
  15712. * Jump directly to a given frame
  15713. * @param frame defines the frame to jump to
  15714. */
  15715. goToFrame(frame: number): void;
  15716. /**
  15717. * Pause the animation
  15718. */
  15719. pause(): void;
  15720. /**
  15721. * Restart the animation
  15722. */
  15723. restart(): void;
  15724. private _raiseOnAnimationEnd;
  15725. /**
  15726. * Stop and delete the current animation
  15727. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15728. * @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)
  15729. */
  15730. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15731. /**
  15732. * Wait asynchronously for the animation to end
  15733. * @returns a promise which will be fullfilled when the animation ends
  15734. */
  15735. waitAsync(): Promise<Animatable>;
  15736. /** @hidden */
  15737. _animate(delay: number): boolean;
  15738. }
  15739. interface Scene {
  15740. /** @hidden */
  15741. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15742. /** @hidden */
  15743. _processLateAnimationBindingsForMatrices(holder: {
  15744. totalWeight: number;
  15745. totalAdditiveWeight: number;
  15746. animations: RuntimeAnimation[];
  15747. additiveAnimations: RuntimeAnimation[];
  15748. originalValue: Matrix;
  15749. }): any;
  15750. /** @hidden */
  15751. _processLateAnimationBindingsForQuaternions(holder: {
  15752. totalWeight: number;
  15753. totalAdditiveWeight: number;
  15754. animations: RuntimeAnimation[];
  15755. additiveAnimations: RuntimeAnimation[];
  15756. originalValue: Quaternion;
  15757. }, refQuaternion: Quaternion): Quaternion;
  15758. /** @hidden */
  15759. _processLateAnimationBindings(): void;
  15760. /**
  15761. * Will start the animation sequence of a given target
  15762. * @param target defines the target
  15763. * @param from defines from which frame should animation start
  15764. * @param to defines until which frame should animation run.
  15765. * @param weight defines the weight to apply to the animation (1.0 by default)
  15766. * @param loop defines if the animation loops
  15767. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15768. * @param onAnimationEnd defines the function to be executed when the animation ends
  15769. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15770. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15771. * @param onAnimationLoop defines the callback to call when an animation loops
  15772. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15773. * @returns the animatable object created for this animation
  15774. */
  15775. 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;
  15776. /**
  15777. * Will start the animation sequence of a given target
  15778. * @param target defines the target
  15779. * @param from defines from which frame should animation start
  15780. * @param to defines until which frame should animation run.
  15781. * @param loop defines if the animation loops
  15782. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15783. * @param onAnimationEnd defines the function to be executed when the animation ends
  15784. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15785. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15786. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15787. * @param onAnimationLoop defines the callback to call when an animation loops
  15788. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15789. * @returns the animatable object created for this animation
  15790. */
  15791. 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;
  15792. /**
  15793. * Will start the animation sequence of a given target and its hierarchy
  15794. * @param target defines the target
  15795. * @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.
  15796. * @param from defines from which frame should animation start
  15797. * @param to defines until which frame should animation run.
  15798. * @param loop defines if the animation loops
  15799. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15800. * @param onAnimationEnd defines the function to be executed when the animation ends
  15801. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15802. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15803. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15804. * @param onAnimationLoop defines the callback to call when an animation loops
  15805. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15806. * @returns the list of created animatables
  15807. */
  15808. 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[];
  15809. /**
  15810. * Begin a new animation on a given node
  15811. * @param target defines the target where the animation will take place
  15812. * @param animations defines the list of animations to start
  15813. * @param from defines the initial value
  15814. * @param to defines the final value
  15815. * @param loop defines if you want animation to loop (off by default)
  15816. * @param speedRatio defines the speed ratio to apply to all animations
  15817. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15818. * @param onAnimationLoop defines the callback to call when an animation loops
  15819. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15820. * @returns the list of created animatables
  15821. */
  15822. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15823. /**
  15824. * Begin a new animation on a given node and its hierarchy
  15825. * @param target defines the root node where the animation will take place
  15826. * @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.
  15827. * @param animations defines the list of animations to start
  15828. * @param from defines the initial value
  15829. * @param to defines the final value
  15830. * @param loop defines if you want animation to loop (off by default)
  15831. * @param speedRatio defines the speed ratio to apply to all animations
  15832. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15833. * @param onAnimationLoop defines the callback to call when an animation loops
  15834. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15835. * @returns the list of animatables created for all nodes
  15836. */
  15837. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15838. /**
  15839. * Gets the animatable associated with a specific target
  15840. * @param target defines the target of the animatable
  15841. * @returns the required animatable if found
  15842. */
  15843. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15844. /**
  15845. * Gets all animatables associated with a given target
  15846. * @param target defines the target to look animatables for
  15847. * @returns an array of Animatables
  15848. */
  15849. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15850. /**
  15851. * Stops and removes all animations that have been applied to the scene
  15852. */
  15853. stopAllAnimations(): void;
  15854. /**
  15855. * Gets the current delta time used by animation engine
  15856. */
  15857. deltaTime: number;
  15858. }
  15859. interface Bone {
  15860. /**
  15861. * Copy an animation range from another bone
  15862. * @param source defines the source bone
  15863. * @param rangeName defines the range name to copy
  15864. * @param frameOffset defines the frame offset
  15865. * @param rescaleAsRequired defines if rescaling must be applied if required
  15866. * @param skelDimensionsRatio defines the scaling ratio
  15867. * @returns true if operation was successful
  15868. */
  15869. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15870. }
  15871. }
  15872. declare module BABYLON {
  15873. /**
  15874. * Class used to handle skinning animations
  15875. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15876. */
  15877. export class Skeleton implements IAnimatable {
  15878. /** defines the skeleton name */
  15879. name: string;
  15880. /** defines the skeleton Id */
  15881. id: string;
  15882. /**
  15883. * Defines the list of child bones
  15884. */
  15885. bones: Bone[];
  15886. /**
  15887. * Defines an estimate of the dimension of the skeleton at rest
  15888. */
  15889. dimensionsAtRest: Vector3;
  15890. /**
  15891. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15892. */
  15893. needInitialSkinMatrix: boolean;
  15894. /**
  15895. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15896. */
  15897. overrideMesh: Nullable<AbstractMesh>;
  15898. /**
  15899. * Gets the list of animations attached to this skeleton
  15900. */
  15901. animations: Array<Animation>;
  15902. private _scene;
  15903. private _isDirty;
  15904. private _transformMatrices;
  15905. private _transformMatrixTexture;
  15906. private _meshesWithPoseMatrix;
  15907. private _animatables;
  15908. private _identity;
  15909. private _synchronizedWithMesh;
  15910. private _ranges;
  15911. private _lastAbsoluteTransformsUpdateId;
  15912. private _canUseTextureForBones;
  15913. private _uniqueId;
  15914. /** @hidden */
  15915. _numBonesWithLinkedTransformNode: number;
  15916. /** @hidden */
  15917. _hasWaitingData: Nullable<boolean>;
  15918. /**
  15919. * Specifies if the skeleton should be serialized
  15920. */
  15921. doNotSerialize: boolean;
  15922. private _useTextureToStoreBoneMatrices;
  15923. /**
  15924. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15925. * Please note that this option is not available if the hardware does not support it
  15926. */
  15927. get useTextureToStoreBoneMatrices(): boolean;
  15928. set useTextureToStoreBoneMatrices(value: boolean);
  15929. private _animationPropertiesOverride;
  15930. /**
  15931. * Gets or sets the animation properties override
  15932. */
  15933. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15934. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15935. /**
  15936. * List of inspectable custom properties (used by the Inspector)
  15937. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15938. */
  15939. inspectableCustomProperties: IInspectable[];
  15940. /**
  15941. * An observable triggered before computing the skeleton's matrices
  15942. */
  15943. onBeforeComputeObservable: Observable<Skeleton>;
  15944. /**
  15945. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15946. */
  15947. get isUsingTextureForMatrices(): boolean;
  15948. /**
  15949. * Gets the unique ID of this skeleton
  15950. */
  15951. get uniqueId(): number;
  15952. /**
  15953. * Creates a new skeleton
  15954. * @param name defines the skeleton name
  15955. * @param id defines the skeleton Id
  15956. * @param scene defines the hosting scene
  15957. */
  15958. constructor(
  15959. /** defines the skeleton name */
  15960. name: string,
  15961. /** defines the skeleton Id */
  15962. id: string, scene: Scene);
  15963. /**
  15964. * Gets the current object class name.
  15965. * @return the class name
  15966. */
  15967. getClassName(): string;
  15968. /**
  15969. * Returns an array containing the root bones
  15970. * @returns an array containing the root bones
  15971. */
  15972. getChildren(): Array<Bone>;
  15973. /**
  15974. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15975. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15976. * @returns a Float32Array containing matrices data
  15977. */
  15978. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15979. /**
  15980. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15981. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15982. * @returns a raw texture containing the data
  15983. */
  15984. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15985. /**
  15986. * Gets the current hosting scene
  15987. * @returns a scene object
  15988. */
  15989. getScene(): Scene;
  15990. /**
  15991. * Gets a string representing the current skeleton data
  15992. * @param fullDetails defines a boolean indicating if we want a verbose version
  15993. * @returns a string representing the current skeleton data
  15994. */
  15995. toString(fullDetails?: boolean): string;
  15996. /**
  15997. * Get bone's index searching by name
  15998. * @param name defines bone's name to search for
  15999. * @return the indice of the bone. Returns -1 if not found
  16000. */
  16001. getBoneIndexByName(name: string): number;
  16002. /**
  16003. * Creater a new animation range
  16004. * @param name defines the name of the range
  16005. * @param from defines the start key
  16006. * @param to defines the end key
  16007. */
  16008. createAnimationRange(name: string, from: number, to: number): void;
  16009. /**
  16010. * Delete a specific animation range
  16011. * @param name defines the name of the range
  16012. * @param deleteFrames defines if frames must be removed as well
  16013. */
  16014. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16015. /**
  16016. * Gets a specific animation range
  16017. * @param name defines the name of the range to look for
  16018. * @returns the requested animation range or null if not found
  16019. */
  16020. getAnimationRange(name: string): Nullable<AnimationRange>;
  16021. /**
  16022. * Gets the list of all animation ranges defined on this skeleton
  16023. * @returns an array
  16024. */
  16025. getAnimationRanges(): Nullable<AnimationRange>[];
  16026. /**
  16027. * Copy animation range from a source skeleton.
  16028. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16029. * @param source defines the source skeleton
  16030. * @param name defines the name of the range to copy
  16031. * @param rescaleAsRequired defines if rescaling must be applied if required
  16032. * @returns true if operation was successful
  16033. */
  16034. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16035. /**
  16036. * Forces the skeleton to go to rest pose
  16037. */
  16038. returnToRest(): void;
  16039. private _getHighestAnimationFrame;
  16040. /**
  16041. * Begin a specific animation range
  16042. * @param name defines the name of the range to start
  16043. * @param loop defines if looping must be turned on (false by default)
  16044. * @param speedRatio defines the speed ratio to apply (1 by default)
  16045. * @param onAnimationEnd defines a callback which will be called when animation will end
  16046. * @returns a new animatable
  16047. */
  16048. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16049. /**
  16050. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16051. * @param skeleton defines the Skeleton containing the animation range to convert
  16052. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16053. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16054. * @returns the original skeleton
  16055. */
  16056. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16057. /** @hidden */
  16058. _markAsDirty(): void;
  16059. /** @hidden */
  16060. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16061. /** @hidden */
  16062. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16063. private _computeTransformMatrices;
  16064. /**
  16065. * Build all resources required to render a skeleton
  16066. */
  16067. prepare(): void;
  16068. /**
  16069. * Gets the list of animatables currently running for this skeleton
  16070. * @returns an array of animatables
  16071. */
  16072. getAnimatables(): IAnimatable[];
  16073. /**
  16074. * Clone the current skeleton
  16075. * @param name defines the name of the new skeleton
  16076. * @param id defines the id of the new skeleton
  16077. * @returns the new skeleton
  16078. */
  16079. clone(name: string, id?: string): Skeleton;
  16080. /**
  16081. * Enable animation blending for this skeleton
  16082. * @param blendingSpeed defines the blending speed to apply
  16083. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  16084. */
  16085. enableBlending(blendingSpeed?: number): void;
  16086. /**
  16087. * Releases all resources associated with the current skeleton
  16088. */
  16089. dispose(): void;
  16090. /**
  16091. * Serialize the skeleton in a JSON object
  16092. * @returns a JSON object
  16093. */
  16094. serialize(): any;
  16095. /**
  16096. * Creates a new skeleton from serialized data
  16097. * @param parsedSkeleton defines the serialized data
  16098. * @param scene defines the hosting scene
  16099. * @returns a new skeleton
  16100. */
  16101. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16102. /**
  16103. * Compute all node absolute transforms
  16104. * @param forceUpdate defines if computation must be done even if cache is up to date
  16105. */
  16106. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16107. /**
  16108. * Gets the root pose matrix
  16109. * @returns a matrix
  16110. */
  16111. getPoseMatrix(): Nullable<Matrix>;
  16112. /**
  16113. * Sorts bones per internal index
  16114. */
  16115. sortBones(): void;
  16116. private _sortBones;
  16117. }
  16118. }
  16119. declare module BABYLON {
  16120. /**
  16121. * Creates an instance based on a source mesh.
  16122. */
  16123. export class InstancedMesh extends AbstractMesh {
  16124. private _sourceMesh;
  16125. private _currentLOD;
  16126. /** @hidden */
  16127. _indexInSourceMeshInstanceArray: number;
  16128. constructor(name: string, source: Mesh);
  16129. /**
  16130. * Returns the string "InstancedMesh".
  16131. */
  16132. getClassName(): string;
  16133. /** Gets the list of lights affecting that mesh */
  16134. get lightSources(): Light[];
  16135. _resyncLightSources(): void;
  16136. _resyncLightSource(light: Light): void;
  16137. _removeLightSource(light: Light, dispose: boolean): void;
  16138. /**
  16139. * If the source mesh receives shadows
  16140. */
  16141. get receiveShadows(): boolean;
  16142. /**
  16143. * The material of the source mesh
  16144. */
  16145. get material(): Nullable<Material>;
  16146. /**
  16147. * Visibility of the source mesh
  16148. */
  16149. get visibility(): number;
  16150. /**
  16151. * Skeleton of the source mesh
  16152. */
  16153. get skeleton(): Nullable<Skeleton>;
  16154. /**
  16155. * Rendering ground id of the source mesh
  16156. */
  16157. get renderingGroupId(): number;
  16158. set renderingGroupId(value: number);
  16159. /**
  16160. * Returns the total number of vertices (integer).
  16161. */
  16162. getTotalVertices(): number;
  16163. /**
  16164. * Returns a positive integer : the total number of indices in this mesh geometry.
  16165. * @returns the numner of indices or zero if the mesh has no geometry.
  16166. */
  16167. getTotalIndices(): number;
  16168. /**
  16169. * The source mesh of the instance
  16170. */
  16171. get sourceMesh(): Mesh;
  16172. /**
  16173. * Creates a new InstancedMesh object from the mesh model.
  16174. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16175. * @param name defines the name of the new instance
  16176. * @returns a new InstancedMesh
  16177. */
  16178. createInstance(name: string): InstancedMesh;
  16179. /**
  16180. * Is this node ready to be used/rendered
  16181. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16182. * @return {boolean} is it ready
  16183. */
  16184. isReady(completeCheck?: boolean): boolean;
  16185. /**
  16186. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16187. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16188. * @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.
  16189. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16190. */
  16191. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16192. /**
  16193. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16194. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16195. * The `data` are either a numeric array either a Float32Array.
  16196. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16197. * 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).
  16198. * Note that a new underlying VertexBuffer object is created each call.
  16199. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16200. *
  16201. * Possible `kind` values :
  16202. * - VertexBuffer.PositionKind
  16203. * - VertexBuffer.UVKind
  16204. * - VertexBuffer.UV2Kind
  16205. * - VertexBuffer.UV3Kind
  16206. * - VertexBuffer.UV4Kind
  16207. * - VertexBuffer.UV5Kind
  16208. * - VertexBuffer.UV6Kind
  16209. * - VertexBuffer.ColorKind
  16210. * - VertexBuffer.MatricesIndicesKind
  16211. * - VertexBuffer.MatricesIndicesExtraKind
  16212. * - VertexBuffer.MatricesWeightsKind
  16213. * - VertexBuffer.MatricesWeightsExtraKind
  16214. *
  16215. * Returns the Mesh.
  16216. */
  16217. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16218. /**
  16219. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16220. * If the mesh has no geometry, it is simply returned as it is.
  16221. * The `data` are either a numeric array either a Float32Array.
  16222. * No new underlying VertexBuffer object is created.
  16223. * 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.
  16224. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16225. *
  16226. * Possible `kind` values :
  16227. * - VertexBuffer.PositionKind
  16228. * - VertexBuffer.UVKind
  16229. * - VertexBuffer.UV2Kind
  16230. * - VertexBuffer.UV3Kind
  16231. * - VertexBuffer.UV4Kind
  16232. * - VertexBuffer.UV5Kind
  16233. * - VertexBuffer.UV6Kind
  16234. * - VertexBuffer.ColorKind
  16235. * - VertexBuffer.MatricesIndicesKind
  16236. * - VertexBuffer.MatricesIndicesExtraKind
  16237. * - VertexBuffer.MatricesWeightsKind
  16238. * - VertexBuffer.MatricesWeightsExtraKind
  16239. *
  16240. * Returns the Mesh.
  16241. */
  16242. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16243. /**
  16244. * Sets the mesh indices.
  16245. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16246. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16247. * This method creates a new index buffer each call.
  16248. * Returns the Mesh.
  16249. */
  16250. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16251. /**
  16252. * Boolean : True if the mesh owns the requested kind of data.
  16253. */
  16254. isVerticesDataPresent(kind: string): boolean;
  16255. /**
  16256. * Returns an array of indices (IndicesArray).
  16257. */
  16258. getIndices(): Nullable<IndicesArray>;
  16259. get _positions(): Nullable<Vector3[]>;
  16260. /**
  16261. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16262. * This means the mesh underlying bounding box and sphere are recomputed.
  16263. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16264. * @returns the current mesh
  16265. */
  16266. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16267. /** @hidden */
  16268. _preActivate(): InstancedMesh;
  16269. /** @hidden */
  16270. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16271. /** @hidden */
  16272. _postActivate(): void;
  16273. getWorldMatrix(): Matrix;
  16274. get isAnInstance(): boolean;
  16275. /**
  16276. * Returns the current associated LOD AbstractMesh.
  16277. */
  16278. getLOD(camera: Camera): AbstractMesh;
  16279. /** @hidden */
  16280. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16281. /** @hidden */
  16282. _syncSubMeshes(): InstancedMesh;
  16283. /** @hidden */
  16284. _generatePointsArray(): boolean;
  16285. /**
  16286. * Creates a new InstancedMesh from the current mesh.
  16287. * - name (string) : the cloned mesh name
  16288. * - newParent (optional Node) : the optional Node to parent the clone to.
  16289. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16290. *
  16291. * Returns the clone.
  16292. */
  16293. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16294. /**
  16295. * Disposes the InstancedMesh.
  16296. * Returns nothing.
  16297. */
  16298. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16299. }
  16300. interface Mesh {
  16301. /**
  16302. * Register a custom buffer that will be instanced
  16303. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16304. * @param kind defines the buffer kind
  16305. * @param stride defines the stride in floats
  16306. */
  16307. registerInstancedBuffer(kind: string, stride: number): void;
  16308. /**
  16309. * true to use the edge renderer for all instances of this mesh
  16310. */
  16311. edgesShareWithInstances: boolean;
  16312. /** @hidden */
  16313. _userInstancedBuffersStorage: {
  16314. data: {
  16315. [key: string]: Float32Array;
  16316. };
  16317. sizes: {
  16318. [key: string]: number;
  16319. };
  16320. vertexBuffers: {
  16321. [key: string]: Nullable<VertexBuffer>;
  16322. };
  16323. strides: {
  16324. [key: string]: number;
  16325. };
  16326. };
  16327. }
  16328. interface AbstractMesh {
  16329. /**
  16330. * Object used to store instanced buffers defined by user
  16331. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16332. */
  16333. instancedBuffers: {
  16334. [key: string]: any;
  16335. };
  16336. }
  16337. }
  16338. declare module BABYLON {
  16339. /**
  16340. * Defines the options associated with the creation of a shader material.
  16341. */
  16342. export interface IShaderMaterialOptions {
  16343. /**
  16344. * Does the material work in alpha blend mode
  16345. */
  16346. needAlphaBlending: boolean;
  16347. /**
  16348. * Does the material work in alpha test mode
  16349. */
  16350. needAlphaTesting: boolean;
  16351. /**
  16352. * The list of attribute names used in the shader
  16353. */
  16354. attributes: string[];
  16355. /**
  16356. * The list of unifrom names used in the shader
  16357. */
  16358. uniforms: string[];
  16359. /**
  16360. * The list of UBO names used in the shader
  16361. */
  16362. uniformBuffers: string[];
  16363. /**
  16364. * The list of sampler names used in the shader
  16365. */
  16366. samplers: string[];
  16367. /**
  16368. * The list of defines used in the shader
  16369. */
  16370. defines: string[];
  16371. }
  16372. /**
  16373. * 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.
  16374. *
  16375. * This returned material effects how the mesh will look based on the code in the shaders.
  16376. *
  16377. * @see http://doc.babylonjs.com/how_to/shader_material
  16378. */
  16379. export class ShaderMaterial extends Material {
  16380. private _shaderPath;
  16381. private _options;
  16382. private _textures;
  16383. private _textureArrays;
  16384. private _floats;
  16385. private _ints;
  16386. private _floatsArrays;
  16387. private _colors3;
  16388. private _colors3Arrays;
  16389. private _colors4;
  16390. private _colors4Arrays;
  16391. private _vectors2;
  16392. private _vectors3;
  16393. private _vectors4;
  16394. private _matrices;
  16395. private _matrixArrays;
  16396. private _matrices3x3;
  16397. private _matrices2x2;
  16398. private _vectors2Arrays;
  16399. private _vectors3Arrays;
  16400. private _vectors4Arrays;
  16401. private _cachedWorldViewMatrix;
  16402. private _cachedWorldViewProjectionMatrix;
  16403. private _renderId;
  16404. private _multiview;
  16405. private _cachedDefines;
  16406. /** Define the Url to load snippets */
  16407. static SnippetUrl: string;
  16408. /** Snippet ID if the material was created from the snippet server */
  16409. snippetId: string;
  16410. /**
  16411. * Instantiate a new shader material.
  16412. * 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.
  16413. * This returned material effects how the mesh will look based on the code in the shaders.
  16414. * @see http://doc.babylonjs.com/how_to/shader_material
  16415. * @param name Define the name of the material in the scene
  16416. * @param scene Define the scene the material belongs to
  16417. * @param shaderPath Defines the route to the shader code in one of three ways:
  16418. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16419. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16420. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16421. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16422. * @param options Define the options used to create the shader
  16423. */
  16424. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16425. /**
  16426. * Gets the shader path used to define the shader code
  16427. * It can be modified to trigger a new compilation
  16428. */
  16429. get shaderPath(): any;
  16430. /**
  16431. * Sets the shader path used to define the shader code
  16432. * It can be modified to trigger a new compilation
  16433. */
  16434. set shaderPath(shaderPath: any);
  16435. /**
  16436. * Gets the options used to compile the shader.
  16437. * They can be modified to trigger a new compilation
  16438. */
  16439. get options(): IShaderMaterialOptions;
  16440. /**
  16441. * Gets the current class name of the material e.g. "ShaderMaterial"
  16442. * Mainly use in serialization.
  16443. * @returns the class name
  16444. */
  16445. getClassName(): string;
  16446. /**
  16447. * Specifies if the material will require alpha blending
  16448. * @returns a boolean specifying if alpha blending is needed
  16449. */
  16450. needAlphaBlending(): boolean;
  16451. /**
  16452. * Specifies if this material should be rendered in alpha test mode
  16453. * @returns a boolean specifying if an alpha test is needed.
  16454. */
  16455. needAlphaTesting(): boolean;
  16456. private _checkUniform;
  16457. /**
  16458. * Set a texture in the shader.
  16459. * @param name Define the name of the uniform samplers as defined in the shader
  16460. * @param texture Define the texture to bind to this sampler
  16461. * @return the material itself allowing "fluent" like uniform updates
  16462. */
  16463. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16464. /**
  16465. * Set a texture array in the shader.
  16466. * @param name Define the name of the uniform sampler array as defined in the shader
  16467. * @param textures Define the list of textures to bind to this sampler
  16468. * @return the material itself allowing "fluent" like uniform updates
  16469. */
  16470. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16471. /**
  16472. * Set a float in the shader.
  16473. * @param name Define the name of the uniform as defined in the shader
  16474. * @param value Define the value to give to the uniform
  16475. * @return the material itself allowing "fluent" like uniform updates
  16476. */
  16477. setFloat(name: string, value: number): ShaderMaterial;
  16478. /**
  16479. * Set a int in the shader.
  16480. * @param name Define the name of the uniform as defined in the shader
  16481. * @param value Define the value to give to the uniform
  16482. * @return the material itself allowing "fluent" like uniform updates
  16483. */
  16484. setInt(name: string, value: number): ShaderMaterial;
  16485. /**
  16486. * Set an array of floats in the shader.
  16487. * @param name Define the name of the uniform as defined in the shader
  16488. * @param value Define the value to give to the uniform
  16489. * @return the material itself allowing "fluent" like uniform updates
  16490. */
  16491. setFloats(name: string, value: number[]): ShaderMaterial;
  16492. /**
  16493. * Set a vec3 in the shader from a Color3.
  16494. * @param name Define the name of the uniform as defined in the shader
  16495. * @param value Define the value to give to the uniform
  16496. * @return the material itself allowing "fluent" like uniform updates
  16497. */
  16498. setColor3(name: string, value: Color3): ShaderMaterial;
  16499. /**
  16500. * Set a vec3 array in the shader from a Color3 array.
  16501. * @param name Define the name of the uniform as defined in the shader
  16502. * @param value Define the value to give to the uniform
  16503. * @return the material itself allowing "fluent" like uniform updates
  16504. */
  16505. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16506. /**
  16507. * Set a vec4 in the shader from a Color4.
  16508. * @param name Define the name of the uniform as defined in the shader
  16509. * @param value Define the value to give to the uniform
  16510. * @return the material itself allowing "fluent" like uniform updates
  16511. */
  16512. setColor4(name: string, value: Color4): ShaderMaterial;
  16513. /**
  16514. * Set a vec4 array in the shader from a Color4 array.
  16515. * @param name Define the name of the uniform as defined in the shader
  16516. * @param value Define the value to give to the uniform
  16517. * @return the material itself allowing "fluent" like uniform updates
  16518. */
  16519. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16520. /**
  16521. * Set a vec2 in the shader from a Vector2.
  16522. * @param name Define the name of the uniform as defined in the shader
  16523. * @param value Define the value to give to the uniform
  16524. * @return the material itself allowing "fluent" like uniform updates
  16525. */
  16526. setVector2(name: string, value: Vector2): ShaderMaterial;
  16527. /**
  16528. * Set a vec3 in the shader from a Vector3.
  16529. * @param name Define the name of the uniform as defined in the shader
  16530. * @param value Define the value to give to the uniform
  16531. * @return the material itself allowing "fluent" like uniform updates
  16532. */
  16533. setVector3(name: string, value: Vector3): ShaderMaterial;
  16534. /**
  16535. * Set a vec4 in the shader from a Vector4.
  16536. * @param name Define the name of the uniform as defined in the shader
  16537. * @param value Define the value to give to the uniform
  16538. * @return the material itself allowing "fluent" like uniform updates
  16539. */
  16540. setVector4(name: string, value: Vector4): ShaderMaterial;
  16541. /**
  16542. * Set a mat4 in the shader from a Matrix.
  16543. * @param name Define the name of the uniform as defined in the shader
  16544. * @param value Define the value to give to the uniform
  16545. * @return the material itself allowing "fluent" like uniform updates
  16546. */
  16547. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16548. /**
  16549. * Set a float32Array in the shader from a matrix array.
  16550. * @param name Define the name of the uniform as defined in the shader
  16551. * @param value Define the value to give to the uniform
  16552. * @return the material itself allowing "fluent" like uniform updates
  16553. */
  16554. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16555. /**
  16556. * Set a mat3 in the shader from a Float32Array.
  16557. * @param name Define the name of the uniform as defined in the shader
  16558. * @param value Define the value to give to the uniform
  16559. * @return the material itself allowing "fluent" like uniform updates
  16560. */
  16561. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16562. /**
  16563. * Set a mat2 in the shader from a Float32Array.
  16564. * @param name Define the name of the uniform as defined in the shader
  16565. * @param value Define the value to give to the uniform
  16566. * @return the material itself allowing "fluent" like uniform updates
  16567. */
  16568. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16569. /**
  16570. * Set a vec2 array in the shader from a number array.
  16571. * @param name Define the name of the uniform as defined in the shader
  16572. * @param value Define the value to give to the uniform
  16573. * @return the material itself allowing "fluent" like uniform updates
  16574. */
  16575. setArray2(name: string, value: number[]): ShaderMaterial;
  16576. /**
  16577. * Set a vec3 array in the shader from a number array.
  16578. * @param name Define the name of the uniform as defined in the shader
  16579. * @param value Define the value to give to the uniform
  16580. * @return the material itself allowing "fluent" like uniform updates
  16581. */
  16582. setArray3(name: string, value: number[]): ShaderMaterial;
  16583. /**
  16584. * Set a vec4 array in the shader from a number array.
  16585. * @param name Define the name of the uniform as defined in the shader
  16586. * @param value Define the value to give to the uniform
  16587. * @return the material itself allowing "fluent" like uniform updates
  16588. */
  16589. setArray4(name: string, value: number[]): ShaderMaterial;
  16590. private _checkCache;
  16591. /**
  16592. * Specifies that the submesh is ready to be used
  16593. * @param mesh defines the mesh to check
  16594. * @param subMesh defines which submesh to check
  16595. * @param useInstances specifies that instances should be used
  16596. * @returns a boolean indicating that the submesh is ready or not
  16597. */
  16598. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16599. /**
  16600. * Checks if the material is ready to render the requested mesh
  16601. * @param mesh Define the mesh to render
  16602. * @param useInstances Define whether or not the material is used with instances
  16603. * @returns true if ready, otherwise false
  16604. */
  16605. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16606. /**
  16607. * Binds the world matrix to the material
  16608. * @param world defines the world transformation matrix
  16609. * @param effectOverride - If provided, use this effect instead of internal effect
  16610. */
  16611. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16612. /**
  16613. * Binds the submesh to this material by preparing the effect and shader to draw
  16614. * @param world defines the world transformation matrix
  16615. * @param mesh defines the mesh containing the submesh
  16616. * @param subMesh defines the submesh to bind the material to
  16617. */
  16618. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16619. /**
  16620. * Binds the material to the mesh
  16621. * @param world defines the world transformation matrix
  16622. * @param mesh defines the mesh to bind the material to
  16623. * @param effectOverride - If provided, use this effect instead of internal effect
  16624. */
  16625. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16626. protected _afterBind(mesh?: Mesh): void;
  16627. /**
  16628. * Gets the active textures from the material
  16629. * @returns an array of textures
  16630. */
  16631. getActiveTextures(): BaseTexture[];
  16632. /**
  16633. * Specifies if the material uses a texture
  16634. * @param texture defines the texture to check against the material
  16635. * @returns a boolean specifying if the material uses the texture
  16636. */
  16637. hasTexture(texture: BaseTexture): boolean;
  16638. /**
  16639. * Makes a duplicate of the material, and gives it a new name
  16640. * @param name defines the new name for the duplicated material
  16641. * @returns the cloned material
  16642. */
  16643. clone(name: string): ShaderMaterial;
  16644. /**
  16645. * Disposes the material
  16646. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16647. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16648. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16649. */
  16650. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16651. /**
  16652. * Serializes this material in a JSON representation
  16653. * @returns the serialized material object
  16654. */
  16655. serialize(): any;
  16656. /**
  16657. * Creates a shader material from parsed shader material data
  16658. * @param source defines the JSON represnetation of the material
  16659. * @param scene defines the hosting scene
  16660. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16661. * @returns a new material
  16662. */
  16663. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16664. /**
  16665. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16666. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16667. * @param url defines the url to load from
  16668. * @param scene defines the hosting scene
  16669. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16670. * @returns a promise that will resolve to the new ShaderMaterial
  16671. */
  16672. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16673. /**
  16674. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16675. * @param snippetId defines the snippet to load
  16676. * @param scene defines the hosting scene
  16677. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16678. * @returns a promise that will resolve to the new ShaderMaterial
  16679. */
  16680. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16681. }
  16682. }
  16683. declare module BABYLON {
  16684. /** @hidden */
  16685. export var colorPixelShader: {
  16686. name: string;
  16687. shader: string;
  16688. };
  16689. }
  16690. declare module BABYLON {
  16691. /** @hidden */
  16692. export var colorVertexShader: {
  16693. name: string;
  16694. shader: string;
  16695. };
  16696. }
  16697. declare module BABYLON {
  16698. /**
  16699. * Line mesh
  16700. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16701. */
  16702. export class LinesMesh extends Mesh {
  16703. /**
  16704. * If vertex color should be applied to the mesh
  16705. */
  16706. readonly useVertexColor?: boolean | undefined;
  16707. /**
  16708. * If vertex alpha should be applied to the mesh
  16709. */
  16710. readonly useVertexAlpha?: boolean | undefined;
  16711. /**
  16712. * Color of the line (Default: White)
  16713. */
  16714. color: Color3;
  16715. /**
  16716. * Alpha of the line (Default: 1)
  16717. */
  16718. alpha: number;
  16719. /**
  16720. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16721. * This margin is expressed in world space coordinates, so its value may vary.
  16722. * Default value is 0.1
  16723. */
  16724. intersectionThreshold: number;
  16725. private _colorShader;
  16726. private color4;
  16727. /**
  16728. * Creates a new LinesMesh
  16729. * @param name defines the name
  16730. * @param scene defines the hosting scene
  16731. * @param parent defines the parent mesh if any
  16732. * @param source defines the optional source LinesMesh used to clone data from
  16733. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16734. * When false, achieved by calling a clone(), also passing False.
  16735. * This will make creation of children, recursive.
  16736. * @param useVertexColor defines if this LinesMesh supports vertex color
  16737. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16738. */
  16739. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16740. /**
  16741. * If vertex color should be applied to the mesh
  16742. */
  16743. useVertexColor?: boolean | undefined,
  16744. /**
  16745. * If vertex alpha should be applied to the mesh
  16746. */
  16747. useVertexAlpha?: boolean | undefined);
  16748. private _addClipPlaneDefine;
  16749. private _removeClipPlaneDefine;
  16750. isReady(): boolean;
  16751. /**
  16752. * Returns the string "LineMesh"
  16753. */
  16754. getClassName(): string;
  16755. /**
  16756. * @hidden
  16757. */
  16758. get material(): Material;
  16759. /**
  16760. * @hidden
  16761. */
  16762. set material(value: Material);
  16763. /**
  16764. * @hidden
  16765. */
  16766. get checkCollisions(): boolean;
  16767. /** @hidden */
  16768. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16769. /** @hidden */
  16770. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16771. /**
  16772. * Disposes of the line mesh
  16773. * @param doNotRecurse If children should be disposed
  16774. */
  16775. dispose(doNotRecurse?: boolean): void;
  16776. /**
  16777. * Returns a new LineMesh object cloned from the current one.
  16778. */
  16779. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16780. /**
  16781. * Creates a new InstancedLinesMesh object from the mesh model.
  16782. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16783. * @param name defines the name of the new instance
  16784. * @returns a new InstancedLinesMesh
  16785. */
  16786. createInstance(name: string): InstancedLinesMesh;
  16787. }
  16788. /**
  16789. * Creates an instance based on a source LinesMesh
  16790. */
  16791. export class InstancedLinesMesh extends InstancedMesh {
  16792. /**
  16793. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16794. * This margin is expressed in world space coordinates, so its value may vary.
  16795. * Initilized with the intersectionThreshold value of the source LinesMesh
  16796. */
  16797. intersectionThreshold: number;
  16798. constructor(name: string, source: LinesMesh);
  16799. /**
  16800. * Returns the string "InstancedLinesMesh".
  16801. */
  16802. getClassName(): string;
  16803. }
  16804. }
  16805. declare module BABYLON {
  16806. /** @hidden */
  16807. export var linePixelShader: {
  16808. name: string;
  16809. shader: string;
  16810. };
  16811. }
  16812. declare module BABYLON {
  16813. /** @hidden */
  16814. export var lineVertexShader: {
  16815. name: string;
  16816. shader: string;
  16817. };
  16818. }
  16819. declare module BABYLON {
  16820. interface Scene {
  16821. /** @hidden */
  16822. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16823. }
  16824. interface AbstractMesh {
  16825. /**
  16826. * Gets the edgesRenderer associated with the mesh
  16827. */
  16828. edgesRenderer: Nullable<EdgesRenderer>;
  16829. }
  16830. interface LinesMesh {
  16831. /**
  16832. * Enables the edge rendering mode on the mesh.
  16833. * This mode makes the mesh edges visible
  16834. * @param epsilon defines the maximal distance between two angles to detect a face
  16835. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16836. * @returns the currentAbstractMesh
  16837. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16838. */
  16839. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16840. }
  16841. interface InstancedLinesMesh {
  16842. /**
  16843. * Enables the edge rendering mode on the mesh.
  16844. * This mode makes the mesh edges visible
  16845. * @param epsilon defines the maximal distance between two angles to detect a face
  16846. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16847. * @returns the current InstancedLinesMesh
  16848. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16849. */
  16850. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16851. }
  16852. /**
  16853. * Defines the minimum contract an Edges renderer should follow.
  16854. */
  16855. export interface IEdgesRenderer extends IDisposable {
  16856. /**
  16857. * Gets or sets a boolean indicating if the edgesRenderer is active
  16858. */
  16859. isEnabled: boolean;
  16860. /**
  16861. * Renders the edges of the attached mesh,
  16862. */
  16863. render(): void;
  16864. /**
  16865. * Checks wether or not the edges renderer is ready to render.
  16866. * @return true if ready, otherwise false.
  16867. */
  16868. isReady(): boolean;
  16869. /**
  16870. * List of instances to render in case the source mesh has instances
  16871. */
  16872. customInstances: SmartArray<Matrix>;
  16873. }
  16874. /**
  16875. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16876. */
  16877. export class EdgesRenderer implements IEdgesRenderer {
  16878. /**
  16879. * Define the size of the edges with an orthographic camera
  16880. */
  16881. edgesWidthScalerForOrthographic: number;
  16882. /**
  16883. * Define the size of the edges with a perspective camera
  16884. */
  16885. edgesWidthScalerForPerspective: number;
  16886. protected _source: AbstractMesh;
  16887. protected _linesPositions: number[];
  16888. protected _linesNormals: number[];
  16889. protected _linesIndices: number[];
  16890. protected _epsilon: number;
  16891. protected _indicesCount: number;
  16892. protected _lineShader: ShaderMaterial;
  16893. protected _ib: DataBuffer;
  16894. protected _buffers: {
  16895. [key: string]: Nullable<VertexBuffer>;
  16896. };
  16897. protected _buffersForInstances: {
  16898. [key: string]: Nullable<VertexBuffer>;
  16899. };
  16900. protected _checkVerticesInsteadOfIndices: boolean;
  16901. private _meshRebuildObserver;
  16902. private _meshDisposeObserver;
  16903. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16904. isEnabled: boolean;
  16905. /**
  16906. * List of instances to render in case the source mesh has instances
  16907. */
  16908. customInstances: SmartArray<Matrix>;
  16909. private static GetShader;
  16910. /**
  16911. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16912. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16913. * @param source Mesh used to create edges
  16914. * @param epsilon sum of angles in adjacency to check for edge
  16915. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16916. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16917. */
  16918. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16919. protected _prepareRessources(): void;
  16920. /** @hidden */
  16921. _rebuild(): void;
  16922. /**
  16923. * Releases the required resources for the edges renderer
  16924. */
  16925. dispose(): void;
  16926. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16927. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16928. /**
  16929. * Checks if the pair of p0 and p1 is en edge
  16930. * @param faceIndex
  16931. * @param edge
  16932. * @param faceNormals
  16933. * @param p0
  16934. * @param p1
  16935. * @private
  16936. */
  16937. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16938. /**
  16939. * push line into the position, normal and index buffer
  16940. * @protected
  16941. */
  16942. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16943. /**
  16944. * Generates lines edges from adjacencjes
  16945. * @private
  16946. */
  16947. _generateEdgesLines(): void;
  16948. /**
  16949. * Checks wether or not the edges renderer is ready to render.
  16950. * @return true if ready, otherwise false.
  16951. */
  16952. isReady(): boolean;
  16953. /**
  16954. * Renders the edges of the attached mesh,
  16955. */
  16956. render(): void;
  16957. }
  16958. /**
  16959. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16960. */
  16961. export class LineEdgesRenderer extends EdgesRenderer {
  16962. /**
  16963. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16964. * @param source LineMesh used to generate edges
  16965. * @param epsilon not important (specified angle for edge detection)
  16966. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16967. */
  16968. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16969. /**
  16970. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16971. */
  16972. _generateEdgesLines(): void;
  16973. }
  16974. }
  16975. declare module BABYLON {
  16976. /**
  16977. * This represents the object necessary to create a rendering group.
  16978. * This is exclusively used and created by the rendering manager.
  16979. * To modify the behavior, you use the available helpers in your scene or meshes.
  16980. * @hidden
  16981. */
  16982. export class RenderingGroup {
  16983. index: number;
  16984. private static _zeroVector;
  16985. private _scene;
  16986. private _opaqueSubMeshes;
  16987. private _transparentSubMeshes;
  16988. private _alphaTestSubMeshes;
  16989. private _depthOnlySubMeshes;
  16990. private _particleSystems;
  16991. private _spriteManagers;
  16992. private _opaqueSortCompareFn;
  16993. private _alphaTestSortCompareFn;
  16994. private _transparentSortCompareFn;
  16995. private _renderOpaque;
  16996. private _renderAlphaTest;
  16997. private _renderTransparent;
  16998. /** @hidden */
  16999. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17000. onBeforeTransparentRendering: () => void;
  17001. /**
  17002. * Set the opaque sort comparison function.
  17003. * If null the sub meshes will be render in the order they were created
  17004. */
  17005. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17006. /**
  17007. * Set the alpha test sort comparison function.
  17008. * If null the sub meshes will be render in the order they were created
  17009. */
  17010. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17011. /**
  17012. * Set the transparent sort comparison function.
  17013. * If null the sub meshes will be render in the order they were created
  17014. */
  17015. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17016. /**
  17017. * Creates a new rendering group.
  17018. * @param index The rendering group index
  17019. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17020. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17021. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17022. */
  17023. 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>);
  17024. /**
  17025. * Render all the sub meshes contained in the group.
  17026. * @param customRenderFunction Used to override the default render behaviour of the group.
  17027. * @returns true if rendered some submeshes.
  17028. */
  17029. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17030. /**
  17031. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17032. * @param subMeshes The submeshes to render
  17033. */
  17034. private renderOpaqueSorted;
  17035. /**
  17036. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17037. * @param subMeshes The submeshes to render
  17038. */
  17039. private renderAlphaTestSorted;
  17040. /**
  17041. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17042. * @param subMeshes The submeshes to render
  17043. */
  17044. private renderTransparentSorted;
  17045. /**
  17046. * Renders the submeshes in a specified order.
  17047. * @param subMeshes The submeshes to sort before render
  17048. * @param sortCompareFn The comparison function use to sort
  17049. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17050. * @param transparent Specifies to activate blending if true
  17051. */
  17052. private static renderSorted;
  17053. /**
  17054. * Renders the submeshes in the order they were dispatched (no sort applied).
  17055. * @param subMeshes The submeshes to render
  17056. */
  17057. private static renderUnsorted;
  17058. /**
  17059. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17060. * are rendered back to front if in the same alpha index.
  17061. *
  17062. * @param a The first submesh
  17063. * @param b The second submesh
  17064. * @returns The result of the comparison
  17065. */
  17066. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17067. /**
  17068. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17069. * are rendered back to front.
  17070. *
  17071. * @param a The first submesh
  17072. * @param b The second submesh
  17073. * @returns The result of the comparison
  17074. */
  17075. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17076. /**
  17077. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17078. * are rendered front to back (prevent overdraw).
  17079. *
  17080. * @param a The first submesh
  17081. * @param b The second submesh
  17082. * @returns The result of the comparison
  17083. */
  17084. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17085. /**
  17086. * Resets the different lists of submeshes to prepare a new frame.
  17087. */
  17088. prepare(): void;
  17089. dispose(): void;
  17090. /**
  17091. * Inserts the submesh in its correct queue depending on its material.
  17092. * @param subMesh The submesh to dispatch
  17093. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17094. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17095. */
  17096. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17097. dispatchSprites(spriteManager: ISpriteManager): void;
  17098. dispatchParticles(particleSystem: IParticleSystem): void;
  17099. private _renderParticles;
  17100. private _renderSprites;
  17101. }
  17102. }
  17103. declare module BABYLON {
  17104. /**
  17105. * Interface describing the different options available in the rendering manager
  17106. * regarding Auto Clear between groups.
  17107. */
  17108. export interface IRenderingManagerAutoClearSetup {
  17109. /**
  17110. * Defines whether or not autoclear is enable.
  17111. */
  17112. autoClear: boolean;
  17113. /**
  17114. * Defines whether or not to autoclear the depth buffer.
  17115. */
  17116. depth: boolean;
  17117. /**
  17118. * Defines whether or not to autoclear the stencil buffer.
  17119. */
  17120. stencil: boolean;
  17121. }
  17122. /**
  17123. * This class is used by the onRenderingGroupObservable
  17124. */
  17125. export class RenderingGroupInfo {
  17126. /**
  17127. * The Scene that being rendered
  17128. */
  17129. scene: Scene;
  17130. /**
  17131. * The camera currently used for the rendering pass
  17132. */
  17133. camera: Nullable<Camera>;
  17134. /**
  17135. * The ID of the renderingGroup being processed
  17136. */
  17137. renderingGroupId: number;
  17138. }
  17139. /**
  17140. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17141. * It is enable to manage the different groups as well as the different necessary sort functions.
  17142. * This should not be used directly aside of the few static configurations
  17143. */
  17144. export class RenderingManager {
  17145. /**
  17146. * The max id used for rendering groups (not included)
  17147. */
  17148. static MAX_RENDERINGGROUPS: number;
  17149. /**
  17150. * The min id used for rendering groups (included)
  17151. */
  17152. static MIN_RENDERINGGROUPS: number;
  17153. /**
  17154. * Used to globally prevent autoclearing scenes.
  17155. */
  17156. static AUTOCLEAR: boolean;
  17157. /**
  17158. * @hidden
  17159. */
  17160. _useSceneAutoClearSetup: boolean;
  17161. private _scene;
  17162. private _renderingGroups;
  17163. private _depthStencilBufferAlreadyCleaned;
  17164. private _autoClearDepthStencil;
  17165. private _customOpaqueSortCompareFn;
  17166. private _customAlphaTestSortCompareFn;
  17167. private _customTransparentSortCompareFn;
  17168. private _renderingGroupInfo;
  17169. /**
  17170. * Instantiates a new rendering group for a particular scene
  17171. * @param scene Defines the scene the groups belongs to
  17172. */
  17173. constructor(scene: Scene);
  17174. private _clearDepthStencilBuffer;
  17175. /**
  17176. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17177. * @hidden
  17178. */
  17179. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17180. /**
  17181. * Resets the different information of the group to prepare a new frame
  17182. * @hidden
  17183. */
  17184. reset(): void;
  17185. /**
  17186. * Dispose and release the group and its associated resources.
  17187. * @hidden
  17188. */
  17189. dispose(): void;
  17190. /**
  17191. * Clear the info related to rendering groups preventing retention points during dispose.
  17192. */
  17193. freeRenderingGroups(): void;
  17194. private _prepareRenderingGroup;
  17195. /**
  17196. * Add a sprite manager to the rendering manager in order to render it this frame.
  17197. * @param spriteManager Define the sprite manager to render
  17198. */
  17199. dispatchSprites(spriteManager: ISpriteManager): void;
  17200. /**
  17201. * Add a particle system to the rendering manager in order to render it this frame.
  17202. * @param particleSystem Define the particle system to render
  17203. */
  17204. dispatchParticles(particleSystem: IParticleSystem): void;
  17205. /**
  17206. * Add a submesh to the manager in order to render it this frame
  17207. * @param subMesh The submesh to dispatch
  17208. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17209. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17210. */
  17211. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17212. /**
  17213. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17214. * This allowed control for front to back rendering or reversly depending of the special needs.
  17215. *
  17216. * @param renderingGroupId The rendering group id corresponding to its index
  17217. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17218. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17219. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17220. */
  17221. 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;
  17222. /**
  17223. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17224. *
  17225. * @param renderingGroupId The rendering group id corresponding to its index
  17226. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17227. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17228. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17229. */
  17230. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17231. /**
  17232. * Gets the current auto clear configuration for one rendering group of the rendering
  17233. * manager.
  17234. * @param index the rendering group index to get the information for
  17235. * @returns The auto clear setup for the requested rendering group
  17236. */
  17237. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17238. }
  17239. }
  17240. declare module BABYLON {
  17241. /**
  17242. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17243. */
  17244. export interface ICustomShaderOptions {
  17245. /**
  17246. * Gets or sets the custom shader name to use
  17247. */
  17248. shaderName: string;
  17249. /**
  17250. * The list of attribute names used in the shader
  17251. */
  17252. attributes?: string[];
  17253. /**
  17254. * The list of unifrom names used in the shader
  17255. */
  17256. uniforms?: string[];
  17257. /**
  17258. * The list of sampler names used in the shader
  17259. */
  17260. samplers?: string[];
  17261. /**
  17262. * The list of defines used in the shader
  17263. */
  17264. defines?: string[];
  17265. }
  17266. /**
  17267. * Interface to implement to create a shadow generator compatible with BJS.
  17268. */
  17269. export interface IShadowGenerator {
  17270. /**
  17271. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17272. * @returns The render target texture if present otherwise, null
  17273. */
  17274. getShadowMap(): Nullable<RenderTargetTexture>;
  17275. /**
  17276. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17277. * @param subMesh The submesh we want to render in the shadow map
  17278. * @param useInstances Defines wether will draw in the map using instances
  17279. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17280. * @returns true if ready otherwise, false
  17281. */
  17282. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17283. /**
  17284. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17285. * @param defines Defines of the material we want to update
  17286. * @param lightIndex Index of the light in the enabled light list of the material
  17287. */
  17288. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17289. /**
  17290. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17291. * defined in the generator but impacting the effect).
  17292. * It implies the unifroms available on the materials are the standard BJS ones.
  17293. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17294. * @param effect The effect we are binfing the information for
  17295. */
  17296. bindShadowLight(lightIndex: string, effect: Effect): void;
  17297. /**
  17298. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17299. * (eq to shadow prjection matrix * light transform matrix)
  17300. * @returns The transform matrix used to create the shadow map
  17301. */
  17302. getTransformMatrix(): Matrix;
  17303. /**
  17304. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17305. * Cube and 2D textures for instance.
  17306. */
  17307. recreateShadowMap(): void;
  17308. /**
  17309. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17310. * @param onCompiled Callback triggered at the and of the effects compilation
  17311. * @param options Sets of optional options forcing the compilation with different modes
  17312. */
  17313. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17314. useInstances: boolean;
  17315. }>): void;
  17316. /**
  17317. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17318. * @param options Sets of optional options forcing the compilation with different modes
  17319. * @returns A promise that resolves when the compilation completes
  17320. */
  17321. forceCompilationAsync(options?: Partial<{
  17322. useInstances: boolean;
  17323. }>): Promise<void>;
  17324. /**
  17325. * Serializes the shadow generator setup to a json object.
  17326. * @returns The serialized JSON object
  17327. */
  17328. serialize(): any;
  17329. /**
  17330. * Disposes the Shadow map and related Textures and effects.
  17331. */
  17332. dispose(): void;
  17333. }
  17334. /**
  17335. * Default implementation IShadowGenerator.
  17336. * This is the main object responsible of generating shadows in the framework.
  17337. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17338. */
  17339. export class ShadowGenerator implements IShadowGenerator {
  17340. /**
  17341. * Name of the shadow generator class
  17342. */
  17343. static CLASSNAME: string;
  17344. /**
  17345. * Shadow generator mode None: no filtering applied.
  17346. */
  17347. static readonly FILTER_NONE: number;
  17348. /**
  17349. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17350. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17351. */
  17352. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17353. /**
  17354. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17355. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17356. */
  17357. static readonly FILTER_POISSONSAMPLING: number;
  17358. /**
  17359. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17360. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17361. */
  17362. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17363. /**
  17364. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17365. * edge artifacts on steep falloff.
  17366. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17367. */
  17368. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17369. /**
  17370. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17371. * edge artifacts on steep falloff.
  17372. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17373. */
  17374. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17375. /**
  17376. * Shadow generator mode PCF: Percentage Closer Filtering
  17377. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17378. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17379. */
  17380. static readonly FILTER_PCF: number;
  17381. /**
  17382. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17383. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17384. * Contact Hardening
  17385. */
  17386. static readonly FILTER_PCSS: number;
  17387. /**
  17388. * Reserved for PCF and PCSS
  17389. * Highest Quality.
  17390. *
  17391. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17392. *
  17393. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17394. */
  17395. static readonly QUALITY_HIGH: number;
  17396. /**
  17397. * Reserved for PCF and PCSS
  17398. * Good tradeoff for quality/perf cross devices
  17399. *
  17400. * Execute PCF on a 3*3 kernel.
  17401. *
  17402. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17403. */
  17404. static readonly QUALITY_MEDIUM: number;
  17405. /**
  17406. * Reserved for PCF and PCSS
  17407. * The lowest quality but the fastest.
  17408. *
  17409. * Execute PCF on a 1*1 kernel.
  17410. *
  17411. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17412. */
  17413. static readonly QUALITY_LOW: number;
  17414. /** Gets or sets the custom shader name to use */
  17415. customShaderOptions: ICustomShaderOptions;
  17416. /**
  17417. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17418. */
  17419. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17420. /**
  17421. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17422. */
  17423. onAfterShadowMapRenderObservable: Observable<Effect>;
  17424. /**
  17425. * Observable triggered before a mesh is rendered in the shadow map.
  17426. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17427. */
  17428. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17429. /**
  17430. * Observable triggered after a mesh is rendered in the shadow map.
  17431. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17432. */
  17433. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17434. protected _bias: number;
  17435. /**
  17436. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17437. */
  17438. get bias(): number;
  17439. /**
  17440. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17441. */
  17442. set bias(bias: number);
  17443. protected _normalBias: number;
  17444. /**
  17445. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17446. */
  17447. get normalBias(): number;
  17448. /**
  17449. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17450. */
  17451. set normalBias(normalBias: number);
  17452. protected _blurBoxOffset: number;
  17453. /**
  17454. * Gets the blur box offset: offset applied during the blur pass.
  17455. * Only useful if useKernelBlur = false
  17456. */
  17457. get blurBoxOffset(): number;
  17458. /**
  17459. * Sets the blur box offset: offset applied during the blur pass.
  17460. * Only useful if useKernelBlur = false
  17461. */
  17462. set blurBoxOffset(value: number);
  17463. protected _blurScale: number;
  17464. /**
  17465. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17466. * 2 means half of the size.
  17467. */
  17468. get blurScale(): number;
  17469. /**
  17470. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17471. * 2 means half of the size.
  17472. */
  17473. set blurScale(value: number);
  17474. protected _blurKernel: number;
  17475. /**
  17476. * Gets the blur kernel: kernel size of the blur pass.
  17477. * Only useful if useKernelBlur = true
  17478. */
  17479. get blurKernel(): number;
  17480. /**
  17481. * Sets the blur kernel: kernel size of the blur pass.
  17482. * Only useful if useKernelBlur = true
  17483. */
  17484. set blurKernel(value: number);
  17485. protected _useKernelBlur: boolean;
  17486. /**
  17487. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17488. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17489. */
  17490. get useKernelBlur(): boolean;
  17491. /**
  17492. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17493. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17494. */
  17495. set useKernelBlur(value: boolean);
  17496. protected _depthScale: number;
  17497. /**
  17498. * Gets the depth scale used in ESM mode.
  17499. */
  17500. get depthScale(): number;
  17501. /**
  17502. * Sets the depth scale used in ESM mode.
  17503. * This can override the scale stored on the light.
  17504. */
  17505. set depthScale(value: number);
  17506. protected _validateFilter(filter: number): number;
  17507. protected _filter: number;
  17508. /**
  17509. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17510. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17511. */
  17512. get filter(): number;
  17513. /**
  17514. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17515. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17516. */
  17517. set filter(value: number);
  17518. /**
  17519. * Gets if the current filter is set to Poisson Sampling.
  17520. */
  17521. get usePoissonSampling(): boolean;
  17522. /**
  17523. * Sets the current filter to Poisson Sampling.
  17524. */
  17525. set usePoissonSampling(value: boolean);
  17526. /**
  17527. * Gets if the current filter is set to ESM.
  17528. */
  17529. get useExponentialShadowMap(): boolean;
  17530. /**
  17531. * Sets the current filter is to ESM.
  17532. */
  17533. set useExponentialShadowMap(value: boolean);
  17534. /**
  17535. * Gets if the current filter is set to filtered ESM.
  17536. */
  17537. get useBlurExponentialShadowMap(): boolean;
  17538. /**
  17539. * Gets if the current filter is set to filtered ESM.
  17540. */
  17541. set useBlurExponentialShadowMap(value: boolean);
  17542. /**
  17543. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17544. * exponential to prevent steep falloff artifacts).
  17545. */
  17546. get useCloseExponentialShadowMap(): boolean;
  17547. /**
  17548. * Sets the current filter to "close ESM" (using the inverse of the
  17549. * exponential to prevent steep falloff artifacts).
  17550. */
  17551. set useCloseExponentialShadowMap(value: boolean);
  17552. /**
  17553. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17554. * exponential to prevent steep falloff artifacts).
  17555. */
  17556. get useBlurCloseExponentialShadowMap(): boolean;
  17557. /**
  17558. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17559. * exponential to prevent steep falloff artifacts).
  17560. */
  17561. set useBlurCloseExponentialShadowMap(value: boolean);
  17562. /**
  17563. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17564. */
  17565. get usePercentageCloserFiltering(): boolean;
  17566. /**
  17567. * Sets the current filter to "PCF" (percentage closer filtering).
  17568. */
  17569. set usePercentageCloserFiltering(value: boolean);
  17570. protected _filteringQuality: number;
  17571. /**
  17572. * Gets the PCF or PCSS Quality.
  17573. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17574. */
  17575. get filteringQuality(): number;
  17576. /**
  17577. * Sets the PCF or PCSS Quality.
  17578. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17579. */
  17580. set filteringQuality(filteringQuality: number);
  17581. /**
  17582. * Gets if the current filter is set to "PCSS" (contact hardening).
  17583. */
  17584. get useContactHardeningShadow(): boolean;
  17585. /**
  17586. * Sets the current filter to "PCSS" (contact hardening).
  17587. */
  17588. set useContactHardeningShadow(value: boolean);
  17589. protected _contactHardeningLightSizeUVRatio: number;
  17590. /**
  17591. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17592. * Using a ratio helps keeping shape stability independently of the map size.
  17593. *
  17594. * It does not account for the light projection as it was having too much
  17595. * instability during the light setup or during light position changes.
  17596. *
  17597. * Only valid if useContactHardeningShadow is true.
  17598. */
  17599. get contactHardeningLightSizeUVRatio(): number;
  17600. /**
  17601. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17602. * Using a ratio helps keeping shape stability independently of the map size.
  17603. *
  17604. * It does not account for the light projection as it was having too much
  17605. * instability during the light setup or during light position changes.
  17606. *
  17607. * Only valid if useContactHardeningShadow is true.
  17608. */
  17609. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17610. protected _darkness: number;
  17611. /** Gets or sets the actual darkness of a shadow */
  17612. get darkness(): number;
  17613. set darkness(value: number);
  17614. /**
  17615. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17616. * 0 means strongest and 1 would means no shadow.
  17617. * @returns the darkness.
  17618. */
  17619. getDarkness(): number;
  17620. /**
  17621. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17622. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17623. * @returns the shadow generator allowing fluent coding.
  17624. */
  17625. setDarkness(darkness: number): ShadowGenerator;
  17626. protected _transparencyShadow: boolean;
  17627. /** Gets or sets the ability to have transparent shadow */
  17628. get transparencyShadow(): boolean;
  17629. set transparencyShadow(value: boolean);
  17630. /**
  17631. * Sets the ability to have transparent shadow (boolean).
  17632. * @param transparent True if transparent else False
  17633. * @returns the shadow generator allowing fluent coding
  17634. */
  17635. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17636. /**
  17637. * Enables or disables shadows with varying strength based on the transparency
  17638. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17639. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17640. * mesh.visibility * alphaTexture.a
  17641. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17642. */
  17643. enableSoftTransparentShadow: boolean;
  17644. protected _shadowMap: Nullable<RenderTargetTexture>;
  17645. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17646. /**
  17647. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17648. * @returns The render target texture if present otherwise, null
  17649. */
  17650. getShadowMap(): Nullable<RenderTargetTexture>;
  17651. /**
  17652. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17653. * @returns The render target texture if the shadow map is present otherwise, null
  17654. */
  17655. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17656. /**
  17657. * Gets the class name of that object
  17658. * @returns "ShadowGenerator"
  17659. */
  17660. getClassName(): string;
  17661. /**
  17662. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17663. * @param mesh Mesh to add
  17664. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17665. * @returns the Shadow Generator itself
  17666. */
  17667. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17668. /**
  17669. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17670. * @param mesh Mesh to remove
  17671. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17672. * @returns the Shadow Generator itself
  17673. */
  17674. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17675. /**
  17676. * Controls the extent to which the shadows fade out at the edge of the frustum
  17677. */
  17678. frustumEdgeFalloff: number;
  17679. protected _light: IShadowLight;
  17680. /**
  17681. * Returns the associated light object.
  17682. * @returns the light generating the shadow
  17683. */
  17684. getLight(): IShadowLight;
  17685. /**
  17686. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17687. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17688. * It might on the other hand introduce peter panning.
  17689. */
  17690. forceBackFacesOnly: boolean;
  17691. protected _scene: Scene;
  17692. protected _lightDirection: Vector3;
  17693. protected _effect: Effect;
  17694. protected _viewMatrix: Matrix;
  17695. protected _projectionMatrix: Matrix;
  17696. protected _transformMatrix: Matrix;
  17697. protected _cachedPosition: Vector3;
  17698. protected _cachedDirection: Vector3;
  17699. protected _cachedDefines: string;
  17700. protected _currentRenderID: number;
  17701. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17702. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17703. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17704. protected _blurPostProcesses: PostProcess[];
  17705. protected _mapSize: number;
  17706. protected _currentFaceIndex: number;
  17707. protected _currentFaceIndexCache: number;
  17708. protected _textureType: number;
  17709. protected _defaultTextureMatrix: Matrix;
  17710. protected _storedUniqueId: Nullable<number>;
  17711. /** @hidden */
  17712. static _SceneComponentInitialization: (scene: Scene) => void;
  17713. /**
  17714. * Creates a ShadowGenerator object.
  17715. * A ShadowGenerator is the required tool to use the shadows.
  17716. * Each light casting shadows needs to use its own ShadowGenerator.
  17717. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17718. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17719. * @param light The light object generating the shadows.
  17720. * @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.
  17721. */
  17722. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17723. protected _initializeGenerator(): void;
  17724. protected _createTargetRenderTexture(): void;
  17725. protected _initializeShadowMap(): void;
  17726. protected _initializeBlurRTTAndPostProcesses(): void;
  17727. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17728. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17729. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17730. protected _applyFilterValues(): void;
  17731. /**
  17732. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17733. * @param onCompiled Callback triggered at the and of the effects compilation
  17734. * @param options Sets of optional options forcing the compilation with different modes
  17735. */
  17736. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17737. useInstances: boolean;
  17738. }>): void;
  17739. /**
  17740. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17741. * @param options Sets of optional options forcing the compilation with different modes
  17742. * @returns A promise that resolves when the compilation completes
  17743. */
  17744. forceCompilationAsync(options?: Partial<{
  17745. useInstances: boolean;
  17746. }>): Promise<void>;
  17747. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17748. private _prepareShadowDefines;
  17749. /**
  17750. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17751. * @param subMesh The submesh we want to render in the shadow map
  17752. * @param useInstances Defines wether will draw in the map using instances
  17753. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17754. * @returns true if ready otherwise, false
  17755. */
  17756. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17757. /**
  17758. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17759. * @param defines Defines of the material we want to update
  17760. * @param lightIndex Index of the light in the enabled light list of the material
  17761. */
  17762. prepareDefines(defines: any, lightIndex: number): void;
  17763. /**
  17764. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17765. * defined in the generator but impacting the effect).
  17766. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17767. * @param effect The effect we are binfing the information for
  17768. */
  17769. bindShadowLight(lightIndex: string, effect: Effect): void;
  17770. /**
  17771. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17772. * (eq to shadow prjection matrix * light transform matrix)
  17773. * @returns The transform matrix used to create the shadow map
  17774. */
  17775. getTransformMatrix(): Matrix;
  17776. /**
  17777. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17778. * Cube and 2D textures for instance.
  17779. */
  17780. recreateShadowMap(): void;
  17781. protected _disposeBlurPostProcesses(): void;
  17782. protected _disposeRTTandPostProcesses(): void;
  17783. /**
  17784. * Disposes the ShadowGenerator.
  17785. * Returns nothing.
  17786. */
  17787. dispose(): void;
  17788. /**
  17789. * Serializes the shadow generator setup to a json object.
  17790. * @returns The serialized JSON object
  17791. */
  17792. serialize(): any;
  17793. /**
  17794. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17795. * @param parsedShadowGenerator The JSON object to parse
  17796. * @param scene The scene to create the shadow map for
  17797. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17798. * @returns The parsed shadow generator
  17799. */
  17800. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17801. }
  17802. }
  17803. declare module BABYLON {
  17804. /**
  17805. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17806. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17807. * 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.
  17808. */
  17809. export abstract class Light extends Node {
  17810. /**
  17811. * Falloff Default: light is falling off following the material specification:
  17812. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17813. */
  17814. static readonly FALLOFF_DEFAULT: number;
  17815. /**
  17816. * Falloff Physical: light is falling off following the inverse squared distance law.
  17817. */
  17818. static readonly FALLOFF_PHYSICAL: number;
  17819. /**
  17820. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17821. * to enhance interoperability with other engines.
  17822. */
  17823. static readonly FALLOFF_GLTF: number;
  17824. /**
  17825. * Falloff Standard: light is falling off like in the standard material
  17826. * to enhance interoperability with other materials.
  17827. */
  17828. static readonly FALLOFF_STANDARD: number;
  17829. /**
  17830. * If every light affecting the material is in this lightmapMode,
  17831. * material.lightmapTexture adds or multiplies
  17832. * (depends on material.useLightmapAsShadowmap)
  17833. * after every other light calculations.
  17834. */
  17835. static readonly LIGHTMAP_DEFAULT: number;
  17836. /**
  17837. * material.lightmapTexture as only diffuse lighting from this light
  17838. * adds only specular lighting from this light
  17839. * adds dynamic shadows
  17840. */
  17841. static readonly LIGHTMAP_SPECULAR: number;
  17842. /**
  17843. * material.lightmapTexture as only lighting
  17844. * no light calculation from this light
  17845. * only adds dynamic shadows from this light
  17846. */
  17847. static readonly LIGHTMAP_SHADOWSONLY: number;
  17848. /**
  17849. * Each light type uses the default quantity according to its type:
  17850. * point/spot lights use luminous intensity
  17851. * directional lights use illuminance
  17852. */
  17853. static readonly INTENSITYMODE_AUTOMATIC: number;
  17854. /**
  17855. * lumen (lm)
  17856. */
  17857. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17858. /**
  17859. * candela (lm/sr)
  17860. */
  17861. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17862. /**
  17863. * lux (lm/m^2)
  17864. */
  17865. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17866. /**
  17867. * nit (cd/m^2)
  17868. */
  17869. static readonly INTENSITYMODE_LUMINANCE: number;
  17870. /**
  17871. * Light type const id of the point light.
  17872. */
  17873. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17874. /**
  17875. * Light type const id of the directional light.
  17876. */
  17877. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17878. /**
  17879. * Light type const id of the spot light.
  17880. */
  17881. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17882. /**
  17883. * Light type const id of the hemispheric light.
  17884. */
  17885. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17886. /**
  17887. * Diffuse gives the basic color to an object.
  17888. */
  17889. diffuse: Color3;
  17890. /**
  17891. * Specular produces a highlight color on an object.
  17892. * Note: This is note affecting PBR materials.
  17893. */
  17894. specular: Color3;
  17895. /**
  17896. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17897. * falling off base on range or angle.
  17898. * This can be set to any values in Light.FALLOFF_x.
  17899. *
  17900. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17901. * other types of materials.
  17902. */
  17903. falloffType: number;
  17904. /**
  17905. * Strength of the light.
  17906. * Note: By default it is define in the framework own unit.
  17907. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17908. */
  17909. intensity: number;
  17910. private _range;
  17911. protected _inverseSquaredRange: number;
  17912. /**
  17913. * Defines how far from the source the light is impacting in scene units.
  17914. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17915. */
  17916. get range(): number;
  17917. /**
  17918. * Defines how far from the source the light is impacting in scene units.
  17919. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17920. */
  17921. set range(value: number);
  17922. /**
  17923. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17924. * of light.
  17925. */
  17926. private _photometricScale;
  17927. private _intensityMode;
  17928. /**
  17929. * Gets the photometric scale used to interpret the intensity.
  17930. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17931. */
  17932. get intensityMode(): number;
  17933. /**
  17934. * Sets the photometric scale used to interpret the intensity.
  17935. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17936. */
  17937. set intensityMode(value: number);
  17938. private _radius;
  17939. /**
  17940. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17941. */
  17942. get radius(): number;
  17943. /**
  17944. * sets the light radius used by PBR Materials to simulate soft area lights.
  17945. */
  17946. set radius(value: number);
  17947. private _renderPriority;
  17948. /**
  17949. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17950. * exceeding the number allowed of the materials.
  17951. */
  17952. renderPriority: number;
  17953. private _shadowEnabled;
  17954. /**
  17955. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17956. * the current shadow generator.
  17957. */
  17958. get shadowEnabled(): boolean;
  17959. /**
  17960. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17961. * the current shadow generator.
  17962. */
  17963. set shadowEnabled(value: boolean);
  17964. private _includedOnlyMeshes;
  17965. /**
  17966. * Gets the only meshes impacted by this light.
  17967. */
  17968. get includedOnlyMeshes(): AbstractMesh[];
  17969. /**
  17970. * Sets the only meshes impacted by this light.
  17971. */
  17972. set includedOnlyMeshes(value: AbstractMesh[]);
  17973. private _excludedMeshes;
  17974. /**
  17975. * Gets the meshes not impacted by this light.
  17976. */
  17977. get excludedMeshes(): AbstractMesh[];
  17978. /**
  17979. * Sets the meshes not impacted by this light.
  17980. */
  17981. set excludedMeshes(value: AbstractMesh[]);
  17982. private _excludeWithLayerMask;
  17983. /**
  17984. * Gets the layer id use to find what meshes are not impacted by the light.
  17985. * Inactive if 0
  17986. */
  17987. get excludeWithLayerMask(): number;
  17988. /**
  17989. * Sets the layer id use to find what meshes are not impacted by the light.
  17990. * Inactive if 0
  17991. */
  17992. set excludeWithLayerMask(value: number);
  17993. private _includeOnlyWithLayerMask;
  17994. /**
  17995. * Gets the layer id use to find what meshes are impacted by the light.
  17996. * Inactive if 0
  17997. */
  17998. get includeOnlyWithLayerMask(): number;
  17999. /**
  18000. * Sets the layer id use to find what meshes are impacted by the light.
  18001. * Inactive if 0
  18002. */
  18003. set includeOnlyWithLayerMask(value: number);
  18004. private _lightmapMode;
  18005. /**
  18006. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18007. */
  18008. get lightmapMode(): number;
  18009. /**
  18010. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18011. */
  18012. set lightmapMode(value: number);
  18013. /**
  18014. * Shadow generator associted to the light.
  18015. * @hidden Internal use only.
  18016. */
  18017. _shadowGenerator: Nullable<IShadowGenerator>;
  18018. /**
  18019. * @hidden Internal use only.
  18020. */
  18021. _excludedMeshesIds: string[];
  18022. /**
  18023. * @hidden Internal use only.
  18024. */
  18025. _includedOnlyMeshesIds: string[];
  18026. /**
  18027. * The current light unifom buffer.
  18028. * @hidden Internal use only.
  18029. */
  18030. _uniformBuffer: UniformBuffer;
  18031. /** @hidden */
  18032. _renderId: number;
  18033. /**
  18034. * Creates a Light object in the scene.
  18035. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18036. * @param name The firendly name of the light
  18037. * @param scene The scene the light belongs too
  18038. */
  18039. constructor(name: string, scene: Scene);
  18040. protected abstract _buildUniformLayout(): void;
  18041. /**
  18042. * Sets the passed Effect "effect" with the Light information.
  18043. * @param effect The effect to update
  18044. * @param lightIndex The index of the light in the effect to update
  18045. * @returns The light
  18046. */
  18047. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18048. /**
  18049. * Sets the passed Effect "effect" with the Light textures.
  18050. * @param effect The effect to update
  18051. * @param lightIndex The index of the light in the effect to update
  18052. * @returns The light
  18053. */
  18054. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18055. /**
  18056. * Binds the lights information from the scene to the effect for the given mesh.
  18057. * @param lightIndex Light index
  18058. * @param scene The scene where the light belongs to
  18059. * @param effect The effect we are binding the data to
  18060. * @param useSpecular Defines if specular is supported
  18061. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18062. */
  18063. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18064. /**
  18065. * Sets the passed Effect "effect" with the Light information.
  18066. * @param effect The effect to update
  18067. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18068. * @returns The light
  18069. */
  18070. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18071. /**
  18072. * Returns the string "Light".
  18073. * @returns the class name
  18074. */
  18075. getClassName(): string;
  18076. /** @hidden */
  18077. readonly _isLight: boolean;
  18078. /**
  18079. * Converts the light information to a readable string for debug purpose.
  18080. * @param fullDetails Supports for multiple levels of logging within scene loading
  18081. * @returns the human readable light info
  18082. */
  18083. toString(fullDetails?: boolean): string;
  18084. /** @hidden */
  18085. protected _syncParentEnabledState(): void;
  18086. /**
  18087. * Set the enabled state of this node.
  18088. * @param value - the new enabled state
  18089. */
  18090. setEnabled(value: boolean): void;
  18091. /**
  18092. * Returns the Light associated shadow generator if any.
  18093. * @return the associated shadow generator.
  18094. */
  18095. getShadowGenerator(): Nullable<IShadowGenerator>;
  18096. /**
  18097. * Returns a Vector3, the absolute light position in the World.
  18098. * @returns the world space position of the light
  18099. */
  18100. getAbsolutePosition(): Vector3;
  18101. /**
  18102. * Specifies if the light will affect the passed mesh.
  18103. * @param mesh The mesh to test against the light
  18104. * @return true the mesh is affected otherwise, false.
  18105. */
  18106. canAffectMesh(mesh: AbstractMesh): boolean;
  18107. /**
  18108. * Sort function to order lights for rendering.
  18109. * @param a First Light object to compare to second.
  18110. * @param b Second Light object to compare first.
  18111. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18112. */
  18113. static CompareLightsPriority(a: Light, b: Light): number;
  18114. /**
  18115. * Releases resources associated with this node.
  18116. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18117. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18118. */
  18119. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18120. /**
  18121. * Returns the light type ID (integer).
  18122. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18123. */
  18124. getTypeID(): number;
  18125. /**
  18126. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18127. * @returns the scaled intensity in intensity mode unit
  18128. */
  18129. getScaledIntensity(): number;
  18130. /**
  18131. * Returns a new Light object, named "name", from the current one.
  18132. * @param name The name of the cloned light
  18133. * @param newParent The parent of this light, if it has one
  18134. * @returns the new created light
  18135. */
  18136. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18137. /**
  18138. * Serializes the current light into a Serialization object.
  18139. * @returns the serialized object.
  18140. */
  18141. serialize(): any;
  18142. /**
  18143. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18144. * This new light is named "name" and added to the passed scene.
  18145. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18146. * @param name The friendly name of the light
  18147. * @param scene The scene the new light will belong to
  18148. * @returns the constructor function
  18149. */
  18150. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18151. /**
  18152. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18153. * @param parsedLight The JSON representation of the light
  18154. * @param scene The scene to create the parsed light in
  18155. * @returns the created light after parsing
  18156. */
  18157. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18158. private _hookArrayForExcluded;
  18159. private _hookArrayForIncludedOnly;
  18160. private _resyncMeshes;
  18161. /**
  18162. * Forces the meshes to update their light related information in their rendering used effects
  18163. * @hidden Internal Use Only
  18164. */
  18165. _markMeshesAsLightDirty(): void;
  18166. /**
  18167. * Recomputes the cached photometric scale if needed.
  18168. */
  18169. private _computePhotometricScale;
  18170. /**
  18171. * Returns the Photometric Scale according to the light type and intensity mode.
  18172. */
  18173. private _getPhotometricScale;
  18174. /**
  18175. * Reorder the light in the scene according to their defined priority.
  18176. * @hidden Internal Use Only
  18177. */
  18178. _reorderLightsInScene(): void;
  18179. /**
  18180. * Prepares the list of defines specific to the light type.
  18181. * @param defines the list of defines
  18182. * @param lightIndex defines the index of the light for the effect
  18183. */
  18184. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18185. }
  18186. }
  18187. declare module BABYLON {
  18188. /**
  18189. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18190. * This is the base of the follow, arc rotate cameras and Free camera
  18191. * @see http://doc.babylonjs.com/features/cameras
  18192. */
  18193. export class TargetCamera extends Camera {
  18194. private static _RigCamTransformMatrix;
  18195. private static _TargetTransformMatrix;
  18196. private static _TargetFocalPoint;
  18197. private _tmpUpVector;
  18198. private _tmpTargetVector;
  18199. /**
  18200. * Define the current direction the camera is moving to
  18201. */
  18202. cameraDirection: Vector3;
  18203. /**
  18204. * Define the current rotation the camera is rotating to
  18205. */
  18206. cameraRotation: Vector2;
  18207. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18208. ignoreParentScaling: boolean;
  18209. /**
  18210. * When set, the up vector of the camera will be updated by the rotation of the camera
  18211. */
  18212. updateUpVectorFromRotation: boolean;
  18213. private _tmpQuaternion;
  18214. /**
  18215. * Define the current rotation of the camera
  18216. */
  18217. rotation: Vector3;
  18218. /**
  18219. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18220. */
  18221. rotationQuaternion: Quaternion;
  18222. /**
  18223. * Define the current speed of the camera
  18224. */
  18225. speed: number;
  18226. /**
  18227. * Add constraint to the camera to prevent it to move freely in all directions and
  18228. * around all axis.
  18229. */
  18230. noRotationConstraint: boolean;
  18231. /**
  18232. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18233. * panning
  18234. */
  18235. invertRotation: boolean;
  18236. /**
  18237. * Speed multiplier for inverse camera panning
  18238. */
  18239. inverseRotationSpeed: number;
  18240. /**
  18241. * Define the current target of the camera as an object or a position.
  18242. */
  18243. lockedTarget: any;
  18244. /** @hidden */
  18245. _currentTarget: Vector3;
  18246. /** @hidden */
  18247. _initialFocalDistance: number;
  18248. /** @hidden */
  18249. _viewMatrix: Matrix;
  18250. /** @hidden */
  18251. _camMatrix: Matrix;
  18252. /** @hidden */
  18253. _cameraTransformMatrix: Matrix;
  18254. /** @hidden */
  18255. _cameraRotationMatrix: Matrix;
  18256. /** @hidden */
  18257. _referencePoint: Vector3;
  18258. /** @hidden */
  18259. _transformedReferencePoint: Vector3;
  18260. /** @hidden */
  18261. _reset: () => void;
  18262. private _defaultUp;
  18263. /**
  18264. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18265. * This is the base of the follow, arc rotate cameras and Free camera
  18266. * @see http://doc.babylonjs.com/features/cameras
  18267. * @param name Defines the name of the camera in the scene
  18268. * @param position Defines the start position of the camera in the scene
  18269. * @param scene Defines the scene the camera belongs to
  18270. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18271. */
  18272. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18273. /**
  18274. * Gets the position in front of the camera at a given distance.
  18275. * @param distance The distance from the camera we want the position to be
  18276. * @returns the position
  18277. */
  18278. getFrontPosition(distance: number): Vector3;
  18279. /** @hidden */
  18280. _getLockedTargetPosition(): Nullable<Vector3>;
  18281. private _storedPosition;
  18282. private _storedRotation;
  18283. private _storedRotationQuaternion;
  18284. /**
  18285. * Store current camera state of the camera (fov, position, rotation, etc..)
  18286. * @returns the camera
  18287. */
  18288. storeState(): Camera;
  18289. /**
  18290. * Restored camera state. You must call storeState() first
  18291. * @returns whether it was successful or not
  18292. * @hidden
  18293. */
  18294. _restoreStateValues(): boolean;
  18295. /** @hidden */
  18296. _initCache(): void;
  18297. /** @hidden */
  18298. _updateCache(ignoreParentClass?: boolean): void;
  18299. /** @hidden */
  18300. _isSynchronizedViewMatrix(): boolean;
  18301. /** @hidden */
  18302. _computeLocalCameraSpeed(): number;
  18303. /**
  18304. * Defines the target the camera should look at.
  18305. * @param target Defines the new target as a Vector or a mesh
  18306. */
  18307. setTarget(target: Vector3): void;
  18308. /**
  18309. * Return the current target position of the camera. This value is expressed in local space.
  18310. * @returns the target position
  18311. */
  18312. getTarget(): Vector3;
  18313. /** @hidden */
  18314. _decideIfNeedsToMove(): boolean;
  18315. /** @hidden */
  18316. _updatePosition(): void;
  18317. /** @hidden */
  18318. _checkInputs(): void;
  18319. protected _updateCameraRotationMatrix(): void;
  18320. /**
  18321. * 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)
  18322. * @returns the current camera
  18323. */
  18324. private _rotateUpVectorWithCameraRotationMatrix;
  18325. private _cachedRotationZ;
  18326. private _cachedQuaternionRotationZ;
  18327. /** @hidden */
  18328. _getViewMatrix(): Matrix;
  18329. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18330. /**
  18331. * @hidden
  18332. */
  18333. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18334. /**
  18335. * @hidden
  18336. */
  18337. _updateRigCameras(): void;
  18338. private _getRigCamPositionAndTarget;
  18339. /**
  18340. * Gets the current object class name.
  18341. * @return the class name
  18342. */
  18343. getClassName(): string;
  18344. }
  18345. }
  18346. declare module BABYLON {
  18347. /**
  18348. * Gather the list of keyboard event types as constants.
  18349. */
  18350. export class KeyboardEventTypes {
  18351. /**
  18352. * The keydown event is fired when a key becomes active (pressed).
  18353. */
  18354. static readonly KEYDOWN: number;
  18355. /**
  18356. * The keyup event is fired when a key has been released.
  18357. */
  18358. static readonly KEYUP: number;
  18359. }
  18360. /**
  18361. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18362. */
  18363. export class KeyboardInfo {
  18364. /**
  18365. * Defines the type of event (KeyboardEventTypes)
  18366. */
  18367. type: number;
  18368. /**
  18369. * Defines the related dom event
  18370. */
  18371. event: KeyboardEvent;
  18372. /**
  18373. * Instantiates a new keyboard info.
  18374. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18375. * @param type Defines the type of event (KeyboardEventTypes)
  18376. * @param event Defines the related dom event
  18377. */
  18378. constructor(
  18379. /**
  18380. * Defines the type of event (KeyboardEventTypes)
  18381. */
  18382. type: number,
  18383. /**
  18384. * Defines the related dom event
  18385. */
  18386. event: KeyboardEvent);
  18387. }
  18388. /**
  18389. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18390. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18391. */
  18392. export class KeyboardInfoPre extends KeyboardInfo {
  18393. /**
  18394. * Defines the type of event (KeyboardEventTypes)
  18395. */
  18396. type: number;
  18397. /**
  18398. * Defines the related dom event
  18399. */
  18400. event: KeyboardEvent;
  18401. /**
  18402. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18403. */
  18404. skipOnPointerObservable: boolean;
  18405. /**
  18406. * Instantiates a new keyboard pre info.
  18407. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18408. * @param type Defines the type of event (KeyboardEventTypes)
  18409. * @param event Defines the related dom event
  18410. */
  18411. constructor(
  18412. /**
  18413. * Defines the type of event (KeyboardEventTypes)
  18414. */
  18415. type: number,
  18416. /**
  18417. * Defines the related dom event
  18418. */
  18419. event: KeyboardEvent);
  18420. }
  18421. }
  18422. declare module BABYLON {
  18423. /**
  18424. * Manage the keyboard inputs to control the movement of a free camera.
  18425. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18426. */
  18427. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18428. /**
  18429. * Defines the camera the input is attached to.
  18430. */
  18431. camera: FreeCamera;
  18432. /**
  18433. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18434. */
  18435. keysUp: number[];
  18436. /**
  18437. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18438. */
  18439. keysUpward: number[];
  18440. /**
  18441. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18442. */
  18443. keysDown: number[];
  18444. /**
  18445. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18446. */
  18447. keysDownward: number[];
  18448. /**
  18449. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18450. */
  18451. keysLeft: number[];
  18452. /**
  18453. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18454. */
  18455. keysRight: number[];
  18456. private _keys;
  18457. private _onCanvasBlurObserver;
  18458. private _onKeyboardObserver;
  18459. private _engine;
  18460. private _scene;
  18461. /**
  18462. * Attach the input controls to a specific dom element to get the input from.
  18463. * @param element Defines the element the controls should be listened from
  18464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18465. */
  18466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18467. /**
  18468. * Detach the current controls from the specified dom element.
  18469. * @param element Defines the element to stop listening the inputs from
  18470. */
  18471. detachControl(element: Nullable<HTMLElement>): void;
  18472. /**
  18473. * Update the current camera state depending on the inputs that have been used this frame.
  18474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18475. */
  18476. checkInputs(): void;
  18477. /**
  18478. * Gets the class name of the current intput.
  18479. * @returns the class name
  18480. */
  18481. getClassName(): string;
  18482. /** @hidden */
  18483. _onLostFocus(): void;
  18484. /**
  18485. * Get the friendly name associated with the input class.
  18486. * @returns the input friendly name
  18487. */
  18488. getSimpleName(): string;
  18489. }
  18490. }
  18491. declare module BABYLON {
  18492. /**
  18493. * Gather the list of pointer event types as constants.
  18494. */
  18495. export class PointerEventTypes {
  18496. /**
  18497. * 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.
  18498. */
  18499. static readonly POINTERDOWN: number;
  18500. /**
  18501. * The pointerup event is fired when a pointer is no longer active.
  18502. */
  18503. static readonly POINTERUP: number;
  18504. /**
  18505. * The pointermove event is fired when a pointer changes coordinates.
  18506. */
  18507. static readonly POINTERMOVE: number;
  18508. /**
  18509. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18510. */
  18511. static readonly POINTERWHEEL: number;
  18512. /**
  18513. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18514. */
  18515. static readonly POINTERPICK: number;
  18516. /**
  18517. * The pointertap event is fired when a the object has been touched and released without drag.
  18518. */
  18519. static readonly POINTERTAP: number;
  18520. /**
  18521. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18522. */
  18523. static readonly POINTERDOUBLETAP: number;
  18524. }
  18525. /**
  18526. * Base class of pointer info types.
  18527. */
  18528. export class PointerInfoBase {
  18529. /**
  18530. * Defines the type of event (PointerEventTypes)
  18531. */
  18532. type: number;
  18533. /**
  18534. * Defines the related dom event
  18535. */
  18536. event: PointerEvent | MouseWheelEvent;
  18537. /**
  18538. * Instantiates the base class of pointers info.
  18539. * @param type Defines the type of event (PointerEventTypes)
  18540. * @param event Defines the related dom event
  18541. */
  18542. constructor(
  18543. /**
  18544. * Defines the type of event (PointerEventTypes)
  18545. */
  18546. type: number,
  18547. /**
  18548. * Defines the related dom event
  18549. */
  18550. event: PointerEvent | MouseWheelEvent);
  18551. }
  18552. /**
  18553. * This class is used to store pointer related info for the onPrePointerObservable event.
  18554. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18555. */
  18556. export class PointerInfoPre extends PointerInfoBase {
  18557. /**
  18558. * Ray from a pointer if availible (eg. 6dof controller)
  18559. */
  18560. ray: Nullable<Ray>;
  18561. /**
  18562. * Defines the local position of the pointer on the canvas.
  18563. */
  18564. localPosition: Vector2;
  18565. /**
  18566. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18567. */
  18568. skipOnPointerObservable: boolean;
  18569. /**
  18570. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18571. * @param type Defines the type of event (PointerEventTypes)
  18572. * @param event Defines the related dom event
  18573. * @param localX Defines the local x coordinates of the pointer when the event occured
  18574. * @param localY Defines the local y coordinates of the pointer when the event occured
  18575. */
  18576. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18577. }
  18578. /**
  18579. * This type contains all the data related to a pointer event in Babylon.js.
  18580. * 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.
  18581. */
  18582. export class PointerInfo extends PointerInfoBase {
  18583. /**
  18584. * Defines the picking info associated to the info (if any)\
  18585. */
  18586. pickInfo: Nullable<PickingInfo>;
  18587. /**
  18588. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18589. * @param type Defines the type of event (PointerEventTypes)
  18590. * @param event Defines the related dom event
  18591. * @param pickInfo Defines the picking info associated to the info (if any)\
  18592. */
  18593. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18594. /**
  18595. * Defines the picking info associated to the info (if any)\
  18596. */
  18597. pickInfo: Nullable<PickingInfo>);
  18598. }
  18599. /**
  18600. * Data relating to a touch event on the screen.
  18601. */
  18602. export interface PointerTouch {
  18603. /**
  18604. * X coordinate of touch.
  18605. */
  18606. x: number;
  18607. /**
  18608. * Y coordinate of touch.
  18609. */
  18610. y: number;
  18611. /**
  18612. * Id of touch. Unique for each finger.
  18613. */
  18614. pointerId: number;
  18615. /**
  18616. * Event type passed from DOM.
  18617. */
  18618. type: any;
  18619. }
  18620. }
  18621. declare module BABYLON {
  18622. /**
  18623. * Manage the mouse inputs to control the movement of a free camera.
  18624. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18625. */
  18626. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18627. /**
  18628. * Define if touch is enabled in the mouse input
  18629. */
  18630. touchEnabled: boolean;
  18631. /**
  18632. * Defines the camera the input is attached to.
  18633. */
  18634. camera: FreeCamera;
  18635. /**
  18636. * Defines the buttons associated with the input to handle camera move.
  18637. */
  18638. buttons: number[];
  18639. /**
  18640. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18641. */
  18642. angularSensibility: number;
  18643. private _pointerInput;
  18644. private _onMouseMove;
  18645. private _observer;
  18646. private previousPosition;
  18647. /**
  18648. * Observable for when a pointer move event occurs containing the move offset
  18649. */
  18650. onPointerMovedObservable: Observable<{
  18651. offsetX: number;
  18652. offsetY: number;
  18653. }>;
  18654. /**
  18655. * @hidden
  18656. * If the camera should be rotated automatically based on pointer movement
  18657. */
  18658. _allowCameraRotation: boolean;
  18659. /**
  18660. * Manage the mouse inputs to control the movement of a free camera.
  18661. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18662. * @param touchEnabled Defines if touch is enabled or not
  18663. */
  18664. constructor(
  18665. /**
  18666. * Define if touch is enabled in the mouse input
  18667. */
  18668. touchEnabled?: boolean);
  18669. /**
  18670. * Attach the input controls to a specific dom element to get the input from.
  18671. * @param element Defines the element the controls should be listened from
  18672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18673. */
  18674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18675. /**
  18676. * Called on JS contextmenu event.
  18677. * Override this method to provide functionality.
  18678. */
  18679. protected onContextMenu(evt: PointerEvent): void;
  18680. /**
  18681. * Detach the current controls from the specified dom element.
  18682. * @param element Defines the element to stop listening the inputs from
  18683. */
  18684. detachControl(element: Nullable<HTMLElement>): void;
  18685. /**
  18686. * Gets the class name of the current intput.
  18687. * @returns the class name
  18688. */
  18689. getClassName(): string;
  18690. /**
  18691. * Get the friendly name associated with the input class.
  18692. * @returns the input friendly name
  18693. */
  18694. getSimpleName(): string;
  18695. }
  18696. }
  18697. declare module BABYLON {
  18698. /**
  18699. * Manage the touch inputs to control the movement of a free camera.
  18700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18701. */
  18702. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18703. /**
  18704. * Defines the camera the input is attached to.
  18705. */
  18706. camera: FreeCamera;
  18707. /**
  18708. * Defines the touch sensibility for rotation.
  18709. * The higher the faster.
  18710. */
  18711. touchAngularSensibility: number;
  18712. /**
  18713. * Defines the touch sensibility for move.
  18714. * The higher the faster.
  18715. */
  18716. touchMoveSensibility: number;
  18717. private _offsetX;
  18718. private _offsetY;
  18719. private _pointerPressed;
  18720. private _pointerInput;
  18721. private _observer;
  18722. private _onLostFocus;
  18723. /**
  18724. * Attach the input controls to a specific dom element to get the input from.
  18725. * @param element Defines the element the controls should be listened from
  18726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18727. */
  18728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18729. /**
  18730. * Detach the current controls from the specified dom element.
  18731. * @param element Defines the element to stop listening the inputs from
  18732. */
  18733. detachControl(element: Nullable<HTMLElement>): void;
  18734. /**
  18735. * Update the current camera state depending on the inputs that have been used this frame.
  18736. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18737. */
  18738. checkInputs(): void;
  18739. /**
  18740. * Gets the class name of the current intput.
  18741. * @returns the class name
  18742. */
  18743. getClassName(): string;
  18744. /**
  18745. * Get the friendly name associated with the input class.
  18746. * @returns the input friendly name
  18747. */
  18748. getSimpleName(): string;
  18749. }
  18750. }
  18751. declare module BABYLON {
  18752. /**
  18753. * Default Inputs manager for the FreeCamera.
  18754. * It groups all the default supported inputs for ease of use.
  18755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18756. */
  18757. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18758. /**
  18759. * @hidden
  18760. */
  18761. _mouseInput: Nullable<FreeCameraMouseInput>;
  18762. /**
  18763. * Instantiates a new FreeCameraInputsManager.
  18764. * @param camera Defines the camera the inputs belong to
  18765. */
  18766. constructor(camera: FreeCamera);
  18767. /**
  18768. * Add keyboard input support to the input manager.
  18769. * @returns the current input manager
  18770. */
  18771. addKeyboard(): FreeCameraInputsManager;
  18772. /**
  18773. * Add mouse input support to the input manager.
  18774. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18775. * @returns the current input manager
  18776. */
  18777. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18778. /**
  18779. * Removes the mouse input support from the manager
  18780. * @returns the current input manager
  18781. */
  18782. removeMouse(): FreeCameraInputsManager;
  18783. /**
  18784. * Add touch input support to the input manager.
  18785. * @returns the current input manager
  18786. */
  18787. addTouch(): FreeCameraInputsManager;
  18788. /**
  18789. * Remove all attached input methods from a camera
  18790. */
  18791. clear(): void;
  18792. }
  18793. }
  18794. declare module BABYLON {
  18795. /**
  18796. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18797. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18798. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18799. */
  18800. export class FreeCamera extends TargetCamera {
  18801. /**
  18802. * Define the collision ellipsoid of the camera.
  18803. * This is helpful to simulate a camera body like the player body around the camera
  18804. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18805. */
  18806. ellipsoid: Vector3;
  18807. /**
  18808. * Define an offset for the position of the ellipsoid around the camera.
  18809. * This can be helpful to determine the center of the body near the gravity center of the body
  18810. * instead of its head.
  18811. */
  18812. ellipsoidOffset: Vector3;
  18813. /**
  18814. * Enable or disable collisions of the camera with the rest of the scene objects.
  18815. */
  18816. checkCollisions: boolean;
  18817. /**
  18818. * Enable or disable gravity on the camera.
  18819. */
  18820. applyGravity: boolean;
  18821. /**
  18822. * Define the input manager associated to the camera.
  18823. */
  18824. inputs: FreeCameraInputsManager;
  18825. /**
  18826. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18827. * Higher values reduce sensitivity.
  18828. */
  18829. get angularSensibility(): number;
  18830. /**
  18831. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18832. * Higher values reduce sensitivity.
  18833. */
  18834. set angularSensibility(value: number);
  18835. /**
  18836. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18837. */
  18838. get keysUp(): number[];
  18839. set keysUp(value: number[]);
  18840. /**
  18841. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18842. */
  18843. get keysUpward(): number[];
  18844. set keysUpward(value: number[]);
  18845. /**
  18846. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18847. */
  18848. get keysDown(): number[];
  18849. set keysDown(value: number[]);
  18850. /**
  18851. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18852. */
  18853. get keysDownward(): number[];
  18854. set keysDownward(value: number[]);
  18855. /**
  18856. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18857. */
  18858. get keysLeft(): number[];
  18859. set keysLeft(value: number[]);
  18860. /**
  18861. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18862. */
  18863. get keysRight(): number[];
  18864. set keysRight(value: number[]);
  18865. /**
  18866. * Event raised when the camera collide with a mesh in the scene.
  18867. */
  18868. onCollide: (collidedMesh: AbstractMesh) => void;
  18869. private _collider;
  18870. private _needMoveForGravity;
  18871. private _oldPosition;
  18872. private _diffPosition;
  18873. private _newPosition;
  18874. /** @hidden */
  18875. _localDirection: Vector3;
  18876. /** @hidden */
  18877. _transformedDirection: Vector3;
  18878. /**
  18879. * Instantiates a Free Camera.
  18880. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18881. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18883. * @param name Define the name of the camera in the scene
  18884. * @param position Define the start position of the camera in the scene
  18885. * @param scene Define the scene the camera belongs to
  18886. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18887. */
  18888. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18889. /**
  18890. * Attached controls to the current camera.
  18891. * @param element Defines the element the controls should be listened from
  18892. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18893. */
  18894. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18895. /**
  18896. * Detach the current controls from the camera.
  18897. * The camera will stop reacting to inputs.
  18898. * @param element Defines the element to stop listening the inputs from
  18899. */
  18900. detachControl(element: HTMLElement): void;
  18901. private _collisionMask;
  18902. /**
  18903. * Define a collision mask to limit the list of object the camera can collide with
  18904. */
  18905. get collisionMask(): number;
  18906. set collisionMask(mask: number);
  18907. /** @hidden */
  18908. _collideWithWorld(displacement: Vector3): void;
  18909. private _onCollisionPositionChange;
  18910. /** @hidden */
  18911. _checkInputs(): void;
  18912. /** @hidden */
  18913. _decideIfNeedsToMove(): boolean;
  18914. /** @hidden */
  18915. _updatePosition(): void;
  18916. /**
  18917. * Destroy the camera and release the current resources hold by it.
  18918. */
  18919. dispose(): void;
  18920. /**
  18921. * Gets the current object class name.
  18922. * @return the class name
  18923. */
  18924. getClassName(): string;
  18925. }
  18926. }
  18927. declare module BABYLON {
  18928. /**
  18929. * Represents a gamepad control stick position
  18930. */
  18931. export class StickValues {
  18932. /**
  18933. * The x component of the control stick
  18934. */
  18935. x: number;
  18936. /**
  18937. * The y component of the control stick
  18938. */
  18939. y: number;
  18940. /**
  18941. * Initializes the gamepad x and y control stick values
  18942. * @param x The x component of the gamepad control stick value
  18943. * @param y The y component of the gamepad control stick value
  18944. */
  18945. constructor(
  18946. /**
  18947. * The x component of the control stick
  18948. */
  18949. x: number,
  18950. /**
  18951. * The y component of the control stick
  18952. */
  18953. y: number);
  18954. }
  18955. /**
  18956. * An interface which manages callbacks for gamepad button changes
  18957. */
  18958. export interface GamepadButtonChanges {
  18959. /**
  18960. * Called when a gamepad has been changed
  18961. */
  18962. changed: boolean;
  18963. /**
  18964. * Called when a gamepad press event has been triggered
  18965. */
  18966. pressChanged: boolean;
  18967. /**
  18968. * Called when a touch event has been triggered
  18969. */
  18970. touchChanged: boolean;
  18971. /**
  18972. * Called when a value has changed
  18973. */
  18974. valueChanged: boolean;
  18975. }
  18976. /**
  18977. * Represents a gamepad
  18978. */
  18979. export class Gamepad {
  18980. /**
  18981. * The id of the gamepad
  18982. */
  18983. id: string;
  18984. /**
  18985. * The index of the gamepad
  18986. */
  18987. index: number;
  18988. /**
  18989. * The browser gamepad
  18990. */
  18991. browserGamepad: any;
  18992. /**
  18993. * Specifies what type of gamepad this represents
  18994. */
  18995. type: number;
  18996. private _leftStick;
  18997. private _rightStick;
  18998. /** @hidden */
  18999. _isConnected: boolean;
  19000. private _leftStickAxisX;
  19001. private _leftStickAxisY;
  19002. private _rightStickAxisX;
  19003. private _rightStickAxisY;
  19004. /**
  19005. * Triggered when the left control stick has been changed
  19006. */
  19007. private _onleftstickchanged;
  19008. /**
  19009. * Triggered when the right control stick has been changed
  19010. */
  19011. private _onrightstickchanged;
  19012. /**
  19013. * Represents a gamepad controller
  19014. */
  19015. static GAMEPAD: number;
  19016. /**
  19017. * Represents a generic controller
  19018. */
  19019. static GENERIC: number;
  19020. /**
  19021. * Represents an XBox controller
  19022. */
  19023. static XBOX: number;
  19024. /**
  19025. * Represents a pose-enabled controller
  19026. */
  19027. static POSE_ENABLED: number;
  19028. /**
  19029. * Represents an Dual Shock controller
  19030. */
  19031. static DUALSHOCK: number;
  19032. /**
  19033. * Specifies whether the left control stick should be Y-inverted
  19034. */
  19035. protected _invertLeftStickY: boolean;
  19036. /**
  19037. * Specifies if the gamepad has been connected
  19038. */
  19039. get isConnected(): boolean;
  19040. /**
  19041. * Initializes the gamepad
  19042. * @param id The id of the gamepad
  19043. * @param index The index of the gamepad
  19044. * @param browserGamepad The browser gamepad
  19045. * @param leftStickX The x component of the left joystick
  19046. * @param leftStickY The y component of the left joystick
  19047. * @param rightStickX The x component of the right joystick
  19048. * @param rightStickY The y component of the right joystick
  19049. */
  19050. constructor(
  19051. /**
  19052. * The id of the gamepad
  19053. */
  19054. id: string,
  19055. /**
  19056. * The index of the gamepad
  19057. */
  19058. index: number,
  19059. /**
  19060. * The browser gamepad
  19061. */
  19062. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19063. /**
  19064. * Callback triggered when the left joystick has changed
  19065. * @param callback
  19066. */
  19067. onleftstickchanged(callback: (values: StickValues) => void): void;
  19068. /**
  19069. * Callback triggered when the right joystick has changed
  19070. * @param callback
  19071. */
  19072. onrightstickchanged(callback: (values: StickValues) => void): void;
  19073. /**
  19074. * Gets the left joystick
  19075. */
  19076. get leftStick(): StickValues;
  19077. /**
  19078. * Sets the left joystick values
  19079. */
  19080. set leftStick(newValues: StickValues);
  19081. /**
  19082. * Gets the right joystick
  19083. */
  19084. get rightStick(): StickValues;
  19085. /**
  19086. * Sets the right joystick value
  19087. */
  19088. set rightStick(newValues: StickValues);
  19089. /**
  19090. * Updates the gamepad joystick positions
  19091. */
  19092. update(): void;
  19093. /**
  19094. * Disposes the gamepad
  19095. */
  19096. dispose(): void;
  19097. }
  19098. /**
  19099. * Represents a generic gamepad
  19100. */
  19101. export class GenericPad extends Gamepad {
  19102. private _buttons;
  19103. private _onbuttondown;
  19104. private _onbuttonup;
  19105. /**
  19106. * Observable triggered when a button has been pressed
  19107. */
  19108. onButtonDownObservable: Observable<number>;
  19109. /**
  19110. * Observable triggered when a button has been released
  19111. */
  19112. onButtonUpObservable: Observable<number>;
  19113. /**
  19114. * Callback triggered when a button has been pressed
  19115. * @param callback Called when a button has been pressed
  19116. */
  19117. onbuttondown(callback: (buttonPressed: number) => void): void;
  19118. /**
  19119. * Callback triggered when a button has been released
  19120. * @param callback Called when a button has been released
  19121. */
  19122. onbuttonup(callback: (buttonReleased: number) => void): void;
  19123. /**
  19124. * Initializes the generic gamepad
  19125. * @param id The id of the generic gamepad
  19126. * @param index The index of the generic gamepad
  19127. * @param browserGamepad The browser gamepad
  19128. */
  19129. constructor(id: string, index: number, browserGamepad: any);
  19130. private _setButtonValue;
  19131. /**
  19132. * Updates the generic gamepad
  19133. */
  19134. update(): void;
  19135. /**
  19136. * Disposes the generic gamepad
  19137. */
  19138. dispose(): void;
  19139. }
  19140. }
  19141. declare module BABYLON {
  19142. /**
  19143. * Defines the types of pose enabled controllers that are supported
  19144. */
  19145. export enum PoseEnabledControllerType {
  19146. /**
  19147. * HTC Vive
  19148. */
  19149. VIVE = 0,
  19150. /**
  19151. * Oculus Rift
  19152. */
  19153. OCULUS = 1,
  19154. /**
  19155. * Windows mixed reality
  19156. */
  19157. WINDOWS = 2,
  19158. /**
  19159. * Samsung gear VR
  19160. */
  19161. GEAR_VR = 3,
  19162. /**
  19163. * Google Daydream
  19164. */
  19165. DAYDREAM = 4,
  19166. /**
  19167. * Generic
  19168. */
  19169. GENERIC = 5
  19170. }
  19171. /**
  19172. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19173. */
  19174. export interface MutableGamepadButton {
  19175. /**
  19176. * Value of the button/trigger
  19177. */
  19178. value: number;
  19179. /**
  19180. * If the button/trigger is currently touched
  19181. */
  19182. touched: boolean;
  19183. /**
  19184. * If the button/trigger is currently pressed
  19185. */
  19186. pressed: boolean;
  19187. }
  19188. /**
  19189. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19190. * @hidden
  19191. */
  19192. export interface ExtendedGamepadButton extends GamepadButton {
  19193. /**
  19194. * If the button/trigger is currently pressed
  19195. */
  19196. readonly pressed: boolean;
  19197. /**
  19198. * If the button/trigger is currently touched
  19199. */
  19200. readonly touched: boolean;
  19201. /**
  19202. * Value of the button/trigger
  19203. */
  19204. readonly value: number;
  19205. }
  19206. /** @hidden */
  19207. export interface _GamePadFactory {
  19208. /**
  19209. * Returns whether or not the current gamepad can be created for this type of controller.
  19210. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19211. * @returns true if it can be created, otherwise false
  19212. */
  19213. canCreate(gamepadInfo: any): boolean;
  19214. /**
  19215. * Creates a new instance of the Gamepad.
  19216. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19217. * @returns the new gamepad instance
  19218. */
  19219. create(gamepadInfo: any): Gamepad;
  19220. }
  19221. /**
  19222. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19223. */
  19224. export class PoseEnabledControllerHelper {
  19225. /** @hidden */
  19226. static _ControllerFactories: _GamePadFactory[];
  19227. /** @hidden */
  19228. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19229. /**
  19230. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19231. * @param vrGamepad the gamepad to initialized
  19232. * @returns a vr controller of the type the gamepad identified as
  19233. */
  19234. static InitiateController(vrGamepad: any): Gamepad;
  19235. }
  19236. /**
  19237. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19238. */
  19239. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19240. /**
  19241. * If the controller is used in a webXR session
  19242. */
  19243. isXR: boolean;
  19244. private _deviceRoomPosition;
  19245. private _deviceRoomRotationQuaternion;
  19246. /**
  19247. * The device position in babylon space
  19248. */
  19249. devicePosition: Vector3;
  19250. /**
  19251. * The device rotation in babylon space
  19252. */
  19253. deviceRotationQuaternion: Quaternion;
  19254. /**
  19255. * The scale factor of the device in babylon space
  19256. */
  19257. deviceScaleFactor: number;
  19258. /**
  19259. * (Likely devicePosition should be used instead) The device position in its room space
  19260. */
  19261. position: Vector3;
  19262. /**
  19263. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19264. */
  19265. rotationQuaternion: Quaternion;
  19266. /**
  19267. * The type of controller (Eg. Windows mixed reality)
  19268. */
  19269. controllerType: PoseEnabledControllerType;
  19270. protected _calculatedPosition: Vector3;
  19271. private _calculatedRotation;
  19272. /**
  19273. * The raw pose from the device
  19274. */
  19275. rawPose: DevicePose;
  19276. private _trackPosition;
  19277. private _maxRotationDistFromHeadset;
  19278. private _draggedRoomRotation;
  19279. /**
  19280. * @hidden
  19281. */
  19282. _disableTrackPosition(fixedPosition: Vector3): void;
  19283. /**
  19284. * Internal, the mesh attached to the controller
  19285. * @hidden
  19286. */
  19287. _mesh: Nullable<AbstractMesh>;
  19288. private _poseControlledCamera;
  19289. private _leftHandSystemQuaternion;
  19290. /**
  19291. * Internal, matrix used to convert room space to babylon space
  19292. * @hidden
  19293. */
  19294. _deviceToWorld: Matrix;
  19295. /**
  19296. * Node to be used when casting a ray from the controller
  19297. * @hidden
  19298. */
  19299. _pointingPoseNode: Nullable<TransformNode>;
  19300. /**
  19301. * Name of the child mesh that can be used to cast a ray from the controller
  19302. */
  19303. static readonly POINTING_POSE: string;
  19304. /**
  19305. * Creates a new PoseEnabledController from a gamepad
  19306. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19307. */
  19308. constructor(browserGamepad: any);
  19309. private _workingMatrix;
  19310. /**
  19311. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19312. */
  19313. update(): void;
  19314. /**
  19315. * Updates only the pose device and mesh without doing any button event checking
  19316. */
  19317. protected _updatePoseAndMesh(): void;
  19318. /**
  19319. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19320. * @param poseData raw pose fromthe device
  19321. */
  19322. updateFromDevice(poseData: DevicePose): void;
  19323. /**
  19324. * @hidden
  19325. */
  19326. _meshAttachedObservable: Observable<AbstractMesh>;
  19327. /**
  19328. * Attaches a mesh to the controller
  19329. * @param mesh the mesh to be attached
  19330. */
  19331. attachToMesh(mesh: AbstractMesh): void;
  19332. /**
  19333. * Attaches the controllers mesh to a camera
  19334. * @param camera the camera the mesh should be attached to
  19335. */
  19336. attachToPoseControlledCamera(camera: TargetCamera): void;
  19337. /**
  19338. * Disposes of the controller
  19339. */
  19340. dispose(): void;
  19341. /**
  19342. * The mesh that is attached to the controller
  19343. */
  19344. get mesh(): Nullable<AbstractMesh>;
  19345. /**
  19346. * Gets the ray of the controller in the direction the controller is pointing
  19347. * @param length the length the resulting ray should be
  19348. * @returns a ray in the direction the controller is pointing
  19349. */
  19350. getForwardRay(length?: number): Ray;
  19351. }
  19352. }
  19353. declare module BABYLON {
  19354. /**
  19355. * Defines the WebVRController object that represents controllers tracked in 3D space
  19356. */
  19357. export abstract class WebVRController extends PoseEnabledController {
  19358. /**
  19359. * Internal, the default controller model for the controller
  19360. */
  19361. protected _defaultModel: Nullable<AbstractMesh>;
  19362. /**
  19363. * Fired when the trigger state has changed
  19364. */
  19365. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19366. /**
  19367. * Fired when the main button state has changed
  19368. */
  19369. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19370. /**
  19371. * Fired when the secondary button state has changed
  19372. */
  19373. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19374. /**
  19375. * Fired when the pad state has changed
  19376. */
  19377. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19378. /**
  19379. * Fired when controllers stick values have changed
  19380. */
  19381. onPadValuesChangedObservable: Observable<StickValues>;
  19382. /**
  19383. * Array of button availible on the controller
  19384. */
  19385. protected _buttons: Array<MutableGamepadButton>;
  19386. private _onButtonStateChange;
  19387. /**
  19388. * Fired when a controller button's state has changed
  19389. * @param callback the callback containing the button that was modified
  19390. */
  19391. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19392. /**
  19393. * X and Y axis corresponding to the controllers joystick
  19394. */
  19395. pad: StickValues;
  19396. /**
  19397. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19398. */
  19399. hand: string;
  19400. /**
  19401. * The default controller model for the controller
  19402. */
  19403. get defaultModel(): Nullable<AbstractMesh>;
  19404. /**
  19405. * Creates a new WebVRController from a gamepad
  19406. * @param vrGamepad the gamepad that the WebVRController should be created from
  19407. */
  19408. constructor(vrGamepad: any);
  19409. /**
  19410. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19411. */
  19412. update(): void;
  19413. /**
  19414. * Function to be called when a button is modified
  19415. */
  19416. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19417. /**
  19418. * Loads a mesh and attaches it to the controller
  19419. * @param scene the scene the mesh should be added to
  19420. * @param meshLoaded callback for when the mesh has been loaded
  19421. */
  19422. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19423. private _setButtonValue;
  19424. private _changes;
  19425. private _checkChanges;
  19426. /**
  19427. * Disposes of th webVRCOntroller
  19428. */
  19429. dispose(): void;
  19430. }
  19431. }
  19432. declare module BABYLON {
  19433. /**
  19434. * The HemisphericLight simulates the ambient environment light,
  19435. * so the passed direction is the light reflection direction, not the incoming direction.
  19436. */
  19437. export class HemisphericLight extends Light {
  19438. /**
  19439. * The groundColor is the light in the opposite direction to the one specified during creation.
  19440. * 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.
  19441. */
  19442. groundColor: Color3;
  19443. /**
  19444. * The light reflection direction, not the incoming direction.
  19445. */
  19446. direction: Vector3;
  19447. /**
  19448. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19449. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19450. * The HemisphericLight can't cast shadows.
  19451. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19452. * @param name The friendly name of the light
  19453. * @param direction The direction of the light reflection
  19454. * @param scene The scene the light belongs to
  19455. */
  19456. constructor(name: string, direction: Vector3, scene: Scene);
  19457. protected _buildUniformLayout(): void;
  19458. /**
  19459. * Returns the string "HemisphericLight".
  19460. * @return The class name
  19461. */
  19462. getClassName(): string;
  19463. /**
  19464. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19465. * Returns the updated direction.
  19466. * @param target The target the direction should point to
  19467. * @return The computed direction
  19468. */
  19469. setDirectionToTarget(target: Vector3): Vector3;
  19470. /**
  19471. * Returns the shadow generator associated to the light.
  19472. * @returns Always null for hemispheric lights because it does not support shadows.
  19473. */
  19474. getShadowGenerator(): Nullable<IShadowGenerator>;
  19475. /**
  19476. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19477. * @param effect The effect to update
  19478. * @param lightIndex The index of the light in the effect to update
  19479. * @returns The hemispheric light
  19480. */
  19481. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19482. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19483. /**
  19484. * Computes the world matrix of the node
  19485. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19486. * @param useWasUpdatedFlag defines a reserved property
  19487. * @returns the world matrix
  19488. */
  19489. computeWorldMatrix(): Matrix;
  19490. /**
  19491. * Returns the integer 3.
  19492. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19493. */
  19494. getTypeID(): number;
  19495. /**
  19496. * Prepares the list of defines specific to the light type.
  19497. * @param defines the list of defines
  19498. * @param lightIndex defines the index of the light for the effect
  19499. */
  19500. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19501. }
  19502. }
  19503. declare module BABYLON {
  19504. /** @hidden */
  19505. export var vrMultiviewToSingleviewPixelShader: {
  19506. name: string;
  19507. shader: string;
  19508. };
  19509. }
  19510. declare module BABYLON {
  19511. /**
  19512. * Renders to multiple views with a single draw call
  19513. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19514. */
  19515. export class MultiviewRenderTarget extends RenderTargetTexture {
  19516. /**
  19517. * Creates a multiview render target
  19518. * @param scene scene used with the render target
  19519. * @param size the size of the render target (used for each view)
  19520. */
  19521. constructor(scene: Scene, size?: number | {
  19522. width: number;
  19523. height: number;
  19524. } | {
  19525. ratio: number;
  19526. });
  19527. /**
  19528. * @hidden
  19529. * @param faceIndex the face index, if its a cube texture
  19530. */
  19531. _bindFrameBuffer(faceIndex?: number): void;
  19532. /**
  19533. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19534. * @returns the view count
  19535. */
  19536. getViewCount(): number;
  19537. }
  19538. }
  19539. declare module BABYLON {
  19540. interface Engine {
  19541. /**
  19542. * Creates a new multiview render target
  19543. * @param width defines the width of the texture
  19544. * @param height defines the height of the texture
  19545. * @returns the created multiview texture
  19546. */
  19547. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19548. /**
  19549. * Binds a multiview framebuffer to be drawn to
  19550. * @param multiviewTexture texture to bind
  19551. */
  19552. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19553. }
  19554. interface Camera {
  19555. /**
  19556. * @hidden
  19557. * 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)
  19558. */
  19559. _useMultiviewToSingleView: boolean;
  19560. /**
  19561. * @hidden
  19562. * 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)
  19563. */
  19564. _multiviewTexture: Nullable<RenderTargetTexture>;
  19565. /**
  19566. * @hidden
  19567. * ensures the multiview texture of the camera exists and has the specified width/height
  19568. * @param width height to set on the multiview texture
  19569. * @param height width to set on the multiview texture
  19570. */
  19571. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19572. }
  19573. interface Scene {
  19574. /** @hidden */
  19575. _transformMatrixR: Matrix;
  19576. /** @hidden */
  19577. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19578. /** @hidden */
  19579. _createMultiviewUbo(): void;
  19580. /** @hidden */
  19581. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19582. /** @hidden */
  19583. _renderMultiviewToSingleView(camera: Camera): void;
  19584. }
  19585. }
  19586. declare module BABYLON {
  19587. /**
  19588. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19589. * This will not be used for webXR as it supports displaying texture arrays directly
  19590. */
  19591. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19592. /**
  19593. * Initializes a VRMultiviewToSingleview
  19594. * @param name name of the post process
  19595. * @param camera camera to be applied to
  19596. * @param scaleFactor scaling factor to the size of the output texture
  19597. */
  19598. constructor(name: string, camera: Camera, scaleFactor: number);
  19599. }
  19600. }
  19601. declare module BABYLON {
  19602. /**
  19603. * Interface used to define additional presentation attributes
  19604. */
  19605. export interface IVRPresentationAttributes {
  19606. /**
  19607. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19608. */
  19609. highRefreshRate: boolean;
  19610. /**
  19611. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19612. */
  19613. foveationLevel: number;
  19614. }
  19615. interface Engine {
  19616. /** @hidden */
  19617. _vrDisplay: any;
  19618. /** @hidden */
  19619. _vrSupported: boolean;
  19620. /** @hidden */
  19621. _oldSize: Size;
  19622. /** @hidden */
  19623. _oldHardwareScaleFactor: number;
  19624. /** @hidden */
  19625. _vrExclusivePointerMode: boolean;
  19626. /** @hidden */
  19627. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19628. /** @hidden */
  19629. _onVRDisplayPointerRestricted: () => void;
  19630. /** @hidden */
  19631. _onVRDisplayPointerUnrestricted: () => void;
  19632. /** @hidden */
  19633. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19634. /** @hidden */
  19635. _onVrDisplayDisconnect: Nullable<() => void>;
  19636. /** @hidden */
  19637. _onVrDisplayPresentChange: Nullable<() => void>;
  19638. /**
  19639. * Observable signaled when VR display mode changes
  19640. */
  19641. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19642. /**
  19643. * Observable signaled when VR request present is complete
  19644. */
  19645. onVRRequestPresentComplete: Observable<boolean>;
  19646. /**
  19647. * Observable signaled when VR request present starts
  19648. */
  19649. onVRRequestPresentStart: Observable<Engine>;
  19650. /**
  19651. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19652. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19653. */
  19654. isInVRExclusivePointerMode: boolean;
  19655. /**
  19656. * Gets a boolean indicating if a webVR device was detected
  19657. * @returns true if a webVR device was detected
  19658. */
  19659. isVRDevicePresent(): boolean;
  19660. /**
  19661. * Gets the current webVR device
  19662. * @returns the current webVR device (or null)
  19663. */
  19664. getVRDevice(): any;
  19665. /**
  19666. * Initializes a webVR display and starts listening to display change events
  19667. * The onVRDisplayChangedObservable will be notified upon these changes
  19668. * @returns A promise containing a VRDisplay and if vr is supported
  19669. */
  19670. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19671. /** @hidden */
  19672. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19673. /**
  19674. * Gets or sets the presentation attributes used to configure VR rendering
  19675. */
  19676. vrPresentationAttributes?: IVRPresentationAttributes;
  19677. /**
  19678. * Call this function to switch to webVR mode
  19679. * Will do nothing if webVR is not supported or if there is no webVR device
  19680. * @param options the webvr options provided to the camera. mainly used for multiview
  19681. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19682. */
  19683. enableVR(options: WebVROptions): void;
  19684. /** @hidden */
  19685. _onVRFullScreenTriggered(): void;
  19686. }
  19687. }
  19688. declare module BABYLON {
  19689. /**
  19690. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19691. * IMPORTANT!! The data is right-hand data.
  19692. * @export
  19693. * @interface DevicePose
  19694. */
  19695. export interface DevicePose {
  19696. /**
  19697. * The position of the device, values in array are [x,y,z].
  19698. */
  19699. readonly position: Nullable<Float32Array>;
  19700. /**
  19701. * The linearVelocity of the device, values in array are [x,y,z].
  19702. */
  19703. readonly linearVelocity: Nullable<Float32Array>;
  19704. /**
  19705. * The linearAcceleration of the device, values in array are [x,y,z].
  19706. */
  19707. readonly linearAcceleration: Nullable<Float32Array>;
  19708. /**
  19709. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19710. */
  19711. readonly orientation: Nullable<Float32Array>;
  19712. /**
  19713. * The angularVelocity of the device, values in array are [x,y,z].
  19714. */
  19715. readonly angularVelocity: Nullable<Float32Array>;
  19716. /**
  19717. * The angularAcceleration of the device, values in array are [x,y,z].
  19718. */
  19719. readonly angularAcceleration: Nullable<Float32Array>;
  19720. }
  19721. /**
  19722. * Interface representing a pose controlled object in Babylon.
  19723. * A pose controlled object has both regular pose values as well as pose values
  19724. * from an external device such as a VR head mounted display
  19725. */
  19726. export interface PoseControlled {
  19727. /**
  19728. * The position of the object in babylon space.
  19729. */
  19730. position: Vector3;
  19731. /**
  19732. * The rotation quaternion of the object in babylon space.
  19733. */
  19734. rotationQuaternion: Quaternion;
  19735. /**
  19736. * The position of the device in babylon space.
  19737. */
  19738. devicePosition?: Vector3;
  19739. /**
  19740. * The rotation quaternion of the device in babylon space.
  19741. */
  19742. deviceRotationQuaternion: Quaternion;
  19743. /**
  19744. * The raw pose coming from the device.
  19745. */
  19746. rawPose: Nullable<DevicePose>;
  19747. /**
  19748. * The scale of the device to be used when translating from device space to babylon space.
  19749. */
  19750. deviceScaleFactor: number;
  19751. /**
  19752. * Updates the poseControlled values based on the input device pose.
  19753. * @param poseData the pose data to update the object with
  19754. */
  19755. updateFromDevice(poseData: DevicePose): void;
  19756. }
  19757. /**
  19758. * Set of options to customize the webVRCamera
  19759. */
  19760. export interface WebVROptions {
  19761. /**
  19762. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19763. */
  19764. trackPosition?: boolean;
  19765. /**
  19766. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19767. */
  19768. positionScale?: number;
  19769. /**
  19770. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19771. */
  19772. displayName?: string;
  19773. /**
  19774. * Should the native controller meshes be initialized. (default: true)
  19775. */
  19776. controllerMeshes?: boolean;
  19777. /**
  19778. * Creating a default HemiLight only on controllers. (default: true)
  19779. */
  19780. defaultLightingOnControllers?: boolean;
  19781. /**
  19782. * If you don't want to use the default VR button of the helper. (default: false)
  19783. */
  19784. useCustomVRButton?: boolean;
  19785. /**
  19786. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19787. */
  19788. customVRButton?: HTMLButtonElement;
  19789. /**
  19790. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19791. */
  19792. rayLength?: number;
  19793. /**
  19794. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19795. */
  19796. defaultHeight?: number;
  19797. /**
  19798. * If multiview should be used if availible (default: false)
  19799. */
  19800. useMultiview?: boolean;
  19801. }
  19802. /**
  19803. * This represents a WebVR camera.
  19804. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19805. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19806. */
  19807. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19808. private webVROptions;
  19809. /**
  19810. * @hidden
  19811. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19812. */
  19813. _vrDevice: any;
  19814. /**
  19815. * The rawPose of the vrDevice.
  19816. */
  19817. rawPose: Nullable<DevicePose>;
  19818. private _onVREnabled;
  19819. private _specsVersion;
  19820. private _attached;
  19821. private _frameData;
  19822. protected _descendants: Array<Node>;
  19823. private _deviceRoomPosition;
  19824. /** @hidden */
  19825. _deviceRoomRotationQuaternion: Quaternion;
  19826. private _standingMatrix;
  19827. /**
  19828. * Represents device position in babylon space.
  19829. */
  19830. devicePosition: Vector3;
  19831. /**
  19832. * Represents device rotation in babylon space.
  19833. */
  19834. deviceRotationQuaternion: Quaternion;
  19835. /**
  19836. * The scale of the device to be used when translating from device space to babylon space.
  19837. */
  19838. deviceScaleFactor: number;
  19839. private _deviceToWorld;
  19840. private _worldToDevice;
  19841. /**
  19842. * References to the webVR controllers for the vrDevice.
  19843. */
  19844. controllers: Array<WebVRController>;
  19845. /**
  19846. * Emits an event when a controller is attached.
  19847. */
  19848. onControllersAttachedObservable: Observable<WebVRController[]>;
  19849. /**
  19850. * Emits an event when a controller's mesh has been loaded;
  19851. */
  19852. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19853. /**
  19854. * Emits an event when the HMD's pose has been updated.
  19855. */
  19856. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19857. private _poseSet;
  19858. /**
  19859. * If the rig cameras be used as parent instead of this camera.
  19860. */
  19861. rigParenting: boolean;
  19862. private _lightOnControllers;
  19863. private _defaultHeight?;
  19864. /**
  19865. * Instantiates a WebVRFreeCamera.
  19866. * @param name The name of the WebVRFreeCamera
  19867. * @param position The starting anchor position for the camera
  19868. * @param scene The scene the camera belongs to
  19869. * @param webVROptions a set of customizable options for the webVRCamera
  19870. */
  19871. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19872. /**
  19873. * Gets the device distance from the ground in meters.
  19874. * @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.
  19875. */
  19876. deviceDistanceToRoomGround(): number;
  19877. /**
  19878. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19879. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19880. */
  19881. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19882. /**
  19883. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19884. * @returns A promise with a boolean set to if the standing matrix is supported.
  19885. */
  19886. useStandingMatrixAsync(): Promise<boolean>;
  19887. /**
  19888. * Disposes the camera
  19889. */
  19890. dispose(): void;
  19891. /**
  19892. * Gets a vrController by name.
  19893. * @param name The name of the controller to retreive
  19894. * @returns the controller matching the name specified or null if not found
  19895. */
  19896. getControllerByName(name: string): Nullable<WebVRController>;
  19897. private _leftController;
  19898. /**
  19899. * The controller corresponding to the users left hand.
  19900. */
  19901. get leftController(): Nullable<WebVRController>;
  19902. private _rightController;
  19903. /**
  19904. * The controller corresponding to the users right hand.
  19905. */
  19906. get rightController(): Nullable<WebVRController>;
  19907. /**
  19908. * Casts a ray forward from the vrCamera's gaze.
  19909. * @param length Length of the ray (default: 100)
  19910. * @returns the ray corresponding to the gaze
  19911. */
  19912. getForwardRay(length?: number): Ray;
  19913. /**
  19914. * @hidden
  19915. * Updates the camera based on device's frame data
  19916. */
  19917. _checkInputs(): void;
  19918. /**
  19919. * Updates the poseControlled values based on the input device pose.
  19920. * @param poseData Pose coming from the device
  19921. */
  19922. updateFromDevice(poseData: DevicePose): void;
  19923. private _htmlElementAttached;
  19924. private _detachIfAttached;
  19925. /**
  19926. * WebVR's attach control will start broadcasting frames to the device.
  19927. * Note that in certain browsers (chrome for example) this function must be called
  19928. * within a user-interaction callback. Example:
  19929. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19930. *
  19931. * @param element html element to attach the vrDevice to
  19932. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19933. */
  19934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19935. /**
  19936. * Detaches the camera from the html element and disables VR
  19937. *
  19938. * @param element html element to detach from
  19939. */
  19940. detachControl(element: HTMLElement): void;
  19941. /**
  19942. * @returns the name of this class
  19943. */
  19944. getClassName(): string;
  19945. /**
  19946. * Calls resetPose on the vrDisplay
  19947. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19948. */
  19949. resetToCurrentRotation(): void;
  19950. /**
  19951. * @hidden
  19952. * Updates the rig cameras (left and right eye)
  19953. */
  19954. _updateRigCameras(): void;
  19955. private _workingVector;
  19956. private _oneVector;
  19957. private _workingMatrix;
  19958. private updateCacheCalled;
  19959. private _correctPositionIfNotTrackPosition;
  19960. /**
  19961. * @hidden
  19962. * Updates the cached values of the camera
  19963. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19964. */
  19965. _updateCache(ignoreParentClass?: boolean): void;
  19966. /**
  19967. * @hidden
  19968. * Get current device position in babylon world
  19969. */
  19970. _computeDevicePosition(): void;
  19971. /**
  19972. * Updates the current device position and rotation in the babylon world
  19973. */
  19974. update(): void;
  19975. /**
  19976. * @hidden
  19977. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19978. * @returns an identity matrix
  19979. */
  19980. _getViewMatrix(): Matrix;
  19981. private _tmpMatrix;
  19982. /**
  19983. * This function is called by the two RIG cameras.
  19984. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19985. * @hidden
  19986. */
  19987. _getWebVRViewMatrix(): Matrix;
  19988. /** @hidden */
  19989. _getWebVRProjectionMatrix(): Matrix;
  19990. private _onGamepadConnectedObserver;
  19991. private _onGamepadDisconnectedObserver;
  19992. private _updateCacheWhenTrackingDisabledObserver;
  19993. /**
  19994. * Initializes the controllers and their meshes
  19995. */
  19996. initControllers(): void;
  19997. }
  19998. }
  19999. declare module BABYLON {
  20000. /**
  20001. * "Static Class" containing the most commonly used helper while dealing with material for
  20002. * rendering purpose.
  20003. *
  20004. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20005. *
  20006. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20007. */
  20008. export class MaterialHelper {
  20009. /**
  20010. * Bind the current view position to an effect.
  20011. * @param effect The effect to be bound
  20012. * @param scene The scene the eyes position is used from
  20013. * @param variableName name of the shader variable that will hold the eye position
  20014. */
  20015. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20016. /**
  20017. * Helps preparing the defines values about the UVs in used in the effect.
  20018. * UVs are shared as much as we can accross channels in the shaders.
  20019. * @param texture The texture we are preparing the UVs for
  20020. * @param defines The defines to update
  20021. * @param key The channel key "diffuse", "specular"... used in the shader
  20022. */
  20023. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20024. /**
  20025. * Binds a texture matrix value to its corrsponding uniform
  20026. * @param texture The texture to bind the matrix for
  20027. * @param uniformBuffer The uniform buffer receivin the data
  20028. * @param key The channel key "diffuse", "specular"... used in the shader
  20029. */
  20030. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20031. /**
  20032. * Gets the current status of the fog (should it be enabled?)
  20033. * @param mesh defines the mesh to evaluate for fog support
  20034. * @param scene defines the hosting scene
  20035. * @returns true if fog must be enabled
  20036. */
  20037. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20038. /**
  20039. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20040. * @param mesh defines the current mesh
  20041. * @param scene defines the current scene
  20042. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20043. * @param pointsCloud defines if point cloud rendering has to be turned on
  20044. * @param fogEnabled defines if fog has to be turned on
  20045. * @param alphaTest defines if alpha testing has to be turned on
  20046. * @param defines defines the current list of defines
  20047. */
  20048. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20049. /**
  20050. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20051. * @param scene defines the current scene
  20052. * @param engine defines the current engine
  20053. * @param defines specifies the list of active defines
  20054. * @param useInstances defines if instances have to be turned on
  20055. * @param useClipPlane defines if clip plane have to be turned on
  20056. * @param useInstances defines if instances have to be turned on
  20057. * @param useThinInstances defines if thin instances have to be turned on
  20058. */
  20059. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20060. /**
  20061. * Prepares the defines for bones
  20062. * @param mesh The mesh containing the geometry data we will draw
  20063. * @param defines The defines to update
  20064. */
  20065. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20066. /**
  20067. * Prepares the defines for morph targets
  20068. * @param mesh The mesh containing the geometry data we will draw
  20069. * @param defines The defines to update
  20070. */
  20071. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20072. /**
  20073. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20074. * @param mesh The mesh containing the geometry data we will draw
  20075. * @param defines The defines to update
  20076. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20077. * @param useBones Precise whether bones should be used or not (override mesh info)
  20078. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20079. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20080. * @returns false if defines are considered not dirty and have not been checked
  20081. */
  20082. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20083. /**
  20084. * Prepares the defines related to multiview
  20085. * @param scene The scene we are intending to draw
  20086. * @param defines The defines to update
  20087. */
  20088. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20089. /**
  20090. * Prepares the defines related to the light information passed in parameter
  20091. * @param scene The scene we are intending to draw
  20092. * @param mesh The mesh the effect is compiling for
  20093. * @param light The light the effect is compiling for
  20094. * @param lightIndex The index of the light
  20095. * @param defines The defines to update
  20096. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20097. * @param state Defines the current state regarding what is needed (normals, etc...)
  20098. */
  20099. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20100. needNormals: boolean;
  20101. needRebuild: boolean;
  20102. shadowEnabled: boolean;
  20103. specularEnabled: boolean;
  20104. lightmapMode: boolean;
  20105. }): void;
  20106. /**
  20107. * Prepares the defines related to the light information passed in parameter
  20108. * @param scene The scene we are intending to draw
  20109. * @param mesh The mesh the effect is compiling for
  20110. * @param defines The defines to update
  20111. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20112. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20113. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20114. * @returns true if normals will be required for the rest of the effect
  20115. */
  20116. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20117. /**
  20118. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20119. * @param lightIndex defines the light index
  20120. * @param uniformsList The uniform list
  20121. * @param samplersList The sampler list
  20122. * @param projectedLightTexture defines if projected texture must be used
  20123. * @param uniformBuffersList defines an optional list of uniform buffers
  20124. */
  20125. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20126. /**
  20127. * Prepares the uniforms and samplers list to be used in the effect
  20128. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20129. * @param samplersList The sampler list
  20130. * @param defines The defines helping in the list generation
  20131. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20132. */
  20133. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20134. /**
  20135. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20136. * @param defines The defines to update while falling back
  20137. * @param fallbacks The authorized effect fallbacks
  20138. * @param maxSimultaneousLights The maximum number of lights allowed
  20139. * @param rank the current rank of the Effect
  20140. * @returns The newly affected rank
  20141. */
  20142. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20143. private static _TmpMorphInfluencers;
  20144. /**
  20145. * Prepares the list of attributes required for morph targets according to the effect defines.
  20146. * @param attribs The current list of supported attribs
  20147. * @param mesh The mesh to prepare the morph targets attributes for
  20148. * @param influencers The number of influencers
  20149. */
  20150. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20151. /**
  20152. * Prepares the list of attributes required for morph targets according to the effect defines.
  20153. * @param attribs The current list of supported attribs
  20154. * @param mesh The mesh to prepare the morph targets attributes for
  20155. * @param defines The current Defines of the effect
  20156. */
  20157. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20158. /**
  20159. * Prepares the list of attributes required for bones according to the effect defines.
  20160. * @param attribs The current list of supported attribs
  20161. * @param mesh The mesh to prepare the bones attributes for
  20162. * @param defines The current Defines of the effect
  20163. * @param fallbacks The current efffect fallback strategy
  20164. */
  20165. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20166. /**
  20167. * Check and prepare the list of attributes required for instances according to the effect defines.
  20168. * @param attribs The current list of supported attribs
  20169. * @param defines The current MaterialDefines of the effect
  20170. */
  20171. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20172. /**
  20173. * Add the list of attributes required for instances to the attribs array.
  20174. * @param attribs The current list of supported attribs
  20175. */
  20176. static PushAttributesForInstances(attribs: string[]): void;
  20177. /**
  20178. * Binds the light information to the effect.
  20179. * @param light The light containing the generator
  20180. * @param effect The effect we are binding the data to
  20181. * @param lightIndex The light index in the effect used to render
  20182. */
  20183. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20184. /**
  20185. * Binds the lights information from the scene to the effect for the given mesh.
  20186. * @param light Light to bind
  20187. * @param lightIndex Light index
  20188. * @param scene The scene where the light belongs to
  20189. * @param effect The effect we are binding the data to
  20190. * @param useSpecular Defines if specular is supported
  20191. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20192. */
  20193. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20194. /**
  20195. * Binds the lights information from the scene to the effect for the given mesh.
  20196. * @param scene The scene the lights belongs to
  20197. * @param mesh The mesh we are binding the information to render
  20198. * @param effect The effect we are binding the data to
  20199. * @param defines The generated defines for the effect
  20200. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20201. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20202. */
  20203. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20204. private static _tempFogColor;
  20205. /**
  20206. * Binds the fog information from the scene to the effect for the given mesh.
  20207. * @param scene The scene the lights belongs to
  20208. * @param mesh The mesh we are binding the information to render
  20209. * @param effect The effect we are binding the data to
  20210. * @param linearSpace Defines if the fog effect is applied in linear space
  20211. */
  20212. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20213. /**
  20214. * Binds the bones information from the mesh to the effect.
  20215. * @param mesh The mesh we are binding the information to render
  20216. * @param effect The effect we are binding the data to
  20217. */
  20218. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20219. /**
  20220. * Binds the morph targets information from the mesh to the effect.
  20221. * @param abstractMesh The mesh we are binding the information to render
  20222. * @param effect The effect we are binding the data to
  20223. */
  20224. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20225. /**
  20226. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20227. * @param defines The generated defines used in the effect
  20228. * @param effect The effect we are binding the data to
  20229. * @param scene The scene we are willing to render with logarithmic scale for
  20230. */
  20231. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20232. /**
  20233. * Binds the clip plane information from the scene to the effect.
  20234. * @param scene The scene the clip plane information are extracted from
  20235. * @param effect The effect we are binding the data to
  20236. */
  20237. static BindClipPlane(effect: Effect, scene: Scene): void;
  20238. }
  20239. }
  20240. declare module BABYLON {
  20241. /**
  20242. * Block used to expose an input value
  20243. */
  20244. export class InputBlock extends NodeMaterialBlock {
  20245. private _mode;
  20246. private _associatedVariableName;
  20247. private _storedValue;
  20248. private _valueCallback;
  20249. private _type;
  20250. private _animationType;
  20251. /** Gets or set a value used to limit the range of float values */
  20252. min: number;
  20253. /** Gets or set a value used to limit the range of float values */
  20254. max: number;
  20255. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20256. isBoolean: boolean;
  20257. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20258. matrixMode: number;
  20259. /** @hidden */
  20260. _systemValue: Nullable<NodeMaterialSystemValues>;
  20261. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20262. visibleInInspector: boolean;
  20263. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20264. isConstant: boolean;
  20265. /** Gets or sets the group to use to display this block in the Inspector */
  20266. groupInInspector: string;
  20267. /** Gets an observable raised when the value is changed */
  20268. onValueChangedObservable: Observable<InputBlock>;
  20269. /**
  20270. * Gets or sets the connection point type (default is float)
  20271. */
  20272. get type(): NodeMaterialBlockConnectionPointTypes;
  20273. /**
  20274. * Creates a new InputBlock
  20275. * @param name defines the block name
  20276. * @param target defines the target of that block (Vertex by default)
  20277. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20278. */
  20279. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20280. /**
  20281. * Gets the output component
  20282. */
  20283. get output(): NodeMaterialConnectionPoint;
  20284. /**
  20285. * Set the source of this connection point to a vertex attribute
  20286. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20287. * @returns the current connection point
  20288. */
  20289. setAsAttribute(attributeName?: string): InputBlock;
  20290. /**
  20291. * Set the source of this connection point to a system value
  20292. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20293. * @returns the current connection point
  20294. */
  20295. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20296. /**
  20297. * Gets or sets the value of that point.
  20298. * Please note that this value will be ignored if valueCallback is defined
  20299. */
  20300. get value(): any;
  20301. set value(value: any);
  20302. /**
  20303. * Gets or sets a callback used to get the value of that point.
  20304. * Please note that setting this value will force the connection point to ignore the value property
  20305. */
  20306. get valueCallback(): () => any;
  20307. set valueCallback(value: () => any);
  20308. /**
  20309. * Gets or sets the associated variable name in the shader
  20310. */
  20311. get associatedVariableName(): string;
  20312. set associatedVariableName(value: string);
  20313. /** Gets or sets the type of animation applied to the input */
  20314. get animationType(): AnimatedInputBlockTypes;
  20315. set animationType(value: AnimatedInputBlockTypes);
  20316. /**
  20317. * Gets a boolean indicating that this connection point not defined yet
  20318. */
  20319. get isUndefined(): boolean;
  20320. /**
  20321. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20322. * In this case the connection point name must be the name of the uniform to use.
  20323. * Can only be set on inputs
  20324. */
  20325. get isUniform(): boolean;
  20326. set isUniform(value: boolean);
  20327. /**
  20328. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20329. * In this case the connection point name must be the name of the attribute to use
  20330. * Can only be set on inputs
  20331. */
  20332. get isAttribute(): boolean;
  20333. set isAttribute(value: boolean);
  20334. /**
  20335. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20336. * Can only be set on exit points
  20337. */
  20338. get isVarying(): boolean;
  20339. set isVarying(value: boolean);
  20340. /**
  20341. * Gets a boolean indicating that the current connection point is a system value
  20342. */
  20343. get isSystemValue(): boolean;
  20344. /**
  20345. * Gets or sets the current well known value or null if not defined as a system value
  20346. */
  20347. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20348. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20349. /**
  20350. * Gets the current class name
  20351. * @returns the class name
  20352. */
  20353. getClassName(): string;
  20354. /**
  20355. * Animate the input if animationType !== None
  20356. * @param scene defines the rendering scene
  20357. */
  20358. animate(scene: Scene): void;
  20359. private _emitDefine;
  20360. initialize(state: NodeMaterialBuildState): void;
  20361. /**
  20362. * Set the input block to its default value (based on its type)
  20363. */
  20364. setDefaultValue(): void;
  20365. private _emitConstant;
  20366. /** @hidden */
  20367. get _noContextSwitch(): boolean;
  20368. private _emit;
  20369. /** @hidden */
  20370. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20371. /** @hidden */
  20372. _transmit(effect: Effect, scene: Scene): void;
  20373. protected _buildBlock(state: NodeMaterialBuildState): void;
  20374. protected _dumpPropertiesCode(): string;
  20375. dispose(): void;
  20376. serialize(): any;
  20377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20378. }
  20379. }
  20380. declare module BABYLON {
  20381. /**
  20382. * Enum used to define the compatibility state between two connection points
  20383. */
  20384. export enum NodeMaterialConnectionPointCompatibilityStates {
  20385. /** Points are compatibles */
  20386. Compatible = 0,
  20387. /** Points are incompatible because of their types */
  20388. TypeIncompatible = 1,
  20389. /** Points are incompatible because of their targets (vertex vs fragment) */
  20390. TargetIncompatible = 2
  20391. }
  20392. /**
  20393. * Defines the direction of a connection point
  20394. */
  20395. export enum NodeMaterialConnectionPointDirection {
  20396. /** Input */
  20397. Input = 0,
  20398. /** Output */
  20399. Output = 1
  20400. }
  20401. /**
  20402. * Defines a connection point for a block
  20403. */
  20404. export class NodeMaterialConnectionPoint {
  20405. /** @hidden */
  20406. _ownerBlock: NodeMaterialBlock;
  20407. /** @hidden */
  20408. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20409. private _endpoints;
  20410. private _associatedVariableName;
  20411. private _direction;
  20412. /** @hidden */
  20413. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20414. /** @hidden */
  20415. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20416. private _type;
  20417. /** @hidden */
  20418. _enforceAssociatedVariableName: boolean;
  20419. /** Gets the direction of the point */
  20420. get direction(): NodeMaterialConnectionPointDirection;
  20421. /** Indicates that this connection point needs dual validation before being connected to another point */
  20422. needDualDirectionValidation: boolean;
  20423. /**
  20424. * Gets or sets the additional types supported by this connection point
  20425. */
  20426. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20427. /**
  20428. * Gets or sets the additional types excluded by this connection point
  20429. */
  20430. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20431. /**
  20432. * Observable triggered when this point is connected
  20433. */
  20434. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20435. /**
  20436. * Gets or sets the associated variable name in the shader
  20437. */
  20438. get associatedVariableName(): string;
  20439. set associatedVariableName(value: string);
  20440. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20441. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20442. /**
  20443. * Gets or sets the connection point type (default is float)
  20444. */
  20445. get type(): NodeMaterialBlockConnectionPointTypes;
  20446. set type(value: NodeMaterialBlockConnectionPointTypes);
  20447. /**
  20448. * Gets or sets the connection point name
  20449. */
  20450. name: string;
  20451. /**
  20452. * Gets or sets the connection point name
  20453. */
  20454. displayName: string;
  20455. /**
  20456. * Gets or sets a boolean indicating that this connection point can be omitted
  20457. */
  20458. isOptional: boolean;
  20459. /**
  20460. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20461. */
  20462. isExposedOnFrame: boolean;
  20463. /**
  20464. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20465. */
  20466. define: string;
  20467. /** @hidden */
  20468. _prioritizeVertex: boolean;
  20469. private _target;
  20470. /** Gets or sets the target of that connection point */
  20471. get target(): NodeMaterialBlockTargets;
  20472. set target(value: NodeMaterialBlockTargets);
  20473. /**
  20474. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20475. */
  20476. get isConnected(): boolean;
  20477. /**
  20478. * Gets a boolean indicating that the current point is connected to an input block
  20479. */
  20480. get isConnectedToInputBlock(): boolean;
  20481. /**
  20482. * Gets a the connected input block (if any)
  20483. */
  20484. get connectInputBlock(): Nullable<InputBlock>;
  20485. /** Get the other side of the connection (if any) */
  20486. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20487. /** Get the block that owns this connection point */
  20488. get ownerBlock(): NodeMaterialBlock;
  20489. /** Get the block connected on the other side of this connection (if any) */
  20490. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20491. /** Get the block connected on the endpoints of this connection (if any) */
  20492. get connectedBlocks(): Array<NodeMaterialBlock>;
  20493. /** Gets the list of connected endpoints */
  20494. get endpoints(): NodeMaterialConnectionPoint[];
  20495. /** Gets a boolean indicating if that output point is connected to at least one input */
  20496. get hasEndpoints(): boolean;
  20497. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20498. get isConnectedInVertexShader(): boolean;
  20499. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20500. get isConnectedInFragmentShader(): boolean;
  20501. /**
  20502. * Creates a block suitable to be used as an input for this input point.
  20503. * If null is returned, a block based on the point type will be created.
  20504. * @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
  20505. */
  20506. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20507. /**
  20508. * Creates a new connection point
  20509. * @param name defines the connection point name
  20510. * @param ownerBlock defines the block hosting this connection point
  20511. * @param direction defines the direction of the connection point
  20512. */
  20513. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20514. /**
  20515. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20516. * @returns the class name
  20517. */
  20518. getClassName(): string;
  20519. /**
  20520. * Gets a boolean indicating if the current point can be connected to another point
  20521. * @param connectionPoint defines the other connection point
  20522. * @returns a boolean
  20523. */
  20524. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20525. /**
  20526. * Gets a number indicating if the current point can be connected to another point
  20527. * @param connectionPoint defines the other connection point
  20528. * @returns a number defining the compatibility state
  20529. */
  20530. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20531. /**
  20532. * Connect this point to another connection point
  20533. * @param connectionPoint defines the other connection point
  20534. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20535. * @returns the current connection point
  20536. */
  20537. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20538. /**
  20539. * Disconnect this point from one of his endpoint
  20540. * @param endpoint defines the other connection point
  20541. * @returns the current connection point
  20542. */
  20543. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20544. /**
  20545. * Serializes this point in a JSON representation
  20546. * @param isInput defines if the connection point is an input (default is true)
  20547. * @returns the serialized point object
  20548. */
  20549. serialize(isInput?: boolean): any;
  20550. /**
  20551. * Release resources
  20552. */
  20553. dispose(): void;
  20554. }
  20555. }
  20556. declare module BABYLON {
  20557. /**
  20558. * Enum used to define the material modes
  20559. */
  20560. export enum NodeMaterialModes {
  20561. /** Regular material */
  20562. Material = 0,
  20563. /** For post process */
  20564. PostProcess = 1,
  20565. /** For particle system */
  20566. Particle = 2
  20567. }
  20568. }
  20569. declare module BABYLON {
  20570. /**
  20571. * Block used to read a texture from a sampler
  20572. */
  20573. export class TextureBlock extends NodeMaterialBlock {
  20574. private _defineName;
  20575. private _linearDefineName;
  20576. private _gammaDefineName;
  20577. private _tempTextureRead;
  20578. private _samplerName;
  20579. private _transformedUVName;
  20580. private _textureTransformName;
  20581. private _textureInfoName;
  20582. private _mainUVName;
  20583. private _mainUVDefineName;
  20584. private _fragmentOnly;
  20585. /**
  20586. * Gets or sets the texture associated with the node
  20587. */
  20588. texture: Nullable<Texture>;
  20589. /**
  20590. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20591. */
  20592. convertToGammaSpace: boolean;
  20593. /**
  20594. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20595. */
  20596. convertToLinearSpace: boolean;
  20597. /**
  20598. * Create a new TextureBlock
  20599. * @param name defines the block name
  20600. */
  20601. constructor(name: string, fragmentOnly?: boolean);
  20602. /**
  20603. * Gets the current class name
  20604. * @returns the class name
  20605. */
  20606. getClassName(): string;
  20607. /**
  20608. * Gets the uv input component
  20609. */
  20610. get uv(): NodeMaterialConnectionPoint;
  20611. /**
  20612. * Gets the rgba output component
  20613. */
  20614. get rgba(): NodeMaterialConnectionPoint;
  20615. /**
  20616. * Gets the rgb output component
  20617. */
  20618. get rgb(): NodeMaterialConnectionPoint;
  20619. /**
  20620. * Gets the r output component
  20621. */
  20622. get r(): NodeMaterialConnectionPoint;
  20623. /**
  20624. * Gets the g output component
  20625. */
  20626. get g(): NodeMaterialConnectionPoint;
  20627. /**
  20628. * Gets the b output component
  20629. */
  20630. get b(): NodeMaterialConnectionPoint;
  20631. /**
  20632. * Gets the a output component
  20633. */
  20634. get a(): NodeMaterialConnectionPoint;
  20635. get target(): NodeMaterialBlockTargets;
  20636. autoConfigure(material: NodeMaterial): void;
  20637. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20639. isReady(): boolean;
  20640. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20641. private get _isMixed();
  20642. private _injectVertexCode;
  20643. private _writeTextureRead;
  20644. private _writeOutput;
  20645. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20646. protected _dumpPropertiesCode(): string;
  20647. serialize(): any;
  20648. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20649. }
  20650. }
  20651. declare module BABYLON {
  20652. /** @hidden */
  20653. export var reflectionFunction: {
  20654. name: string;
  20655. shader: string;
  20656. };
  20657. }
  20658. declare module BABYLON {
  20659. /**
  20660. * Base block used to read a reflection texture from a sampler
  20661. */
  20662. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20663. /** @hidden */
  20664. _define3DName: string;
  20665. /** @hidden */
  20666. _defineCubicName: string;
  20667. /** @hidden */
  20668. _defineExplicitName: string;
  20669. /** @hidden */
  20670. _defineProjectionName: string;
  20671. /** @hidden */
  20672. _defineLocalCubicName: string;
  20673. /** @hidden */
  20674. _defineSphericalName: string;
  20675. /** @hidden */
  20676. _definePlanarName: string;
  20677. /** @hidden */
  20678. _defineEquirectangularName: string;
  20679. /** @hidden */
  20680. _defineMirroredEquirectangularFixedName: string;
  20681. /** @hidden */
  20682. _defineEquirectangularFixedName: string;
  20683. /** @hidden */
  20684. _defineSkyboxName: string;
  20685. /** @hidden */
  20686. _defineOppositeZ: string;
  20687. /** @hidden */
  20688. _cubeSamplerName: string;
  20689. /** @hidden */
  20690. _2DSamplerName: string;
  20691. protected _positionUVWName: string;
  20692. protected _directionWName: string;
  20693. protected _reflectionVectorName: string;
  20694. /** @hidden */
  20695. _reflectionCoordsName: string;
  20696. /** @hidden */
  20697. _reflectionMatrixName: string;
  20698. protected _reflectionColorName: string;
  20699. /**
  20700. * Gets or sets the texture associated with the node
  20701. */
  20702. texture: Nullable<BaseTexture>;
  20703. /**
  20704. * Create a new ReflectionTextureBaseBlock
  20705. * @param name defines the block name
  20706. */
  20707. constructor(name: string);
  20708. /**
  20709. * Gets the current class name
  20710. * @returns the class name
  20711. */
  20712. getClassName(): string;
  20713. /**
  20714. * Gets the world position input component
  20715. */
  20716. abstract get position(): NodeMaterialConnectionPoint;
  20717. /**
  20718. * Gets the world position input component
  20719. */
  20720. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20721. /**
  20722. * Gets the world normal input component
  20723. */
  20724. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20725. /**
  20726. * Gets the world input component
  20727. */
  20728. abstract get world(): NodeMaterialConnectionPoint;
  20729. /**
  20730. * Gets the camera (or eye) position component
  20731. */
  20732. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20733. /**
  20734. * Gets the view input component
  20735. */
  20736. abstract get view(): NodeMaterialConnectionPoint;
  20737. protected _getTexture(): Nullable<BaseTexture>;
  20738. autoConfigure(material: NodeMaterial): void;
  20739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20740. isReady(): boolean;
  20741. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20742. /**
  20743. * Gets the code to inject in the vertex shader
  20744. * @param state current state of the node material building
  20745. * @returns the shader code
  20746. */
  20747. handleVertexSide(state: NodeMaterialBuildState): string;
  20748. /**
  20749. * Handles the inits for the fragment code path
  20750. * @param state node material build state
  20751. */
  20752. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20753. /**
  20754. * Generates the reflection coords code for the fragment code path
  20755. * @param worldNormalVarName name of the world normal variable
  20756. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20757. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20758. * @returns the shader code
  20759. */
  20760. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20761. /**
  20762. * Generates the reflection color code for the fragment code path
  20763. * @param lodVarName name of the lod variable
  20764. * @param swizzleLookupTexture swizzle to use for the final color variable
  20765. * @returns the shader code
  20766. */
  20767. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20768. /**
  20769. * Generates the code corresponding to the connected output points
  20770. * @param state node material build state
  20771. * @param varName name of the variable to output
  20772. * @returns the shader code
  20773. */
  20774. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20775. protected _buildBlock(state: NodeMaterialBuildState): this;
  20776. protected _dumpPropertiesCode(): string;
  20777. serialize(): any;
  20778. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20779. }
  20780. }
  20781. declare module BABYLON {
  20782. /**
  20783. * Defines a connection point to be used for points with a custom object type
  20784. */
  20785. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20786. private _blockType;
  20787. private _blockName;
  20788. private _nameForCheking?;
  20789. /**
  20790. * Creates a new connection point
  20791. * @param name defines the connection point name
  20792. * @param ownerBlock defines the block hosting this connection point
  20793. * @param direction defines the direction of the connection point
  20794. */
  20795. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20796. /**
  20797. * Gets a number indicating if the current point can be connected to another point
  20798. * @param connectionPoint defines the other connection point
  20799. * @returns a number defining the compatibility state
  20800. */
  20801. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20802. /**
  20803. * Creates a block suitable to be used as an input for this input point.
  20804. * If null is returned, a block based on the point type will be created.
  20805. * @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
  20806. */
  20807. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20808. }
  20809. }
  20810. declare module BABYLON {
  20811. /**
  20812. * Enum defining the type of properties that can be edited in the property pages in the NME
  20813. */
  20814. export enum PropertyTypeForEdition {
  20815. /** property is a boolean */
  20816. Boolean = 0,
  20817. /** property is a float */
  20818. Float = 1,
  20819. /** property is a Vector2 */
  20820. Vector2 = 2,
  20821. /** property is a list of values */
  20822. List = 3
  20823. }
  20824. /**
  20825. * Interface that defines an option in a variable of type list
  20826. */
  20827. export interface IEditablePropertyListOption {
  20828. /** label of the option */
  20829. "label": string;
  20830. /** value of the option */
  20831. "value": number;
  20832. }
  20833. /**
  20834. * Interface that defines the options available for an editable property
  20835. */
  20836. export interface IEditablePropertyOption {
  20837. /** min value */
  20838. "min"?: number;
  20839. /** max value */
  20840. "max"?: number;
  20841. /** notifiers: indicates which actions to take when the property is changed */
  20842. "notifiers"?: {
  20843. /** the material should be rebuilt */
  20844. "rebuild"?: boolean;
  20845. /** the preview should be updated */
  20846. "update"?: boolean;
  20847. };
  20848. /** list of the options for a variable of type list */
  20849. "options"?: IEditablePropertyListOption[];
  20850. }
  20851. /**
  20852. * Interface that describes an editable property
  20853. */
  20854. export interface IPropertyDescriptionForEdition {
  20855. /** name of the property */
  20856. "propertyName": string;
  20857. /** display name of the property */
  20858. "displayName": string;
  20859. /** type of the property */
  20860. "type": PropertyTypeForEdition;
  20861. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20862. "groupName": string;
  20863. /** options for the property */
  20864. "options": IEditablePropertyOption;
  20865. }
  20866. /**
  20867. * Decorator that flags a property in a node material block as being editable
  20868. */
  20869. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20870. }
  20871. declare module BABYLON {
  20872. /**
  20873. * Block used to implement the refraction part of the sub surface module of the PBR material
  20874. */
  20875. export class RefractionBlock extends NodeMaterialBlock {
  20876. /** @hidden */
  20877. _define3DName: string;
  20878. /** @hidden */
  20879. _refractionMatrixName: string;
  20880. /** @hidden */
  20881. _defineLODRefractionAlpha: string;
  20882. /** @hidden */
  20883. _defineLinearSpecularRefraction: string;
  20884. /** @hidden */
  20885. _defineOppositeZ: string;
  20886. /** @hidden */
  20887. _cubeSamplerName: string;
  20888. /** @hidden */
  20889. _2DSamplerName: string;
  20890. /** @hidden */
  20891. _vRefractionMicrosurfaceInfosName: string;
  20892. /** @hidden */
  20893. _vRefractionInfosName: string;
  20894. private _scene;
  20895. /**
  20896. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20897. * Materials half opaque for instance using refraction could benefit from this control.
  20898. */
  20899. linkRefractionWithTransparency: boolean;
  20900. /**
  20901. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20902. */
  20903. invertRefractionY: boolean;
  20904. /**
  20905. * Gets or sets the texture associated with the node
  20906. */
  20907. texture: Nullable<BaseTexture>;
  20908. /**
  20909. * Create a new RefractionBlock
  20910. * @param name defines the block name
  20911. */
  20912. constructor(name: string);
  20913. /**
  20914. * Gets the current class name
  20915. * @returns the class name
  20916. */
  20917. getClassName(): string;
  20918. /**
  20919. * Gets the intensity input component
  20920. */
  20921. get intensity(): NodeMaterialConnectionPoint;
  20922. /**
  20923. * Gets the index of refraction input component
  20924. */
  20925. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20926. /**
  20927. * Gets the tint at distance input component
  20928. */
  20929. get tintAtDistance(): NodeMaterialConnectionPoint;
  20930. /**
  20931. * Gets the view input component
  20932. */
  20933. get view(): NodeMaterialConnectionPoint;
  20934. /**
  20935. * Gets the refraction object output component
  20936. */
  20937. get refraction(): NodeMaterialConnectionPoint;
  20938. /**
  20939. * Returns true if the block has a texture
  20940. */
  20941. get hasTexture(): boolean;
  20942. protected _getTexture(): Nullable<BaseTexture>;
  20943. autoConfigure(material: NodeMaterial): void;
  20944. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20945. isReady(): boolean;
  20946. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20947. /**
  20948. * Gets the main code of the block (fragment side)
  20949. * @param state current state of the node material building
  20950. * @returns the shader code
  20951. */
  20952. getCode(state: NodeMaterialBuildState): string;
  20953. protected _buildBlock(state: NodeMaterialBuildState): this;
  20954. protected _dumpPropertiesCode(): string;
  20955. serialize(): any;
  20956. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20957. }
  20958. }
  20959. declare module BABYLON {
  20960. /**
  20961. * Base block used as input for post process
  20962. */
  20963. export class CurrentScreenBlock extends NodeMaterialBlock {
  20964. private _samplerName;
  20965. private _linearDefineName;
  20966. private _gammaDefineName;
  20967. private _mainUVName;
  20968. private _tempTextureRead;
  20969. /**
  20970. * Gets or sets the texture associated with the node
  20971. */
  20972. texture: Nullable<BaseTexture>;
  20973. /**
  20974. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20975. */
  20976. convertToGammaSpace: boolean;
  20977. /**
  20978. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20979. */
  20980. convertToLinearSpace: boolean;
  20981. /**
  20982. * Create a new CurrentScreenBlock
  20983. * @param name defines the block name
  20984. */
  20985. constructor(name: string);
  20986. /**
  20987. * Gets the current class name
  20988. * @returns the class name
  20989. */
  20990. getClassName(): string;
  20991. /**
  20992. * Gets the uv input component
  20993. */
  20994. get uv(): NodeMaterialConnectionPoint;
  20995. /**
  20996. * Gets the rgba output component
  20997. */
  20998. get rgba(): NodeMaterialConnectionPoint;
  20999. /**
  21000. * Gets the rgb output component
  21001. */
  21002. get rgb(): NodeMaterialConnectionPoint;
  21003. /**
  21004. * Gets the r output component
  21005. */
  21006. get r(): NodeMaterialConnectionPoint;
  21007. /**
  21008. * Gets the g output component
  21009. */
  21010. get g(): NodeMaterialConnectionPoint;
  21011. /**
  21012. * Gets the b output component
  21013. */
  21014. get b(): NodeMaterialConnectionPoint;
  21015. /**
  21016. * Gets the a output component
  21017. */
  21018. get a(): NodeMaterialConnectionPoint;
  21019. /**
  21020. * Initialize the block and prepare the context for build
  21021. * @param state defines the state that will be used for the build
  21022. */
  21023. initialize(state: NodeMaterialBuildState): void;
  21024. get target(): NodeMaterialBlockTargets;
  21025. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21026. isReady(): boolean;
  21027. private _injectVertexCode;
  21028. private _writeTextureRead;
  21029. private _writeOutput;
  21030. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21031. serialize(): any;
  21032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21033. }
  21034. }
  21035. declare module BABYLON {
  21036. /**
  21037. * Base block used for the particle texture
  21038. */
  21039. export class ParticleTextureBlock extends NodeMaterialBlock {
  21040. private _samplerName;
  21041. private _linearDefineName;
  21042. private _gammaDefineName;
  21043. private _tempTextureRead;
  21044. /**
  21045. * Gets or sets the texture associated with the node
  21046. */
  21047. texture: Nullable<BaseTexture>;
  21048. /**
  21049. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21050. */
  21051. convertToGammaSpace: boolean;
  21052. /**
  21053. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21054. */
  21055. convertToLinearSpace: boolean;
  21056. /**
  21057. * Create a new ParticleTextureBlock
  21058. * @param name defines the block name
  21059. */
  21060. constructor(name: string);
  21061. /**
  21062. * Gets the current class name
  21063. * @returns the class name
  21064. */
  21065. getClassName(): string;
  21066. /**
  21067. * Gets the uv input component
  21068. */
  21069. get uv(): NodeMaterialConnectionPoint;
  21070. /**
  21071. * Gets the rgba output component
  21072. */
  21073. get rgba(): NodeMaterialConnectionPoint;
  21074. /**
  21075. * Gets the rgb output component
  21076. */
  21077. get rgb(): NodeMaterialConnectionPoint;
  21078. /**
  21079. * Gets the r output component
  21080. */
  21081. get r(): NodeMaterialConnectionPoint;
  21082. /**
  21083. * Gets the g output component
  21084. */
  21085. get g(): NodeMaterialConnectionPoint;
  21086. /**
  21087. * Gets the b output component
  21088. */
  21089. get b(): NodeMaterialConnectionPoint;
  21090. /**
  21091. * Gets the a output component
  21092. */
  21093. get a(): NodeMaterialConnectionPoint;
  21094. /**
  21095. * Initialize the block and prepare the context for build
  21096. * @param state defines the state that will be used for the build
  21097. */
  21098. initialize(state: NodeMaterialBuildState): void;
  21099. autoConfigure(material: NodeMaterial): void;
  21100. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21101. isReady(): boolean;
  21102. private _writeOutput;
  21103. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21104. serialize(): any;
  21105. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21106. }
  21107. }
  21108. declare module BABYLON {
  21109. /**
  21110. * Class used to store shared data between 2 NodeMaterialBuildState
  21111. */
  21112. export class NodeMaterialBuildStateSharedData {
  21113. /**
  21114. * Gets the list of emitted varyings
  21115. */
  21116. temps: string[];
  21117. /**
  21118. * Gets the list of emitted varyings
  21119. */
  21120. varyings: string[];
  21121. /**
  21122. * Gets the varying declaration string
  21123. */
  21124. varyingDeclaration: string;
  21125. /**
  21126. * Input blocks
  21127. */
  21128. inputBlocks: InputBlock[];
  21129. /**
  21130. * Input blocks
  21131. */
  21132. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21133. /**
  21134. * Bindable blocks (Blocks that need to set data to the effect)
  21135. */
  21136. bindableBlocks: NodeMaterialBlock[];
  21137. /**
  21138. * List of blocks that can provide a compilation fallback
  21139. */
  21140. blocksWithFallbacks: NodeMaterialBlock[];
  21141. /**
  21142. * List of blocks that can provide a define update
  21143. */
  21144. blocksWithDefines: NodeMaterialBlock[];
  21145. /**
  21146. * List of blocks that can provide a repeatable content
  21147. */
  21148. repeatableContentBlocks: NodeMaterialBlock[];
  21149. /**
  21150. * List of blocks that can provide a dynamic list of uniforms
  21151. */
  21152. dynamicUniformBlocks: NodeMaterialBlock[];
  21153. /**
  21154. * List of blocks that can block the isReady function for the material
  21155. */
  21156. blockingBlocks: NodeMaterialBlock[];
  21157. /**
  21158. * Gets the list of animated inputs
  21159. */
  21160. animatedInputs: InputBlock[];
  21161. /**
  21162. * Build Id used to avoid multiple recompilations
  21163. */
  21164. buildId: number;
  21165. /** List of emitted variables */
  21166. variableNames: {
  21167. [key: string]: number;
  21168. };
  21169. /** List of emitted defines */
  21170. defineNames: {
  21171. [key: string]: number;
  21172. };
  21173. /** Should emit comments? */
  21174. emitComments: boolean;
  21175. /** Emit build activity */
  21176. verbose: boolean;
  21177. /** Gets or sets the hosting scene */
  21178. scene: Scene;
  21179. /**
  21180. * Gets the compilation hints emitted at compilation time
  21181. */
  21182. hints: {
  21183. needWorldViewMatrix: boolean;
  21184. needWorldViewProjectionMatrix: boolean;
  21185. needAlphaBlending: boolean;
  21186. needAlphaTesting: boolean;
  21187. };
  21188. /**
  21189. * List of compilation checks
  21190. */
  21191. checks: {
  21192. emitVertex: boolean;
  21193. emitFragment: boolean;
  21194. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21195. };
  21196. /**
  21197. * Is vertex program allowed to be empty?
  21198. */
  21199. allowEmptyVertexProgram: boolean;
  21200. /** Creates a new shared data */
  21201. constructor();
  21202. /**
  21203. * Emits console errors and exceptions if there is a failing check
  21204. */
  21205. emitErrors(): void;
  21206. }
  21207. }
  21208. declare module BABYLON {
  21209. /**
  21210. * Class used to store node based material build state
  21211. */
  21212. export class NodeMaterialBuildState {
  21213. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21214. supportUniformBuffers: boolean;
  21215. /**
  21216. * Gets the list of emitted attributes
  21217. */
  21218. attributes: string[];
  21219. /**
  21220. * Gets the list of emitted uniforms
  21221. */
  21222. uniforms: string[];
  21223. /**
  21224. * Gets the list of emitted constants
  21225. */
  21226. constants: string[];
  21227. /**
  21228. * Gets the list of emitted samplers
  21229. */
  21230. samplers: string[];
  21231. /**
  21232. * Gets the list of emitted functions
  21233. */
  21234. functions: {
  21235. [key: string]: string;
  21236. };
  21237. /**
  21238. * Gets the list of emitted extensions
  21239. */
  21240. extensions: {
  21241. [key: string]: string;
  21242. };
  21243. /**
  21244. * Gets the target of the compilation state
  21245. */
  21246. target: NodeMaterialBlockTargets;
  21247. /**
  21248. * Gets the list of emitted counters
  21249. */
  21250. counters: {
  21251. [key: string]: number;
  21252. };
  21253. /**
  21254. * Shared data between multiple NodeMaterialBuildState instances
  21255. */
  21256. sharedData: NodeMaterialBuildStateSharedData;
  21257. /** @hidden */
  21258. _vertexState: NodeMaterialBuildState;
  21259. /** @hidden */
  21260. _attributeDeclaration: string;
  21261. /** @hidden */
  21262. _uniformDeclaration: string;
  21263. /** @hidden */
  21264. _constantDeclaration: string;
  21265. /** @hidden */
  21266. _samplerDeclaration: string;
  21267. /** @hidden */
  21268. _varyingTransfer: string;
  21269. /** @hidden */
  21270. _injectAtEnd: string;
  21271. private _repeatableContentAnchorIndex;
  21272. /** @hidden */
  21273. _builtCompilationString: string;
  21274. /**
  21275. * Gets the emitted compilation strings
  21276. */
  21277. compilationString: string;
  21278. /**
  21279. * Finalize the compilation strings
  21280. * @param state defines the current compilation state
  21281. */
  21282. finalize(state: NodeMaterialBuildState): void;
  21283. /** @hidden */
  21284. get _repeatableContentAnchor(): string;
  21285. /** @hidden */
  21286. _getFreeVariableName(prefix: string): string;
  21287. /** @hidden */
  21288. _getFreeDefineName(prefix: string): string;
  21289. /** @hidden */
  21290. _excludeVariableName(name: string): void;
  21291. /** @hidden */
  21292. _emit2DSampler(name: string): void;
  21293. /** @hidden */
  21294. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21295. /** @hidden */
  21296. _emitExtension(name: string, extension: string, define?: string): void;
  21297. /** @hidden */
  21298. _emitFunction(name: string, code: string, comments: string): void;
  21299. /** @hidden */
  21300. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21301. replaceStrings?: {
  21302. search: RegExp;
  21303. replace: string;
  21304. }[];
  21305. repeatKey?: string;
  21306. }): string;
  21307. /** @hidden */
  21308. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21309. repeatKey?: string;
  21310. removeAttributes?: boolean;
  21311. removeUniforms?: boolean;
  21312. removeVaryings?: boolean;
  21313. removeIfDef?: boolean;
  21314. replaceStrings?: {
  21315. search: RegExp;
  21316. replace: string;
  21317. }[];
  21318. }, storeKey?: string): void;
  21319. /** @hidden */
  21320. _registerTempVariable(name: string): boolean;
  21321. /** @hidden */
  21322. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21323. /** @hidden */
  21324. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21325. /** @hidden */
  21326. _emitFloat(value: number): string;
  21327. }
  21328. }
  21329. declare module BABYLON {
  21330. /**
  21331. * Helper class used to generate session unique ID
  21332. */
  21333. export class UniqueIdGenerator {
  21334. private static _UniqueIdCounter;
  21335. /**
  21336. * Gets an unique (relatively to the current scene) Id
  21337. */
  21338. static get UniqueId(): number;
  21339. }
  21340. }
  21341. declare module BABYLON {
  21342. /**
  21343. * Defines a block that can be used inside a node based material
  21344. */
  21345. export class NodeMaterialBlock {
  21346. private _buildId;
  21347. private _buildTarget;
  21348. private _target;
  21349. private _isFinalMerger;
  21350. private _isInput;
  21351. protected _isUnique: boolean;
  21352. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21353. inputsAreExclusive: boolean;
  21354. /** @hidden */
  21355. _codeVariableName: string;
  21356. /** @hidden */
  21357. _inputs: NodeMaterialConnectionPoint[];
  21358. /** @hidden */
  21359. _outputs: NodeMaterialConnectionPoint[];
  21360. /** @hidden */
  21361. _preparationId: number;
  21362. /**
  21363. * Gets or sets the name of the block
  21364. */
  21365. name: string;
  21366. /**
  21367. * Gets or sets the unique id of the node
  21368. */
  21369. uniqueId: number;
  21370. /**
  21371. * Gets or sets the comments associated with this block
  21372. */
  21373. comments: string;
  21374. /**
  21375. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21376. */
  21377. get isUnique(): boolean;
  21378. /**
  21379. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21380. */
  21381. get isFinalMerger(): boolean;
  21382. /**
  21383. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21384. */
  21385. get isInput(): boolean;
  21386. /**
  21387. * Gets or sets the build Id
  21388. */
  21389. get buildId(): number;
  21390. set buildId(value: number);
  21391. /**
  21392. * Gets or sets the target of the block
  21393. */
  21394. get target(): NodeMaterialBlockTargets;
  21395. set target(value: NodeMaterialBlockTargets);
  21396. /**
  21397. * Gets the list of input points
  21398. */
  21399. get inputs(): NodeMaterialConnectionPoint[];
  21400. /** Gets the list of output points */
  21401. get outputs(): NodeMaterialConnectionPoint[];
  21402. /**
  21403. * Find an input by its name
  21404. * @param name defines the name of the input to look for
  21405. * @returns the input or null if not found
  21406. */
  21407. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21408. /**
  21409. * Find an output by its name
  21410. * @param name defines the name of the outputto look for
  21411. * @returns the output or null if not found
  21412. */
  21413. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21414. /**
  21415. * Creates a new NodeMaterialBlock
  21416. * @param name defines the block name
  21417. * @param target defines the target of that block (Vertex by default)
  21418. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21419. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21420. */
  21421. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21422. /**
  21423. * Initialize the block and prepare the context for build
  21424. * @param state defines the state that will be used for the build
  21425. */
  21426. initialize(state: NodeMaterialBuildState): void;
  21427. /**
  21428. * Bind data to effect. Will only be called for blocks with isBindable === true
  21429. * @param effect defines the effect to bind data to
  21430. * @param nodeMaterial defines the hosting NodeMaterial
  21431. * @param mesh defines the mesh that will be rendered
  21432. * @param subMesh defines the submesh that will be rendered
  21433. */
  21434. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21435. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21436. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21437. protected _writeFloat(value: number): string;
  21438. /**
  21439. * Gets the current class name e.g. "NodeMaterialBlock"
  21440. * @returns the class name
  21441. */
  21442. getClassName(): string;
  21443. /**
  21444. * Register a new input. Must be called inside a block constructor
  21445. * @param name defines the connection point name
  21446. * @param type defines the connection point type
  21447. * @param isOptional defines a boolean indicating that this input can be omitted
  21448. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21449. * @param point an already created connection point. If not provided, create a new one
  21450. * @returns the current block
  21451. */
  21452. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21453. /**
  21454. * Register a new output. Must be called inside a block constructor
  21455. * @param name defines the connection point name
  21456. * @param type defines the connection point type
  21457. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21458. * @param point an already created connection point. If not provided, create a new one
  21459. * @returns the current block
  21460. */
  21461. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21462. /**
  21463. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21464. * @param forOutput defines an optional connection point to check compatibility with
  21465. * @returns the first available input or null
  21466. */
  21467. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21468. /**
  21469. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21470. * @param forBlock defines an optional block to check compatibility with
  21471. * @returns the first available input or null
  21472. */
  21473. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21474. /**
  21475. * Gets the sibling of the given output
  21476. * @param current defines the current output
  21477. * @returns the next output in the list or null
  21478. */
  21479. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21480. /**
  21481. * Connect current block with another block
  21482. * @param other defines the block to connect with
  21483. * @param options define the various options to help pick the right connections
  21484. * @returns the current block
  21485. */
  21486. connectTo(other: NodeMaterialBlock, options?: {
  21487. input?: string;
  21488. output?: string;
  21489. outputSwizzle?: string;
  21490. }): this | undefined;
  21491. protected _buildBlock(state: NodeMaterialBuildState): void;
  21492. /**
  21493. * Add uniforms, samplers and uniform buffers at compilation time
  21494. * @param state defines the state to update
  21495. * @param nodeMaterial defines the node material requesting the update
  21496. * @param defines defines the material defines to update
  21497. * @param uniformBuffers defines the list of uniform buffer names
  21498. */
  21499. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21500. /**
  21501. * Add potential fallbacks if shader compilation fails
  21502. * @param mesh defines the mesh to be rendered
  21503. * @param fallbacks defines the current prioritized list of fallbacks
  21504. */
  21505. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21506. /**
  21507. * Initialize defines for shader compilation
  21508. * @param mesh defines the mesh to be rendered
  21509. * @param nodeMaterial defines the node material requesting the update
  21510. * @param defines defines the material defines to update
  21511. * @param useInstances specifies that instances should be used
  21512. */
  21513. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21514. /**
  21515. * Update defines for shader compilation
  21516. * @param mesh defines the mesh to be rendered
  21517. * @param nodeMaterial defines the node material requesting the update
  21518. * @param defines defines the material defines to update
  21519. * @param useInstances specifies that instances should be used
  21520. * @param subMesh defines which submesh to render
  21521. */
  21522. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21523. /**
  21524. * Lets the block try to connect some inputs automatically
  21525. * @param material defines the hosting NodeMaterial
  21526. */
  21527. autoConfigure(material: NodeMaterial): void;
  21528. /**
  21529. * Function called when a block is declared as repeatable content generator
  21530. * @param vertexShaderState defines the current compilation state for the vertex shader
  21531. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21532. * @param mesh defines the mesh to be rendered
  21533. * @param defines defines the material defines to update
  21534. */
  21535. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21536. /**
  21537. * Checks if the block is ready
  21538. * @param mesh defines the mesh to be rendered
  21539. * @param nodeMaterial defines the node material requesting the update
  21540. * @param defines defines the material defines to update
  21541. * @param useInstances specifies that instances should be used
  21542. * @returns true if the block is ready
  21543. */
  21544. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21545. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21546. private _processBuild;
  21547. /**
  21548. * Compile the current node and generate the shader code
  21549. * @param state defines the current compilation state (uniforms, samplers, current string)
  21550. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21551. * @returns true if already built
  21552. */
  21553. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21554. protected _inputRename(name: string): string;
  21555. protected _outputRename(name: string): string;
  21556. protected _dumpPropertiesCode(): string;
  21557. /** @hidden */
  21558. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21559. /** @hidden */
  21560. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21561. /**
  21562. * Clone the current block to a new identical block
  21563. * @param scene defines the hosting scene
  21564. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21565. * @returns a copy of the current block
  21566. */
  21567. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21568. /**
  21569. * Serializes this block in a JSON representation
  21570. * @returns the serialized block object
  21571. */
  21572. serialize(): any;
  21573. /** @hidden */
  21574. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21575. private _deserializePortDisplayNamesAndExposedOnFrame;
  21576. /**
  21577. * Release resources
  21578. */
  21579. dispose(): void;
  21580. }
  21581. }
  21582. declare module BABYLON {
  21583. /**
  21584. * Base class of materials working in push mode in babylon JS
  21585. * @hidden
  21586. */
  21587. export class PushMaterial extends Material {
  21588. protected _activeEffect: Effect;
  21589. protected _normalMatrix: Matrix;
  21590. constructor(name: string, scene: Scene);
  21591. getEffect(): Effect;
  21592. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21593. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21594. /**
  21595. * Binds the given world matrix to the active effect
  21596. *
  21597. * @param world the matrix to bind
  21598. */
  21599. bindOnlyWorldMatrix(world: Matrix): void;
  21600. /**
  21601. * Binds the given normal matrix to the active effect
  21602. *
  21603. * @param normalMatrix the matrix to bind
  21604. */
  21605. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21606. bind(world: Matrix, mesh?: Mesh): void;
  21607. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21608. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21609. }
  21610. }
  21611. declare module BABYLON {
  21612. /**
  21613. * Root class for all node material optimizers
  21614. */
  21615. export class NodeMaterialOptimizer {
  21616. /**
  21617. * Function used to optimize a NodeMaterial graph
  21618. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21619. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21620. */
  21621. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21622. }
  21623. }
  21624. declare module BABYLON {
  21625. /**
  21626. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21627. */
  21628. export class TransformBlock extends NodeMaterialBlock {
  21629. /**
  21630. * Defines the value to use to complement W value to transform it to a Vector4
  21631. */
  21632. complementW: number;
  21633. /**
  21634. * Defines the value to use to complement z value to transform it to a Vector4
  21635. */
  21636. complementZ: number;
  21637. /**
  21638. * Creates a new TransformBlock
  21639. * @param name defines the block name
  21640. */
  21641. constructor(name: string);
  21642. /**
  21643. * Gets the current class name
  21644. * @returns the class name
  21645. */
  21646. getClassName(): string;
  21647. /**
  21648. * Gets the vector input
  21649. */
  21650. get vector(): NodeMaterialConnectionPoint;
  21651. /**
  21652. * Gets the output component
  21653. */
  21654. get output(): NodeMaterialConnectionPoint;
  21655. /**
  21656. * Gets the xyz output component
  21657. */
  21658. get xyz(): NodeMaterialConnectionPoint;
  21659. /**
  21660. * Gets the matrix transform input
  21661. */
  21662. get transform(): NodeMaterialConnectionPoint;
  21663. protected _buildBlock(state: NodeMaterialBuildState): this;
  21664. /**
  21665. * Update defines for shader compilation
  21666. * @param mesh defines the mesh to be rendered
  21667. * @param nodeMaterial defines the node material requesting the update
  21668. * @param defines defines the material defines to update
  21669. * @param useInstances specifies that instances should be used
  21670. * @param subMesh defines which submesh to render
  21671. */
  21672. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21673. serialize(): any;
  21674. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21675. protected _dumpPropertiesCode(): string;
  21676. }
  21677. }
  21678. declare module BABYLON {
  21679. /**
  21680. * Block used to output the vertex position
  21681. */
  21682. export class VertexOutputBlock extends NodeMaterialBlock {
  21683. /**
  21684. * Creates a new VertexOutputBlock
  21685. * @param name defines the block name
  21686. */
  21687. constructor(name: string);
  21688. /**
  21689. * Gets the current class name
  21690. * @returns the class name
  21691. */
  21692. getClassName(): string;
  21693. /**
  21694. * Gets the vector input component
  21695. */
  21696. get vector(): NodeMaterialConnectionPoint;
  21697. protected _buildBlock(state: NodeMaterialBuildState): this;
  21698. }
  21699. }
  21700. declare module BABYLON {
  21701. /**
  21702. * Block used to output the final color
  21703. */
  21704. export class FragmentOutputBlock extends NodeMaterialBlock {
  21705. /**
  21706. * Create a new FragmentOutputBlock
  21707. * @param name defines the block name
  21708. */
  21709. constructor(name: string);
  21710. /**
  21711. * Gets the current class name
  21712. * @returns the class name
  21713. */
  21714. getClassName(): string;
  21715. /**
  21716. * Gets the rgba input component
  21717. */
  21718. get rgba(): NodeMaterialConnectionPoint;
  21719. /**
  21720. * Gets the rgb input component
  21721. */
  21722. get rgb(): NodeMaterialConnectionPoint;
  21723. /**
  21724. * Gets the a input component
  21725. */
  21726. get a(): NodeMaterialConnectionPoint;
  21727. protected _buildBlock(state: NodeMaterialBuildState): this;
  21728. }
  21729. }
  21730. declare module BABYLON {
  21731. /**
  21732. * Block used for the particle ramp gradient section
  21733. */
  21734. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21735. /**
  21736. * Create a new ParticleRampGradientBlock
  21737. * @param name defines the block name
  21738. */
  21739. constructor(name: string);
  21740. /**
  21741. * Gets the current class name
  21742. * @returns the class name
  21743. */
  21744. getClassName(): string;
  21745. /**
  21746. * Gets the color input component
  21747. */
  21748. get color(): NodeMaterialConnectionPoint;
  21749. /**
  21750. * Gets the rampColor output component
  21751. */
  21752. get rampColor(): NodeMaterialConnectionPoint;
  21753. /**
  21754. * Initialize the block and prepare the context for build
  21755. * @param state defines the state that will be used for the build
  21756. */
  21757. initialize(state: NodeMaterialBuildState): void;
  21758. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21759. }
  21760. }
  21761. declare module BABYLON {
  21762. /**
  21763. * Block used for the particle blend multiply section
  21764. */
  21765. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21766. /**
  21767. * Create a new ParticleBlendMultiplyBlock
  21768. * @param name defines the block name
  21769. */
  21770. constructor(name: string);
  21771. /**
  21772. * Gets the current class name
  21773. * @returns the class name
  21774. */
  21775. getClassName(): string;
  21776. /**
  21777. * Gets the color input component
  21778. */
  21779. get color(): NodeMaterialConnectionPoint;
  21780. /**
  21781. * Gets the alphaTexture input component
  21782. */
  21783. get alphaTexture(): NodeMaterialConnectionPoint;
  21784. /**
  21785. * Gets the alphaColor input component
  21786. */
  21787. get alphaColor(): NodeMaterialConnectionPoint;
  21788. /**
  21789. * Gets the blendColor output component
  21790. */
  21791. get blendColor(): NodeMaterialConnectionPoint;
  21792. /**
  21793. * Initialize the block and prepare the context for build
  21794. * @param state defines the state that will be used for the build
  21795. */
  21796. initialize(state: NodeMaterialBuildState): void;
  21797. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21798. }
  21799. }
  21800. declare module BABYLON {
  21801. /**
  21802. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21803. */
  21804. export class VectorMergerBlock extends NodeMaterialBlock {
  21805. /**
  21806. * Create a new VectorMergerBlock
  21807. * @param name defines the block name
  21808. */
  21809. constructor(name: string);
  21810. /**
  21811. * Gets the current class name
  21812. * @returns the class name
  21813. */
  21814. getClassName(): string;
  21815. /**
  21816. * Gets the xyz component (input)
  21817. */
  21818. get xyzIn(): NodeMaterialConnectionPoint;
  21819. /**
  21820. * Gets the xy component (input)
  21821. */
  21822. get xyIn(): NodeMaterialConnectionPoint;
  21823. /**
  21824. * Gets the x component (input)
  21825. */
  21826. get x(): NodeMaterialConnectionPoint;
  21827. /**
  21828. * Gets the y component (input)
  21829. */
  21830. get y(): NodeMaterialConnectionPoint;
  21831. /**
  21832. * Gets the z component (input)
  21833. */
  21834. get z(): NodeMaterialConnectionPoint;
  21835. /**
  21836. * Gets the w component (input)
  21837. */
  21838. get w(): NodeMaterialConnectionPoint;
  21839. /**
  21840. * Gets the xyzw component (output)
  21841. */
  21842. get xyzw(): NodeMaterialConnectionPoint;
  21843. /**
  21844. * Gets the xyz component (output)
  21845. */
  21846. get xyzOut(): NodeMaterialConnectionPoint;
  21847. /**
  21848. * Gets the xy component (output)
  21849. */
  21850. get xyOut(): NodeMaterialConnectionPoint;
  21851. /**
  21852. * Gets the xy component (output)
  21853. * @deprecated Please use xyOut instead.
  21854. */
  21855. get xy(): NodeMaterialConnectionPoint;
  21856. /**
  21857. * Gets the xyz component (output)
  21858. * @deprecated Please use xyzOut instead.
  21859. */
  21860. get xyz(): NodeMaterialConnectionPoint;
  21861. protected _buildBlock(state: NodeMaterialBuildState): this;
  21862. }
  21863. }
  21864. declare module BABYLON {
  21865. /**
  21866. * Block used to remap a float from a range to a new one
  21867. */
  21868. export class RemapBlock extends NodeMaterialBlock {
  21869. /**
  21870. * Gets or sets the source range
  21871. */
  21872. sourceRange: Vector2;
  21873. /**
  21874. * Gets or sets the target range
  21875. */
  21876. targetRange: Vector2;
  21877. /**
  21878. * Creates a new RemapBlock
  21879. * @param name defines the block name
  21880. */
  21881. constructor(name: string);
  21882. /**
  21883. * Gets the current class name
  21884. * @returns the class name
  21885. */
  21886. getClassName(): string;
  21887. /**
  21888. * Gets the input component
  21889. */
  21890. get input(): NodeMaterialConnectionPoint;
  21891. /**
  21892. * Gets the source min input component
  21893. */
  21894. get sourceMin(): NodeMaterialConnectionPoint;
  21895. /**
  21896. * Gets the source max input component
  21897. */
  21898. get sourceMax(): NodeMaterialConnectionPoint;
  21899. /**
  21900. * Gets the target min input component
  21901. */
  21902. get targetMin(): NodeMaterialConnectionPoint;
  21903. /**
  21904. * Gets the target max input component
  21905. */
  21906. get targetMax(): NodeMaterialConnectionPoint;
  21907. /**
  21908. * Gets the output component
  21909. */
  21910. get output(): NodeMaterialConnectionPoint;
  21911. protected _buildBlock(state: NodeMaterialBuildState): this;
  21912. protected _dumpPropertiesCode(): string;
  21913. serialize(): any;
  21914. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21915. }
  21916. }
  21917. declare module BABYLON {
  21918. /**
  21919. * Block used to multiply 2 values
  21920. */
  21921. export class MultiplyBlock extends NodeMaterialBlock {
  21922. /**
  21923. * Creates a new MultiplyBlock
  21924. * @param name defines the block name
  21925. */
  21926. constructor(name: string);
  21927. /**
  21928. * Gets the current class name
  21929. * @returns the class name
  21930. */
  21931. getClassName(): string;
  21932. /**
  21933. * Gets the left operand input component
  21934. */
  21935. get left(): NodeMaterialConnectionPoint;
  21936. /**
  21937. * Gets the right operand input component
  21938. */
  21939. get right(): NodeMaterialConnectionPoint;
  21940. /**
  21941. * Gets the output component
  21942. */
  21943. get output(): NodeMaterialConnectionPoint;
  21944. protected _buildBlock(state: NodeMaterialBuildState): this;
  21945. }
  21946. }
  21947. declare module BABYLON {
  21948. /**
  21949. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21950. */
  21951. export class ColorSplitterBlock extends NodeMaterialBlock {
  21952. /**
  21953. * Create a new ColorSplitterBlock
  21954. * @param name defines the block name
  21955. */
  21956. constructor(name: string);
  21957. /**
  21958. * Gets the current class name
  21959. * @returns the class name
  21960. */
  21961. getClassName(): string;
  21962. /**
  21963. * Gets the rgba component (input)
  21964. */
  21965. get rgba(): NodeMaterialConnectionPoint;
  21966. /**
  21967. * Gets the rgb component (input)
  21968. */
  21969. get rgbIn(): NodeMaterialConnectionPoint;
  21970. /**
  21971. * Gets the rgb component (output)
  21972. */
  21973. get rgbOut(): NodeMaterialConnectionPoint;
  21974. /**
  21975. * Gets the r component (output)
  21976. */
  21977. get r(): NodeMaterialConnectionPoint;
  21978. /**
  21979. * Gets the g component (output)
  21980. */
  21981. get g(): NodeMaterialConnectionPoint;
  21982. /**
  21983. * Gets the b component (output)
  21984. */
  21985. get b(): NodeMaterialConnectionPoint;
  21986. /**
  21987. * Gets the a component (output)
  21988. */
  21989. get a(): NodeMaterialConnectionPoint;
  21990. protected _inputRename(name: string): string;
  21991. protected _outputRename(name: string): string;
  21992. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21993. }
  21994. }
  21995. declare module BABYLON {
  21996. /**
  21997. * Interface used to configure the node material editor
  21998. */
  21999. export interface INodeMaterialEditorOptions {
  22000. /** Define the URl to load node editor script */
  22001. editorURL?: string;
  22002. }
  22003. /** @hidden */
  22004. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22005. NORMAL: boolean;
  22006. TANGENT: boolean;
  22007. UV1: boolean;
  22008. /** BONES */
  22009. NUM_BONE_INFLUENCERS: number;
  22010. BonesPerMesh: number;
  22011. BONETEXTURE: boolean;
  22012. /** MORPH TARGETS */
  22013. MORPHTARGETS: boolean;
  22014. MORPHTARGETS_NORMAL: boolean;
  22015. MORPHTARGETS_TANGENT: boolean;
  22016. MORPHTARGETS_UV: boolean;
  22017. NUM_MORPH_INFLUENCERS: number;
  22018. /** IMAGE PROCESSING */
  22019. IMAGEPROCESSING: boolean;
  22020. VIGNETTE: boolean;
  22021. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22022. VIGNETTEBLENDMODEOPAQUE: boolean;
  22023. TONEMAPPING: boolean;
  22024. TONEMAPPING_ACES: boolean;
  22025. CONTRAST: boolean;
  22026. EXPOSURE: boolean;
  22027. COLORCURVES: boolean;
  22028. COLORGRADING: boolean;
  22029. COLORGRADING3D: boolean;
  22030. SAMPLER3DGREENDEPTH: boolean;
  22031. SAMPLER3DBGRMAP: boolean;
  22032. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22033. /** MISC. */
  22034. BUMPDIRECTUV: number;
  22035. constructor();
  22036. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22037. }
  22038. /**
  22039. * Class used to configure NodeMaterial
  22040. */
  22041. export interface INodeMaterialOptions {
  22042. /**
  22043. * Defines if blocks should emit comments
  22044. */
  22045. emitComments: boolean;
  22046. }
  22047. /**
  22048. * Class used to create a node based material built by assembling shader blocks
  22049. */
  22050. export class NodeMaterial extends PushMaterial {
  22051. private static _BuildIdGenerator;
  22052. private _options;
  22053. private _vertexCompilationState;
  22054. private _fragmentCompilationState;
  22055. private _sharedData;
  22056. private _buildId;
  22057. private _buildWasSuccessful;
  22058. private _cachedWorldViewMatrix;
  22059. private _cachedWorldViewProjectionMatrix;
  22060. private _optimizers;
  22061. private _animationFrame;
  22062. /** Define the Url to load node editor script */
  22063. static EditorURL: string;
  22064. /** Define the Url to load snippets */
  22065. static SnippetUrl: string;
  22066. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22067. static IgnoreTexturesAtLoadTime: boolean;
  22068. private BJSNODEMATERIALEDITOR;
  22069. /** Get the inspector from bundle or global */
  22070. private _getGlobalNodeMaterialEditor;
  22071. /**
  22072. * Snippet ID if the material was created from the snippet server
  22073. */
  22074. snippetId: string;
  22075. /**
  22076. * Gets or sets data used by visual editor
  22077. * @see https://nme.babylonjs.com
  22078. */
  22079. editorData: any;
  22080. /**
  22081. * 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)
  22082. */
  22083. ignoreAlpha: boolean;
  22084. /**
  22085. * Defines the maximum number of lights that can be used in the material
  22086. */
  22087. maxSimultaneousLights: number;
  22088. /**
  22089. * Observable raised when the material is built
  22090. */
  22091. onBuildObservable: Observable<NodeMaterial>;
  22092. /**
  22093. * Gets or sets the root nodes of the material vertex shader
  22094. */
  22095. _vertexOutputNodes: NodeMaterialBlock[];
  22096. /**
  22097. * Gets or sets the root nodes of the material fragment (pixel) shader
  22098. */
  22099. _fragmentOutputNodes: NodeMaterialBlock[];
  22100. /** Gets or sets options to control the node material overall behavior */
  22101. get options(): INodeMaterialOptions;
  22102. set options(options: INodeMaterialOptions);
  22103. /**
  22104. * Default configuration related to image processing available in the standard Material.
  22105. */
  22106. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22107. /**
  22108. * Gets the image processing configuration used either in this material.
  22109. */
  22110. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22111. /**
  22112. * Sets the Default image processing configuration used either in the this material.
  22113. *
  22114. * If sets to null, the scene one is in use.
  22115. */
  22116. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22117. /**
  22118. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22119. */
  22120. attachedBlocks: NodeMaterialBlock[];
  22121. /**
  22122. * Specifies the mode of the node material
  22123. * @hidden
  22124. */
  22125. _mode: NodeMaterialModes;
  22126. /**
  22127. * Gets the mode property
  22128. */
  22129. get mode(): NodeMaterialModes;
  22130. /**
  22131. * Create a new node based material
  22132. * @param name defines the material name
  22133. * @param scene defines the hosting scene
  22134. * @param options defines creation option
  22135. */
  22136. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22137. /**
  22138. * Gets the current class name of the material e.g. "NodeMaterial"
  22139. * @returns the class name
  22140. */
  22141. getClassName(): string;
  22142. /**
  22143. * Keep track of the image processing observer to allow dispose and replace.
  22144. */
  22145. private _imageProcessingObserver;
  22146. /**
  22147. * Attaches a new image processing configuration to the Standard Material.
  22148. * @param configuration
  22149. */
  22150. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22151. /**
  22152. * Get a block by its name
  22153. * @param name defines the name of the block to retrieve
  22154. * @returns the required block or null if not found
  22155. */
  22156. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22157. /**
  22158. * Get a block by its name
  22159. * @param predicate defines the predicate used to find the good candidate
  22160. * @returns the required block or null if not found
  22161. */
  22162. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22163. /**
  22164. * Get an input block by its name
  22165. * @param predicate defines the predicate used to find the good candidate
  22166. * @returns the required input block or null if not found
  22167. */
  22168. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22169. /**
  22170. * Gets the list of input blocks attached to this material
  22171. * @returns an array of InputBlocks
  22172. */
  22173. getInputBlocks(): InputBlock[];
  22174. /**
  22175. * Adds a new optimizer to the list of optimizers
  22176. * @param optimizer defines the optimizers to add
  22177. * @returns the current material
  22178. */
  22179. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22180. /**
  22181. * Remove an optimizer from the list of optimizers
  22182. * @param optimizer defines the optimizers to remove
  22183. * @returns the current material
  22184. */
  22185. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22186. /**
  22187. * Add a new block to the list of output nodes
  22188. * @param node defines the node to add
  22189. * @returns the current material
  22190. */
  22191. addOutputNode(node: NodeMaterialBlock): this;
  22192. /**
  22193. * Remove a block from the list of root nodes
  22194. * @param node defines the node to remove
  22195. * @returns the current material
  22196. */
  22197. removeOutputNode(node: NodeMaterialBlock): this;
  22198. private _addVertexOutputNode;
  22199. private _removeVertexOutputNode;
  22200. private _addFragmentOutputNode;
  22201. private _removeFragmentOutputNode;
  22202. /**
  22203. * Specifies if the material will require alpha blending
  22204. * @returns a boolean specifying if alpha blending is needed
  22205. */
  22206. needAlphaBlending(): boolean;
  22207. /**
  22208. * Specifies if this material should be rendered in alpha test mode
  22209. * @returns a boolean specifying if an alpha test is needed.
  22210. */
  22211. needAlphaTesting(): boolean;
  22212. private _initializeBlock;
  22213. private _resetDualBlocks;
  22214. /**
  22215. * Remove a block from the current node material
  22216. * @param block defines the block to remove
  22217. */
  22218. removeBlock(block: NodeMaterialBlock): void;
  22219. /**
  22220. * Build the material and generates the inner effect
  22221. * @param verbose defines if the build should log activity
  22222. */
  22223. build(verbose?: boolean): void;
  22224. /**
  22225. * Runs an otpimization phase to try to improve the shader code
  22226. */
  22227. optimize(): void;
  22228. private _prepareDefinesForAttributes;
  22229. /**
  22230. * Create a post process from the material
  22231. * @param camera The camera to apply the render pass to.
  22232. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22234. * @param engine The engine which the post process will be applied. (default: current engine)
  22235. * @param reusable If the post process can be reused on the same frame. (default: false)
  22236. * @param textureType Type of textures used when performing the post process. (default: 0)
  22237. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22238. * @returns the post process created
  22239. */
  22240. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22241. /**
  22242. * Create the post process effect from the material
  22243. * @param postProcess The post process to create the effect for
  22244. */
  22245. createEffectForPostProcess(postProcess: PostProcess): void;
  22246. private _createEffectOrPostProcess;
  22247. private _createEffectForParticles;
  22248. /**
  22249. * Create the effect to be used as the custom effect for a particle system
  22250. * @param particleSystem Particle system to create the effect for
  22251. * @param onCompiled defines a function to call when the effect creation is successful
  22252. * @param onError defines a function to call when the effect creation has failed
  22253. */
  22254. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22255. private _processDefines;
  22256. /**
  22257. * Get if the submesh is ready to be used and all its information available.
  22258. * Child classes can use it to update shaders
  22259. * @param mesh defines the mesh to check
  22260. * @param subMesh defines which submesh to check
  22261. * @param useInstances specifies that instances should be used
  22262. * @returns a boolean indicating that the submesh is ready or not
  22263. */
  22264. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22265. /**
  22266. * Get a string representing the shaders built by the current node graph
  22267. */
  22268. get compiledShaders(): string;
  22269. /**
  22270. * Binds the world matrix to the material
  22271. * @param world defines the world transformation matrix
  22272. */
  22273. bindOnlyWorldMatrix(world: Matrix): void;
  22274. /**
  22275. * Binds the submesh to this material by preparing the effect and shader to draw
  22276. * @param world defines the world transformation matrix
  22277. * @param mesh defines the mesh containing the submesh
  22278. * @param subMesh defines the submesh to bind the material to
  22279. */
  22280. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22281. /**
  22282. * Gets the active textures from the material
  22283. * @returns an array of textures
  22284. */
  22285. getActiveTextures(): BaseTexture[];
  22286. /**
  22287. * Gets the list of texture blocks
  22288. * @returns an array of texture blocks
  22289. */
  22290. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22291. /**
  22292. * Specifies if the material uses a texture
  22293. * @param texture defines the texture to check against the material
  22294. * @returns a boolean specifying if the material uses the texture
  22295. */
  22296. hasTexture(texture: BaseTexture): boolean;
  22297. /**
  22298. * Disposes the material
  22299. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22300. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22301. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22302. */
  22303. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22304. /** Creates the node editor window. */
  22305. private _createNodeEditor;
  22306. /**
  22307. * Launch the node material editor
  22308. * @param config Define the configuration of the editor
  22309. * @return a promise fulfilled when the node editor is visible
  22310. */
  22311. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22312. /**
  22313. * Clear the current material
  22314. */
  22315. clear(): void;
  22316. /**
  22317. * Clear the current material and set it to a default state
  22318. */
  22319. setToDefault(): void;
  22320. /**
  22321. * Clear the current material and set it to a default state for post process
  22322. */
  22323. setToDefaultPostProcess(): void;
  22324. /**
  22325. * Clear the current material and set it to a default state for particle
  22326. */
  22327. setToDefaultParticle(): void;
  22328. /**
  22329. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22330. * @param url defines the url to load from
  22331. * @returns a promise that will fullfil when the material is fully loaded
  22332. */
  22333. loadAsync(url: string): Promise<void>;
  22334. private _gatherBlocks;
  22335. /**
  22336. * Generate a string containing the code declaration required to create an equivalent of this material
  22337. * @returns a string
  22338. */
  22339. generateCode(): string;
  22340. /**
  22341. * Serializes this material in a JSON representation
  22342. * @returns the serialized material object
  22343. */
  22344. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22345. private _restoreConnections;
  22346. /**
  22347. * Clear the current graph and load a new one from a serialization object
  22348. * @param source defines the JSON representation of the material
  22349. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22350. * @param merge defines whether or not the source must be merged or replace the current content
  22351. */
  22352. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22353. /**
  22354. * Makes a duplicate of the current material.
  22355. * @param name - name to use for the new material.
  22356. */
  22357. clone(name: string): NodeMaterial;
  22358. /**
  22359. * Creates a node material from parsed material data
  22360. * @param source defines the JSON representation of the material
  22361. * @param scene defines the hosting scene
  22362. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22363. * @returns a new node material
  22364. */
  22365. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22366. /**
  22367. * Creates a node material from a snippet saved in a remote file
  22368. * @param name defines the name of the material to create
  22369. * @param url defines the url to load from
  22370. * @param scene defines the hosting scene
  22371. * @returns a promise that will resolve to the new node material
  22372. */
  22373. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22374. /**
  22375. * Creates a node material from a snippet saved by the node material editor
  22376. * @param snippetId defines the snippet to load
  22377. * @param scene defines the hosting scene
  22378. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22379. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22380. * @returns a promise that will resolve to the new node material
  22381. */
  22382. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22383. /**
  22384. * Creates a new node material set to default basic configuration
  22385. * @param name defines the name of the material
  22386. * @param scene defines the hosting scene
  22387. * @returns a new NodeMaterial
  22388. */
  22389. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22390. }
  22391. }
  22392. declare module BABYLON {
  22393. /**
  22394. * Size options for a post process
  22395. */
  22396. export type PostProcessOptions = {
  22397. width: number;
  22398. height: number;
  22399. };
  22400. /**
  22401. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22402. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22403. */
  22404. export class PostProcess {
  22405. /** Name of the PostProcess. */
  22406. name: string;
  22407. /**
  22408. * Gets or sets the unique id of the post process
  22409. */
  22410. uniqueId: number;
  22411. /**
  22412. * Width of the texture to apply the post process on
  22413. */
  22414. width: number;
  22415. /**
  22416. * Height of the texture to apply the post process on
  22417. */
  22418. height: number;
  22419. /**
  22420. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22421. */
  22422. nodeMaterialSource: Nullable<NodeMaterial>;
  22423. /**
  22424. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22425. * @hidden
  22426. */
  22427. _outputTexture: Nullable<InternalTexture>;
  22428. /**
  22429. * Sampling mode used by the shader
  22430. * See https://doc.babylonjs.com/classes/3.1/texture
  22431. */
  22432. renderTargetSamplingMode: number;
  22433. /**
  22434. * Clear color to use when screen clearing
  22435. */
  22436. clearColor: Color4;
  22437. /**
  22438. * If the buffer needs to be cleared before applying the post process. (default: true)
  22439. * Should be set to false if shader will overwrite all previous pixels.
  22440. */
  22441. autoClear: boolean;
  22442. /**
  22443. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22444. */
  22445. alphaMode: number;
  22446. /**
  22447. * Sets the setAlphaBlendConstants of the babylon engine
  22448. */
  22449. alphaConstants: Color4;
  22450. /**
  22451. * Animations to be used for the post processing
  22452. */
  22453. animations: Animation[];
  22454. /**
  22455. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22456. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22457. */
  22458. enablePixelPerfectMode: boolean;
  22459. /**
  22460. * Force the postprocess to be applied without taking in account viewport
  22461. */
  22462. forceFullscreenViewport: boolean;
  22463. /**
  22464. * List of inspectable custom properties (used by the Inspector)
  22465. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22466. */
  22467. inspectableCustomProperties: IInspectable[];
  22468. /**
  22469. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22470. *
  22471. * | Value | Type | Description |
  22472. * | ----- | ----------------------------------- | ----------- |
  22473. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22474. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22475. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22476. *
  22477. */
  22478. scaleMode: number;
  22479. /**
  22480. * Force textures to be a power of two (default: false)
  22481. */
  22482. alwaysForcePOT: boolean;
  22483. private _samples;
  22484. /**
  22485. * Number of sample textures (default: 1)
  22486. */
  22487. get samples(): number;
  22488. set samples(n: number);
  22489. /**
  22490. * Modify the scale of the post process to be the same as the viewport (default: false)
  22491. */
  22492. adaptScaleToCurrentViewport: boolean;
  22493. private _camera;
  22494. private _scene;
  22495. private _engine;
  22496. private _options;
  22497. private _reusable;
  22498. private _textureType;
  22499. private _textureFormat;
  22500. /**
  22501. * Smart array of input and output textures for the post process.
  22502. * @hidden
  22503. */
  22504. _textures: SmartArray<InternalTexture>;
  22505. /**
  22506. * The index in _textures that corresponds to the output texture.
  22507. * @hidden
  22508. */
  22509. _currentRenderTextureInd: number;
  22510. private _effect;
  22511. private _samplers;
  22512. private _fragmentUrl;
  22513. private _vertexUrl;
  22514. private _parameters;
  22515. private _scaleRatio;
  22516. protected _indexParameters: any;
  22517. private _shareOutputWithPostProcess;
  22518. private _texelSize;
  22519. private _forcedOutputTexture;
  22520. /**
  22521. * Returns the fragment url or shader name used in the post process.
  22522. * @returns the fragment url or name in the shader store.
  22523. */
  22524. getEffectName(): string;
  22525. /**
  22526. * An event triggered when the postprocess is activated.
  22527. */
  22528. onActivateObservable: Observable<Camera>;
  22529. private _onActivateObserver;
  22530. /**
  22531. * A function that is added to the onActivateObservable
  22532. */
  22533. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22534. /**
  22535. * An event triggered when the postprocess changes its size.
  22536. */
  22537. onSizeChangedObservable: Observable<PostProcess>;
  22538. private _onSizeChangedObserver;
  22539. /**
  22540. * A function that is added to the onSizeChangedObservable
  22541. */
  22542. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22543. /**
  22544. * An event triggered when the postprocess applies its effect.
  22545. */
  22546. onApplyObservable: Observable<Effect>;
  22547. private _onApplyObserver;
  22548. /**
  22549. * A function that is added to the onApplyObservable
  22550. */
  22551. set onApply(callback: (effect: Effect) => void);
  22552. /**
  22553. * An event triggered before rendering the postprocess
  22554. */
  22555. onBeforeRenderObservable: Observable<Effect>;
  22556. private _onBeforeRenderObserver;
  22557. /**
  22558. * A function that is added to the onBeforeRenderObservable
  22559. */
  22560. set onBeforeRender(callback: (effect: Effect) => void);
  22561. /**
  22562. * An event triggered after rendering the postprocess
  22563. */
  22564. onAfterRenderObservable: Observable<Effect>;
  22565. private _onAfterRenderObserver;
  22566. /**
  22567. * A function that is added to the onAfterRenderObservable
  22568. */
  22569. set onAfterRender(callback: (efect: Effect) => void);
  22570. /**
  22571. * 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
  22572. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22573. */
  22574. get inputTexture(): InternalTexture;
  22575. set inputTexture(value: InternalTexture);
  22576. /**
  22577. * Gets the camera which post process is applied to.
  22578. * @returns The camera the post process is applied to.
  22579. */
  22580. getCamera(): Camera;
  22581. /**
  22582. * Gets the texel size of the postprocess.
  22583. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22584. */
  22585. get texelSize(): Vector2;
  22586. /**
  22587. * Creates a new instance PostProcess
  22588. * @param name The name of the PostProcess.
  22589. * @param fragmentUrl The url of the fragment shader to be used.
  22590. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22591. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22592. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22593. * @param camera The camera to apply the render pass to.
  22594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22595. * @param engine The engine which the post process will be applied. (default: current engine)
  22596. * @param reusable If the post process can be reused on the same frame. (default: false)
  22597. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22598. * @param textureType Type of textures used when performing the post process. (default: 0)
  22599. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22600. * @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
  22601. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22602. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22603. */
  22604. constructor(
  22605. /** Name of the PostProcess. */
  22606. 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);
  22607. /**
  22608. * Gets a string idenfifying the name of the class
  22609. * @returns "PostProcess" string
  22610. */
  22611. getClassName(): string;
  22612. /**
  22613. * Gets the engine which this post process belongs to.
  22614. * @returns The engine the post process was enabled with.
  22615. */
  22616. getEngine(): Engine;
  22617. /**
  22618. * The effect that is created when initializing the post process.
  22619. * @returns The created effect corresponding the the postprocess.
  22620. */
  22621. getEffect(): Effect;
  22622. /**
  22623. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22624. * @param postProcess The post process to share the output with.
  22625. * @returns This post process.
  22626. */
  22627. shareOutputWith(postProcess: PostProcess): PostProcess;
  22628. /**
  22629. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22630. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22631. */
  22632. useOwnOutput(): void;
  22633. /**
  22634. * Updates the effect with the current post process compile time values and recompiles the shader.
  22635. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22636. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22637. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22638. * @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
  22639. * @param onCompiled Called when the shader has been compiled.
  22640. * @param onError Called if there is an error when compiling a shader.
  22641. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22642. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22643. */
  22644. 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;
  22645. /**
  22646. * The post process is reusable if it can be used multiple times within one frame.
  22647. * @returns If the post process is reusable
  22648. */
  22649. isReusable(): boolean;
  22650. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22651. markTextureDirty(): void;
  22652. /**
  22653. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22654. * 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.
  22655. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22656. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22657. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22658. * @returns The target texture that was bound to be written to.
  22659. */
  22660. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22661. /**
  22662. * If the post process is supported.
  22663. */
  22664. get isSupported(): boolean;
  22665. /**
  22666. * The aspect ratio of the output texture.
  22667. */
  22668. get aspectRatio(): number;
  22669. /**
  22670. * Get a value indicating if the post-process is ready to be used
  22671. * @returns true if the post-process is ready (shader is compiled)
  22672. */
  22673. isReady(): boolean;
  22674. /**
  22675. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22676. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22677. */
  22678. apply(): Nullable<Effect>;
  22679. private _disposeTextures;
  22680. /**
  22681. * Disposes the post process.
  22682. * @param camera The camera to dispose the post process on.
  22683. */
  22684. dispose(camera?: Camera): void;
  22685. }
  22686. }
  22687. declare module BABYLON {
  22688. /** @hidden */
  22689. export var kernelBlurVaryingDeclaration: {
  22690. name: string;
  22691. shader: string;
  22692. };
  22693. }
  22694. declare module BABYLON {
  22695. /** @hidden */
  22696. export var kernelBlurFragment: {
  22697. name: string;
  22698. shader: string;
  22699. };
  22700. }
  22701. declare module BABYLON {
  22702. /** @hidden */
  22703. export var kernelBlurFragment2: {
  22704. name: string;
  22705. shader: string;
  22706. };
  22707. }
  22708. declare module BABYLON {
  22709. /** @hidden */
  22710. export var kernelBlurPixelShader: {
  22711. name: string;
  22712. shader: string;
  22713. };
  22714. }
  22715. declare module BABYLON {
  22716. /** @hidden */
  22717. export var kernelBlurVertex: {
  22718. name: string;
  22719. shader: string;
  22720. };
  22721. }
  22722. declare module BABYLON {
  22723. /** @hidden */
  22724. export var kernelBlurVertexShader: {
  22725. name: string;
  22726. shader: string;
  22727. };
  22728. }
  22729. declare module BABYLON {
  22730. /**
  22731. * The Blur Post Process which blurs an image based on a kernel and direction.
  22732. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22733. */
  22734. export class BlurPostProcess extends PostProcess {
  22735. /** The direction in which to blur the image. */
  22736. direction: Vector2;
  22737. private blockCompilation;
  22738. protected _kernel: number;
  22739. protected _idealKernel: number;
  22740. protected _packedFloat: boolean;
  22741. private _staticDefines;
  22742. /**
  22743. * Sets the length in pixels of the blur sample region
  22744. */
  22745. set kernel(v: number);
  22746. /**
  22747. * Gets the length in pixels of the blur sample region
  22748. */
  22749. get kernel(): number;
  22750. /**
  22751. * Sets wether or not the blur needs to unpack/repack floats
  22752. */
  22753. set packedFloat(v: boolean);
  22754. /**
  22755. * Gets wether or not the blur is unpacking/repacking floats
  22756. */
  22757. get packedFloat(): boolean;
  22758. /**
  22759. * Creates a new instance BlurPostProcess
  22760. * @param name The name of the effect.
  22761. * @param direction The direction in which to blur the image.
  22762. * @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.
  22763. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22764. * @param camera The camera to apply the render pass to.
  22765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22766. * @param engine The engine which the post process will be applied. (default: current engine)
  22767. * @param reusable If the post process can be reused on the same frame. (default: false)
  22768. * @param textureType Type of textures used when performing the post process. (default: 0)
  22769. * @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)
  22770. */
  22771. constructor(name: string,
  22772. /** The direction in which to blur the image. */
  22773. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22774. /**
  22775. * Updates the effect with the current post process compile time values and recompiles the shader.
  22776. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22777. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22778. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22779. * @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
  22780. * @param onCompiled Called when the shader has been compiled.
  22781. * @param onError Called if there is an error when compiling a shader.
  22782. */
  22783. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22784. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22785. /**
  22786. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22787. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22788. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22789. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22790. * The gaps between physical kernels are compensated for in the weighting of the samples
  22791. * @param idealKernel Ideal blur kernel.
  22792. * @return Nearest best kernel.
  22793. */
  22794. protected _nearestBestKernel(idealKernel: number): number;
  22795. /**
  22796. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22797. * @param x The point on the Gaussian distribution to sample.
  22798. * @return the value of the Gaussian function at x.
  22799. */
  22800. protected _gaussianWeight(x: number): number;
  22801. /**
  22802. * Generates a string that can be used as a floating point number in GLSL.
  22803. * @param x Value to print.
  22804. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22805. * @return GLSL float string.
  22806. */
  22807. protected _glslFloat(x: number, decimalFigures?: number): string;
  22808. }
  22809. }
  22810. declare module BABYLON {
  22811. /**
  22812. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22813. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22814. * You can then easily use it as a reflectionTexture on a flat surface.
  22815. * In case the surface is not a plane, please consider relying on reflection probes.
  22816. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22817. */
  22818. export class MirrorTexture extends RenderTargetTexture {
  22819. private scene;
  22820. /**
  22821. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22822. * 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.
  22823. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22824. */
  22825. mirrorPlane: Plane;
  22826. /**
  22827. * Define the blur ratio used to blur the reflection if needed.
  22828. */
  22829. set blurRatio(value: number);
  22830. get blurRatio(): number;
  22831. /**
  22832. * Define the adaptive blur kernel used to blur the reflection if needed.
  22833. * This will autocompute the closest best match for the `blurKernel`
  22834. */
  22835. set adaptiveBlurKernel(value: number);
  22836. /**
  22837. * Define the blur kernel used to blur the reflection if needed.
  22838. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22839. */
  22840. set blurKernel(value: number);
  22841. /**
  22842. * Define the blur kernel on the X 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 blurKernelX(value: number);
  22846. get blurKernelX(): number;
  22847. /**
  22848. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22849. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22850. */
  22851. set blurKernelY(value: number);
  22852. get blurKernelY(): number;
  22853. private _autoComputeBlurKernel;
  22854. protected _onRatioRescale(): void;
  22855. private _updateGammaSpace;
  22856. private _imageProcessingConfigChangeObserver;
  22857. private _transformMatrix;
  22858. private _mirrorMatrix;
  22859. private _savedViewMatrix;
  22860. private _blurX;
  22861. private _blurY;
  22862. private _adaptiveBlurKernel;
  22863. private _blurKernelX;
  22864. private _blurKernelY;
  22865. private _blurRatio;
  22866. /**
  22867. * Instantiates a Mirror Texture.
  22868. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22869. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22870. * You can then easily use it as a reflectionTexture on a flat surface.
  22871. * In case the surface is not a plane, please consider relying on reflection probes.
  22872. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22873. * @param name
  22874. * @param size
  22875. * @param scene
  22876. * @param generateMipMaps
  22877. * @param type
  22878. * @param samplingMode
  22879. * @param generateDepthBuffer
  22880. */
  22881. constructor(name: string, size: number | {
  22882. width: number;
  22883. height: number;
  22884. } | {
  22885. ratio: number;
  22886. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22887. private _preparePostProcesses;
  22888. /**
  22889. * Clone the mirror texture.
  22890. * @returns the cloned texture
  22891. */
  22892. clone(): MirrorTexture;
  22893. /**
  22894. * Serialize the texture to a JSON representation you could use in Parse later on
  22895. * @returns the serialized JSON representation
  22896. */
  22897. serialize(): any;
  22898. /**
  22899. * Dispose the texture and release its associated resources.
  22900. */
  22901. dispose(): void;
  22902. }
  22903. }
  22904. declare module BABYLON {
  22905. /**
  22906. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22907. * @see http://doc.babylonjs.com/babylon101/materials#texture
  22908. */
  22909. export class Texture extends BaseTexture {
  22910. /**
  22911. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22912. */
  22913. static SerializeBuffers: boolean;
  22914. /** @hidden */
  22915. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22916. /** @hidden */
  22917. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22918. /** @hidden */
  22919. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22920. /** nearest is mag = nearest and min = nearest and mip = linear */
  22921. static readonly NEAREST_SAMPLINGMODE: number;
  22922. /** nearest is mag = nearest and min = nearest and mip = linear */
  22923. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22924. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22925. static readonly BILINEAR_SAMPLINGMODE: number;
  22926. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22927. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22928. /** Trilinear is mag = linear and min = linear and mip = linear */
  22929. static readonly TRILINEAR_SAMPLINGMODE: number;
  22930. /** Trilinear is mag = linear and min = linear and mip = linear */
  22931. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22932. /** mag = nearest and min = nearest and mip = nearest */
  22933. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22934. /** mag = nearest and min = linear and mip = nearest */
  22935. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22936. /** mag = nearest and min = linear and mip = linear */
  22937. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22938. /** mag = nearest and min = linear and mip = none */
  22939. static readonly NEAREST_LINEAR: number;
  22940. /** mag = nearest and min = nearest and mip = none */
  22941. static readonly NEAREST_NEAREST: number;
  22942. /** mag = linear and min = nearest and mip = nearest */
  22943. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22944. /** mag = linear and min = nearest and mip = linear */
  22945. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22946. /** mag = linear and min = linear and mip = none */
  22947. static readonly LINEAR_LINEAR: number;
  22948. /** mag = linear and min = nearest and mip = none */
  22949. static readonly LINEAR_NEAREST: number;
  22950. /** Explicit coordinates mode */
  22951. static readonly EXPLICIT_MODE: number;
  22952. /** Spherical coordinates mode */
  22953. static readonly SPHERICAL_MODE: number;
  22954. /** Planar coordinates mode */
  22955. static readonly PLANAR_MODE: number;
  22956. /** Cubic coordinates mode */
  22957. static readonly CUBIC_MODE: number;
  22958. /** Projection coordinates mode */
  22959. static readonly PROJECTION_MODE: number;
  22960. /** Inverse Cubic coordinates mode */
  22961. static readonly SKYBOX_MODE: number;
  22962. /** Inverse Cubic coordinates mode */
  22963. static readonly INVCUBIC_MODE: number;
  22964. /** Equirectangular coordinates mode */
  22965. static readonly EQUIRECTANGULAR_MODE: number;
  22966. /** Equirectangular Fixed coordinates mode */
  22967. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22968. /** Equirectangular Fixed Mirrored coordinates mode */
  22969. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22970. /** Texture is not repeating outside of 0..1 UVs */
  22971. static readonly CLAMP_ADDRESSMODE: number;
  22972. /** Texture is repeating outside of 0..1 UVs */
  22973. static readonly WRAP_ADDRESSMODE: number;
  22974. /** Texture is repeating and mirrored */
  22975. static readonly MIRROR_ADDRESSMODE: number;
  22976. /**
  22977. * 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
  22978. */
  22979. static UseSerializedUrlIfAny: boolean;
  22980. /**
  22981. * Define the url of the texture.
  22982. */
  22983. url: Nullable<string>;
  22984. /**
  22985. * Define an offset on the texture to offset the u coordinates of the UVs
  22986. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22987. */
  22988. uOffset: number;
  22989. /**
  22990. * Define an offset on the texture to offset the v coordinates of the UVs
  22991. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  22992. */
  22993. vOffset: number;
  22994. /**
  22995. * Define an offset on the texture to scale the u coordinates of the UVs
  22996. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  22997. */
  22998. uScale: number;
  22999. /**
  23000. * Define an offset on the texture to scale the v coordinates of the UVs
  23001. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  23002. */
  23003. vScale: number;
  23004. /**
  23005. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23006. * @see http://doc.babylonjs.com/how_to/more_materials
  23007. */
  23008. uAng: number;
  23009. /**
  23010. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23011. * @see http://doc.babylonjs.com/how_to/more_materials
  23012. */
  23013. vAng: number;
  23014. /**
  23015. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23016. * @see http://doc.babylonjs.com/how_to/more_materials
  23017. */
  23018. wAng: number;
  23019. /**
  23020. * Defines the center of rotation (U)
  23021. */
  23022. uRotationCenter: number;
  23023. /**
  23024. * Defines the center of rotation (V)
  23025. */
  23026. vRotationCenter: number;
  23027. /**
  23028. * Defines the center of rotation (W)
  23029. */
  23030. wRotationCenter: number;
  23031. /**
  23032. * Are mip maps generated for this texture or not.
  23033. */
  23034. get noMipmap(): boolean;
  23035. /**
  23036. * List of inspectable custom properties (used by the Inspector)
  23037. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23038. */
  23039. inspectableCustomProperties: Nullable<IInspectable[]>;
  23040. private _noMipmap;
  23041. /** @hidden */
  23042. _invertY: boolean;
  23043. private _rowGenerationMatrix;
  23044. private _cachedTextureMatrix;
  23045. private _projectionModeMatrix;
  23046. private _t0;
  23047. private _t1;
  23048. private _t2;
  23049. private _cachedUOffset;
  23050. private _cachedVOffset;
  23051. private _cachedUScale;
  23052. private _cachedVScale;
  23053. private _cachedUAng;
  23054. private _cachedVAng;
  23055. private _cachedWAng;
  23056. private _cachedProjectionMatrixId;
  23057. private _cachedCoordinatesMode;
  23058. /** @hidden */
  23059. protected _initialSamplingMode: number;
  23060. /** @hidden */
  23061. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23062. private _deleteBuffer;
  23063. protected _format: Nullable<number>;
  23064. private _delayedOnLoad;
  23065. private _delayedOnError;
  23066. private _mimeType?;
  23067. /**
  23068. * Observable triggered once the texture has been loaded.
  23069. */
  23070. onLoadObservable: Observable<Texture>;
  23071. protected _isBlocking: boolean;
  23072. /**
  23073. * Is the texture preventing material to render while loading.
  23074. * If false, a default texture will be used instead of the loading one during the preparation step.
  23075. */
  23076. set isBlocking(value: boolean);
  23077. get isBlocking(): boolean;
  23078. /**
  23079. * Get the current sampling mode associated with the texture.
  23080. */
  23081. get samplingMode(): number;
  23082. /**
  23083. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23084. */
  23085. get invertY(): boolean;
  23086. /**
  23087. * Instantiates a new texture.
  23088. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23089. * @see http://doc.babylonjs.com/babylon101/materials#texture
  23090. * @param url defines the url of the picture to load as a texture
  23091. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23092. * @param noMipmap defines if the texture will require mip maps or not
  23093. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23094. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23095. * @param onLoad defines a callback triggered when the texture has been loaded
  23096. * @param onError defines a callback triggered when an error occurred during the loading session
  23097. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23098. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23099. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23100. * @param mimeType defines an optional mime type information
  23101. */
  23102. 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);
  23103. /**
  23104. * Update the url (and optional buffer) of this texture if url was null during construction.
  23105. * @param url the url of the texture
  23106. * @param buffer the buffer of the texture (defaults to null)
  23107. * @param onLoad callback called when the texture is loaded (defaults to null)
  23108. */
  23109. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23110. /**
  23111. * Finish the loading sequence of a texture flagged as delayed load.
  23112. * @hidden
  23113. */
  23114. delayLoad(): void;
  23115. private _prepareRowForTextureGeneration;
  23116. /**
  23117. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23118. * @returns the transform matrix of the texture.
  23119. */
  23120. getTextureMatrix(uBase?: number): Matrix;
  23121. /**
  23122. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23123. * @returns The reflection texture transform
  23124. */
  23125. getReflectionTextureMatrix(): Matrix;
  23126. /**
  23127. * Clones the texture.
  23128. * @returns the cloned texture
  23129. */
  23130. clone(): Texture;
  23131. /**
  23132. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23133. * @returns The JSON representation of the texture
  23134. */
  23135. serialize(): any;
  23136. /**
  23137. * Get the current class name of the texture useful for serialization or dynamic coding.
  23138. * @returns "Texture"
  23139. */
  23140. getClassName(): string;
  23141. /**
  23142. * Dispose the texture and release its associated resources.
  23143. */
  23144. dispose(): void;
  23145. /**
  23146. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23147. * @param parsedTexture Define the JSON representation of the texture
  23148. * @param scene Define the scene the parsed texture should be instantiated in
  23149. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23150. * @returns The parsed texture if successful
  23151. */
  23152. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23153. /**
  23154. * Creates a texture from its base 64 representation.
  23155. * @param data Define the base64 payload without the data: prefix
  23156. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23157. * @param scene Define the scene the texture should belong to
  23158. * @param noMipmap Forces the texture to not create mip map information if true
  23159. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23160. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23161. * @param onLoad define a callback triggered when the texture has been loaded
  23162. * @param onError define a callback triggered when an error occurred during the loading session
  23163. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23164. * @returns the created texture
  23165. */
  23166. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23167. /**
  23168. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23169. * @param data Define the base64 payload without the data: prefix
  23170. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23171. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23172. * @param scene Define the scene the texture should belong to
  23173. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23174. * @param noMipmap Forces the texture to not create mip map information if true
  23175. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23176. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23177. * @param onLoad define a callback triggered when the texture has been loaded
  23178. * @param onError define a callback triggered when an error occurred during the loading session
  23179. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23180. * @returns the created texture
  23181. */
  23182. 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;
  23183. }
  23184. }
  23185. declare module BABYLON {
  23186. /**
  23187. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23188. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23189. */
  23190. export class PostProcessManager {
  23191. private _scene;
  23192. private _indexBuffer;
  23193. private _vertexBuffers;
  23194. /**
  23195. * Creates a new instance PostProcess
  23196. * @param scene The scene that the post process is associated with.
  23197. */
  23198. constructor(scene: Scene);
  23199. private _prepareBuffers;
  23200. private _buildIndexBuffer;
  23201. /**
  23202. * Rebuilds the vertex buffers of the manager.
  23203. * @hidden
  23204. */
  23205. _rebuild(): void;
  23206. /**
  23207. * Prepares a frame to be run through a post process.
  23208. * @param sourceTexture The input texture to the post procesess. (default: null)
  23209. * @param postProcesses An array of post processes to be run. (default: null)
  23210. * @returns True if the post processes were able to be run.
  23211. * @hidden
  23212. */
  23213. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23214. /**
  23215. * Manually render a set of post processes to a texture.
  23216. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23217. * @param postProcesses An array of post processes to be run.
  23218. * @param targetTexture The target texture to render to.
  23219. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23220. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23221. * @param lodLevel defines which lod of the texture to render to
  23222. */
  23223. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  23224. /**
  23225. * Finalize the result of the output of the postprocesses.
  23226. * @param doNotPresent If true the result will not be displayed to the screen.
  23227. * @param targetTexture The target texture to render to.
  23228. * @param faceIndex The index of the face to bind the target texture to.
  23229. * @param postProcesses The array of post processes to render.
  23230. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23231. * @hidden
  23232. */
  23233. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23234. /**
  23235. * Disposes of the post process manager.
  23236. */
  23237. dispose(): void;
  23238. }
  23239. }
  23240. declare module BABYLON {
  23241. /**
  23242. * This Helps creating a texture that will be created from a camera in your scene.
  23243. * It is basically a dynamic texture that could be used to create special effects for instance.
  23244. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23245. */
  23246. export class RenderTargetTexture extends Texture {
  23247. isCube: boolean;
  23248. /**
  23249. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23250. */
  23251. static readonly REFRESHRATE_RENDER_ONCE: number;
  23252. /**
  23253. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23254. */
  23255. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23256. /**
  23257. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23258. * the central point of your effect and can save a lot of performances.
  23259. */
  23260. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23261. /**
  23262. * Use this predicate to dynamically define the list of mesh you want to render.
  23263. * If set, the renderList property will be overwritten.
  23264. */
  23265. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23266. private _renderList;
  23267. /**
  23268. * Use this list to define the list of mesh you want to render.
  23269. */
  23270. get renderList(): Nullable<Array<AbstractMesh>>;
  23271. set renderList(value: Nullable<Array<AbstractMesh>>);
  23272. /**
  23273. * Use this function to overload the renderList array at rendering time.
  23274. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23275. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23276. * the cube (if the RTT is a cube, else layerOrFace=0).
  23277. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23278. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23279. * hold dummy elements!
  23280. */
  23281. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23282. private _hookArray;
  23283. /**
  23284. * Define if particles should be rendered in your texture.
  23285. */
  23286. renderParticles: boolean;
  23287. /**
  23288. * Define if sprites should be rendered in your texture.
  23289. */
  23290. renderSprites: boolean;
  23291. /**
  23292. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23293. */
  23294. coordinatesMode: number;
  23295. /**
  23296. * Define the camera used to render the texture.
  23297. */
  23298. activeCamera: Nullable<Camera>;
  23299. /**
  23300. * Override the mesh isReady function with your own one.
  23301. */
  23302. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23303. /**
  23304. * Override the render function of the texture with your own one.
  23305. */
  23306. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23307. /**
  23308. * Define if camera post processes should be use while rendering the texture.
  23309. */
  23310. useCameraPostProcesses: boolean;
  23311. /**
  23312. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23313. */
  23314. ignoreCameraViewport: boolean;
  23315. private _postProcessManager;
  23316. private _postProcesses;
  23317. private _resizeObserver;
  23318. /**
  23319. * An event triggered when the texture is unbind.
  23320. */
  23321. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23322. /**
  23323. * An event triggered when the texture is unbind.
  23324. */
  23325. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23326. private _onAfterUnbindObserver;
  23327. /**
  23328. * Set a after unbind callback in the texture.
  23329. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23330. */
  23331. set onAfterUnbind(callback: () => void);
  23332. /**
  23333. * An event triggered before rendering the texture
  23334. */
  23335. onBeforeRenderObservable: Observable<number>;
  23336. private _onBeforeRenderObserver;
  23337. /**
  23338. * Set a before render callback in the texture.
  23339. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23340. */
  23341. set onBeforeRender(callback: (faceIndex: number) => void);
  23342. /**
  23343. * An event triggered after rendering the texture
  23344. */
  23345. onAfterRenderObservable: Observable<number>;
  23346. private _onAfterRenderObserver;
  23347. /**
  23348. * Set a after render callback in the texture.
  23349. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23350. */
  23351. set onAfterRender(callback: (faceIndex: number) => void);
  23352. /**
  23353. * An event triggered after the texture clear
  23354. */
  23355. onClearObservable: Observable<Engine>;
  23356. private _onClearObserver;
  23357. /**
  23358. * Set a clear callback in the texture.
  23359. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23360. */
  23361. set onClear(callback: (Engine: Engine) => void);
  23362. /**
  23363. * An event triggered when the texture is resized.
  23364. */
  23365. onResizeObservable: Observable<RenderTargetTexture>;
  23366. /**
  23367. * Define the clear color of the Render Target if it should be different from the scene.
  23368. */
  23369. clearColor: Color4;
  23370. protected _size: number | {
  23371. width: number;
  23372. height: number;
  23373. layers?: number;
  23374. };
  23375. protected _initialSizeParameter: number | {
  23376. width: number;
  23377. height: number;
  23378. } | {
  23379. ratio: number;
  23380. };
  23381. protected _sizeRatio: Nullable<number>;
  23382. /** @hidden */
  23383. _generateMipMaps: boolean;
  23384. protected _renderingManager: RenderingManager;
  23385. /** @hidden */
  23386. _waitingRenderList: string[];
  23387. protected _doNotChangeAspectRatio: boolean;
  23388. protected _currentRefreshId: number;
  23389. protected _refreshRate: number;
  23390. protected _textureMatrix: Matrix;
  23391. protected _samples: number;
  23392. protected _renderTargetOptions: RenderTargetCreationOptions;
  23393. /**
  23394. * Gets render target creation options that were used.
  23395. */
  23396. get renderTargetOptions(): RenderTargetCreationOptions;
  23397. protected _onRatioRescale(): void;
  23398. /**
  23399. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23400. * It must define where the camera used to render the texture is set
  23401. */
  23402. boundingBoxPosition: Vector3;
  23403. private _boundingBoxSize;
  23404. /**
  23405. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23406. * When defined, the cubemap will switch to local mode
  23407. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23408. * @example https://www.babylonjs-playground.com/#RNASML
  23409. */
  23410. set boundingBoxSize(value: Vector3);
  23411. get boundingBoxSize(): Vector3;
  23412. /**
  23413. * In case the RTT has been created with a depth texture, get the associated
  23414. * depth texture.
  23415. * Otherwise, return null.
  23416. */
  23417. get depthStencilTexture(): Nullable<InternalTexture>;
  23418. /**
  23419. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23420. * or used a shadow, depth texture...
  23421. * @param name The friendly name of the texture
  23422. * @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)
  23423. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23424. * @param generateMipMaps True if mip maps need to be generated after render.
  23425. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23426. * @param type The type of the buffer in the RTT (int, half float, float...)
  23427. * @param isCube True if a cube texture needs to be created
  23428. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23429. * @param generateDepthBuffer True to generate a depth buffer
  23430. * @param generateStencilBuffer True to generate a stencil buffer
  23431. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23432. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23433. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23434. */
  23435. constructor(name: string, size: number | {
  23436. width: number;
  23437. height: number;
  23438. layers?: number;
  23439. } | {
  23440. ratio: number;
  23441. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23442. /**
  23443. * Creates a depth stencil texture.
  23444. * This is only available in WebGL 2 or with the depth texture extension available.
  23445. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23446. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23447. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23448. */
  23449. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23450. private _processSizeParameter;
  23451. /**
  23452. * Define the number of samples to use in case of MSAA.
  23453. * It defaults to one meaning no MSAA has been enabled.
  23454. */
  23455. get samples(): number;
  23456. set samples(value: number);
  23457. /**
  23458. * Resets the refresh counter of the texture and start bak from scratch.
  23459. * Could be useful to regenerate the texture if it is setup to render only once.
  23460. */
  23461. resetRefreshCounter(): void;
  23462. /**
  23463. * Define the refresh rate of the texture or the rendering frequency.
  23464. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23465. */
  23466. get refreshRate(): number;
  23467. set refreshRate(value: number);
  23468. /**
  23469. * Adds a post process to the render target rendering passes.
  23470. * @param postProcess define the post process to add
  23471. */
  23472. addPostProcess(postProcess: PostProcess): void;
  23473. /**
  23474. * Clear all the post processes attached to the render target
  23475. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23476. */
  23477. clearPostProcesses(dispose?: boolean): void;
  23478. /**
  23479. * Remove one of the post process from the list of attached post processes to the texture
  23480. * @param postProcess define the post process to remove from the list
  23481. */
  23482. removePostProcess(postProcess: PostProcess): void;
  23483. /** @hidden */
  23484. _shouldRender(): boolean;
  23485. /**
  23486. * Gets the actual render size of the texture.
  23487. * @returns the width of the render size
  23488. */
  23489. getRenderSize(): number;
  23490. /**
  23491. * Gets the actual render width of the texture.
  23492. * @returns the width of the render size
  23493. */
  23494. getRenderWidth(): number;
  23495. /**
  23496. * Gets the actual render height of the texture.
  23497. * @returns the height of the render size
  23498. */
  23499. getRenderHeight(): number;
  23500. /**
  23501. * Gets the actual number of layers of the texture.
  23502. * @returns the number of layers
  23503. */
  23504. getRenderLayers(): number;
  23505. /**
  23506. * Get if the texture can be rescaled or not.
  23507. */
  23508. get canRescale(): boolean;
  23509. /**
  23510. * Resize the texture using a ratio.
  23511. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23512. */
  23513. scale(ratio: number): void;
  23514. /**
  23515. * Get the texture reflection matrix used to rotate/transform the reflection.
  23516. * @returns the reflection matrix
  23517. */
  23518. getReflectionTextureMatrix(): Matrix;
  23519. /**
  23520. * Resize the texture to a new desired size.
  23521. * Be carrefull as it will recreate all the data in the new texture.
  23522. * @param size Define the new size. It can be:
  23523. * - a number for squared texture,
  23524. * - an object containing { width: number, height: number }
  23525. * - or an object containing a ratio { ratio: number }
  23526. */
  23527. resize(size: number | {
  23528. width: number;
  23529. height: number;
  23530. } | {
  23531. ratio: number;
  23532. }): void;
  23533. private _defaultRenderListPrepared;
  23534. /**
  23535. * Renders all the objects from the render list into the texture.
  23536. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23537. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23538. */
  23539. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23540. private _bestReflectionRenderTargetDimension;
  23541. private _prepareRenderingManager;
  23542. /**
  23543. * @hidden
  23544. * @param faceIndex face index to bind to if this is a cubetexture
  23545. * @param layer defines the index of the texture to bind in the array
  23546. */
  23547. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23548. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23549. private renderToTarget;
  23550. /**
  23551. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23552. * This allowed control for front to back rendering or reversly depending of the special needs.
  23553. *
  23554. * @param renderingGroupId The rendering group id corresponding to its index
  23555. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23556. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23557. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23558. */
  23559. 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;
  23560. /**
  23561. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23562. *
  23563. * @param renderingGroupId The rendering group id corresponding to its index
  23564. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23565. */
  23566. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23567. /**
  23568. * Clones the texture.
  23569. * @returns the cloned texture
  23570. */
  23571. clone(): RenderTargetTexture;
  23572. /**
  23573. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23574. * @returns The JSON representation of the texture
  23575. */
  23576. serialize(): any;
  23577. /**
  23578. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23579. */
  23580. disposeFramebufferObjects(): void;
  23581. /**
  23582. * Dispose the texture and release its associated resources.
  23583. */
  23584. dispose(): void;
  23585. /** @hidden */
  23586. _rebuild(): void;
  23587. /**
  23588. * Clear the info related to rendering groups preventing retention point in material dispose.
  23589. */
  23590. freeRenderingGroups(): void;
  23591. /**
  23592. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23593. * @returns the view count
  23594. */
  23595. getViewCount(): number;
  23596. }
  23597. }
  23598. declare module BABYLON {
  23599. /**
  23600. * Class used to manipulate GUIDs
  23601. */
  23602. export class GUID {
  23603. /**
  23604. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23605. * Be aware Math.random() could cause collisions, but:
  23606. * "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"
  23607. * @returns a pseudo random id
  23608. */
  23609. static RandomId(): string;
  23610. }
  23611. }
  23612. declare module BABYLON {
  23613. /**
  23614. * Options to be used when creating a shadow depth material
  23615. */
  23616. export interface IIOptionShadowDepthMaterial {
  23617. /** Variables in the vertex shader code that need to have their names remapped.
  23618. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23619. * "var_name" should be either: worldPos or vNormalW
  23620. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23621. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23622. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23623. */
  23624. remappedVariables?: string[];
  23625. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23626. standalone?: boolean;
  23627. }
  23628. /**
  23629. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23630. */
  23631. export class ShadowDepthWrapper {
  23632. private _scene;
  23633. private _options?;
  23634. private _baseMaterial;
  23635. private _onEffectCreatedObserver;
  23636. private _subMeshToEffect;
  23637. private _subMeshToDepthEffect;
  23638. private _meshes;
  23639. /** @hidden */
  23640. _matriceNames: any;
  23641. /** Gets the standalone status of the wrapper */
  23642. get standalone(): boolean;
  23643. /** Gets the base material the wrapper is built upon */
  23644. get baseMaterial(): Material;
  23645. /**
  23646. * Instantiate a new shadow depth wrapper.
  23647. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23648. * generate the shadow depth map. For more information, please refer to the documentation:
  23649. * https://doc.babylonjs.com/babylon101/shadows
  23650. * @param baseMaterial Material to wrap
  23651. * @param scene Define the scene the material belongs to
  23652. * @param options Options used to create the wrapper
  23653. */
  23654. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23655. /**
  23656. * Gets the effect to use to generate the depth map
  23657. * @param subMesh subMesh to get the effect for
  23658. * @param shadowGenerator shadow generator to get the effect for
  23659. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23660. */
  23661. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23662. /**
  23663. * Specifies that the submesh is ready to be used for depth rendering
  23664. * @param subMesh submesh to check
  23665. * @param defines the list of defines to take into account when checking the effect
  23666. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23667. * @param useInstances specifies that instances should be used
  23668. * @returns a boolean indicating that the submesh is ready or not
  23669. */
  23670. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23671. /**
  23672. * Disposes the resources
  23673. */
  23674. dispose(): void;
  23675. private _makeEffect;
  23676. }
  23677. }
  23678. declare module BABYLON {
  23679. /**
  23680. * Options for compiling materials.
  23681. */
  23682. export interface IMaterialCompilationOptions {
  23683. /**
  23684. * Defines whether clip planes are enabled.
  23685. */
  23686. clipPlane: boolean;
  23687. /**
  23688. * Defines whether instances are enabled.
  23689. */
  23690. useInstances: boolean;
  23691. }
  23692. /**
  23693. * Options passed when calling customShaderNameResolve
  23694. */
  23695. export interface ICustomShaderNameResolveOptions {
  23696. /**
  23697. * 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
  23698. */
  23699. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23700. }
  23701. /**
  23702. * Base class for the main features of a material in Babylon.js
  23703. */
  23704. export class Material implements IAnimatable {
  23705. /**
  23706. * Returns the triangle fill mode
  23707. */
  23708. static readonly TriangleFillMode: number;
  23709. /**
  23710. * Returns the wireframe mode
  23711. */
  23712. static readonly WireFrameFillMode: number;
  23713. /**
  23714. * Returns the point fill mode
  23715. */
  23716. static readonly PointFillMode: number;
  23717. /**
  23718. * Returns the point list draw mode
  23719. */
  23720. static readonly PointListDrawMode: number;
  23721. /**
  23722. * Returns the line list draw mode
  23723. */
  23724. static readonly LineListDrawMode: number;
  23725. /**
  23726. * Returns the line loop draw mode
  23727. */
  23728. static readonly LineLoopDrawMode: number;
  23729. /**
  23730. * Returns the line strip draw mode
  23731. */
  23732. static readonly LineStripDrawMode: number;
  23733. /**
  23734. * Returns the triangle strip draw mode
  23735. */
  23736. static readonly TriangleStripDrawMode: number;
  23737. /**
  23738. * Returns the triangle fan draw mode
  23739. */
  23740. static readonly TriangleFanDrawMode: number;
  23741. /**
  23742. * Stores the clock-wise side orientation
  23743. */
  23744. static readonly ClockWiseSideOrientation: number;
  23745. /**
  23746. * Stores the counter clock-wise side orientation
  23747. */
  23748. static readonly CounterClockWiseSideOrientation: number;
  23749. /**
  23750. * The dirty texture flag value
  23751. */
  23752. static readonly TextureDirtyFlag: number;
  23753. /**
  23754. * The dirty light flag value
  23755. */
  23756. static readonly LightDirtyFlag: number;
  23757. /**
  23758. * The dirty fresnel flag value
  23759. */
  23760. static readonly FresnelDirtyFlag: number;
  23761. /**
  23762. * The dirty attribute flag value
  23763. */
  23764. static readonly AttributesDirtyFlag: number;
  23765. /**
  23766. * The dirty misc flag value
  23767. */
  23768. static readonly MiscDirtyFlag: number;
  23769. /**
  23770. * The all dirty flag value
  23771. */
  23772. static readonly AllDirtyFlag: number;
  23773. /**
  23774. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23775. */
  23776. static readonly MATERIAL_OPAQUE: number;
  23777. /**
  23778. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23779. */
  23780. static readonly MATERIAL_ALPHATEST: number;
  23781. /**
  23782. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23783. */
  23784. static readonly MATERIAL_ALPHABLEND: number;
  23785. /**
  23786. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23787. * They are also discarded below the alpha cutoff threshold to improve performances.
  23788. */
  23789. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23790. /**
  23791. * The Whiteout method is used to blend normals.
  23792. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23793. */
  23794. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  23795. /**
  23796. * The Reoriented Normal Mapping method is used to blend normals.
  23797. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23798. */
  23799. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  23800. /**
  23801. * Custom callback helping to override the default shader used in the material.
  23802. */
  23803. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23804. /**
  23805. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23806. */
  23807. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23808. /**
  23809. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23810. * This means that the material can keep using a previous shader while a new one is being compiled.
  23811. * This is mostly used when shader parallel compilation is supported (true by default)
  23812. */
  23813. allowShaderHotSwapping: boolean;
  23814. /**
  23815. * The ID of the material
  23816. */
  23817. id: string;
  23818. /**
  23819. * Gets or sets the unique id of the material
  23820. */
  23821. uniqueId: number;
  23822. /**
  23823. * The name of the material
  23824. */
  23825. name: string;
  23826. /**
  23827. * Gets or sets user defined metadata
  23828. */
  23829. metadata: any;
  23830. /**
  23831. * For internal use only. Please do not use.
  23832. */
  23833. reservedDataStore: any;
  23834. /**
  23835. * Specifies if the ready state should be checked on each call
  23836. */
  23837. checkReadyOnEveryCall: boolean;
  23838. /**
  23839. * Specifies if the ready state should be checked once
  23840. */
  23841. checkReadyOnlyOnce: boolean;
  23842. /**
  23843. * The state of the material
  23844. */
  23845. state: string;
  23846. /**
  23847. * The alpha value of the material
  23848. */
  23849. protected _alpha: number;
  23850. /**
  23851. * List of inspectable custom properties (used by the Inspector)
  23852. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23853. */
  23854. inspectableCustomProperties: IInspectable[];
  23855. /**
  23856. * Sets the alpha value of the material
  23857. */
  23858. set alpha(value: number);
  23859. /**
  23860. * Gets the alpha value of the material
  23861. */
  23862. get alpha(): number;
  23863. /**
  23864. * Specifies if back face culling is enabled
  23865. */
  23866. protected _backFaceCulling: boolean;
  23867. /**
  23868. * Sets the back-face culling state
  23869. */
  23870. set backFaceCulling(value: boolean);
  23871. /**
  23872. * Gets the back-face culling state
  23873. */
  23874. get backFaceCulling(): boolean;
  23875. /**
  23876. * Stores the value for side orientation
  23877. */
  23878. sideOrientation: number;
  23879. /**
  23880. * Callback triggered when the material is compiled
  23881. */
  23882. onCompiled: Nullable<(effect: Effect) => void>;
  23883. /**
  23884. * Callback triggered when an error occurs
  23885. */
  23886. onError: Nullable<(effect: Effect, errors: string) => void>;
  23887. /**
  23888. * Callback triggered to get the render target textures
  23889. */
  23890. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23891. /**
  23892. * Gets a boolean indicating that current material needs to register RTT
  23893. */
  23894. get hasRenderTargetTextures(): boolean;
  23895. /**
  23896. * Specifies if the material should be serialized
  23897. */
  23898. doNotSerialize: boolean;
  23899. /**
  23900. * @hidden
  23901. */
  23902. _storeEffectOnSubMeshes: boolean;
  23903. /**
  23904. * Stores the animations for the material
  23905. */
  23906. animations: Nullable<Array<Animation>>;
  23907. /**
  23908. * An event triggered when the material is disposed
  23909. */
  23910. onDisposeObservable: Observable<Material>;
  23911. /**
  23912. * An observer which watches for dispose events
  23913. */
  23914. private _onDisposeObserver;
  23915. private _onUnBindObservable;
  23916. /**
  23917. * Called during a dispose event
  23918. */
  23919. set onDispose(callback: () => void);
  23920. private _onBindObservable;
  23921. /**
  23922. * An event triggered when the material is bound
  23923. */
  23924. get onBindObservable(): Observable<AbstractMesh>;
  23925. /**
  23926. * An observer which watches for bind events
  23927. */
  23928. private _onBindObserver;
  23929. /**
  23930. * Called during a bind event
  23931. */
  23932. set onBind(callback: (Mesh: AbstractMesh) => void);
  23933. /**
  23934. * An event triggered when the material is unbound
  23935. */
  23936. get onUnBindObservable(): Observable<Material>;
  23937. protected _onEffectCreatedObservable: Nullable<Observable<{
  23938. effect: Effect;
  23939. subMesh: Nullable<SubMesh>;
  23940. }>>;
  23941. /**
  23942. * An event triggered when the effect is (re)created
  23943. */
  23944. get onEffectCreatedObservable(): Observable<{
  23945. effect: Effect;
  23946. subMesh: Nullable<SubMesh>;
  23947. }>;
  23948. /**
  23949. * Stores the value of the alpha mode
  23950. */
  23951. private _alphaMode;
  23952. /**
  23953. * Sets the value of the alpha mode.
  23954. *
  23955. * | Value | Type | Description |
  23956. * | --- | --- | --- |
  23957. * | 0 | ALPHA_DISABLE | |
  23958. * | 1 | ALPHA_ADD | |
  23959. * | 2 | ALPHA_COMBINE | |
  23960. * | 3 | ALPHA_SUBTRACT | |
  23961. * | 4 | ALPHA_MULTIPLY | |
  23962. * | 5 | ALPHA_MAXIMIZED | |
  23963. * | 6 | ALPHA_ONEONE | |
  23964. * | 7 | ALPHA_PREMULTIPLIED | |
  23965. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23966. * | 9 | ALPHA_INTERPOLATE | |
  23967. * | 10 | ALPHA_SCREENMODE | |
  23968. *
  23969. */
  23970. set alphaMode(value: number);
  23971. /**
  23972. * Gets the value of the alpha mode
  23973. */
  23974. get alphaMode(): number;
  23975. /**
  23976. * Stores the state of the need depth pre-pass value
  23977. */
  23978. private _needDepthPrePass;
  23979. /**
  23980. * Sets the need depth pre-pass value
  23981. */
  23982. set needDepthPrePass(value: boolean);
  23983. /**
  23984. * Gets the depth pre-pass value
  23985. */
  23986. get needDepthPrePass(): boolean;
  23987. /**
  23988. * Specifies if depth writing should be disabled
  23989. */
  23990. disableDepthWrite: boolean;
  23991. /**
  23992. * Specifies if color writing should be disabled
  23993. */
  23994. disableColorWrite: boolean;
  23995. /**
  23996. * Specifies if depth writing should be forced
  23997. */
  23998. forceDepthWrite: boolean;
  23999. /**
  24000. * Specifies the depth function that should be used. 0 means the default engine function
  24001. */
  24002. depthFunction: number;
  24003. /**
  24004. * Specifies if there should be a separate pass for culling
  24005. */
  24006. separateCullingPass: boolean;
  24007. /**
  24008. * Stores the state specifing if fog should be enabled
  24009. */
  24010. private _fogEnabled;
  24011. /**
  24012. * Sets the state for enabling fog
  24013. */
  24014. set fogEnabled(value: boolean);
  24015. /**
  24016. * Gets the value of the fog enabled state
  24017. */
  24018. get fogEnabled(): boolean;
  24019. /**
  24020. * Stores the size of points
  24021. */
  24022. pointSize: number;
  24023. /**
  24024. * Stores the z offset value
  24025. */
  24026. zOffset: number;
  24027. get wireframe(): boolean;
  24028. /**
  24029. * Sets the state of wireframe mode
  24030. */
  24031. set wireframe(value: boolean);
  24032. /**
  24033. * Gets the value specifying if point clouds are enabled
  24034. */
  24035. get pointsCloud(): boolean;
  24036. /**
  24037. * Sets the state of point cloud mode
  24038. */
  24039. set pointsCloud(value: boolean);
  24040. /**
  24041. * Gets the material fill mode
  24042. */
  24043. get fillMode(): number;
  24044. /**
  24045. * Sets the material fill mode
  24046. */
  24047. set fillMode(value: number);
  24048. /**
  24049. * @hidden
  24050. * Stores the effects for the material
  24051. */
  24052. _effect: Nullable<Effect>;
  24053. /**
  24054. * Specifies if uniform buffers should be used
  24055. */
  24056. private _useUBO;
  24057. /**
  24058. * Stores a reference to the scene
  24059. */
  24060. private _scene;
  24061. /**
  24062. * Stores the fill mode state
  24063. */
  24064. private _fillMode;
  24065. /**
  24066. * Specifies if the depth write state should be cached
  24067. */
  24068. private _cachedDepthWriteState;
  24069. /**
  24070. * Specifies if the color write state should be cached
  24071. */
  24072. private _cachedColorWriteState;
  24073. /**
  24074. * Specifies if the depth function state should be cached
  24075. */
  24076. private _cachedDepthFunctionState;
  24077. /**
  24078. * Stores the uniform buffer
  24079. */
  24080. protected _uniformBuffer: UniformBuffer;
  24081. /** @hidden */
  24082. _indexInSceneMaterialArray: number;
  24083. /** @hidden */
  24084. meshMap: Nullable<{
  24085. [id: string]: AbstractMesh | undefined;
  24086. }>;
  24087. /**
  24088. * Creates a material instance
  24089. * @param name defines the name of the material
  24090. * @param scene defines the scene to reference
  24091. * @param doNotAdd specifies if the material should be added to the scene
  24092. */
  24093. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24094. /**
  24095. * Returns a string representation of the current material
  24096. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24097. * @returns a string with material information
  24098. */
  24099. toString(fullDetails?: boolean): string;
  24100. /**
  24101. * Gets the class name of the material
  24102. * @returns a string with the class name of the material
  24103. */
  24104. getClassName(): string;
  24105. /**
  24106. * Specifies if updates for the material been locked
  24107. */
  24108. get isFrozen(): boolean;
  24109. /**
  24110. * Locks updates for the material
  24111. */
  24112. freeze(): void;
  24113. /**
  24114. * Unlocks updates for the material
  24115. */
  24116. unfreeze(): void;
  24117. /**
  24118. * Specifies if the material is ready to be used
  24119. * @param mesh defines the mesh to check
  24120. * @param useInstances specifies if instances should be used
  24121. * @returns a boolean indicating if the material is ready to be used
  24122. */
  24123. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24124. /**
  24125. * Specifies that the submesh is ready to be used
  24126. * @param mesh defines the mesh to check
  24127. * @param subMesh defines which submesh to check
  24128. * @param useInstances specifies that instances should be used
  24129. * @returns a boolean indicating that the submesh is ready or not
  24130. */
  24131. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24132. /**
  24133. * Returns the material effect
  24134. * @returns the effect associated with the material
  24135. */
  24136. getEffect(): Nullable<Effect>;
  24137. /**
  24138. * Returns the current scene
  24139. * @returns a Scene
  24140. */
  24141. getScene(): Scene;
  24142. /**
  24143. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24144. */
  24145. protected _forceAlphaTest: boolean;
  24146. /**
  24147. * The transparency mode of the material.
  24148. */
  24149. protected _transparencyMode: Nullable<number>;
  24150. /**
  24151. * Gets the current transparency mode.
  24152. */
  24153. get transparencyMode(): Nullable<number>;
  24154. /**
  24155. * Sets the transparency mode of the material.
  24156. *
  24157. * | Value | Type | Description |
  24158. * | ----- | ----------------------------------- | ----------- |
  24159. * | 0 | OPAQUE | |
  24160. * | 1 | ALPHATEST | |
  24161. * | 2 | ALPHABLEND | |
  24162. * | 3 | ALPHATESTANDBLEND | |
  24163. *
  24164. */
  24165. set transparencyMode(value: Nullable<number>);
  24166. /**
  24167. * Returns true if alpha blending should be disabled.
  24168. */
  24169. protected get _disableAlphaBlending(): boolean;
  24170. /**
  24171. * Specifies whether or not this material should be rendered in alpha blend mode.
  24172. * @returns a boolean specifying if alpha blending is needed
  24173. */
  24174. needAlphaBlending(): boolean;
  24175. /**
  24176. * Specifies if the mesh will require alpha blending
  24177. * @param mesh defines the mesh to check
  24178. * @returns a boolean specifying if alpha blending is needed for the mesh
  24179. */
  24180. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24181. /**
  24182. * Specifies whether or not this material should be rendered in alpha test mode.
  24183. * @returns a boolean specifying if an alpha test is needed.
  24184. */
  24185. needAlphaTesting(): boolean;
  24186. /**
  24187. * Specifies if material alpha testing should be turned on for the mesh
  24188. * @param mesh defines the mesh to check
  24189. */
  24190. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24191. /**
  24192. * Gets the texture used for the alpha test
  24193. * @returns the texture to use for alpha testing
  24194. */
  24195. getAlphaTestTexture(): Nullable<BaseTexture>;
  24196. /**
  24197. * Marks the material to indicate that it needs to be re-calculated
  24198. */
  24199. markDirty(): void;
  24200. /** @hidden */
  24201. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24202. /**
  24203. * Binds the material to the mesh
  24204. * @param world defines the world transformation matrix
  24205. * @param mesh defines the mesh to bind the material to
  24206. */
  24207. bind(world: Matrix, mesh?: Mesh): void;
  24208. /**
  24209. * Binds the submesh to the material
  24210. * @param world defines the world transformation matrix
  24211. * @param mesh defines the mesh containing the submesh
  24212. * @param subMesh defines the submesh to bind the material to
  24213. */
  24214. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24215. /**
  24216. * Binds the world matrix to the material
  24217. * @param world defines the world transformation matrix
  24218. */
  24219. bindOnlyWorldMatrix(world: Matrix): void;
  24220. /**
  24221. * Binds the scene's uniform buffer to the effect.
  24222. * @param effect defines the effect to bind to the scene uniform buffer
  24223. * @param sceneUbo defines the uniform buffer storing scene data
  24224. */
  24225. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24226. /**
  24227. * Binds the view matrix to the effect
  24228. * @param effect defines the effect to bind the view matrix to
  24229. */
  24230. bindView(effect: Effect): void;
  24231. /**
  24232. * Binds the view projection matrix to the effect
  24233. * @param effect defines the effect to bind the view projection matrix to
  24234. */
  24235. bindViewProjection(effect: Effect): void;
  24236. /**
  24237. * Processes to execute after binding the material to a mesh
  24238. * @param mesh defines the rendered mesh
  24239. */
  24240. protected _afterBind(mesh?: Mesh): void;
  24241. /**
  24242. * Unbinds the material from the mesh
  24243. */
  24244. unbind(): void;
  24245. /**
  24246. * Gets the active textures from the material
  24247. * @returns an array of textures
  24248. */
  24249. getActiveTextures(): BaseTexture[];
  24250. /**
  24251. * Specifies if the material uses a texture
  24252. * @param texture defines the texture to check against the material
  24253. * @returns a boolean specifying if the material uses the texture
  24254. */
  24255. hasTexture(texture: BaseTexture): boolean;
  24256. /**
  24257. * Makes a duplicate of the material, and gives it a new name
  24258. * @param name defines the new name for the duplicated material
  24259. * @returns the cloned material
  24260. */
  24261. clone(name: string): Nullable<Material>;
  24262. /**
  24263. * Gets the meshes bound to the material
  24264. * @returns an array of meshes bound to the material
  24265. */
  24266. getBindedMeshes(): AbstractMesh[];
  24267. /**
  24268. * Force shader compilation
  24269. * @param mesh defines the mesh associated with this material
  24270. * @param onCompiled defines a function to execute once the material is compiled
  24271. * @param options defines the options to configure the compilation
  24272. * @param onError defines a function to execute if the material fails compiling
  24273. */
  24274. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24275. /**
  24276. * Force shader compilation
  24277. * @param mesh defines the mesh that will use this material
  24278. * @param options defines additional options for compiling the shaders
  24279. * @returns a promise that resolves when the compilation completes
  24280. */
  24281. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24282. private static readonly _AllDirtyCallBack;
  24283. private static readonly _ImageProcessingDirtyCallBack;
  24284. private static readonly _TextureDirtyCallBack;
  24285. private static readonly _FresnelDirtyCallBack;
  24286. private static readonly _MiscDirtyCallBack;
  24287. private static readonly _LightsDirtyCallBack;
  24288. private static readonly _AttributeDirtyCallBack;
  24289. private static _FresnelAndMiscDirtyCallBack;
  24290. private static _TextureAndMiscDirtyCallBack;
  24291. private static readonly _DirtyCallbackArray;
  24292. private static readonly _RunDirtyCallBacks;
  24293. /**
  24294. * Marks a define in the material to indicate that it needs to be re-computed
  24295. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24296. */
  24297. markAsDirty(flag: number): void;
  24298. /**
  24299. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24300. * @param func defines a function which checks material defines against the submeshes
  24301. */
  24302. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24303. /**
  24304. * Indicates that we need to re-calculated for all submeshes
  24305. */
  24306. protected _markAllSubMeshesAsAllDirty(): void;
  24307. /**
  24308. * Indicates that image processing needs to be re-calculated for all submeshes
  24309. */
  24310. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24311. /**
  24312. * Indicates that textures need to be re-calculated for all submeshes
  24313. */
  24314. protected _markAllSubMeshesAsTexturesDirty(): void;
  24315. /**
  24316. * Indicates that fresnel needs to be re-calculated for all submeshes
  24317. */
  24318. protected _markAllSubMeshesAsFresnelDirty(): void;
  24319. /**
  24320. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24321. */
  24322. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24323. /**
  24324. * Indicates that lights need to be re-calculated for all submeshes
  24325. */
  24326. protected _markAllSubMeshesAsLightsDirty(): void;
  24327. /**
  24328. * Indicates that attributes need to be re-calculated for all submeshes
  24329. */
  24330. protected _markAllSubMeshesAsAttributesDirty(): void;
  24331. /**
  24332. * Indicates that misc needs to be re-calculated for all submeshes
  24333. */
  24334. protected _markAllSubMeshesAsMiscDirty(): void;
  24335. /**
  24336. * Indicates that textures and misc need to be re-calculated for all submeshes
  24337. */
  24338. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24339. /**
  24340. * Disposes the material
  24341. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24342. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24343. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24344. */
  24345. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24346. /** @hidden */
  24347. private releaseVertexArrayObject;
  24348. /**
  24349. * Serializes this material
  24350. * @returns the serialized material object
  24351. */
  24352. serialize(): any;
  24353. /**
  24354. * Creates a material from parsed material data
  24355. * @param parsedMaterial defines parsed material data
  24356. * @param scene defines the hosting scene
  24357. * @param rootUrl defines the root URL to use to load textures
  24358. * @returns a new material
  24359. */
  24360. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24361. }
  24362. }
  24363. declare module BABYLON {
  24364. /**
  24365. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24366. * separate meshes. This can be use to improve performances.
  24367. * @see http://doc.babylonjs.com/how_to/multi_materials
  24368. */
  24369. export class MultiMaterial extends Material {
  24370. private _subMaterials;
  24371. /**
  24372. * Gets or Sets the list of Materials used within the multi material.
  24373. * They need to be ordered according to the submeshes order in the associated mesh
  24374. */
  24375. get subMaterials(): Nullable<Material>[];
  24376. set subMaterials(value: Nullable<Material>[]);
  24377. /**
  24378. * Function used to align with Node.getChildren()
  24379. * @returns the list of Materials used within the multi material
  24380. */
  24381. getChildren(): Nullable<Material>[];
  24382. /**
  24383. * Instantiates a new Multi Material
  24384. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24385. * separate meshes. This can be use to improve performances.
  24386. * @see http://doc.babylonjs.com/how_to/multi_materials
  24387. * @param name Define the name in the scene
  24388. * @param scene Define the scene the material belongs to
  24389. */
  24390. constructor(name: string, scene: Scene);
  24391. private _hookArray;
  24392. /**
  24393. * Get one of the submaterial by its index in the submaterials array
  24394. * @param index The index to look the sub material at
  24395. * @returns The Material if the index has been defined
  24396. */
  24397. getSubMaterial(index: number): Nullable<Material>;
  24398. /**
  24399. * Get the list of active textures for the whole sub materials list.
  24400. * @returns All the textures that will be used during the rendering
  24401. */
  24402. getActiveTextures(): BaseTexture[];
  24403. /**
  24404. * Gets the current class name of the material e.g. "MultiMaterial"
  24405. * Mainly use in serialization.
  24406. * @returns the class name
  24407. */
  24408. getClassName(): string;
  24409. /**
  24410. * Checks if the material is ready to render the requested sub mesh
  24411. * @param mesh Define the mesh the submesh belongs to
  24412. * @param subMesh Define the sub mesh to look readyness for
  24413. * @param useInstances Define whether or not the material is used with instances
  24414. * @returns true if ready, otherwise false
  24415. */
  24416. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24417. /**
  24418. * Clones the current material and its related sub materials
  24419. * @param name Define the name of the newly cloned material
  24420. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24421. * @returns the cloned material
  24422. */
  24423. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24424. /**
  24425. * Serializes the materials into a JSON representation.
  24426. * @returns the JSON representation
  24427. */
  24428. serialize(): any;
  24429. /**
  24430. * Dispose the material and release its associated resources
  24431. * @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)
  24432. * @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)
  24433. * @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)
  24434. */
  24435. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24436. /**
  24437. * Creates a MultiMaterial from parsed MultiMaterial data.
  24438. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24439. * @param scene defines the hosting scene
  24440. * @returns a new MultiMaterial
  24441. */
  24442. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24443. }
  24444. }
  24445. declare module BABYLON {
  24446. /**
  24447. * Defines a subdivision inside a mesh
  24448. */
  24449. export class SubMesh implements ICullable {
  24450. /** the material index to use */
  24451. materialIndex: number;
  24452. /** vertex index start */
  24453. verticesStart: number;
  24454. /** vertices count */
  24455. verticesCount: number;
  24456. /** index start */
  24457. indexStart: number;
  24458. /** indices count */
  24459. indexCount: number;
  24460. /** @hidden */
  24461. _materialDefines: Nullable<MaterialDefines>;
  24462. /** @hidden */
  24463. _materialEffect: Nullable<Effect>;
  24464. /** @hidden */
  24465. _effectOverride: Nullable<Effect>;
  24466. /**
  24467. * Gets material defines used by the effect associated to the sub mesh
  24468. */
  24469. get materialDefines(): Nullable<MaterialDefines>;
  24470. /**
  24471. * Sets material defines used by the effect associated to the sub mesh
  24472. */
  24473. set materialDefines(defines: Nullable<MaterialDefines>);
  24474. /**
  24475. * Gets associated effect
  24476. */
  24477. get effect(): Nullable<Effect>;
  24478. /**
  24479. * Sets associated effect (effect used to render this submesh)
  24480. * @param effect defines the effect to associate with
  24481. * @param defines defines the set of defines used to compile this effect
  24482. */
  24483. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24484. /** @hidden */
  24485. _linesIndexCount: number;
  24486. private _mesh;
  24487. private _renderingMesh;
  24488. private _boundingInfo;
  24489. private _linesIndexBuffer;
  24490. /** @hidden */
  24491. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24492. /** @hidden */
  24493. _trianglePlanes: Plane[];
  24494. /** @hidden */
  24495. _lastColliderTransformMatrix: Nullable<Matrix>;
  24496. /** @hidden */
  24497. _renderId: number;
  24498. /** @hidden */
  24499. _alphaIndex: number;
  24500. /** @hidden */
  24501. _distanceToCamera: number;
  24502. /** @hidden */
  24503. _id: number;
  24504. private _currentMaterial;
  24505. /**
  24506. * Add a new submesh to a mesh
  24507. * @param materialIndex defines the material index to use
  24508. * @param verticesStart defines vertex index start
  24509. * @param verticesCount defines vertices count
  24510. * @param indexStart defines index start
  24511. * @param indexCount defines indices count
  24512. * @param mesh defines the parent mesh
  24513. * @param renderingMesh defines an optional rendering mesh
  24514. * @param createBoundingBox defines if bounding box should be created for this submesh
  24515. * @returns the new submesh
  24516. */
  24517. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24518. /**
  24519. * Creates a new submesh
  24520. * @param materialIndex defines the material index to use
  24521. * @param verticesStart defines vertex index start
  24522. * @param verticesCount defines vertices count
  24523. * @param indexStart defines index start
  24524. * @param indexCount defines indices count
  24525. * @param mesh defines the parent mesh
  24526. * @param renderingMesh defines an optional rendering mesh
  24527. * @param createBoundingBox defines if bounding box should be created for this submesh
  24528. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24529. */
  24530. constructor(
  24531. /** the material index to use */
  24532. materialIndex: number,
  24533. /** vertex index start */
  24534. verticesStart: number,
  24535. /** vertices count */
  24536. verticesCount: number,
  24537. /** index start */
  24538. indexStart: number,
  24539. /** indices count */
  24540. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24541. /**
  24542. * Returns true if this submesh covers the entire parent mesh
  24543. * @ignorenaming
  24544. */
  24545. get IsGlobal(): boolean;
  24546. /**
  24547. * Returns the submesh BoudingInfo object
  24548. * @returns current bounding info (or mesh's one if the submesh is global)
  24549. */
  24550. getBoundingInfo(): BoundingInfo;
  24551. /**
  24552. * Sets the submesh BoundingInfo
  24553. * @param boundingInfo defines the new bounding info to use
  24554. * @returns the SubMesh
  24555. */
  24556. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24557. /**
  24558. * Returns the mesh of the current submesh
  24559. * @return the parent mesh
  24560. */
  24561. getMesh(): AbstractMesh;
  24562. /**
  24563. * Returns the rendering mesh of the submesh
  24564. * @returns the rendering mesh (could be different from parent mesh)
  24565. */
  24566. getRenderingMesh(): Mesh;
  24567. /**
  24568. * Returns the replacement mesh of the submesh
  24569. * @returns the replacement mesh (could be different from parent mesh)
  24570. */
  24571. getReplacementMesh(): Nullable<AbstractMesh>;
  24572. /**
  24573. * Returns the effective mesh of the submesh
  24574. * @returns the effective mesh (could be different from parent mesh)
  24575. */
  24576. getEffectiveMesh(): AbstractMesh;
  24577. /**
  24578. * Returns the submesh material
  24579. * @returns null or the current material
  24580. */
  24581. getMaterial(): Nullable<Material>;
  24582. /**
  24583. * Sets a new updated BoundingInfo object to the submesh
  24584. * @param data defines an optional position array to use to determine the bounding info
  24585. * @returns the SubMesh
  24586. */
  24587. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24588. /** @hidden */
  24589. _checkCollision(collider: Collider): boolean;
  24590. /**
  24591. * Updates the submesh BoundingInfo
  24592. * @param world defines the world matrix to use to update the bounding info
  24593. * @returns the submesh
  24594. */
  24595. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24596. /**
  24597. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24598. * @param frustumPlanes defines the frustum planes
  24599. * @returns true if the submesh is intersecting with the frustum
  24600. */
  24601. isInFrustum(frustumPlanes: Plane[]): boolean;
  24602. /**
  24603. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24604. * @param frustumPlanes defines the frustum planes
  24605. * @returns true if the submesh is inside the frustum
  24606. */
  24607. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24608. /**
  24609. * Renders the submesh
  24610. * @param enableAlphaMode defines if alpha needs to be used
  24611. * @returns the submesh
  24612. */
  24613. render(enableAlphaMode: boolean): SubMesh;
  24614. /**
  24615. * @hidden
  24616. */
  24617. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24618. /**
  24619. * Checks if the submesh intersects with a ray
  24620. * @param ray defines the ray to test
  24621. * @returns true is the passed ray intersects the submesh bounding box
  24622. */
  24623. canIntersects(ray: Ray): boolean;
  24624. /**
  24625. * Intersects current submesh with a ray
  24626. * @param ray defines the ray to test
  24627. * @param positions defines mesh's positions array
  24628. * @param indices defines mesh's indices array
  24629. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24630. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24631. * @returns intersection info or null if no intersection
  24632. */
  24633. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24634. /** @hidden */
  24635. private _intersectLines;
  24636. /** @hidden */
  24637. private _intersectUnIndexedLines;
  24638. /** @hidden */
  24639. private _intersectTriangles;
  24640. /** @hidden */
  24641. private _intersectUnIndexedTriangles;
  24642. /** @hidden */
  24643. _rebuild(): void;
  24644. /**
  24645. * Creates a new submesh from the passed mesh
  24646. * @param newMesh defines the new hosting mesh
  24647. * @param newRenderingMesh defines an optional rendering mesh
  24648. * @returns the new submesh
  24649. */
  24650. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24651. /**
  24652. * Release associated resources
  24653. */
  24654. dispose(): void;
  24655. /**
  24656. * Gets the class name
  24657. * @returns the string "SubMesh".
  24658. */
  24659. getClassName(): string;
  24660. /**
  24661. * Creates a new submesh from indices data
  24662. * @param materialIndex the index of the main mesh material
  24663. * @param startIndex the index where to start the copy in the mesh indices array
  24664. * @param indexCount the number of indices to copy then from the startIndex
  24665. * @param mesh the main mesh to create the submesh from
  24666. * @param renderingMesh the optional rendering mesh
  24667. * @returns a new submesh
  24668. */
  24669. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24670. }
  24671. }
  24672. declare module BABYLON {
  24673. /**
  24674. * Class used to represent data loading progression
  24675. */
  24676. export class SceneLoaderFlags {
  24677. private static _ForceFullSceneLoadingForIncremental;
  24678. private static _ShowLoadingScreen;
  24679. private static _CleanBoneMatrixWeights;
  24680. private static _loggingLevel;
  24681. /**
  24682. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24683. */
  24684. static get ForceFullSceneLoadingForIncremental(): boolean;
  24685. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24686. /**
  24687. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24688. */
  24689. static get ShowLoadingScreen(): boolean;
  24690. static set ShowLoadingScreen(value: boolean);
  24691. /**
  24692. * Defines the current logging level (while loading the scene)
  24693. * @ignorenaming
  24694. */
  24695. static get loggingLevel(): number;
  24696. static set loggingLevel(value: number);
  24697. /**
  24698. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24699. */
  24700. static get CleanBoneMatrixWeights(): boolean;
  24701. static set CleanBoneMatrixWeights(value: boolean);
  24702. }
  24703. }
  24704. declare module BABYLON {
  24705. /**
  24706. * Class used to store geometry data (vertex buffers + index buffer)
  24707. */
  24708. export class Geometry implements IGetSetVerticesData {
  24709. /**
  24710. * Gets or sets the ID of the geometry
  24711. */
  24712. id: string;
  24713. /**
  24714. * Gets or sets the unique ID of the geometry
  24715. */
  24716. uniqueId: number;
  24717. /**
  24718. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24719. */
  24720. delayLoadState: number;
  24721. /**
  24722. * Gets the file containing the data to load when running in delay load state
  24723. */
  24724. delayLoadingFile: Nullable<string>;
  24725. /**
  24726. * Callback called when the geometry is updated
  24727. */
  24728. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24729. private _scene;
  24730. private _engine;
  24731. private _meshes;
  24732. private _totalVertices;
  24733. /** @hidden */
  24734. _indices: IndicesArray;
  24735. /** @hidden */
  24736. _vertexBuffers: {
  24737. [key: string]: VertexBuffer;
  24738. };
  24739. private _isDisposed;
  24740. private _extend;
  24741. private _boundingBias;
  24742. /** @hidden */
  24743. _delayInfo: Array<string>;
  24744. private _indexBuffer;
  24745. private _indexBufferIsUpdatable;
  24746. /** @hidden */
  24747. _boundingInfo: Nullable<BoundingInfo>;
  24748. /** @hidden */
  24749. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24750. /** @hidden */
  24751. _softwareSkinningFrameId: number;
  24752. private _vertexArrayObjects;
  24753. private _updatable;
  24754. /** @hidden */
  24755. _positions: Nullable<Vector3[]>;
  24756. /**
  24757. * 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
  24758. */
  24759. get boundingBias(): Vector2;
  24760. /**
  24761. * 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
  24762. */
  24763. set boundingBias(value: Vector2);
  24764. /**
  24765. * Static function used to attach a new empty geometry to a mesh
  24766. * @param mesh defines the mesh to attach the geometry to
  24767. * @returns the new Geometry
  24768. */
  24769. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24770. /** Get the list of meshes using this geometry */
  24771. get meshes(): Mesh[];
  24772. /**
  24773. * Creates a new geometry
  24774. * @param id defines the unique ID
  24775. * @param scene defines the hosting scene
  24776. * @param vertexData defines the VertexData used to get geometry data
  24777. * @param updatable defines if geometry must be updatable (false by default)
  24778. * @param mesh defines the mesh that will be associated with the geometry
  24779. */
  24780. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24781. /**
  24782. * Gets the current extend of the geometry
  24783. */
  24784. get extend(): {
  24785. minimum: Vector3;
  24786. maximum: Vector3;
  24787. };
  24788. /**
  24789. * Gets the hosting scene
  24790. * @returns the hosting Scene
  24791. */
  24792. getScene(): Scene;
  24793. /**
  24794. * Gets the hosting engine
  24795. * @returns the hosting Engine
  24796. */
  24797. getEngine(): Engine;
  24798. /**
  24799. * Defines if the geometry is ready to use
  24800. * @returns true if the geometry is ready to be used
  24801. */
  24802. isReady(): boolean;
  24803. /**
  24804. * Gets a value indicating that the geometry should not be serialized
  24805. */
  24806. get doNotSerialize(): boolean;
  24807. /** @hidden */
  24808. _rebuild(): void;
  24809. /**
  24810. * Affects all geometry data in one call
  24811. * @param vertexData defines the geometry data
  24812. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24813. */
  24814. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24815. /**
  24816. * Set specific vertex data
  24817. * @param kind defines the data kind (Position, normal, etc...)
  24818. * @param data defines the vertex data to use
  24819. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24820. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24821. */
  24822. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24823. /**
  24824. * Removes a specific vertex data
  24825. * @param kind defines the data kind (Position, normal, etc...)
  24826. */
  24827. removeVerticesData(kind: string): void;
  24828. /**
  24829. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24830. * @param buffer defines the vertex buffer to use
  24831. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24832. */
  24833. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24834. /**
  24835. * Update a specific vertex buffer
  24836. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24837. * It will do nothing if the buffer is not updatable
  24838. * @param kind defines the data kind (Position, normal, etc...)
  24839. * @param data defines the data to use
  24840. * @param offset defines the offset in the target buffer where to store the data
  24841. * @param useBytes set to true if the offset is in bytes
  24842. */
  24843. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24844. /**
  24845. * Update a specific vertex buffer
  24846. * This function will create a new buffer if the current one is not updatable
  24847. * @param kind defines the data kind (Position, normal, etc...)
  24848. * @param data defines the data to use
  24849. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24850. */
  24851. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24852. private _updateBoundingInfo;
  24853. /** @hidden */
  24854. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24855. /**
  24856. * Gets total number of vertices
  24857. * @returns the total number of vertices
  24858. */
  24859. getTotalVertices(): number;
  24860. /**
  24861. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24862. * @param kind defines the data kind (Position, normal, etc...)
  24863. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24864. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24865. * @returns a float array containing vertex data
  24866. */
  24867. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24868. /**
  24869. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24870. * @param kind defines the data kind (Position, normal, etc...)
  24871. * @returns true if the vertex buffer with the specified kind is updatable
  24872. */
  24873. isVertexBufferUpdatable(kind: string): boolean;
  24874. /**
  24875. * Gets a specific vertex buffer
  24876. * @param kind defines the data kind (Position, normal, etc...)
  24877. * @returns a VertexBuffer
  24878. */
  24879. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24880. /**
  24881. * Returns all vertex buffers
  24882. * @return an object holding all vertex buffers indexed by kind
  24883. */
  24884. getVertexBuffers(): Nullable<{
  24885. [key: string]: VertexBuffer;
  24886. }>;
  24887. /**
  24888. * Gets a boolean indicating if specific vertex buffer is present
  24889. * @param kind defines the data kind (Position, normal, etc...)
  24890. * @returns true if data is present
  24891. */
  24892. isVerticesDataPresent(kind: string): boolean;
  24893. /**
  24894. * Gets a list of all attached data kinds (Position, normal, etc...)
  24895. * @returns a list of string containing all kinds
  24896. */
  24897. getVerticesDataKinds(): string[];
  24898. /**
  24899. * Update index buffer
  24900. * @param indices defines the indices to store in the index buffer
  24901. * @param offset defines the offset in the target buffer where to store the data
  24902. * @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)
  24903. */
  24904. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24905. /**
  24906. * Creates a new index buffer
  24907. * @param indices defines the indices to store in the index buffer
  24908. * @param totalVertices defines the total number of vertices (could be null)
  24909. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24910. */
  24911. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24912. /**
  24913. * Return the total number of indices
  24914. * @returns the total number of indices
  24915. */
  24916. getTotalIndices(): number;
  24917. /**
  24918. * Gets the index buffer array
  24919. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24920. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24921. * @returns the index buffer array
  24922. */
  24923. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24924. /**
  24925. * Gets the index buffer
  24926. * @return the index buffer
  24927. */
  24928. getIndexBuffer(): Nullable<DataBuffer>;
  24929. /** @hidden */
  24930. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24931. /**
  24932. * Release the associated resources for a specific mesh
  24933. * @param mesh defines the source mesh
  24934. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24935. */
  24936. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24937. /**
  24938. * Apply current geometry to a given mesh
  24939. * @param mesh defines the mesh to apply geometry to
  24940. */
  24941. applyToMesh(mesh: Mesh): void;
  24942. private _updateExtend;
  24943. private _applyToMesh;
  24944. private notifyUpdate;
  24945. /**
  24946. * Load the geometry if it was flagged as delay loaded
  24947. * @param scene defines the hosting scene
  24948. * @param onLoaded defines a callback called when the geometry is loaded
  24949. */
  24950. load(scene: Scene, onLoaded?: () => void): void;
  24951. private _queueLoad;
  24952. /**
  24953. * Invert the geometry to move from a right handed system to a left handed one.
  24954. */
  24955. toLeftHanded(): void;
  24956. /** @hidden */
  24957. _resetPointsArrayCache(): void;
  24958. /** @hidden */
  24959. _generatePointsArray(): boolean;
  24960. /**
  24961. * Gets a value indicating if the geometry is disposed
  24962. * @returns true if the geometry was disposed
  24963. */
  24964. isDisposed(): boolean;
  24965. private _disposeVertexArrayObjects;
  24966. /**
  24967. * Free all associated resources
  24968. */
  24969. dispose(): void;
  24970. /**
  24971. * Clone the current geometry into a new geometry
  24972. * @param id defines the unique ID of the new geometry
  24973. * @returns a new geometry object
  24974. */
  24975. copy(id: string): Geometry;
  24976. /**
  24977. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24978. * @return a JSON representation of the current geometry data (without the vertices data)
  24979. */
  24980. serialize(): any;
  24981. private toNumberArray;
  24982. /**
  24983. * Serialize all vertices data into a JSON oject
  24984. * @returns a JSON representation of the current geometry data
  24985. */
  24986. serializeVerticeData(): any;
  24987. /**
  24988. * Extracts a clone of a mesh geometry
  24989. * @param mesh defines the source mesh
  24990. * @param id defines the unique ID of the new geometry object
  24991. * @returns the new geometry object
  24992. */
  24993. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24994. /**
  24995. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24996. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24997. * Be aware Math.random() could cause collisions, but:
  24998. * "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"
  24999. * @returns a string containing a new GUID
  25000. */
  25001. static RandomId(): string;
  25002. /** @hidden */
  25003. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25004. private static _CleanMatricesWeights;
  25005. /**
  25006. * Create a new geometry from persisted data (Using .babylon file format)
  25007. * @param parsedVertexData defines the persisted data
  25008. * @param scene defines the hosting scene
  25009. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25010. * @returns the new geometry object
  25011. */
  25012. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25013. }
  25014. }
  25015. declare module BABYLON {
  25016. /**
  25017. * Define an interface for all classes that will get and set the data on vertices
  25018. */
  25019. export interface IGetSetVerticesData {
  25020. /**
  25021. * Gets a boolean indicating if specific vertex data is present
  25022. * @param kind defines the vertex data kind to use
  25023. * @returns true is data kind is present
  25024. */
  25025. isVerticesDataPresent(kind: string): boolean;
  25026. /**
  25027. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25028. * @param kind defines the data kind (Position, normal, etc...)
  25029. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25030. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25031. * @returns a float array containing vertex data
  25032. */
  25033. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25034. /**
  25035. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25036. * @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.
  25037. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25038. * @returns the indices array or an empty array if the mesh has no geometry
  25039. */
  25040. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25041. /**
  25042. * Set specific vertex data
  25043. * @param kind defines the data kind (Position, normal, etc...)
  25044. * @param data defines the vertex data to use
  25045. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25046. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25047. */
  25048. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25049. /**
  25050. * Update a specific associated vertex buffer
  25051. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25052. * - VertexBuffer.PositionKind
  25053. * - VertexBuffer.UVKind
  25054. * - VertexBuffer.UV2Kind
  25055. * - VertexBuffer.UV3Kind
  25056. * - VertexBuffer.UV4Kind
  25057. * - VertexBuffer.UV5Kind
  25058. * - VertexBuffer.UV6Kind
  25059. * - VertexBuffer.ColorKind
  25060. * - VertexBuffer.MatricesIndicesKind
  25061. * - VertexBuffer.MatricesIndicesExtraKind
  25062. * - VertexBuffer.MatricesWeightsKind
  25063. * - VertexBuffer.MatricesWeightsExtraKind
  25064. * @param data defines the data source
  25065. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25066. * @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)
  25067. */
  25068. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25069. /**
  25070. * Creates a new index buffer
  25071. * @param indices defines the indices to store in the index buffer
  25072. * @param totalVertices defines the total number of vertices (could be null)
  25073. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25074. */
  25075. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25076. }
  25077. /**
  25078. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25079. */
  25080. export class VertexData {
  25081. /**
  25082. * Mesh side orientation : usually the external or front surface
  25083. */
  25084. static readonly FRONTSIDE: number;
  25085. /**
  25086. * Mesh side orientation : usually the internal or back surface
  25087. */
  25088. static readonly BACKSIDE: number;
  25089. /**
  25090. * Mesh side orientation : both internal and external or front and back surfaces
  25091. */
  25092. static readonly DOUBLESIDE: number;
  25093. /**
  25094. * Mesh side orientation : by default, `FRONTSIDE`
  25095. */
  25096. static readonly DEFAULTSIDE: number;
  25097. /**
  25098. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25099. */
  25100. positions: Nullable<FloatArray>;
  25101. /**
  25102. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25103. */
  25104. normals: Nullable<FloatArray>;
  25105. /**
  25106. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25107. */
  25108. tangents: Nullable<FloatArray>;
  25109. /**
  25110. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25111. */
  25112. uvs: Nullable<FloatArray>;
  25113. /**
  25114. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25115. */
  25116. uvs2: Nullable<FloatArray>;
  25117. /**
  25118. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25119. */
  25120. uvs3: Nullable<FloatArray>;
  25121. /**
  25122. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25123. */
  25124. uvs4: Nullable<FloatArray>;
  25125. /**
  25126. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25127. */
  25128. uvs5: Nullable<FloatArray>;
  25129. /**
  25130. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25131. */
  25132. uvs6: Nullable<FloatArray>;
  25133. /**
  25134. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25135. */
  25136. colors: Nullable<FloatArray>;
  25137. /**
  25138. * 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).
  25139. */
  25140. matricesIndices: Nullable<FloatArray>;
  25141. /**
  25142. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25143. */
  25144. matricesWeights: Nullable<FloatArray>;
  25145. /**
  25146. * An array extending the number of possible indices
  25147. */
  25148. matricesIndicesExtra: Nullable<FloatArray>;
  25149. /**
  25150. * An array extending the number of possible weights when the number of indices is extended
  25151. */
  25152. matricesWeightsExtra: Nullable<FloatArray>;
  25153. /**
  25154. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25155. */
  25156. indices: Nullable<IndicesArray>;
  25157. /**
  25158. * Uses the passed data array to set the set the values for the specified kind of data
  25159. * @param data a linear array of floating numbers
  25160. * @param kind the type of data that is being set, eg positions, colors etc
  25161. */
  25162. set(data: FloatArray, kind: string): void;
  25163. /**
  25164. * Associates the vertexData to the passed Mesh.
  25165. * Sets it as updatable or not (default `false`)
  25166. * @param mesh the mesh the vertexData is applied to
  25167. * @param updatable when used and having the value true allows new data to update the vertexData
  25168. * @returns the VertexData
  25169. */
  25170. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25171. /**
  25172. * Associates the vertexData to the passed Geometry.
  25173. * Sets it as updatable or not (default `false`)
  25174. * @param geometry the geometry the vertexData is applied to
  25175. * @param updatable when used and having the value true allows new data to update the vertexData
  25176. * @returns VertexData
  25177. */
  25178. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25179. /**
  25180. * Updates the associated mesh
  25181. * @param mesh the mesh to be updated
  25182. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25183. * @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
  25184. * @returns VertexData
  25185. */
  25186. updateMesh(mesh: Mesh): VertexData;
  25187. /**
  25188. * Updates the associated geometry
  25189. * @param geometry the geometry to be updated
  25190. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25191. * @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
  25192. * @returns VertexData.
  25193. */
  25194. updateGeometry(geometry: Geometry): VertexData;
  25195. private _applyTo;
  25196. private _update;
  25197. /**
  25198. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25199. * @param matrix the transforming matrix
  25200. * @returns the VertexData
  25201. */
  25202. transform(matrix: Matrix): VertexData;
  25203. /**
  25204. * Merges the passed VertexData into the current one
  25205. * @param other the VertexData to be merged into the current one
  25206. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25207. * @returns the modified VertexData
  25208. */
  25209. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25210. private _mergeElement;
  25211. private _validate;
  25212. /**
  25213. * Serializes the VertexData
  25214. * @returns a serialized object
  25215. */
  25216. serialize(): any;
  25217. /**
  25218. * Extracts the vertexData from a mesh
  25219. * @param mesh the mesh from which to extract the VertexData
  25220. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25221. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25222. * @returns the object VertexData associated to the passed mesh
  25223. */
  25224. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25225. /**
  25226. * Extracts the vertexData from the geometry
  25227. * @param geometry the geometry from which to extract the VertexData
  25228. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25229. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25230. * @returns the object VertexData associated to the passed mesh
  25231. */
  25232. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25233. private static _ExtractFrom;
  25234. /**
  25235. * Creates the VertexData for a Ribbon
  25236. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25237. * * pathArray array of paths, each of which an array of successive Vector3
  25238. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25239. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25240. * * 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
  25241. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25242. * * 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)
  25243. * * 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)
  25244. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25245. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25246. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25247. * @returns the VertexData of the ribbon
  25248. */
  25249. static CreateRibbon(options: {
  25250. pathArray: Vector3[][];
  25251. closeArray?: boolean;
  25252. closePath?: boolean;
  25253. offset?: number;
  25254. sideOrientation?: number;
  25255. frontUVs?: Vector4;
  25256. backUVs?: Vector4;
  25257. invertUV?: boolean;
  25258. uvs?: Vector2[];
  25259. colors?: Color4[];
  25260. }): VertexData;
  25261. /**
  25262. * Creates the VertexData for a box
  25263. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25264. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25265. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25266. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25267. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25268. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25269. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25270. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25271. * * 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)
  25272. * * 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)
  25273. * @returns the VertexData of the box
  25274. */
  25275. static CreateBox(options: {
  25276. size?: number;
  25277. width?: number;
  25278. height?: number;
  25279. depth?: number;
  25280. faceUV?: Vector4[];
  25281. faceColors?: Color4[];
  25282. sideOrientation?: number;
  25283. frontUVs?: Vector4;
  25284. backUVs?: Vector4;
  25285. }): VertexData;
  25286. /**
  25287. * Creates the VertexData for a tiled box
  25288. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25289. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25290. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25291. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25292. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25293. * @returns the VertexData of the box
  25294. */
  25295. static CreateTiledBox(options: {
  25296. pattern?: number;
  25297. width?: number;
  25298. height?: number;
  25299. depth?: number;
  25300. tileSize?: number;
  25301. tileWidth?: number;
  25302. tileHeight?: number;
  25303. alignHorizontal?: number;
  25304. alignVertical?: number;
  25305. faceUV?: Vector4[];
  25306. faceColors?: Color4[];
  25307. sideOrientation?: number;
  25308. }): VertexData;
  25309. /**
  25310. * Creates the VertexData for a tiled plane
  25311. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25312. * * pattern a limited pattern arrangement depending on the number
  25313. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25314. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25315. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25316. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25317. * * 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)
  25318. * * 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)
  25319. * @returns the VertexData of the tiled plane
  25320. */
  25321. static CreateTiledPlane(options: {
  25322. pattern?: number;
  25323. tileSize?: number;
  25324. tileWidth?: number;
  25325. tileHeight?: number;
  25326. size?: number;
  25327. width?: number;
  25328. height?: number;
  25329. alignHorizontal?: number;
  25330. alignVertical?: number;
  25331. sideOrientation?: number;
  25332. frontUVs?: Vector4;
  25333. backUVs?: Vector4;
  25334. }): VertexData;
  25335. /**
  25336. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25337. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25338. * * segments sets the number of horizontal strips optional, default 32
  25339. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25340. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25341. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25342. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25343. * * 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
  25344. * * 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
  25345. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25346. * * 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)
  25347. * * 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)
  25348. * @returns the VertexData of the ellipsoid
  25349. */
  25350. static CreateSphere(options: {
  25351. segments?: number;
  25352. diameter?: number;
  25353. diameterX?: number;
  25354. diameterY?: number;
  25355. diameterZ?: number;
  25356. arc?: number;
  25357. slice?: number;
  25358. sideOrientation?: number;
  25359. frontUVs?: Vector4;
  25360. backUVs?: Vector4;
  25361. }): VertexData;
  25362. /**
  25363. * Creates the VertexData for a cylinder, cone or prism
  25364. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25365. * * height sets the height (y direction) of the cylinder, optional, default 2
  25366. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25367. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25368. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25369. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25370. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25371. * * 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
  25372. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25373. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25374. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25375. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25377. * * 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)
  25378. * * 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)
  25379. * @returns the VertexData of the cylinder, cone or prism
  25380. */
  25381. static CreateCylinder(options: {
  25382. height?: number;
  25383. diameterTop?: number;
  25384. diameterBottom?: number;
  25385. diameter?: number;
  25386. tessellation?: number;
  25387. subdivisions?: number;
  25388. arc?: number;
  25389. faceColors?: Color4[];
  25390. faceUV?: Vector4[];
  25391. hasRings?: boolean;
  25392. enclose?: boolean;
  25393. sideOrientation?: number;
  25394. frontUVs?: Vector4;
  25395. backUVs?: Vector4;
  25396. }): VertexData;
  25397. /**
  25398. * Creates the VertexData for a torus
  25399. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25400. * * diameter the diameter of the torus, optional default 1
  25401. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25402. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25404. * * 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)
  25405. * * 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)
  25406. * @returns the VertexData of the torus
  25407. */
  25408. static CreateTorus(options: {
  25409. diameter?: number;
  25410. thickness?: number;
  25411. tessellation?: number;
  25412. sideOrientation?: number;
  25413. frontUVs?: Vector4;
  25414. backUVs?: Vector4;
  25415. }): VertexData;
  25416. /**
  25417. * Creates the VertexData of the LineSystem
  25418. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25419. * - lines an array of lines, each line being an array of successive Vector3
  25420. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25421. * @returns the VertexData of the LineSystem
  25422. */
  25423. static CreateLineSystem(options: {
  25424. lines: Vector3[][];
  25425. colors?: Nullable<Color4[][]>;
  25426. }): VertexData;
  25427. /**
  25428. * Create the VertexData for a DashedLines
  25429. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25430. * - points an array successive Vector3
  25431. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25432. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25433. * - dashNb the intended total number of dashes, optional, default 200
  25434. * @returns the VertexData for the DashedLines
  25435. */
  25436. static CreateDashedLines(options: {
  25437. points: Vector3[];
  25438. dashSize?: number;
  25439. gapSize?: number;
  25440. dashNb?: number;
  25441. }): VertexData;
  25442. /**
  25443. * Creates the VertexData for a Ground
  25444. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25445. * - width the width (x direction) of the ground, optional, default 1
  25446. * - height the height (z direction) of the ground, optional, default 1
  25447. * - subdivisions the number of subdivisions per side, optional, default 1
  25448. * @returns the VertexData of the Ground
  25449. */
  25450. static CreateGround(options: {
  25451. width?: number;
  25452. height?: number;
  25453. subdivisions?: number;
  25454. subdivisionsX?: number;
  25455. subdivisionsY?: number;
  25456. }): VertexData;
  25457. /**
  25458. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25459. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25460. * * xmin the ground minimum X coordinate, optional, default -1
  25461. * * zmin the ground minimum Z coordinate, optional, default -1
  25462. * * xmax the ground maximum X coordinate, optional, default 1
  25463. * * zmax the ground maximum Z coordinate, optional, default 1
  25464. * * 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}
  25465. * * 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}
  25466. * @returns the VertexData of the TiledGround
  25467. */
  25468. static CreateTiledGround(options: {
  25469. xmin: number;
  25470. zmin: number;
  25471. xmax: number;
  25472. zmax: number;
  25473. subdivisions?: {
  25474. w: number;
  25475. h: number;
  25476. };
  25477. precision?: {
  25478. w: number;
  25479. h: number;
  25480. };
  25481. }): VertexData;
  25482. /**
  25483. * Creates the VertexData of the Ground designed from a heightmap
  25484. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25485. * * width the width (x direction) of the ground
  25486. * * height the height (z direction) of the ground
  25487. * * subdivisions the number of subdivisions per side
  25488. * * minHeight the minimum altitude on the ground, optional, default 0
  25489. * * maxHeight the maximum altitude on the ground, optional default 1
  25490. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25491. * * buffer the array holding the image color data
  25492. * * bufferWidth the width of image
  25493. * * bufferHeight the height of image
  25494. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25495. * @returns the VertexData of the Ground designed from a heightmap
  25496. */
  25497. static CreateGroundFromHeightMap(options: {
  25498. width: number;
  25499. height: number;
  25500. subdivisions: number;
  25501. minHeight: number;
  25502. maxHeight: number;
  25503. colorFilter: Color3;
  25504. buffer: Uint8Array;
  25505. bufferWidth: number;
  25506. bufferHeight: number;
  25507. alphaFilter: number;
  25508. }): VertexData;
  25509. /**
  25510. * Creates the VertexData for a Plane
  25511. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25512. * * size sets the width and height of the plane to the value of size, optional default 1
  25513. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25514. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25515. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25516. * * 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)
  25517. * * 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)
  25518. * @returns the VertexData of the box
  25519. */
  25520. static CreatePlane(options: {
  25521. size?: number;
  25522. width?: number;
  25523. height?: number;
  25524. sideOrientation?: number;
  25525. frontUVs?: Vector4;
  25526. backUVs?: Vector4;
  25527. }): VertexData;
  25528. /**
  25529. * Creates the VertexData of the Disc or regular Polygon
  25530. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25531. * * radius the radius of the disc, optional default 0.5
  25532. * * tessellation the number of polygon sides, optional, default 64
  25533. * * 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
  25534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25535. * * 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)
  25536. * * 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)
  25537. * @returns the VertexData of the box
  25538. */
  25539. static CreateDisc(options: {
  25540. radius?: number;
  25541. tessellation?: number;
  25542. arc?: number;
  25543. sideOrientation?: number;
  25544. frontUVs?: Vector4;
  25545. backUVs?: Vector4;
  25546. }): VertexData;
  25547. /**
  25548. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25549. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25550. * @param polygon a mesh built from polygonTriangulation.build()
  25551. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25552. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25553. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25554. * @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)
  25555. * @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)
  25556. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25557. * @returns the VertexData of the Polygon
  25558. */
  25559. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25560. /**
  25561. * Creates the VertexData of the IcoSphere
  25562. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25563. * * radius the radius of the IcoSphere, optional default 1
  25564. * * radiusX allows stretching in the x direction, optional, default radius
  25565. * * radiusY allows stretching in the y direction, optional, default radius
  25566. * * radiusZ allows stretching in the z direction, optional, default radius
  25567. * * flat when true creates a flat shaded mesh, optional, default true
  25568. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25569. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25570. * * 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)
  25571. * * 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)
  25572. * @returns the VertexData of the IcoSphere
  25573. */
  25574. static CreateIcoSphere(options: {
  25575. radius?: number;
  25576. radiusX?: number;
  25577. radiusY?: number;
  25578. radiusZ?: number;
  25579. flat?: boolean;
  25580. subdivisions?: number;
  25581. sideOrientation?: number;
  25582. frontUVs?: Vector4;
  25583. backUVs?: Vector4;
  25584. }): VertexData;
  25585. /**
  25586. * Creates the VertexData for a Polyhedron
  25587. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25588. * * type provided types are:
  25589. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25590. * * 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)
  25591. * * size the size of the IcoSphere, optional default 1
  25592. * * sizeX allows stretching in the x direction, optional, default size
  25593. * * sizeY allows stretching in the y direction, optional, default size
  25594. * * sizeZ allows stretching in the z direction, optional, default size
  25595. * * 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
  25596. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25597. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25598. * * flat when true creates a flat shaded mesh, optional, default true
  25599. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25600. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25601. * * 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)
  25602. * * 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)
  25603. * @returns the VertexData of the Polyhedron
  25604. */
  25605. static CreatePolyhedron(options: {
  25606. type?: number;
  25607. size?: number;
  25608. sizeX?: number;
  25609. sizeY?: number;
  25610. sizeZ?: number;
  25611. custom?: any;
  25612. faceUV?: Vector4[];
  25613. faceColors?: Color4[];
  25614. flat?: boolean;
  25615. sideOrientation?: number;
  25616. frontUVs?: Vector4;
  25617. backUVs?: Vector4;
  25618. }): VertexData;
  25619. /**
  25620. * Creates the VertexData for a TorusKnot
  25621. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25622. * * radius the radius of the torus knot, optional, default 2
  25623. * * tube the thickness of the tube, optional, default 0.5
  25624. * * radialSegments the number of sides on each tube segments, optional, default 32
  25625. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25626. * * p the number of windings around the z axis, optional, default 2
  25627. * * q the number of windings around the x axis, optional, default 3
  25628. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25629. * * 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)
  25630. * * 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)
  25631. * @returns the VertexData of the Torus Knot
  25632. */
  25633. static CreateTorusKnot(options: {
  25634. radius?: number;
  25635. tube?: number;
  25636. radialSegments?: number;
  25637. tubularSegments?: number;
  25638. p?: number;
  25639. q?: number;
  25640. sideOrientation?: number;
  25641. frontUVs?: Vector4;
  25642. backUVs?: Vector4;
  25643. }): VertexData;
  25644. /**
  25645. * Compute normals for given positions and indices
  25646. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25647. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25648. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25649. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25650. * * facetNormals : optional array of facet normals (vector3)
  25651. * * facetPositions : optional array of facet positions (vector3)
  25652. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25653. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25654. * * bInfo : optional bounding info, required for facetPartitioning computation
  25655. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25656. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25657. * * useRightHandedSystem: optional boolean to for right handed system computation
  25658. * * depthSort : optional boolean to enable the facet depth sort computation
  25659. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25660. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25661. */
  25662. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25663. facetNormals?: any;
  25664. facetPositions?: any;
  25665. facetPartitioning?: any;
  25666. ratio?: number;
  25667. bInfo?: any;
  25668. bbSize?: Vector3;
  25669. subDiv?: any;
  25670. useRightHandedSystem?: boolean;
  25671. depthSort?: boolean;
  25672. distanceTo?: Vector3;
  25673. depthSortedFacets?: any;
  25674. }): void;
  25675. /** @hidden */
  25676. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25677. /**
  25678. * Applies VertexData created from the imported parameters to the geometry
  25679. * @param parsedVertexData the parsed data from an imported file
  25680. * @param geometry the geometry to apply the VertexData to
  25681. */
  25682. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25683. }
  25684. }
  25685. declare module BABYLON {
  25686. /**
  25687. * Defines a target to use with MorphTargetManager
  25688. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25689. */
  25690. export class MorphTarget implements IAnimatable {
  25691. /** defines the name of the target */
  25692. name: string;
  25693. /**
  25694. * Gets or sets the list of animations
  25695. */
  25696. animations: Animation[];
  25697. private _scene;
  25698. private _positions;
  25699. private _normals;
  25700. private _tangents;
  25701. private _uvs;
  25702. private _influence;
  25703. private _uniqueId;
  25704. /**
  25705. * Observable raised when the influence changes
  25706. */
  25707. onInfluenceChanged: Observable<boolean>;
  25708. /** @hidden */
  25709. _onDataLayoutChanged: Observable<void>;
  25710. /**
  25711. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25712. */
  25713. get influence(): number;
  25714. set influence(influence: number);
  25715. /**
  25716. * Gets or sets the id of the morph Target
  25717. */
  25718. id: string;
  25719. private _animationPropertiesOverride;
  25720. /**
  25721. * Gets or sets the animation properties override
  25722. */
  25723. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25724. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25725. /**
  25726. * Creates a new MorphTarget
  25727. * @param name defines the name of the target
  25728. * @param influence defines the influence to use
  25729. * @param scene defines the scene the morphtarget belongs to
  25730. */
  25731. constructor(
  25732. /** defines the name of the target */
  25733. name: string, influence?: number, scene?: Nullable<Scene>);
  25734. /**
  25735. * Gets the unique ID of this manager
  25736. */
  25737. get uniqueId(): number;
  25738. /**
  25739. * Gets a boolean defining if the target contains position data
  25740. */
  25741. get hasPositions(): boolean;
  25742. /**
  25743. * Gets a boolean defining if the target contains normal data
  25744. */
  25745. get hasNormals(): boolean;
  25746. /**
  25747. * Gets a boolean defining if the target contains tangent data
  25748. */
  25749. get hasTangents(): boolean;
  25750. /**
  25751. * Gets a boolean defining if the target contains texture coordinates data
  25752. */
  25753. get hasUVs(): boolean;
  25754. /**
  25755. * Affects position data to this target
  25756. * @param data defines the position data to use
  25757. */
  25758. setPositions(data: Nullable<FloatArray>): void;
  25759. /**
  25760. * Gets the position data stored in this target
  25761. * @returns a FloatArray containing the position data (or null if not present)
  25762. */
  25763. getPositions(): Nullable<FloatArray>;
  25764. /**
  25765. * Affects normal data to this target
  25766. * @param data defines the normal data to use
  25767. */
  25768. setNormals(data: Nullable<FloatArray>): void;
  25769. /**
  25770. * Gets the normal data stored in this target
  25771. * @returns a FloatArray containing the normal data (or null if not present)
  25772. */
  25773. getNormals(): Nullable<FloatArray>;
  25774. /**
  25775. * Affects tangent data to this target
  25776. * @param data defines the tangent data to use
  25777. */
  25778. setTangents(data: Nullable<FloatArray>): void;
  25779. /**
  25780. * Gets the tangent data stored in this target
  25781. * @returns a FloatArray containing the tangent data (or null if not present)
  25782. */
  25783. getTangents(): Nullable<FloatArray>;
  25784. /**
  25785. * Affects texture coordinates data to this target
  25786. * @param data defines the texture coordinates data to use
  25787. */
  25788. setUVs(data: Nullable<FloatArray>): void;
  25789. /**
  25790. * Gets the texture coordinates data stored in this target
  25791. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25792. */
  25793. getUVs(): Nullable<FloatArray>;
  25794. /**
  25795. * Clone the current target
  25796. * @returns a new MorphTarget
  25797. */
  25798. clone(): MorphTarget;
  25799. /**
  25800. * Serializes the current target into a Serialization object
  25801. * @returns the serialized object
  25802. */
  25803. serialize(): any;
  25804. /**
  25805. * Returns the string "MorphTarget"
  25806. * @returns "MorphTarget"
  25807. */
  25808. getClassName(): string;
  25809. /**
  25810. * Creates a new target from serialized data
  25811. * @param serializationObject defines the serialized data to use
  25812. * @returns a new MorphTarget
  25813. */
  25814. static Parse(serializationObject: any): MorphTarget;
  25815. /**
  25816. * Creates a MorphTarget from mesh data
  25817. * @param mesh defines the source mesh
  25818. * @param name defines the name to use for the new target
  25819. * @param influence defines the influence to attach to the target
  25820. * @returns a new MorphTarget
  25821. */
  25822. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25823. }
  25824. }
  25825. declare module BABYLON {
  25826. /**
  25827. * This class is used to deform meshes using morphing between different targets
  25828. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25829. */
  25830. export class MorphTargetManager {
  25831. private _targets;
  25832. private _targetInfluenceChangedObservers;
  25833. private _targetDataLayoutChangedObservers;
  25834. private _activeTargets;
  25835. private _scene;
  25836. private _influences;
  25837. private _supportsNormals;
  25838. private _supportsTangents;
  25839. private _supportsUVs;
  25840. private _vertexCount;
  25841. private _uniqueId;
  25842. private _tempInfluences;
  25843. /**
  25844. * Gets or sets a boolean indicating if normals must be morphed
  25845. */
  25846. enableNormalMorphing: boolean;
  25847. /**
  25848. * Gets or sets a boolean indicating if tangents must be morphed
  25849. */
  25850. enableTangentMorphing: boolean;
  25851. /**
  25852. * Gets or sets a boolean indicating if UV must be morphed
  25853. */
  25854. enableUVMorphing: boolean;
  25855. /**
  25856. * Creates a new MorphTargetManager
  25857. * @param scene defines the current scene
  25858. */
  25859. constructor(scene?: Nullable<Scene>);
  25860. /**
  25861. * Gets the unique ID of this manager
  25862. */
  25863. get uniqueId(): number;
  25864. /**
  25865. * Gets the number of vertices handled by this manager
  25866. */
  25867. get vertexCount(): number;
  25868. /**
  25869. * Gets a boolean indicating if this manager supports morphing of normals
  25870. */
  25871. get supportsNormals(): boolean;
  25872. /**
  25873. * Gets a boolean indicating if this manager supports morphing of tangents
  25874. */
  25875. get supportsTangents(): boolean;
  25876. /**
  25877. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25878. */
  25879. get supportsUVs(): boolean;
  25880. /**
  25881. * Gets the number of targets stored in this manager
  25882. */
  25883. get numTargets(): number;
  25884. /**
  25885. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25886. */
  25887. get numInfluencers(): number;
  25888. /**
  25889. * Gets the list of influences (one per target)
  25890. */
  25891. get influences(): Float32Array;
  25892. /**
  25893. * Gets the active target at specified index. An active target is a target with an influence > 0
  25894. * @param index defines the index to check
  25895. * @returns the requested target
  25896. */
  25897. getActiveTarget(index: number): MorphTarget;
  25898. /**
  25899. * Gets the target at specified index
  25900. * @param index defines the index to check
  25901. * @returns the requested target
  25902. */
  25903. getTarget(index: number): MorphTarget;
  25904. /**
  25905. * Add a new target to this manager
  25906. * @param target defines the target to add
  25907. */
  25908. addTarget(target: MorphTarget): void;
  25909. /**
  25910. * Removes a target from the manager
  25911. * @param target defines the target to remove
  25912. */
  25913. removeTarget(target: MorphTarget): void;
  25914. /**
  25915. * Clone the current manager
  25916. * @returns a new MorphTargetManager
  25917. */
  25918. clone(): MorphTargetManager;
  25919. /**
  25920. * Serializes the current manager into a Serialization object
  25921. * @returns the serialized object
  25922. */
  25923. serialize(): any;
  25924. private _syncActiveTargets;
  25925. /**
  25926. * Syncrhonize the targets with all the meshes using this morph target manager
  25927. */
  25928. synchronize(): void;
  25929. /**
  25930. * Creates a new MorphTargetManager from serialized data
  25931. * @param serializationObject defines the serialized data
  25932. * @param scene defines the hosting scene
  25933. * @returns the new MorphTargetManager
  25934. */
  25935. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25936. }
  25937. }
  25938. declare module BABYLON {
  25939. /**
  25940. * Class used to represent a specific level of detail of a mesh
  25941. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25942. */
  25943. export class MeshLODLevel {
  25944. /** Defines the distance where this level should start being displayed */
  25945. distance: number;
  25946. /** Defines the mesh to use to render this level */
  25947. mesh: Nullable<Mesh>;
  25948. /**
  25949. * Creates a new LOD level
  25950. * @param distance defines the distance where this level should star being displayed
  25951. * @param mesh defines the mesh to use to render this level
  25952. */
  25953. constructor(
  25954. /** Defines the distance where this level should start being displayed */
  25955. distance: number,
  25956. /** Defines the mesh to use to render this level */
  25957. mesh: Nullable<Mesh>);
  25958. }
  25959. }
  25960. declare module BABYLON {
  25961. /**
  25962. * Mesh representing the gorund
  25963. */
  25964. export class GroundMesh extends Mesh {
  25965. /** If octree should be generated */
  25966. generateOctree: boolean;
  25967. private _heightQuads;
  25968. /** @hidden */
  25969. _subdivisionsX: number;
  25970. /** @hidden */
  25971. _subdivisionsY: number;
  25972. /** @hidden */
  25973. _width: number;
  25974. /** @hidden */
  25975. _height: number;
  25976. /** @hidden */
  25977. _minX: number;
  25978. /** @hidden */
  25979. _maxX: number;
  25980. /** @hidden */
  25981. _minZ: number;
  25982. /** @hidden */
  25983. _maxZ: number;
  25984. constructor(name: string, scene: Scene);
  25985. /**
  25986. * "GroundMesh"
  25987. * @returns "GroundMesh"
  25988. */
  25989. getClassName(): string;
  25990. /**
  25991. * The minimum of x and y subdivisions
  25992. */
  25993. get subdivisions(): number;
  25994. /**
  25995. * X subdivisions
  25996. */
  25997. get subdivisionsX(): number;
  25998. /**
  25999. * Y subdivisions
  26000. */
  26001. get subdivisionsY(): number;
  26002. /**
  26003. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26004. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26005. * @param chunksCount the number of subdivisions for x and y
  26006. * @param octreeBlocksSize (Default: 32)
  26007. */
  26008. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26009. /**
  26010. * Returns a height (y) value in the Worl system :
  26011. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26012. * @param x x coordinate
  26013. * @param z z coordinate
  26014. * @returns the ground y position if (x, z) are outside the ground surface.
  26015. */
  26016. getHeightAtCoordinates(x: number, z: number): number;
  26017. /**
  26018. * Returns a normalized vector (Vector3) orthogonal to the ground
  26019. * at the ground coordinates (x, z) expressed in the World system.
  26020. * @param x x coordinate
  26021. * @param z z coordinate
  26022. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26023. */
  26024. getNormalAtCoordinates(x: number, z: number): Vector3;
  26025. /**
  26026. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26027. * at the ground coordinates (x, z) expressed in the World system.
  26028. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26029. * @param x x coordinate
  26030. * @param z z coordinate
  26031. * @param ref vector to store the result
  26032. * @returns the GroundMesh.
  26033. */
  26034. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26035. /**
  26036. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26037. * if the ground has been updated.
  26038. * This can be used in the render loop.
  26039. * @returns the GroundMesh.
  26040. */
  26041. updateCoordinateHeights(): GroundMesh;
  26042. private _getFacetAt;
  26043. private _initHeightQuads;
  26044. private _computeHeightQuads;
  26045. /**
  26046. * Serializes this ground mesh
  26047. * @param serializationObject object to write serialization to
  26048. */
  26049. serialize(serializationObject: any): void;
  26050. /**
  26051. * Parses a serialized ground mesh
  26052. * @param parsedMesh the serialized mesh
  26053. * @param scene the scene to create the ground mesh in
  26054. * @returns the created ground mesh
  26055. */
  26056. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26057. }
  26058. }
  26059. declare module BABYLON {
  26060. /**
  26061. * Interface for Physics-Joint data
  26062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26063. */
  26064. export interface PhysicsJointData {
  26065. /**
  26066. * The main pivot of the joint
  26067. */
  26068. mainPivot?: Vector3;
  26069. /**
  26070. * The connected pivot of the joint
  26071. */
  26072. connectedPivot?: Vector3;
  26073. /**
  26074. * The main axis of the joint
  26075. */
  26076. mainAxis?: Vector3;
  26077. /**
  26078. * The connected axis of the joint
  26079. */
  26080. connectedAxis?: Vector3;
  26081. /**
  26082. * The collision of the joint
  26083. */
  26084. collision?: boolean;
  26085. /**
  26086. * Native Oimo/Cannon/Energy data
  26087. */
  26088. nativeParams?: any;
  26089. }
  26090. /**
  26091. * This is a holder class for the physics joint created by the physics plugin
  26092. * It holds a set of functions to control the underlying joint
  26093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26094. */
  26095. export class PhysicsJoint {
  26096. /**
  26097. * The type of the physics joint
  26098. */
  26099. type: number;
  26100. /**
  26101. * The data for the physics joint
  26102. */
  26103. jointData: PhysicsJointData;
  26104. private _physicsJoint;
  26105. protected _physicsPlugin: IPhysicsEnginePlugin;
  26106. /**
  26107. * Initializes the physics joint
  26108. * @param type The type of the physics joint
  26109. * @param jointData The data for the physics joint
  26110. */
  26111. constructor(
  26112. /**
  26113. * The type of the physics joint
  26114. */
  26115. type: number,
  26116. /**
  26117. * The data for the physics joint
  26118. */
  26119. jointData: PhysicsJointData);
  26120. /**
  26121. * Gets the physics joint
  26122. */
  26123. get physicsJoint(): any;
  26124. /**
  26125. * Sets the physics joint
  26126. */
  26127. set physicsJoint(newJoint: any);
  26128. /**
  26129. * Sets the physics plugin
  26130. */
  26131. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26132. /**
  26133. * Execute a function that is physics-plugin specific.
  26134. * @param {Function} func the function that will be executed.
  26135. * It accepts two parameters: the physics world and the physics joint
  26136. */
  26137. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26138. /**
  26139. * Distance-Joint type
  26140. */
  26141. static DistanceJoint: number;
  26142. /**
  26143. * Hinge-Joint type
  26144. */
  26145. static HingeJoint: number;
  26146. /**
  26147. * Ball-and-Socket joint type
  26148. */
  26149. static BallAndSocketJoint: number;
  26150. /**
  26151. * Wheel-Joint type
  26152. */
  26153. static WheelJoint: number;
  26154. /**
  26155. * Slider-Joint type
  26156. */
  26157. static SliderJoint: number;
  26158. /**
  26159. * Prismatic-Joint type
  26160. */
  26161. static PrismaticJoint: number;
  26162. /**
  26163. * Universal-Joint type
  26164. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26165. */
  26166. static UniversalJoint: number;
  26167. /**
  26168. * Hinge-Joint 2 type
  26169. */
  26170. static Hinge2Joint: number;
  26171. /**
  26172. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26173. */
  26174. static PointToPointJoint: number;
  26175. /**
  26176. * Spring-Joint type
  26177. */
  26178. static SpringJoint: number;
  26179. /**
  26180. * Lock-Joint type
  26181. */
  26182. static LockJoint: number;
  26183. }
  26184. /**
  26185. * A class representing a physics distance joint
  26186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26187. */
  26188. export class DistanceJoint extends PhysicsJoint {
  26189. /**
  26190. *
  26191. * @param jointData The data for the Distance-Joint
  26192. */
  26193. constructor(jointData: DistanceJointData);
  26194. /**
  26195. * Update the predefined distance.
  26196. * @param maxDistance The maximum preferred distance
  26197. * @param minDistance The minimum preferred distance
  26198. */
  26199. updateDistance(maxDistance: number, minDistance?: number): void;
  26200. }
  26201. /**
  26202. * Represents a Motor-Enabled Joint
  26203. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26204. */
  26205. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26206. /**
  26207. * Initializes the Motor-Enabled Joint
  26208. * @param type The type of the joint
  26209. * @param jointData The physica joint data for the joint
  26210. */
  26211. constructor(type: number, jointData: PhysicsJointData);
  26212. /**
  26213. * Set the motor values.
  26214. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26215. * @param force the force to apply
  26216. * @param maxForce max force for this motor.
  26217. */
  26218. setMotor(force?: number, maxForce?: number): void;
  26219. /**
  26220. * Set the motor's limits.
  26221. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26222. * @param upperLimit The upper limit of the motor
  26223. * @param lowerLimit The lower limit of the motor
  26224. */
  26225. setLimit(upperLimit: number, lowerLimit?: number): void;
  26226. }
  26227. /**
  26228. * This class represents a single physics Hinge-Joint
  26229. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26230. */
  26231. export class HingeJoint extends MotorEnabledJoint {
  26232. /**
  26233. * Initializes the Hinge-Joint
  26234. * @param jointData The joint data for the Hinge-Joint
  26235. */
  26236. constructor(jointData: PhysicsJointData);
  26237. /**
  26238. * Set the motor values.
  26239. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26240. * @param {number} force the force to apply
  26241. * @param {number} maxForce max force for this motor.
  26242. */
  26243. setMotor(force?: number, maxForce?: number): void;
  26244. /**
  26245. * Set the motor's limits.
  26246. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26247. * @param upperLimit The upper limit of the motor
  26248. * @param lowerLimit The lower limit of the motor
  26249. */
  26250. setLimit(upperLimit: number, lowerLimit?: number): void;
  26251. }
  26252. /**
  26253. * This class represents a dual hinge physics joint (same as wheel joint)
  26254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26255. */
  26256. export class Hinge2Joint extends MotorEnabledJoint {
  26257. /**
  26258. * Initializes the Hinge2-Joint
  26259. * @param jointData The joint data for the Hinge2-Joint
  26260. */
  26261. constructor(jointData: PhysicsJointData);
  26262. /**
  26263. * Set the motor values.
  26264. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26265. * @param {number} targetSpeed the speed the motor is to reach
  26266. * @param {number} maxForce max force for this motor.
  26267. * @param {motorIndex} the motor's index, 0 or 1.
  26268. */
  26269. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26270. /**
  26271. * Set the motor limits.
  26272. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26273. * @param {number} upperLimit the upper limit
  26274. * @param {number} lowerLimit lower limit
  26275. * @param {motorIndex} the motor's index, 0 or 1.
  26276. */
  26277. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26278. }
  26279. /**
  26280. * Interface for a motor enabled joint
  26281. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26282. */
  26283. export interface IMotorEnabledJoint {
  26284. /**
  26285. * Physics joint
  26286. */
  26287. physicsJoint: any;
  26288. /**
  26289. * Sets the motor of the motor-enabled joint
  26290. * @param force The force of the motor
  26291. * @param maxForce The maximum force of the motor
  26292. * @param motorIndex The index of the motor
  26293. */
  26294. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26295. /**
  26296. * Sets the limit of the motor
  26297. * @param upperLimit The upper limit of the motor
  26298. * @param lowerLimit The lower limit of the motor
  26299. * @param motorIndex The index of the motor
  26300. */
  26301. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26302. }
  26303. /**
  26304. * Joint data for a Distance-Joint
  26305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26306. */
  26307. export interface DistanceJointData extends PhysicsJointData {
  26308. /**
  26309. * Max distance the 2 joint objects can be apart
  26310. */
  26311. maxDistance: number;
  26312. }
  26313. /**
  26314. * Joint data from a spring joint
  26315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26316. */
  26317. export interface SpringJointData extends PhysicsJointData {
  26318. /**
  26319. * Length of the spring
  26320. */
  26321. length: number;
  26322. /**
  26323. * Stiffness of the spring
  26324. */
  26325. stiffness: number;
  26326. /**
  26327. * Damping of the spring
  26328. */
  26329. damping: number;
  26330. /** this callback will be called when applying the force to the impostors. */
  26331. forceApplicationCallback: () => void;
  26332. }
  26333. }
  26334. declare module BABYLON {
  26335. /**
  26336. * Holds the data for the raycast result
  26337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26338. */
  26339. export class PhysicsRaycastResult {
  26340. private _hasHit;
  26341. private _hitDistance;
  26342. private _hitNormalWorld;
  26343. private _hitPointWorld;
  26344. private _rayFromWorld;
  26345. private _rayToWorld;
  26346. /**
  26347. * Gets if there was a hit
  26348. */
  26349. get hasHit(): boolean;
  26350. /**
  26351. * Gets the distance from the hit
  26352. */
  26353. get hitDistance(): number;
  26354. /**
  26355. * Gets the hit normal/direction in the world
  26356. */
  26357. get hitNormalWorld(): Vector3;
  26358. /**
  26359. * Gets the hit point in the world
  26360. */
  26361. get hitPointWorld(): Vector3;
  26362. /**
  26363. * Gets the ray "start point" of the ray in the world
  26364. */
  26365. get rayFromWorld(): Vector3;
  26366. /**
  26367. * Gets the ray "end point" of the ray in the world
  26368. */
  26369. get rayToWorld(): Vector3;
  26370. /**
  26371. * Sets the hit data (normal & point in world space)
  26372. * @param hitNormalWorld defines the normal in world space
  26373. * @param hitPointWorld defines the point in world space
  26374. */
  26375. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26376. /**
  26377. * Sets the distance from the start point to the hit point
  26378. * @param distance
  26379. */
  26380. setHitDistance(distance: number): void;
  26381. /**
  26382. * Calculates the distance manually
  26383. */
  26384. calculateHitDistance(): void;
  26385. /**
  26386. * Resets all the values to default
  26387. * @param from The from point on world space
  26388. * @param to The to point on world space
  26389. */
  26390. reset(from?: Vector3, to?: Vector3): void;
  26391. }
  26392. /**
  26393. * Interface for the size containing width and height
  26394. */
  26395. interface IXYZ {
  26396. /**
  26397. * X
  26398. */
  26399. x: number;
  26400. /**
  26401. * Y
  26402. */
  26403. y: number;
  26404. /**
  26405. * Z
  26406. */
  26407. z: number;
  26408. }
  26409. }
  26410. declare module BABYLON {
  26411. /**
  26412. * Interface used to describe a physics joint
  26413. */
  26414. export interface PhysicsImpostorJoint {
  26415. /** Defines the main impostor to which the joint is linked */
  26416. mainImpostor: PhysicsImpostor;
  26417. /** Defines the impostor that is connected to the main impostor using this joint */
  26418. connectedImpostor: PhysicsImpostor;
  26419. /** Defines the joint itself */
  26420. joint: PhysicsJoint;
  26421. }
  26422. /** @hidden */
  26423. export interface IPhysicsEnginePlugin {
  26424. world: any;
  26425. name: string;
  26426. setGravity(gravity: Vector3): void;
  26427. setTimeStep(timeStep: number): void;
  26428. getTimeStep(): number;
  26429. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26430. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26431. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26432. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26433. removePhysicsBody(impostor: PhysicsImpostor): void;
  26434. generateJoint(joint: PhysicsImpostorJoint): void;
  26435. removeJoint(joint: PhysicsImpostorJoint): void;
  26436. isSupported(): boolean;
  26437. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26438. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26439. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26440. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26441. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26442. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26443. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26444. getBodyMass(impostor: PhysicsImpostor): number;
  26445. getBodyFriction(impostor: PhysicsImpostor): number;
  26446. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26447. getBodyRestitution(impostor: PhysicsImpostor): number;
  26448. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26449. getBodyPressure?(impostor: PhysicsImpostor): number;
  26450. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26451. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26452. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26453. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26454. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26455. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26456. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26457. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26458. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26459. sleepBody(impostor: PhysicsImpostor): void;
  26460. wakeUpBody(impostor: PhysicsImpostor): void;
  26461. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26462. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26463. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26464. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26465. getRadius(impostor: PhysicsImpostor): number;
  26466. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26467. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26468. dispose(): void;
  26469. }
  26470. /**
  26471. * Interface used to define a physics engine
  26472. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  26473. */
  26474. export interface IPhysicsEngine {
  26475. /**
  26476. * Gets the gravity vector used by the simulation
  26477. */
  26478. gravity: Vector3;
  26479. /**
  26480. * Sets the gravity vector used by the simulation
  26481. * @param gravity defines the gravity vector to use
  26482. */
  26483. setGravity(gravity: Vector3): void;
  26484. /**
  26485. * Set the time step of the physics engine.
  26486. * Default is 1/60.
  26487. * To slow it down, enter 1/600 for example.
  26488. * To speed it up, 1/30
  26489. * @param newTimeStep the new timestep to apply to this world.
  26490. */
  26491. setTimeStep(newTimeStep: number): void;
  26492. /**
  26493. * Get the time step of the physics engine.
  26494. * @returns the current time step
  26495. */
  26496. getTimeStep(): number;
  26497. /**
  26498. * Set the sub time step of the physics engine.
  26499. * Default is 0 meaning there is no sub steps
  26500. * To increase physics resolution precision, set a small value (like 1 ms)
  26501. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26502. */
  26503. setSubTimeStep(subTimeStep: number): void;
  26504. /**
  26505. * Get the sub time step of the physics engine.
  26506. * @returns the current sub time step
  26507. */
  26508. getSubTimeStep(): number;
  26509. /**
  26510. * Release all resources
  26511. */
  26512. dispose(): void;
  26513. /**
  26514. * Gets the name of the current physics plugin
  26515. * @returns the name of the plugin
  26516. */
  26517. getPhysicsPluginName(): string;
  26518. /**
  26519. * Adding a new impostor for the impostor tracking.
  26520. * This will be done by the impostor itself.
  26521. * @param impostor the impostor to add
  26522. */
  26523. addImpostor(impostor: PhysicsImpostor): void;
  26524. /**
  26525. * Remove an impostor from the engine.
  26526. * This impostor and its mesh will not longer be updated by the physics engine.
  26527. * @param impostor the impostor to remove
  26528. */
  26529. removeImpostor(impostor: PhysicsImpostor): void;
  26530. /**
  26531. * Add a joint to the physics engine
  26532. * @param mainImpostor defines the main impostor to which the joint is added.
  26533. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26534. * @param joint defines the joint that will connect both impostors.
  26535. */
  26536. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26537. /**
  26538. * Removes a joint from the simulation
  26539. * @param mainImpostor defines the impostor used with the joint
  26540. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26541. * @param joint defines the joint to remove
  26542. */
  26543. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26544. /**
  26545. * Gets the current plugin used to run the simulation
  26546. * @returns current plugin
  26547. */
  26548. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26549. /**
  26550. * Gets the list of physic impostors
  26551. * @returns an array of PhysicsImpostor
  26552. */
  26553. getImpostors(): Array<PhysicsImpostor>;
  26554. /**
  26555. * Gets the impostor for a physics enabled object
  26556. * @param object defines the object impersonated by the impostor
  26557. * @returns the PhysicsImpostor or null if not found
  26558. */
  26559. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26560. /**
  26561. * Gets the impostor for a physics body object
  26562. * @param body defines physics body used by the impostor
  26563. * @returns the PhysicsImpostor or null if not found
  26564. */
  26565. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26566. /**
  26567. * Does a raycast in the physics world
  26568. * @param from when should the ray start?
  26569. * @param to when should the ray end?
  26570. * @returns PhysicsRaycastResult
  26571. */
  26572. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26573. /**
  26574. * Called by the scene. No need to call it.
  26575. * @param delta defines the timespam between frames
  26576. */
  26577. _step(delta: number): void;
  26578. }
  26579. }
  26580. declare module BABYLON {
  26581. /**
  26582. * The interface for the physics imposter parameters
  26583. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26584. */
  26585. export interface PhysicsImpostorParameters {
  26586. /**
  26587. * The mass of the physics imposter
  26588. */
  26589. mass: number;
  26590. /**
  26591. * The friction of the physics imposter
  26592. */
  26593. friction?: number;
  26594. /**
  26595. * The coefficient of restitution of the physics imposter
  26596. */
  26597. restitution?: number;
  26598. /**
  26599. * The native options of the physics imposter
  26600. */
  26601. nativeOptions?: any;
  26602. /**
  26603. * Specifies if the parent should be ignored
  26604. */
  26605. ignoreParent?: boolean;
  26606. /**
  26607. * Specifies if bi-directional transformations should be disabled
  26608. */
  26609. disableBidirectionalTransformation?: boolean;
  26610. /**
  26611. * The pressure inside the physics imposter, soft object only
  26612. */
  26613. pressure?: number;
  26614. /**
  26615. * The stiffness the physics imposter, soft object only
  26616. */
  26617. stiffness?: number;
  26618. /**
  26619. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26620. */
  26621. velocityIterations?: number;
  26622. /**
  26623. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26624. */
  26625. positionIterations?: number;
  26626. /**
  26627. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26628. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26629. * Add to fix multiple points
  26630. */
  26631. fixedPoints?: number;
  26632. /**
  26633. * The collision margin around a soft object
  26634. */
  26635. margin?: number;
  26636. /**
  26637. * The collision margin around a soft object
  26638. */
  26639. damping?: number;
  26640. /**
  26641. * The path for a rope based on an extrusion
  26642. */
  26643. path?: any;
  26644. /**
  26645. * The shape of an extrusion used for a rope based on an extrusion
  26646. */
  26647. shape?: any;
  26648. }
  26649. /**
  26650. * Interface for a physics-enabled object
  26651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26652. */
  26653. export interface IPhysicsEnabledObject {
  26654. /**
  26655. * The position of the physics-enabled object
  26656. */
  26657. position: Vector3;
  26658. /**
  26659. * The rotation of the physics-enabled object
  26660. */
  26661. rotationQuaternion: Nullable<Quaternion>;
  26662. /**
  26663. * The scale of the physics-enabled object
  26664. */
  26665. scaling: Vector3;
  26666. /**
  26667. * The rotation of the physics-enabled object
  26668. */
  26669. rotation?: Vector3;
  26670. /**
  26671. * The parent of the physics-enabled object
  26672. */
  26673. parent?: any;
  26674. /**
  26675. * The bounding info of the physics-enabled object
  26676. * @returns The bounding info of the physics-enabled object
  26677. */
  26678. getBoundingInfo(): BoundingInfo;
  26679. /**
  26680. * Computes the world matrix
  26681. * @param force Specifies if the world matrix should be computed by force
  26682. * @returns A world matrix
  26683. */
  26684. computeWorldMatrix(force: boolean): Matrix;
  26685. /**
  26686. * Gets the world matrix
  26687. * @returns A world matrix
  26688. */
  26689. getWorldMatrix?(): Matrix;
  26690. /**
  26691. * Gets the child meshes
  26692. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26693. * @returns An array of abstract meshes
  26694. */
  26695. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26696. /**
  26697. * Gets the vertex data
  26698. * @param kind The type of vertex data
  26699. * @returns A nullable array of numbers, or a float32 array
  26700. */
  26701. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26702. /**
  26703. * Gets the indices from the mesh
  26704. * @returns A nullable array of index arrays
  26705. */
  26706. getIndices?(): Nullable<IndicesArray>;
  26707. /**
  26708. * Gets the scene from the mesh
  26709. * @returns the indices array or null
  26710. */
  26711. getScene?(): Scene;
  26712. /**
  26713. * Gets the absolute position from the mesh
  26714. * @returns the absolute position
  26715. */
  26716. getAbsolutePosition(): Vector3;
  26717. /**
  26718. * Gets the absolute pivot point from the mesh
  26719. * @returns the absolute pivot point
  26720. */
  26721. getAbsolutePivotPoint(): Vector3;
  26722. /**
  26723. * Rotates the mesh
  26724. * @param axis The axis of rotation
  26725. * @param amount The amount of rotation
  26726. * @param space The space of the rotation
  26727. * @returns The rotation transform node
  26728. */
  26729. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26730. /**
  26731. * Translates the mesh
  26732. * @param axis The axis of translation
  26733. * @param distance The distance of translation
  26734. * @param space The space of the translation
  26735. * @returns The transform node
  26736. */
  26737. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26738. /**
  26739. * Sets the absolute position of the mesh
  26740. * @param absolutePosition The absolute position of the mesh
  26741. * @returns The transform node
  26742. */
  26743. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26744. /**
  26745. * Gets the class name of the mesh
  26746. * @returns The class name
  26747. */
  26748. getClassName(): string;
  26749. }
  26750. /**
  26751. * Represents a physics imposter
  26752. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26753. */
  26754. export class PhysicsImpostor {
  26755. /**
  26756. * The physics-enabled object used as the physics imposter
  26757. */
  26758. object: IPhysicsEnabledObject;
  26759. /**
  26760. * The type of the physics imposter
  26761. */
  26762. type: number;
  26763. private _options;
  26764. private _scene?;
  26765. /**
  26766. * The default object size of the imposter
  26767. */
  26768. static DEFAULT_OBJECT_SIZE: Vector3;
  26769. /**
  26770. * The identity quaternion of the imposter
  26771. */
  26772. static IDENTITY_QUATERNION: Quaternion;
  26773. /** @hidden */
  26774. _pluginData: any;
  26775. private _physicsEngine;
  26776. private _physicsBody;
  26777. private _bodyUpdateRequired;
  26778. private _onBeforePhysicsStepCallbacks;
  26779. private _onAfterPhysicsStepCallbacks;
  26780. /** @hidden */
  26781. _onPhysicsCollideCallbacks: Array<{
  26782. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26783. otherImpostors: Array<PhysicsImpostor>;
  26784. }>;
  26785. private _deltaPosition;
  26786. private _deltaRotation;
  26787. private _deltaRotationConjugated;
  26788. /** @hidden */
  26789. _isFromLine: boolean;
  26790. private _parent;
  26791. private _isDisposed;
  26792. private static _tmpVecs;
  26793. private static _tmpQuat;
  26794. /**
  26795. * Specifies if the physics imposter is disposed
  26796. */
  26797. get isDisposed(): boolean;
  26798. /**
  26799. * Gets the mass of the physics imposter
  26800. */
  26801. get mass(): number;
  26802. set mass(value: number);
  26803. /**
  26804. * Gets the coefficient of friction
  26805. */
  26806. get friction(): number;
  26807. /**
  26808. * Sets the coefficient of friction
  26809. */
  26810. set friction(value: number);
  26811. /**
  26812. * Gets the coefficient of restitution
  26813. */
  26814. get restitution(): number;
  26815. /**
  26816. * Sets the coefficient of restitution
  26817. */
  26818. set restitution(value: number);
  26819. /**
  26820. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26821. */
  26822. get pressure(): number;
  26823. /**
  26824. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26825. */
  26826. set pressure(value: number);
  26827. /**
  26828. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26829. */
  26830. get stiffness(): number;
  26831. /**
  26832. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26833. */
  26834. set stiffness(value: number);
  26835. /**
  26836. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26837. */
  26838. get velocityIterations(): number;
  26839. /**
  26840. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26841. */
  26842. set velocityIterations(value: number);
  26843. /**
  26844. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26845. */
  26846. get positionIterations(): number;
  26847. /**
  26848. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26849. */
  26850. set positionIterations(value: number);
  26851. /**
  26852. * The unique id of the physics imposter
  26853. * set by the physics engine when adding this impostor to the array
  26854. */
  26855. uniqueId: number;
  26856. /**
  26857. * @hidden
  26858. */
  26859. soft: boolean;
  26860. /**
  26861. * @hidden
  26862. */
  26863. segments: number;
  26864. private _joints;
  26865. /**
  26866. * Initializes the physics imposter
  26867. * @param object The physics-enabled object used as the physics imposter
  26868. * @param type The type of the physics imposter
  26869. * @param _options The options for the physics imposter
  26870. * @param _scene The Babylon scene
  26871. */
  26872. constructor(
  26873. /**
  26874. * The physics-enabled object used as the physics imposter
  26875. */
  26876. object: IPhysicsEnabledObject,
  26877. /**
  26878. * The type of the physics imposter
  26879. */
  26880. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26881. /**
  26882. * This function will completly initialize this impostor.
  26883. * It will create a new body - but only if this mesh has no parent.
  26884. * If it has, this impostor will not be used other than to define the impostor
  26885. * of the child mesh.
  26886. * @hidden
  26887. */
  26888. _init(): void;
  26889. private _getPhysicsParent;
  26890. /**
  26891. * Should a new body be generated.
  26892. * @returns boolean specifying if body initialization is required
  26893. */
  26894. isBodyInitRequired(): boolean;
  26895. /**
  26896. * Sets the updated scaling
  26897. * @param updated Specifies if the scaling is updated
  26898. */
  26899. setScalingUpdated(): void;
  26900. /**
  26901. * Force a regeneration of this or the parent's impostor's body.
  26902. * Use under cautious - This will remove all joints already implemented.
  26903. */
  26904. forceUpdate(): void;
  26905. /**
  26906. * Gets the body that holds this impostor. Either its own, or its parent.
  26907. */
  26908. get physicsBody(): any;
  26909. /**
  26910. * Get the parent of the physics imposter
  26911. * @returns Physics imposter or null
  26912. */
  26913. get parent(): Nullable<PhysicsImpostor>;
  26914. /**
  26915. * Sets the parent of the physics imposter
  26916. */
  26917. set parent(value: Nullable<PhysicsImpostor>);
  26918. /**
  26919. * Set the physics body. Used mainly by the physics engine/plugin
  26920. */
  26921. set physicsBody(physicsBody: any);
  26922. /**
  26923. * Resets the update flags
  26924. */
  26925. resetUpdateFlags(): void;
  26926. /**
  26927. * Gets the object extend size
  26928. * @returns the object extend size
  26929. */
  26930. getObjectExtendSize(): Vector3;
  26931. /**
  26932. * Gets the object center
  26933. * @returns The object center
  26934. */
  26935. getObjectCenter(): Vector3;
  26936. /**
  26937. * Get a specific parameter from the options parameters
  26938. * @param paramName The object parameter name
  26939. * @returns The object parameter
  26940. */
  26941. getParam(paramName: string): any;
  26942. /**
  26943. * Sets a specific parameter in the options given to the physics plugin
  26944. * @param paramName The parameter name
  26945. * @param value The value of the parameter
  26946. */
  26947. setParam(paramName: string, value: number): void;
  26948. /**
  26949. * Specifically change the body's mass option. Won't recreate the physics body object
  26950. * @param mass The mass of the physics imposter
  26951. */
  26952. setMass(mass: number): void;
  26953. /**
  26954. * Gets the linear velocity
  26955. * @returns linear velocity or null
  26956. */
  26957. getLinearVelocity(): Nullable<Vector3>;
  26958. /**
  26959. * Sets the linear velocity
  26960. * @param velocity linear velocity or null
  26961. */
  26962. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26963. /**
  26964. * Gets the angular velocity
  26965. * @returns angular velocity or null
  26966. */
  26967. getAngularVelocity(): Nullable<Vector3>;
  26968. /**
  26969. * Sets the angular velocity
  26970. * @param velocity The velocity or null
  26971. */
  26972. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26973. /**
  26974. * Execute a function with the physics plugin native code
  26975. * Provide a function the will have two variables - the world object and the physics body object
  26976. * @param func The function to execute with the physics plugin native code
  26977. */
  26978. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26979. /**
  26980. * Register a function that will be executed before the physics world is stepping forward
  26981. * @param func The function to execute before the physics world is stepped forward
  26982. */
  26983. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26984. /**
  26985. * Unregister a function that will be executed before the physics world is stepping forward
  26986. * @param func The function to execute before the physics world is stepped forward
  26987. */
  26988. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26989. /**
  26990. * Register a function that will be executed after the physics step
  26991. * @param func The function to execute after physics step
  26992. */
  26993. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26994. /**
  26995. * Unregisters a function that will be executed after the physics step
  26996. * @param func The function to execute after physics step
  26997. */
  26998. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26999. /**
  27000. * register a function that will be executed when this impostor collides against a different body
  27001. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27002. * @param func Callback that is executed on collision
  27003. */
  27004. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27005. /**
  27006. * Unregisters the physics imposter on contact
  27007. * @param collideAgainst The physics object to collide against
  27008. * @param func Callback to execute on collision
  27009. */
  27010. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27011. private _tmpQuat;
  27012. private _tmpQuat2;
  27013. /**
  27014. * Get the parent rotation
  27015. * @returns The parent rotation
  27016. */
  27017. getParentsRotation(): Quaternion;
  27018. /**
  27019. * this function is executed by the physics engine.
  27020. */
  27021. beforeStep: () => void;
  27022. /**
  27023. * this function is executed by the physics engine
  27024. */
  27025. afterStep: () => void;
  27026. /**
  27027. * Legacy collision detection event support
  27028. */
  27029. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27030. /**
  27031. * event and body object due to cannon's event-based architecture.
  27032. */
  27033. onCollide: (e: {
  27034. body: any;
  27035. }) => void;
  27036. /**
  27037. * Apply a force
  27038. * @param force The force to apply
  27039. * @param contactPoint The contact point for the force
  27040. * @returns The physics imposter
  27041. */
  27042. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27043. /**
  27044. * Apply an impulse
  27045. * @param force The impulse force
  27046. * @param contactPoint The contact point for the impulse force
  27047. * @returns The physics imposter
  27048. */
  27049. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27050. /**
  27051. * A help function to create a joint
  27052. * @param otherImpostor A physics imposter used to create a joint
  27053. * @param jointType The type of joint
  27054. * @param jointData The data for the joint
  27055. * @returns The physics imposter
  27056. */
  27057. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27058. /**
  27059. * Add a joint to this impostor with a different impostor
  27060. * @param otherImpostor A physics imposter used to add a joint
  27061. * @param joint The joint to add
  27062. * @returns The physics imposter
  27063. */
  27064. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27065. /**
  27066. * Add an anchor to a cloth impostor
  27067. * @param otherImpostor rigid impostor to anchor to
  27068. * @param width ratio across width from 0 to 1
  27069. * @param height ratio up height from 0 to 1
  27070. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27071. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27072. * @returns impostor the soft imposter
  27073. */
  27074. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27075. /**
  27076. * Add a hook to a rope impostor
  27077. * @param otherImpostor rigid impostor to anchor to
  27078. * @param length ratio across rope from 0 to 1
  27079. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27080. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27081. * @returns impostor the rope imposter
  27082. */
  27083. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27084. /**
  27085. * Will keep this body still, in a sleep mode.
  27086. * @returns the physics imposter
  27087. */
  27088. sleep(): PhysicsImpostor;
  27089. /**
  27090. * Wake the body up.
  27091. * @returns The physics imposter
  27092. */
  27093. wakeUp(): PhysicsImpostor;
  27094. /**
  27095. * Clones the physics imposter
  27096. * @param newObject The physics imposter clones to this physics-enabled object
  27097. * @returns A nullable physics imposter
  27098. */
  27099. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27100. /**
  27101. * Disposes the physics imposter
  27102. */
  27103. dispose(): void;
  27104. /**
  27105. * Sets the delta position
  27106. * @param position The delta position amount
  27107. */
  27108. setDeltaPosition(position: Vector3): void;
  27109. /**
  27110. * Sets the delta rotation
  27111. * @param rotation The delta rotation amount
  27112. */
  27113. setDeltaRotation(rotation: Quaternion): void;
  27114. /**
  27115. * Gets the box size of the physics imposter and stores the result in the input parameter
  27116. * @param result Stores the box size
  27117. * @returns The physics imposter
  27118. */
  27119. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27120. /**
  27121. * Gets the radius of the physics imposter
  27122. * @returns Radius of the physics imposter
  27123. */
  27124. getRadius(): number;
  27125. /**
  27126. * Sync a bone with this impostor
  27127. * @param bone The bone to sync to the impostor.
  27128. * @param boneMesh The mesh that the bone is influencing.
  27129. * @param jointPivot The pivot of the joint / bone in local space.
  27130. * @param distToJoint Optional distance from the impostor to the joint.
  27131. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27132. */
  27133. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27134. /**
  27135. * Sync impostor to a bone
  27136. * @param bone The bone that the impostor will be synced to.
  27137. * @param boneMesh The mesh that the bone is influencing.
  27138. * @param jointPivot The pivot of the joint / bone in local space.
  27139. * @param distToJoint Optional distance from the impostor to the joint.
  27140. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27141. * @param boneAxis Optional vector3 axis the bone is aligned with
  27142. */
  27143. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27144. /**
  27145. * No-Imposter type
  27146. */
  27147. static NoImpostor: number;
  27148. /**
  27149. * Sphere-Imposter type
  27150. */
  27151. static SphereImpostor: number;
  27152. /**
  27153. * Box-Imposter type
  27154. */
  27155. static BoxImpostor: number;
  27156. /**
  27157. * Plane-Imposter type
  27158. */
  27159. static PlaneImpostor: number;
  27160. /**
  27161. * Mesh-imposter type
  27162. */
  27163. static MeshImpostor: number;
  27164. /**
  27165. * Capsule-Impostor type (Ammo.js plugin only)
  27166. */
  27167. static CapsuleImpostor: number;
  27168. /**
  27169. * Cylinder-Imposter type
  27170. */
  27171. static CylinderImpostor: number;
  27172. /**
  27173. * Particle-Imposter type
  27174. */
  27175. static ParticleImpostor: number;
  27176. /**
  27177. * Heightmap-Imposter type
  27178. */
  27179. static HeightmapImpostor: number;
  27180. /**
  27181. * ConvexHull-Impostor type (Ammo.js plugin only)
  27182. */
  27183. static ConvexHullImpostor: number;
  27184. /**
  27185. * Custom-Imposter type (Ammo.js plugin only)
  27186. */
  27187. static CustomImpostor: number;
  27188. /**
  27189. * Rope-Imposter type
  27190. */
  27191. static RopeImpostor: number;
  27192. /**
  27193. * Cloth-Imposter type
  27194. */
  27195. static ClothImpostor: number;
  27196. /**
  27197. * Softbody-Imposter type
  27198. */
  27199. static SoftbodyImpostor: number;
  27200. }
  27201. }
  27202. declare module BABYLON {
  27203. /**
  27204. * @hidden
  27205. **/
  27206. export class _CreationDataStorage {
  27207. closePath?: boolean;
  27208. closeArray?: boolean;
  27209. idx: number[];
  27210. dashSize: number;
  27211. gapSize: number;
  27212. path3D: Path3D;
  27213. pathArray: Vector3[][];
  27214. arc: number;
  27215. radius: number;
  27216. cap: number;
  27217. tessellation: number;
  27218. }
  27219. /**
  27220. * @hidden
  27221. **/
  27222. class _InstanceDataStorage {
  27223. visibleInstances: any;
  27224. batchCache: _InstancesBatch;
  27225. instancesBufferSize: number;
  27226. instancesBuffer: Nullable<Buffer>;
  27227. instancesData: Float32Array;
  27228. overridenInstanceCount: number;
  27229. isFrozen: boolean;
  27230. previousBatch: Nullable<_InstancesBatch>;
  27231. hardwareInstancedRendering: boolean;
  27232. sideOrientation: number;
  27233. manualUpdate: boolean;
  27234. }
  27235. /**
  27236. * @hidden
  27237. **/
  27238. export class _InstancesBatch {
  27239. mustReturn: boolean;
  27240. visibleInstances: Nullable<InstancedMesh[]>[];
  27241. renderSelf: boolean[];
  27242. hardwareInstancedRendering: boolean[];
  27243. }
  27244. /**
  27245. * @hidden
  27246. **/
  27247. class _ThinInstanceDataStorage {
  27248. instancesCount: number;
  27249. matrixBuffer: Nullable<Buffer>;
  27250. matrixBufferSize: number;
  27251. matrixData: Nullable<Float32Array>;
  27252. boundingVectors: Array<Vector3>;
  27253. }
  27254. /**
  27255. * Class used to represent renderable models
  27256. */
  27257. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27258. /**
  27259. * Mesh side orientation : usually the external or front surface
  27260. */
  27261. static readonly FRONTSIDE: number;
  27262. /**
  27263. * Mesh side orientation : usually the internal or back surface
  27264. */
  27265. static readonly BACKSIDE: number;
  27266. /**
  27267. * Mesh side orientation : both internal and external or front and back surfaces
  27268. */
  27269. static readonly DOUBLESIDE: number;
  27270. /**
  27271. * Mesh side orientation : by default, `FRONTSIDE`
  27272. */
  27273. static readonly DEFAULTSIDE: number;
  27274. /**
  27275. * Mesh cap setting : no cap
  27276. */
  27277. static readonly NO_CAP: number;
  27278. /**
  27279. * Mesh cap setting : one cap at the beginning of the mesh
  27280. */
  27281. static readonly CAP_START: number;
  27282. /**
  27283. * Mesh cap setting : one cap at the end of the mesh
  27284. */
  27285. static readonly CAP_END: number;
  27286. /**
  27287. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27288. */
  27289. static readonly CAP_ALL: number;
  27290. /**
  27291. * Mesh pattern setting : no flip or rotate
  27292. */
  27293. static readonly NO_FLIP: number;
  27294. /**
  27295. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27296. */
  27297. static readonly FLIP_TILE: number;
  27298. /**
  27299. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27300. */
  27301. static readonly ROTATE_TILE: number;
  27302. /**
  27303. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27304. */
  27305. static readonly FLIP_ROW: number;
  27306. /**
  27307. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27308. */
  27309. static readonly ROTATE_ROW: number;
  27310. /**
  27311. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27312. */
  27313. static readonly FLIP_N_ROTATE_TILE: number;
  27314. /**
  27315. * Mesh pattern setting : rotate pattern and rotate
  27316. */
  27317. static readonly FLIP_N_ROTATE_ROW: number;
  27318. /**
  27319. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27320. */
  27321. static readonly CENTER: number;
  27322. /**
  27323. * Mesh tile positioning : part tiles on left
  27324. */
  27325. static readonly LEFT: number;
  27326. /**
  27327. * Mesh tile positioning : part tiles on right
  27328. */
  27329. static readonly RIGHT: number;
  27330. /**
  27331. * Mesh tile positioning : part tiles on top
  27332. */
  27333. static readonly TOP: number;
  27334. /**
  27335. * Mesh tile positioning : part tiles on bottom
  27336. */
  27337. static readonly BOTTOM: number;
  27338. /**
  27339. * Gets the default side orientation.
  27340. * @param orientation the orientation to value to attempt to get
  27341. * @returns the default orientation
  27342. * @hidden
  27343. */
  27344. static _GetDefaultSideOrientation(orientation?: number): number;
  27345. private _internalMeshDataInfo;
  27346. /**
  27347. * An event triggered before rendering the mesh
  27348. */
  27349. get onBeforeRenderObservable(): Observable<Mesh>;
  27350. /**
  27351. * An event triggered before binding the mesh
  27352. */
  27353. get onBeforeBindObservable(): Observable<Mesh>;
  27354. /**
  27355. * An event triggered after rendering the mesh
  27356. */
  27357. get onAfterRenderObservable(): Observable<Mesh>;
  27358. /**
  27359. * An event triggered before drawing the mesh
  27360. */
  27361. get onBeforeDrawObservable(): Observable<Mesh>;
  27362. private _onBeforeDrawObserver;
  27363. /**
  27364. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27365. */
  27366. set onBeforeDraw(callback: () => void);
  27367. get hasInstances(): boolean;
  27368. get hasThinInstances(): boolean;
  27369. /**
  27370. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27371. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27372. */
  27373. delayLoadState: number;
  27374. /**
  27375. * Gets the list of instances created from this mesh
  27376. * it is not supposed to be modified manually.
  27377. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27378. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27379. */
  27380. instances: InstancedMesh[];
  27381. /**
  27382. * Gets the file containing delay loading data for this mesh
  27383. */
  27384. delayLoadingFile: string;
  27385. /** @hidden */
  27386. _binaryInfo: any;
  27387. /**
  27388. * User defined function used to change how LOD level selection is done
  27389. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  27390. */
  27391. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27392. /**
  27393. * Gets or sets the morph target manager
  27394. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27395. */
  27396. get morphTargetManager(): Nullable<MorphTargetManager>;
  27397. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27398. /** @hidden */
  27399. _creationDataStorage: Nullable<_CreationDataStorage>;
  27400. /** @hidden */
  27401. _geometry: Nullable<Geometry>;
  27402. /** @hidden */
  27403. _delayInfo: Array<string>;
  27404. /** @hidden */
  27405. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27406. /** @hidden */
  27407. _instanceDataStorage: _InstanceDataStorage;
  27408. /** @hidden */
  27409. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27410. private _effectiveMaterial;
  27411. /** @hidden */
  27412. _shouldGenerateFlatShading: boolean;
  27413. /** @hidden */
  27414. _originalBuilderSideOrientation: number;
  27415. /**
  27416. * Use this property to change the original side orientation defined at construction time
  27417. */
  27418. overrideMaterialSideOrientation: Nullable<number>;
  27419. /**
  27420. * Gets the source mesh (the one used to clone this one from)
  27421. */
  27422. get source(): Nullable<Mesh>;
  27423. /**
  27424. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27425. */
  27426. get isUnIndexed(): boolean;
  27427. set isUnIndexed(value: boolean);
  27428. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27429. get worldMatrixInstancedBuffer(): Float32Array;
  27430. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27431. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27432. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27433. /**
  27434. * @constructor
  27435. * @param name The value used by scene.getMeshByName() to do a lookup.
  27436. * @param scene The scene to add this mesh to.
  27437. * @param parent The parent of this mesh, if it has one
  27438. * @param source An optional Mesh from which geometry is shared, cloned.
  27439. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27440. * When false, achieved by calling a clone(), also passing False.
  27441. * This will make creation of children, recursive.
  27442. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27443. */
  27444. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27445. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27446. doNotInstantiate: boolean;
  27447. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27448. /**
  27449. * Gets the class name
  27450. * @returns the string "Mesh".
  27451. */
  27452. getClassName(): string;
  27453. /** @hidden */
  27454. get _isMesh(): boolean;
  27455. /**
  27456. * Returns a description of this mesh
  27457. * @param fullDetails define if full details about this mesh must be used
  27458. * @returns a descriptive string representing this mesh
  27459. */
  27460. toString(fullDetails?: boolean): string;
  27461. /** @hidden */
  27462. _unBindEffect(): void;
  27463. /**
  27464. * Gets a boolean indicating if this mesh has LOD
  27465. */
  27466. get hasLODLevels(): boolean;
  27467. /**
  27468. * Gets the list of MeshLODLevel associated with the current mesh
  27469. * @returns an array of MeshLODLevel
  27470. */
  27471. getLODLevels(): MeshLODLevel[];
  27472. private _sortLODLevels;
  27473. /**
  27474. * Add a mesh as LOD level triggered at the given distance.
  27475. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27476. * @param distance The distance from the center of the object to show this level
  27477. * @param mesh The mesh to be added as LOD level (can be null)
  27478. * @return This mesh (for chaining)
  27479. */
  27480. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27481. /**
  27482. * Returns the LOD level mesh at the passed distance or null if not found.
  27483. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27484. * @param distance The distance from the center of the object to show this level
  27485. * @returns a Mesh or `null`
  27486. */
  27487. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27488. /**
  27489. * Remove a mesh from the LOD array
  27490. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27491. * @param mesh defines the mesh to be removed
  27492. * @return This mesh (for chaining)
  27493. */
  27494. removeLODLevel(mesh: Mesh): Mesh;
  27495. /**
  27496. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27497. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27498. * @param camera defines the camera to use to compute distance
  27499. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27500. * @return This mesh (for chaining)
  27501. */
  27502. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27503. /**
  27504. * Gets the mesh internal Geometry object
  27505. */
  27506. get geometry(): Nullable<Geometry>;
  27507. /**
  27508. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27509. * @returns the total number of vertices
  27510. */
  27511. getTotalVertices(): number;
  27512. /**
  27513. * Returns the content of an associated vertex buffer
  27514. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27515. * - VertexBuffer.PositionKind
  27516. * - VertexBuffer.UVKind
  27517. * - VertexBuffer.UV2Kind
  27518. * - VertexBuffer.UV3Kind
  27519. * - VertexBuffer.UV4Kind
  27520. * - VertexBuffer.UV5Kind
  27521. * - VertexBuffer.UV6Kind
  27522. * - VertexBuffer.ColorKind
  27523. * - VertexBuffer.MatricesIndicesKind
  27524. * - VertexBuffer.MatricesIndicesExtraKind
  27525. * - VertexBuffer.MatricesWeightsKind
  27526. * - VertexBuffer.MatricesWeightsExtraKind
  27527. * @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
  27528. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27529. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27530. */
  27531. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27532. /**
  27533. * Returns the mesh VertexBuffer object from the requested `kind`
  27534. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27535. * - VertexBuffer.PositionKind
  27536. * - VertexBuffer.NormalKind
  27537. * - VertexBuffer.UVKind
  27538. * - VertexBuffer.UV2Kind
  27539. * - VertexBuffer.UV3Kind
  27540. * - VertexBuffer.UV4Kind
  27541. * - VertexBuffer.UV5Kind
  27542. * - VertexBuffer.UV6Kind
  27543. * - VertexBuffer.ColorKind
  27544. * - VertexBuffer.MatricesIndicesKind
  27545. * - VertexBuffer.MatricesIndicesExtraKind
  27546. * - VertexBuffer.MatricesWeightsKind
  27547. * - VertexBuffer.MatricesWeightsExtraKind
  27548. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27549. */
  27550. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27551. /**
  27552. * Tests if a specific vertex buffer is associated with this mesh
  27553. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27554. * - VertexBuffer.PositionKind
  27555. * - VertexBuffer.NormalKind
  27556. * - VertexBuffer.UVKind
  27557. * - VertexBuffer.UV2Kind
  27558. * - VertexBuffer.UV3Kind
  27559. * - VertexBuffer.UV4Kind
  27560. * - VertexBuffer.UV5Kind
  27561. * - VertexBuffer.UV6Kind
  27562. * - VertexBuffer.ColorKind
  27563. * - VertexBuffer.MatricesIndicesKind
  27564. * - VertexBuffer.MatricesIndicesExtraKind
  27565. * - VertexBuffer.MatricesWeightsKind
  27566. * - VertexBuffer.MatricesWeightsExtraKind
  27567. * @returns a boolean
  27568. */
  27569. isVerticesDataPresent(kind: string): boolean;
  27570. /**
  27571. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27572. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27573. * - VertexBuffer.PositionKind
  27574. * - VertexBuffer.UVKind
  27575. * - VertexBuffer.UV2Kind
  27576. * - VertexBuffer.UV3Kind
  27577. * - VertexBuffer.UV4Kind
  27578. * - VertexBuffer.UV5Kind
  27579. * - VertexBuffer.UV6Kind
  27580. * - VertexBuffer.ColorKind
  27581. * - VertexBuffer.MatricesIndicesKind
  27582. * - VertexBuffer.MatricesIndicesExtraKind
  27583. * - VertexBuffer.MatricesWeightsKind
  27584. * - VertexBuffer.MatricesWeightsExtraKind
  27585. * @returns a boolean
  27586. */
  27587. isVertexBufferUpdatable(kind: string): boolean;
  27588. /**
  27589. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27590. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27591. * - VertexBuffer.PositionKind
  27592. * - VertexBuffer.NormalKind
  27593. * - VertexBuffer.UVKind
  27594. * - VertexBuffer.UV2Kind
  27595. * - VertexBuffer.UV3Kind
  27596. * - VertexBuffer.UV4Kind
  27597. * - VertexBuffer.UV5Kind
  27598. * - VertexBuffer.UV6Kind
  27599. * - VertexBuffer.ColorKind
  27600. * - VertexBuffer.MatricesIndicesKind
  27601. * - VertexBuffer.MatricesIndicesExtraKind
  27602. * - VertexBuffer.MatricesWeightsKind
  27603. * - VertexBuffer.MatricesWeightsExtraKind
  27604. * @returns an array of strings
  27605. */
  27606. getVerticesDataKinds(): string[];
  27607. /**
  27608. * Returns a positive integer : the total number of indices in this mesh geometry.
  27609. * @returns the numner of indices or zero if the mesh has no geometry.
  27610. */
  27611. getTotalIndices(): number;
  27612. /**
  27613. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27614. * @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.
  27615. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27616. * @returns the indices array or an empty array if the mesh has no geometry
  27617. */
  27618. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27619. get isBlocked(): boolean;
  27620. /**
  27621. * Determine if the current mesh is ready to be rendered
  27622. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27623. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27624. * @returns true if all associated assets are ready (material, textures, shaders)
  27625. */
  27626. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27627. /**
  27628. * 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.
  27629. */
  27630. get areNormalsFrozen(): boolean;
  27631. /**
  27632. * 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.
  27633. * @returns the current mesh
  27634. */
  27635. freezeNormals(): Mesh;
  27636. /**
  27637. * 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
  27638. * @returns the current mesh
  27639. */
  27640. unfreezeNormals(): Mesh;
  27641. /**
  27642. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27643. */
  27644. set overridenInstanceCount(count: number);
  27645. /** @hidden */
  27646. _preActivate(): Mesh;
  27647. /** @hidden */
  27648. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27649. /** @hidden */
  27650. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27651. protected _afterComputeWorldMatrix(): void;
  27652. /** @hidden */
  27653. _postActivate(): void;
  27654. /**
  27655. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27656. * This means the mesh underlying bounding box and sphere are recomputed.
  27657. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27658. * @returns the current mesh
  27659. */
  27660. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27661. /** @hidden */
  27662. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27663. /**
  27664. * This function will subdivide the mesh into multiple submeshes
  27665. * @param count defines the expected number of submeshes
  27666. */
  27667. subdivide(count: number): void;
  27668. /**
  27669. * Copy a FloatArray into a specific associated vertex buffer
  27670. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27671. * - VertexBuffer.PositionKind
  27672. * - VertexBuffer.UVKind
  27673. * - VertexBuffer.UV2Kind
  27674. * - VertexBuffer.UV3Kind
  27675. * - VertexBuffer.UV4Kind
  27676. * - VertexBuffer.UV5Kind
  27677. * - VertexBuffer.UV6Kind
  27678. * - VertexBuffer.ColorKind
  27679. * - VertexBuffer.MatricesIndicesKind
  27680. * - VertexBuffer.MatricesIndicesExtraKind
  27681. * - VertexBuffer.MatricesWeightsKind
  27682. * - VertexBuffer.MatricesWeightsExtraKind
  27683. * @param data defines the data source
  27684. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27685. * @param stride defines the data stride size (can be null)
  27686. * @returns the current mesh
  27687. */
  27688. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27689. /**
  27690. * Delete a vertex buffer associated with this mesh
  27691. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27692. * - VertexBuffer.PositionKind
  27693. * - VertexBuffer.UVKind
  27694. * - VertexBuffer.UV2Kind
  27695. * - VertexBuffer.UV3Kind
  27696. * - VertexBuffer.UV4Kind
  27697. * - VertexBuffer.UV5Kind
  27698. * - VertexBuffer.UV6Kind
  27699. * - VertexBuffer.ColorKind
  27700. * - VertexBuffer.MatricesIndicesKind
  27701. * - VertexBuffer.MatricesIndicesExtraKind
  27702. * - VertexBuffer.MatricesWeightsKind
  27703. * - VertexBuffer.MatricesWeightsExtraKind
  27704. */
  27705. removeVerticesData(kind: string): void;
  27706. /**
  27707. * Flags an associated vertex buffer as updatable
  27708. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27709. * - VertexBuffer.PositionKind
  27710. * - VertexBuffer.UVKind
  27711. * - VertexBuffer.UV2Kind
  27712. * - VertexBuffer.UV3Kind
  27713. * - VertexBuffer.UV4Kind
  27714. * - VertexBuffer.UV5Kind
  27715. * - VertexBuffer.UV6Kind
  27716. * - VertexBuffer.ColorKind
  27717. * - VertexBuffer.MatricesIndicesKind
  27718. * - VertexBuffer.MatricesIndicesExtraKind
  27719. * - VertexBuffer.MatricesWeightsKind
  27720. * - VertexBuffer.MatricesWeightsExtraKind
  27721. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27722. */
  27723. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27724. /**
  27725. * Sets the mesh global Vertex Buffer
  27726. * @param buffer defines the buffer to use
  27727. * @returns the current mesh
  27728. */
  27729. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27730. /**
  27731. * Update a specific associated vertex buffer
  27732. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27733. * - VertexBuffer.PositionKind
  27734. * - VertexBuffer.UVKind
  27735. * - VertexBuffer.UV2Kind
  27736. * - VertexBuffer.UV3Kind
  27737. * - VertexBuffer.UV4Kind
  27738. * - VertexBuffer.UV5Kind
  27739. * - VertexBuffer.UV6Kind
  27740. * - VertexBuffer.ColorKind
  27741. * - VertexBuffer.MatricesIndicesKind
  27742. * - VertexBuffer.MatricesIndicesExtraKind
  27743. * - VertexBuffer.MatricesWeightsKind
  27744. * - VertexBuffer.MatricesWeightsExtraKind
  27745. * @param data defines the data source
  27746. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27747. * @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)
  27748. * @returns the current mesh
  27749. */
  27750. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27751. /**
  27752. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27753. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27754. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27755. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27756. * @returns the current mesh
  27757. */
  27758. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27759. /**
  27760. * Creates a un-shared specific occurence of the geometry for the mesh.
  27761. * @returns the current mesh
  27762. */
  27763. makeGeometryUnique(): Mesh;
  27764. /**
  27765. * Set the index buffer of this mesh
  27766. * @param indices defines the source data
  27767. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27768. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27769. * @returns the current mesh
  27770. */
  27771. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27772. /**
  27773. * Update the current index buffer
  27774. * @param indices defines the source data
  27775. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27776. * @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)
  27777. * @returns the current mesh
  27778. */
  27779. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27780. /**
  27781. * Invert the geometry to move from a right handed system to a left handed one.
  27782. * @returns the current mesh
  27783. */
  27784. toLeftHanded(): Mesh;
  27785. /** @hidden */
  27786. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27787. /** @hidden */
  27788. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27789. /**
  27790. * Registers for this mesh a javascript function called just before the rendering process
  27791. * @param func defines the function to call before rendering this mesh
  27792. * @returns the current mesh
  27793. */
  27794. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27795. /**
  27796. * Disposes a previously registered javascript function called before the rendering
  27797. * @param func defines the function to remove
  27798. * @returns the current mesh
  27799. */
  27800. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27801. /**
  27802. * Registers for this mesh a javascript function called just after the rendering is complete
  27803. * @param func defines the function to call after rendering this mesh
  27804. * @returns the current mesh
  27805. */
  27806. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27807. /**
  27808. * Disposes a previously registered javascript function called after the rendering.
  27809. * @param func defines the function to remove
  27810. * @returns the current mesh
  27811. */
  27812. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27813. /** @hidden */
  27814. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27815. /** @hidden */
  27816. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27817. /** @hidden */
  27818. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27819. /** @hidden */
  27820. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27821. /** @hidden */
  27822. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27823. /** @hidden */
  27824. _rebuild(): void;
  27825. /** @hidden */
  27826. _freeze(): void;
  27827. /** @hidden */
  27828. _unFreeze(): void;
  27829. /**
  27830. * 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
  27831. * @param subMesh defines the subMesh to render
  27832. * @param enableAlphaMode defines if alpha mode can be changed
  27833. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27834. * @returns the current mesh
  27835. */
  27836. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27837. private _onBeforeDraw;
  27838. /**
  27839. * Renormalize the mesh and patch it up if there are no weights
  27840. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27841. * However in the case of zero weights then we set just a single influence to 1.
  27842. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27843. */
  27844. cleanMatrixWeights(): void;
  27845. private normalizeSkinFourWeights;
  27846. private normalizeSkinWeightsAndExtra;
  27847. /**
  27848. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27849. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27850. * the user know there was an issue with importing the mesh
  27851. * @returns a validation object with skinned, valid and report string
  27852. */
  27853. validateSkinning(): {
  27854. skinned: boolean;
  27855. valid: boolean;
  27856. report: string;
  27857. };
  27858. /** @hidden */
  27859. _checkDelayState(): Mesh;
  27860. private _queueLoad;
  27861. /**
  27862. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27863. * A mesh is in the frustum if its bounding box intersects the frustum
  27864. * @param frustumPlanes defines the frustum to test
  27865. * @returns true if the mesh is in the frustum planes
  27866. */
  27867. isInFrustum(frustumPlanes: Plane[]): boolean;
  27868. /**
  27869. * Sets the mesh material by the material or multiMaterial `id` property
  27870. * @param id is a string identifying the material or the multiMaterial
  27871. * @returns the current mesh
  27872. */
  27873. setMaterialByID(id: string): Mesh;
  27874. /**
  27875. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27876. * @returns an array of IAnimatable
  27877. */
  27878. getAnimatables(): IAnimatable[];
  27879. /**
  27880. * Modifies the mesh geometry according to the passed transformation matrix.
  27881. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27882. * The mesh normals are modified using the same transformation.
  27883. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27884. * @param transform defines the transform matrix to use
  27885. * @see http://doc.babylonjs.com/resources/baking_transformations
  27886. * @returns the current mesh
  27887. */
  27888. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27889. /**
  27890. * Modifies the mesh geometry according to its own current World Matrix.
  27891. * The mesh World Matrix is then reset.
  27892. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27893. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27894. * @see http://doc.babylonjs.com/resources/baking_transformations
  27895. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27896. * @returns the current mesh
  27897. */
  27898. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27899. /** @hidden */
  27900. get _positions(): Nullable<Vector3[]>;
  27901. /** @hidden */
  27902. _resetPointsArrayCache(): Mesh;
  27903. /** @hidden */
  27904. _generatePointsArray(): boolean;
  27905. /**
  27906. * Returns a new Mesh object generated from the current mesh properties.
  27907. * This method must not get confused with createInstance()
  27908. * @param name is a string, the name given to the new mesh
  27909. * @param newParent can be any Node object (default `null`)
  27910. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27911. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27912. * @returns a new mesh
  27913. */
  27914. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27915. /**
  27916. * Releases resources associated with this mesh.
  27917. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27918. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27919. */
  27920. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27921. /** @hidden */
  27922. _disposeInstanceSpecificData(): void;
  27923. /** @hidden */
  27924. _disposeThinInstanceSpecificData(): void;
  27925. /**
  27926. * Modifies the mesh geometry according to a displacement map.
  27927. * 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.
  27928. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27929. * @param url is a string, the URL from the image file is to be downloaded.
  27930. * @param minHeight is the lower limit of the displacement.
  27931. * @param maxHeight is the upper limit of the displacement.
  27932. * @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.
  27933. * @param uvOffset is an optional vector2 used to offset UV.
  27934. * @param uvScale is an optional vector2 used to scale UV.
  27935. * @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.
  27936. * @returns the Mesh.
  27937. */
  27938. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27939. /**
  27940. * Modifies the mesh geometry according to a displacementMap buffer.
  27941. * 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.
  27942. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27943. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27944. * @param heightMapWidth is the width of the buffer image.
  27945. * @param heightMapHeight is the height of the buffer image.
  27946. * @param minHeight is the lower limit of the displacement.
  27947. * @param maxHeight is the upper limit of the displacement.
  27948. * @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.
  27949. * @param uvOffset is an optional vector2 used to offset UV.
  27950. * @param uvScale is an optional vector2 used to scale UV.
  27951. * @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.
  27952. * @returns the Mesh.
  27953. */
  27954. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27955. /**
  27956. * Modify the mesh to get a flat shading rendering.
  27957. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27958. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27959. * @returns current mesh
  27960. */
  27961. convertToFlatShadedMesh(): Mesh;
  27962. /**
  27963. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27964. * In other words, more vertices, no more indices and a single bigger VBO.
  27965. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27966. * @returns current mesh
  27967. */
  27968. convertToUnIndexedMesh(): Mesh;
  27969. /**
  27970. * Inverses facet orientations.
  27971. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27972. * @param flipNormals will also inverts the normals
  27973. * @returns current mesh
  27974. */
  27975. flipFaces(flipNormals?: boolean): Mesh;
  27976. /**
  27977. * Increase the number of facets and hence vertices in a mesh
  27978. * Vertex normals are interpolated from existing vertex normals
  27979. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27980. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27981. */
  27982. increaseVertices(numberPerEdge: number): void;
  27983. /**
  27984. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27985. * This will undo any application of covertToFlatShadedMesh
  27986. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27987. */
  27988. forceSharedVertices(): void;
  27989. /** @hidden */
  27990. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27991. /** @hidden */
  27992. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27993. /**
  27994. * Creates a new InstancedMesh object from the mesh model.
  27995. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27996. * @param name defines the name of the new instance
  27997. * @returns a new InstancedMesh
  27998. */
  27999. createInstance(name: string): InstancedMesh;
  28000. /**
  28001. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28002. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28003. * @returns the current mesh
  28004. */
  28005. synchronizeInstances(): Mesh;
  28006. /**
  28007. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28008. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28009. * This should be used together with the simplification to avoid disappearing triangles.
  28010. * @param successCallback an optional success callback to be called after the optimization finished.
  28011. * @returns the current mesh
  28012. */
  28013. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28014. /**
  28015. * Serialize current mesh
  28016. * @param serializationObject defines the object which will receive the serialization data
  28017. */
  28018. serialize(serializationObject: any): void;
  28019. /** @hidden */
  28020. _syncGeometryWithMorphTargetManager(): void;
  28021. /** @hidden */
  28022. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28023. /**
  28024. * Returns a new Mesh object parsed from the source provided.
  28025. * @param parsedMesh is the source
  28026. * @param scene defines the hosting scene
  28027. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28028. * @returns a new Mesh
  28029. */
  28030. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28031. /**
  28032. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28033. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28034. * @param name defines the name of the mesh to create
  28035. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28036. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28037. * @param closePath creates a seam between the first and the last points of each path of the path array
  28038. * @param offset is taken in account only if the `pathArray` is containing a single path
  28039. * @param scene defines the hosting scene
  28040. * @param updatable defines if the mesh must be flagged as updatable
  28041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28042. * @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)
  28043. * @returns a new Mesh
  28044. */
  28045. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28046. /**
  28047. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28048. * @param name defines the name of the mesh to create
  28049. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28050. * @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
  28051. * @param scene defines the hosting scene
  28052. * @param updatable defines if the mesh must be flagged as updatable
  28053. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28054. * @returns a new Mesh
  28055. */
  28056. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28057. /**
  28058. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28059. * @param name defines the name of the mesh to create
  28060. * @param size sets the size (float) of each box side (default 1)
  28061. * @param scene defines the hosting scene
  28062. * @param updatable defines if the mesh must be flagged as updatable
  28063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28064. * @returns a new Mesh
  28065. */
  28066. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28067. /**
  28068. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28069. * @param name defines the name of the mesh to create
  28070. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28071. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28072. * @param scene defines the hosting scene
  28073. * @param updatable defines if the mesh must be flagged as updatable
  28074. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28075. * @returns a new Mesh
  28076. */
  28077. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28078. /**
  28079. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28080. * @param name defines the name of the mesh to create
  28081. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28082. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28083. * @param scene defines the hosting scene
  28084. * @returns a new Mesh
  28085. */
  28086. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28087. /**
  28088. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28089. * @param name defines the name of the mesh to create
  28090. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28091. * @param diameterTop set the top cap diameter (floats, default 1)
  28092. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28093. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28094. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28095. * @param scene defines the hosting scene
  28096. * @param updatable defines if the mesh must be flagged as updatable
  28097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28098. * @returns a new Mesh
  28099. */
  28100. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28101. /**
  28102. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28103. * @param name defines the name of the mesh to create
  28104. * @param diameter sets the diameter size (float) of the torus (default 1)
  28105. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28106. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28107. * @param scene defines the hosting scene
  28108. * @param updatable defines if the mesh must be flagged as updatable
  28109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28110. * @returns a new Mesh
  28111. */
  28112. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28113. /**
  28114. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28115. * @param name defines the name of the mesh to create
  28116. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28117. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28118. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28119. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28120. * @param p the number of windings on X axis (positive integers, default 2)
  28121. * @param q the number of windings on Y axis (positive integers, default 3)
  28122. * @param scene defines the hosting scene
  28123. * @param updatable defines if the mesh must be flagged as updatable
  28124. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28125. * @returns a new Mesh
  28126. */
  28127. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28128. /**
  28129. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28130. * @param name defines the name of the mesh to create
  28131. * @param points is an array successive Vector3
  28132. * @param scene defines the hosting scene
  28133. * @param updatable defines if the mesh must be flagged as updatable
  28134. * @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).
  28135. * @returns a new Mesh
  28136. */
  28137. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28138. /**
  28139. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28140. * @param name defines the name of the mesh to create
  28141. * @param points is an array successive Vector3
  28142. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28143. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28144. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28145. * @param scene defines the hosting scene
  28146. * @param updatable defines if the mesh must be flagged as updatable
  28147. * @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)
  28148. * @returns a new Mesh
  28149. */
  28150. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28151. /**
  28152. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28153. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28154. * 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.
  28155. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28156. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28157. * Remember you can only change the shape positions, not their number when updating a polygon.
  28158. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28159. * @param name defines the name of the mesh to create
  28160. * @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
  28161. * @param scene defines the hosting scene
  28162. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28163. * @param updatable defines if the mesh must be flagged as updatable
  28164. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28165. * @param earcutInjection can be used to inject your own earcut reference
  28166. * @returns a new Mesh
  28167. */
  28168. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28169. /**
  28170. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28171. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28172. * @param name defines the name of the mesh to create
  28173. * @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
  28174. * @param depth defines the height of extrusion
  28175. * @param scene defines the hosting scene
  28176. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28177. * @param updatable defines if the mesh must be flagged as updatable
  28178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28179. * @param earcutInjection can be used to inject your own earcut reference
  28180. * @returns a new Mesh
  28181. */
  28182. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28183. /**
  28184. * Creates an extruded shape mesh.
  28185. * 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
  28186. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28187. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28188. * @param name defines the name of the mesh to create
  28189. * @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
  28190. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28191. * @param scale is the value to scale the shape
  28192. * @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
  28193. * @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
  28194. * @param scene defines the hosting scene
  28195. * @param updatable defines if the mesh must be flagged as updatable
  28196. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28197. * @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)
  28198. * @returns a new Mesh
  28199. */
  28200. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28201. /**
  28202. * Creates an custom extruded shape mesh.
  28203. * The custom extrusion is a parametric shape.
  28204. * It has no predefined shape. Its final shape will depend on the input parameters.
  28205. * Please consider using the same method from the MeshBuilder class instead
  28206. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28207. * @param name defines the name of the mesh to create
  28208. * @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
  28209. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28210. * @param scaleFunction is a custom Javascript function called on each path point
  28211. * @param rotationFunction is a custom Javascript function called on each path point
  28212. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28213. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28214. * @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
  28215. * @param scene defines the hosting scene
  28216. * @param updatable defines if the mesh must be flagged as updatable
  28217. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28218. * @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)
  28219. * @returns a new Mesh
  28220. */
  28221. 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;
  28222. /**
  28223. * Creates lathe mesh.
  28224. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28225. * Please consider using the same method from the MeshBuilder class instead
  28226. * @param name defines the name of the mesh to create
  28227. * @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
  28228. * @param radius is the radius value of the lathe
  28229. * @param tessellation is the side number of the lathe.
  28230. * @param scene defines the hosting scene
  28231. * @param updatable defines if the mesh must be flagged as updatable
  28232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28233. * @returns a new Mesh
  28234. */
  28235. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28236. /**
  28237. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28238. * @param name defines the name of the mesh to create
  28239. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28240. * @param scene defines the hosting scene
  28241. * @param updatable defines if the mesh must be flagged as updatable
  28242. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28243. * @returns a new Mesh
  28244. */
  28245. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28246. /**
  28247. * Creates a ground mesh.
  28248. * Please consider using the same method from the MeshBuilder class instead
  28249. * @param name defines the name of the mesh to create
  28250. * @param width set the width of the ground
  28251. * @param height set the height of the ground
  28252. * @param subdivisions sets the number of subdivisions per side
  28253. * @param scene defines the hosting scene
  28254. * @param updatable defines if the mesh must be flagged as updatable
  28255. * @returns a new Mesh
  28256. */
  28257. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28258. /**
  28259. * Creates a tiled ground mesh.
  28260. * Please consider using the same method from the MeshBuilder class instead
  28261. * @param name defines the name of the mesh to create
  28262. * @param xmin set the ground minimum X coordinate
  28263. * @param zmin set the ground minimum Y coordinate
  28264. * @param xmax set the ground maximum X coordinate
  28265. * @param zmax set the ground maximum Z coordinate
  28266. * @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
  28267. * @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
  28268. * @param scene defines the hosting scene
  28269. * @param updatable defines if the mesh must be flagged as updatable
  28270. * @returns a new Mesh
  28271. */
  28272. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28273. w: number;
  28274. h: number;
  28275. }, precision: {
  28276. w: number;
  28277. h: number;
  28278. }, scene: Scene, updatable?: boolean): Mesh;
  28279. /**
  28280. * Creates a ground mesh from a height map.
  28281. * Please consider using the same method from the MeshBuilder class instead
  28282. * @see http://doc.babylonjs.com/babylon101/height_map
  28283. * @param name defines the name of the mesh to create
  28284. * @param url sets the URL of the height map image resource
  28285. * @param width set the ground width size
  28286. * @param height set the ground height size
  28287. * @param subdivisions sets the number of subdivision per side
  28288. * @param minHeight is the minimum altitude on the ground
  28289. * @param maxHeight is the maximum altitude on the ground
  28290. * @param scene defines the hosting scene
  28291. * @param updatable defines if the mesh must be flagged as updatable
  28292. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28293. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28294. * @returns a new Mesh
  28295. */
  28296. 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;
  28297. /**
  28298. * Creates a tube mesh.
  28299. * The tube is a parametric shape.
  28300. * It has no predefined shape. Its final shape will depend on the input parameters.
  28301. * Please consider using the same method from the MeshBuilder class instead
  28302. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  28303. * @param name defines the name of the mesh to create
  28304. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28305. * @param radius sets the tube radius size
  28306. * @param tessellation is the number of sides on the tubular surface
  28307. * @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
  28308. * @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
  28309. * @param scene defines the hosting scene
  28310. * @param updatable defines if the mesh must be flagged as updatable
  28311. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28312. * @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)
  28313. * @returns a new Mesh
  28314. */
  28315. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28316. (i: number, distance: number): number;
  28317. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28318. /**
  28319. * Creates a polyhedron mesh.
  28320. * Please consider using the same method from the MeshBuilder class instead.
  28321. * * 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
  28322. * * The parameter `size` (positive float, default 1) sets the polygon size
  28323. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28324. * * 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`
  28325. * * 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
  28326. * * 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)`)
  28327. * * 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
  28328. * * 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
  28329. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28330. * * 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
  28331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28332. * @param name defines the name of the mesh to create
  28333. * @param options defines the options used to create the mesh
  28334. * @param scene defines the hosting scene
  28335. * @returns a new Mesh
  28336. */
  28337. static CreatePolyhedron(name: string, options: {
  28338. type?: number;
  28339. size?: number;
  28340. sizeX?: number;
  28341. sizeY?: number;
  28342. sizeZ?: number;
  28343. custom?: any;
  28344. faceUV?: Vector4[];
  28345. faceColors?: Color4[];
  28346. updatable?: boolean;
  28347. sideOrientation?: number;
  28348. }, scene: Scene): Mesh;
  28349. /**
  28350. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28351. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28352. * * 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`)
  28353. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28354. * * 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
  28355. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28356. * * 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
  28357. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28358. * @param name defines the name of the mesh
  28359. * @param options defines the options used to create the mesh
  28360. * @param scene defines the hosting scene
  28361. * @returns a new Mesh
  28362. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28363. */
  28364. static CreateIcoSphere(name: string, options: {
  28365. radius?: number;
  28366. flat?: boolean;
  28367. subdivisions?: number;
  28368. sideOrientation?: number;
  28369. updatable?: boolean;
  28370. }, scene: Scene): Mesh;
  28371. /**
  28372. * Creates a decal mesh.
  28373. * Please consider using the same method from the MeshBuilder class instead.
  28374. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28375. * @param name defines the name of the mesh
  28376. * @param sourceMesh defines the mesh receiving the decal
  28377. * @param position sets the position of the decal in world coordinates
  28378. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28379. * @param size sets the decal scaling
  28380. * @param angle sets the angle to rotate the decal
  28381. * @returns a new Mesh
  28382. */
  28383. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28384. /**
  28385. * Prepare internal position array for software CPU skinning
  28386. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28387. */
  28388. setPositionsForCPUSkinning(): Float32Array;
  28389. /**
  28390. * Prepare internal normal array for software CPU skinning
  28391. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28392. */
  28393. setNormalsForCPUSkinning(): Float32Array;
  28394. /**
  28395. * Updates the vertex buffer by applying transformation from the bones
  28396. * @param skeleton defines the skeleton to apply to current mesh
  28397. * @returns the current mesh
  28398. */
  28399. applySkeleton(skeleton: Skeleton): Mesh;
  28400. /**
  28401. * 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
  28402. * @param meshes defines the list of meshes to scan
  28403. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28404. */
  28405. static MinMax(meshes: AbstractMesh[]): {
  28406. min: Vector3;
  28407. max: Vector3;
  28408. };
  28409. /**
  28410. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28411. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28412. * @returns a vector3
  28413. */
  28414. static Center(meshesOrMinMaxVector: {
  28415. min: Vector3;
  28416. max: Vector3;
  28417. } | AbstractMesh[]): Vector3;
  28418. /**
  28419. * Merge the array of meshes into a single mesh for performance reasons.
  28420. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28421. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28422. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28423. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28424. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28425. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28426. * @returns a new mesh
  28427. */
  28428. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28429. /** @hidden */
  28430. addInstance(instance: InstancedMesh): void;
  28431. /** @hidden */
  28432. removeInstance(instance: InstancedMesh): void;
  28433. }
  28434. }
  28435. declare module BABYLON {
  28436. /**
  28437. * This is the base class of all the camera used in the application.
  28438. * @see http://doc.babylonjs.com/features/cameras
  28439. */
  28440. export class Camera extends Node {
  28441. /** @hidden */
  28442. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28443. /**
  28444. * This is the default projection mode used by the cameras.
  28445. * It helps recreating a feeling of perspective and better appreciate depth.
  28446. * This is the best way to simulate real life cameras.
  28447. */
  28448. static readonly PERSPECTIVE_CAMERA: number;
  28449. /**
  28450. * This helps creating camera with an orthographic mode.
  28451. * 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.
  28452. */
  28453. static readonly ORTHOGRAPHIC_CAMERA: number;
  28454. /**
  28455. * This is the default FOV mode for perspective cameras.
  28456. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28457. */
  28458. static readonly FOVMODE_VERTICAL_FIXED: number;
  28459. /**
  28460. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28461. */
  28462. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28463. /**
  28464. * This specifies ther is no need for a camera rig.
  28465. * Basically only one eye is rendered corresponding to the camera.
  28466. */
  28467. static readonly RIG_MODE_NONE: number;
  28468. /**
  28469. * Simulates a camera Rig with one blue eye and one red eye.
  28470. * This can be use with 3d blue and red glasses.
  28471. */
  28472. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28473. /**
  28474. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28475. */
  28476. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28477. /**
  28478. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28479. */
  28480. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28481. /**
  28482. * Defines that both eyes of the camera will be rendered over under each other.
  28483. */
  28484. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28485. /**
  28486. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28487. */
  28488. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28489. /**
  28490. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28491. */
  28492. static readonly RIG_MODE_VR: number;
  28493. /**
  28494. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28495. */
  28496. static readonly RIG_MODE_WEBVR: number;
  28497. /**
  28498. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28499. */
  28500. static readonly RIG_MODE_CUSTOM: number;
  28501. /**
  28502. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28503. */
  28504. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28505. /**
  28506. * Define the input manager associated with the camera.
  28507. */
  28508. inputs: CameraInputsManager<Camera>;
  28509. /** @hidden */
  28510. _position: Vector3;
  28511. /**
  28512. * Define the current local position of the camera in the scene
  28513. */
  28514. get position(): Vector3;
  28515. set position(newPosition: Vector3);
  28516. /**
  28517. * The vector the camera should consider as up.
  28518. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28519. */
  28520. upVector: Vector3;
  28521. /**
  28522. * Define the current limit on the left side for an orthographic camera
  28523. * In scene unit
  28524. */
  28525. orthoLeft: Nullable<number>;
  28526. /**
  28527. * Define the current limit on the right side for an orthographic camera
  28528. * In scene unit
  28529. */
  28530. orthoRight: Nullable<number>;
  28531. /**
  28532. * Define the current limit on the bottom side for an orthographic camera
  28533. * In scene unit
  28534. */
  28535. orthoBottom: Nullable<number>;
  28536. /**
  28537. * Define the current limit on the top side for an orthographic camera
  28538. * In scene unit
  28539. */
  28540. orthoTop: Nullable<number>;
  28541. /**
  28542. * Field Of View is set in Radians. (default is 0.8)
  28543. */
  28544. fov: number;
  28545. /**
  28546. * Define the minimum distance the camera can see from.
  28547. * This is important to note that the depth buffer are not infinite and the closer it starts
  28548. * the more your scene might encounter depth fighting issue.
  28549. */
  28550. minZ: number;
  28551. /**
  28552. * Define the maximum distance the camera can see to.
  28553. * This is important to note that the depth buffer are not infinite and the further it end
  28554. * the more your scene might encounter depth fighting issue.
  28555. */
  28556. maxZ: number;
  28557. /**
  28558. * Define the default inertia of the camera.
  28559. * This helps giving a smooth feeling to the camera movement.
  28560. */
  28561. inertia: number;
  28562. /**
  28563. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28564. */
  28565. mode: number;
  28566. /**
  28567. * Define whether the camera is intermediate.
  28568. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28569. */
  28570. isIntermediate: boolean;
  28571. /**
  28572. * Define the viewport of the camera.
  28573. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28574. */
  28575. viewport: Viewport;
  28576. /**
  28577. * Restricts the camera to viewing objects with the same layerMask.
  28578. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28579. */
  28580. layerMask: number;
  28581. /**
  28582. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28583. */
  28584. fovMode: number;
  28585. /**
  28586. * Rig mode of the camera.
  28587. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28588. * This is normally controlled byt the camera themselves as internal use.
  28589. */
  28590. cameraRigMode: number;
  28591. /**
  28592. * Defines the distance between both "eyes" in case of a RIG
  28593. */
  28594. interaxialDistance: number;
  28595. /**
  28596. * Defines if stereoscopic rendering is done side by side or over under.
  28597. */
  28598. isStereoscopicSideBySide: boolean;
  28599. /**
  28600. * 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
  28601. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28602. * else in the scene. (Eg. security camera)
  28603. *
  28604. * 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)
  28605. */
  28606. customRenderTargets: RenderTargetTexture[];
  28607. /**
  28608. * When set, the camera will render to this render target instead of the default canvas
  28609. *
  28610. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28611. */
  28612. outputRenderTarget: Nullable<RenderTargetTexture>;
  28613. /**
  28614. * Observable triggered when the camera view matrix has changed.
  28615. */
  28616. onViewMatrixChangedObservable: Observable<Camera>;
  28617. /**
  28618. * Observable triggered when the camera Projection matrix has changed.
  28619. */
  28620. onProjectionMatrixChangedObservable: Observable<Camera>;
  28621. /**
  28622. * Observable triggered when the inputs have been processed.
  28623. */
  28624. onAfterCheckInputsObservable: Observable<Camera>;
  28625. /**
  28626. * Observable triggered when reset has been called and applied to the camera.
  28627. */
  28628. onRestoreStateObservable: Observable<Camera>;
  28629. /**
  28630. * Is this camera a part of a rig system?
  28631. */
  28632. isRigCamera: boolean;
  28633. /**
  28634. * If isRigCamera set to true this will be set with the parent camera.
  28635. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28636. */
  28637. rigParent?: Camera;
  28638. /** @hidden */
  28639. _cameraRigParams: any;
  28640. /** @hidden */
  28641. _rigCameras: Camera[];
  28642. /** @hidden */
  28643. _rigPostProcess: Nullable<PostProcess>;
  28644. protected _webvrViewMatrix: Matrix;
  28645. /** @hidden */
  28646. _skipRendering: boolean;
  28647. /** @hidden */
  28648. _projectionMatrix: Matrix;
  28649. /** @hidden */
  28650. _postProcesses: Nullable<PostProcess>[];
  28651. /** @hidden */
  28652. _activeMeshes: SmartArray<AbstractMesh>;
  28653. protected _globalPosition: Vector3;
  28654. /** @hidden */
  28655. _computedViewMatrix: Matrix;
  28656. private _doNotComputeProjectionMatrix;
  28657. private _transformMatrix;
  28658. private _frustumPlanes;
  28659. private _refreshFrustumPlanes;
  28660. private _storedFov;
  28661. private _stateStored;
  28662. /**
  28663. * Instantiates a new camera object.
  28664. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28665. * @see http://doc.babylonjs.com/features/cameras
  28666. * @param name Defines the name of the camera in the scene
  28667. * @param position Defines the position of the camera
  28668. * @param scene Defines the scene the camera belongs too
  28669. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28670. */
  28671. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28672. /**
  28673. * Store current camera state (fov, position, etc..)
  28674. * @returns the camera
  28675. */
  28676. storeState(): Camera;
  28677. /**
  28678. * Restores the camera state values if it has been stored. You must call storeState() first
  28679. */
  28680. protected _restoreStateValues(): boolean;
  28681. /**
  28682. * Restored camera state. You must call storeState() first.
  28683. * @returns true if restored and false otherwise
  28684. */
  28685. restoreState(): boolean;
  28686. /**
  28687. * Gets the class name of the camera.
  28688. * @returns the class name
  28689. */
  28690. getClassName(): string;
  28691. /** @hidden */
  28692. readonly _isCamera: boolean;
  28693. /**
  28694. * Gets a string representation of the camera useful for debug purpose.
  28695. * @param fullDetails Defines that a more verboe level of logging is required
  28696. * @returns the string representation
  28697. */
  28698. toString(fullDetails?: boolean): string;
  28699. /**
  28700. * Gets the current world space position of the camera.
  28701. */
  28702. get globalPosition(): Vector3;
  28703. /**
  28704. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28705. * @returns the active meshe list
  28706. */
  28707. getActiveMeshes(): SmartArray<AbstractMesh>;
  28708. /**
  28709. * Check whether a mesh is part of the current active mesh list of the camera
  28710. * @param mesh Defines the mesh to check
  28711. * @returns true if active, false otherwise
  28712. */
  28713. isActiveMesh(mesh: Mesh): boolean;
  28714. /**
  28715. * Is this camera ready to be used/rendered
  28716. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28717. * @return true if the camera is ready
  28718. */
  28719. isReady(completeCheck?: boolean): boolean;
  28720. /** @hidden */
  28721. _initCache(): void;
  28722. /** @hidden */
  28723. _updateCache(ignoreParentClass?: boolean): void;
  28724. /** @hidden */
  28725. _isSynchronized(): boolean;
  28726. /** @hidden */
  28727. _isSynchronizedViewMatrix(): boolean;
  28728. /** @hidden */
  28729. _isSynchronizedProjectionMatrix(): boolean;
  28730. /**
  28731. * Attach the input controls to a specific dom element to get the input from.
  28732. * @param element Defines the element the controls should be listened from
  28733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28734. */
  28735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28736. /**
  28737. * Detach the current controls from the specified dom element.
  28738. * @param element Defines the element to stop listening the inputs from
  28739. */
  28740. detachControl(element: HTMLElement): void;
  28741. /**
  28742. * Update the camera state according to the different inputs gathered during the frame.
  28743. */
  28744. update(): void;
  28745. /** @hidden */
  28746. _checkInputs(): void;
  28747. /** @hidden */
  28748. get rigCameras(): Camera[];
  28749. /**
  28750. * Gets the post process used by the rig cameras
  28751. */
  28752. get rigPostProcess(): Nullable<PostProcess>;
  28753. /**
  28754. * Internal, gets the first post proces.
  28755. * @returns the first post process to be run on this camera.
  28756. */
  28757. _getFirstPostProcess(): Nullable<PostProcess>;
  28758. private _cascadePostProcessesToRigCams;
  28759. /**
  28760. * Attach a post process to the camera.
  28761. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28762. * @param postProcess The post process to attach to the camera
  28763. * @param insertAt The position of the post process in case several of them are in use in the scene
  28764. * @returns the position the post process has been inserted at
  28765. */
  28766. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28767. /**
  28768. * Detach a post process to the camera.
  28769. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28770. * @param postProcess The post process to detach from the camera
  28771. */
  28772. detachPostProcess(postProcess: PostProcess): void;
  28773. /**
  28774. * Gets the current world matrix of the camera
  28775. */
  28776. getWorldMatrix(): Matrix;
  28777. /** @hidden */
  28778. _getViewMatrix(): Matrix;
  28779. /**
  28780. * Gets the current view matrix of the camera.
  28781. * @param force forces the camera to recompute the matrix without looking at the cached state
  28782. * @returns the view matrix
  28783. */
  28784. getViewMatrix(force?: boolean): Matrix;
  28785. /**
  28786. * Freeze the projection matrix.
  28787. * It will prevent the cache check of the camera projection compute and can speed up perf
  28788. * if no parameter of the camera are meant to change
  28789. * @param projection Defines manually a projection if necessary
  28790. */
  28791. freezeProjectionMatrix(projection?: Matrix): void;
  28792. /**
  28793. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28794. */
  28795. unfreezeProjectionMatrix(): void;
  28796. /**
  28797. * Gets the current projection matrix of the camera.
  28798. * @param force forces the camera to recompute the matrix without looking at the cached state
  28799. * @returns the projection matrix
  28800. */
  28801. getProjectionMatrix(force?: boolean): Matrix;
  28802. /**
  28803. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28804. * @returns a Matrix
  28805. */
  28806. getTransformationMatrix(): Matrix;
  28807. private _updateFrustumPlanes;
  28808. /**
  28809. * Checks if a cullable object (mesh...) is in the camera frustum
  28810. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28811. * @param target The object to check
  28812. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28813. * @returns true if the object is in frustum otherwise false
  28814. */
  28815. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28816. /**
  28817. * Checks if a cullable object (mesh...) is in the camera frustum
  28818. * Unlike isInFrustum this cheks the full bounding box
  28819. * @param target The object to check
  28820. * @returns true if the object is in frustum otherwise false
  28821. */
  28822. isCompletelyInFrustum(target: ICullable): boolean;
  28823. /**
  28824. * Gets a ray in the forward direction from the camera.
  28825. * @param length Defines the length of the ray to create
  28826. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28827. * @param origin Defines the start point of the ray which defaults to the camera position
  28828. * @returns the forward ray
  28829. */
  28830. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28831. /**
  28832. * Releases resources associated with this node.
  28833. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28834. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28835. */
  28836. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28837. /** @hidden */
  28838. _isLeftCamera: boolean;
  28839. /**
  28840. * Gets the left camera of a rig setup in case of Rigged Camera
  28841. */
  28842. get isLeftCamera(): boolean;
  28843. /** @hidden */
  28844. _isRightCamera: boolean;
  28845. /**
  28846. * Gets the right camera of a rig setup in case of Rigged Camera
  28847. */
  28848. get isRightCamera(): boolean;
  28849. /**
  28850. * Gets the left camera of a rig setup in case of Rigged Camera
  28851. */
  28852. get leftCamera(): Nullable<FreeCamera>;
  28853. /**
  28854. * Gets the right camera of a rig setup in case of Rigged Camera
  28855. */
  28856. get rightCamera(): Nullable<FreeCamera>;
  28857. /**
  28858. * Gets the left camera target of a rig setup in case of Rigged Camera
  28859. * @returns the target position
  28860. */
  28861. getLeftTarget(): Nullable<Vector3>;
  28862. /**
  28863. * Gets the right camera target of a rig setup in case of Rigged Camera
  28864. * @returns the target position
  28865. */
  28866. getRightTarget(): Nullable<Vector3>;
  28867. /**
  28868. * @hidden
  28869. */
  28870. setCameraRigMode(mode: number, rigParams: any): void;
  28871. /** @hidden */
  28872. static _setStereoscopicRigMode(camera: Camera): void;
  28873. /** @hidden */
  28874. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28875. /** @hidden */
  28876. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28877. /** @hidden */
  28878. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28879. /** @hidden */
  28880. _getVRProjectionMatrix(): Matrix;
  28881. protected _updateCameraRotationMatrix(): void;
  28882. protected _updateWebVRCameraRotationMatrix(): void;
  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. _getWebVRProjectionMatrix(): Matrix;
  28889. /**
  28890. * This function MUST be overwritten by the different WebVR cameras available.
  28891. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28892. * @hidden
  28893. */
  28894. _getWebVRViewMatrix(): Matrix;
  28895. /** @hidden */
  28896. setCameraRigParameter(name: string, value: any): void;
  28897. /**
  28898. * needs to be overridden by children so sub has required properties to be copied
  28899. * @hidden
  28900. */
  28901. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28902. /**
  28903. * May need to be overridden by children
  28904. * @hidden
  28905. */
  28906. _updateRigCameras(): void;
  28907. /** @hidden */
  28908. _setupInputs(): void;
  28909. /**
  28910. * Serialiaze the camera setup to a json represention
  28911. * @returns the JSON representation
  28912. */
  28913. serialize(): any;
  28914. /**
  28915. * Clones the current camera.
  28916. * @param name The cloned camera name
  28917. * @returns the cloned camera
  28918. */
  28919. clone(name: string): Camera;
  28920. /**
  28921. * Gets the direction of the camera relative to a given local axis.
  28922. * @param localAxis Defines the reference axis to provide a relative direction.
  28923. * @return the direction
  28924. */
  28925. getDirection(localAxis: Vector3): Vector3;
  28926. /**
  28927. * Returns the current camera absolute rotation
  28928. */
  28929. get absoluteRotation(): Quaternion;
  28930. /**
  28931. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28932. * @param localAxis Defines the reference axis to provide a relative direction.
  28933. * @param result Defines the vector to store the result in
  28934. */
  28935. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28936. /**
  28937. * Gets a camera constructor for a given camera type
  28938. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28939. * @param name The name of the camera the result will be able to instantiate
  28940. * @param scene The scene the result will construct the camera in
  28941. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28942. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28943. * @returns a factory method to construc the camera
  28944. */
  28945. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28946. /**
  28947. * Compute the world matrix of the camera.
  28948. * @returns the camera world matrix
  28949. */
  28950. computeWorldMatrix(): Matrix;
  28951. /**
  28952. * Parse a JSON and creates the camera from the parsed information
  28953. * @param parsedCamera The JSON to parse
  28954. * @param scene The scene to instantiate the camera in
  28955. * @returns the newly constructed camera
  28956. */
  28957. static Parse(parsedCamera: any, scene: Scene): Camera;
  28958. }
  28959. }
  28960. declare module BABYLON {
  28961. /**
  28962. * Class containing static functions to help procedurally build meshes
  28963. */
  28964. export class DiscBuilder {
  28965. /**
  28966. * Creates a plane polygonal mesh. By default, this is a disc
  28967. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28968. * * 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
  28969. * * 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
  28970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28971. * * 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
  28972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28973. * @param name defines the name of the mesh
  28974. * @param options defines the options used to create the mesh
  28975. * @param scene defines the hosting scene
  28976. * @returns the plane polygonal mesh
  28977. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28978. */
  28979. static CreateDisc(name: string, options: {
  28980. radius?: number;
  28981. tessellation?: number;
  28982. arc?: number;
  28983. updatable?: boolean;
  28984. sideOrientation?: number;
  28985. frontUVs?: Vector4;
  28986. backUVs?: Vector4;
  28987. }, scene?: Nullable<Scene>): Mesh;
  28988. }
  28989. }
  28990. declare module BABYLON {
  28991. /**
  28992. * Options to be used when creating a FresnelParameters.
  28993. */
  28994. export type IFresnelParametersCreationOptions = {
  28995. /**
  28996. * Define the color used on edges (grazing angle)
  28997. */
  28998. leftColor?: Color3;
  28999. /**
  29000. * Define the color used on center
  29001. */
  29002. rightColor?: Color3;
  29003. /**
  29004. * Define bias applied to computed fresnel term
  29005. */
  29006. bias?: number;
  29007. /**
  29008. * Defined the power exponent applied to fresnel term
  29009. */
  29010. power?: number;
  29011. /**
  29012. * Define if the fresnel effect is enable or not.
  29013. */
  29014. isEnabled?: boolean;
  29015. };
  29016. /**
  29017. * Serialized format for FresnelParameters.
  29018. */
  29019. export type IFresnelParametersSerialized = {
  29020. /**
  29021. * Define the color used on edges (grazing angle) [as an array]
  29022. */
  29023. leftColor: number[];
  29024. /**
  29025. * Define the color used on center [as an array]
  29026. */
  29027. rightColor: number[];
  29028. /**
  29029. * Define bias applied to computed fresnel term
  29030. */
  29031. bias: number;
  29032. /**
  29033. * Defined the power exponent applied to fresnel term
  29034. */
  29035. power?: number;
  29036. /**
  29037. * Define if the fresnel effect is enable or not.
  29038. */
  29039. isEnabled: boolean;
  29040. };
  29041. /**
  29042. * This represents all the required information to add a fresnel effect on a material:
  29043. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29044. */
  29045. export class FresnelParameters {
  29046. private _isEnabled;
  29047. /**
  29048. * Define if the fresnel effect is enable or not.
  29049. */
  29050. get isEnabled(): boolean;
  29051. set isEnabled(value: boolean);
  29052. /**
  29053. * Define the color used on edges (grazing angle)
  29054. */
  29055. leftColor: Color3;
  29056. /**
  29057. * Define the color used on center
  29058. */
  29059. rightColor: Color3;
  29060. /**
  29061. * Define bias applied to computed fresnel term
  29062. */
  29063. bias: number;
  29064. /**
  29065. * Defined the power exponent applied to fresnel term
  29066. */
  29067. power: number;
  29068. /**
  29069. * Creates a new FresnelParameters object.
  29070. *
  29071. * @param options provide your own settings to optionally to override defaults
  29072. */
  29073. constructor(options?: IFresnelParametersCreationOptions);
  29074. /**
  29075. * Clones the current fresnel and its valuues
  29076. * @returns a clone fresnel configuration
  29077. */
  29078. clone(): FresnelParameters;
  29079. /**
  29080. * Determines equality between FresnelParameters objects
  29081. * @param otherFresnelParameters defines the second operand
  29082. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29083. */
  29084. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29085. /**
  29086. * Serializes the current fresnel parameters to a JSON representation.
  29087. * @return the JSON serialization
  29088. */
  29089. serialize(): IFresnelParametersSerialized;
  29090. /**
  29091. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29092. * @param parsedFresnelParameters Define the JSON representation
  29093. * @returns the parsed parameters
  29094. */
  29095. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29096. }
  29097. }
  29098. declare module BABYLON {
  29099. /**
  29100. * This groups all the flags used to control the materials channel.
  29101. */
  29102. export class MaterialFlags {
  29103. private static _DiffuseTextureEnabled;
  29104. /**
  29105. * Are diffuse textures enabled in the application.
  29106. */
  29107. static get DiffuseTextureEnabled(): boolean;
  29108. static set DiffuseTextureEnabled(value: boolean);
  29109. private static _DetailTextureEnabled;
  29110. /**
  29111. * Are detail textures enabled in the application.
  29112. */
  29113. static get DetailTextureEnabled(): boolean;
  29114. static set DetailTextureEnabled(value: boolean);
  29115. private static _AmbientTextureEnabled;
  29116. /**
  29117. * Are ambient textures enabled in the application.
  29118. */
  29119. static get AmbientTextureEnabled(): boolean;
  29120. static set AmbientTextureEnabled(value: boolean);
  29121. private static _OpacityTextureEnabled;
  29122. /**
  29123. * Are opacity textures enabled in the application.
  29124. */
  29125. static get OpacityTextureEnabled(): boolean;
  29126. static set OpacityTextureEnabled(value: boolean);
  29127. private static _ReflectionTextureEnabled;
  29128. /**
  29129. * Are reflection textures enabled in the application.
  29130. */
  29131. static get ReflectionTextureEnabled(): boolean;
  29132. static set ReflectionTextureEnabled(value: boolean);
  29133. private static _EmissiveTextureEnabled;
  29134. /**
  29135. * Are emissive textures enabled in the application.
  29136. */
  29137. static get EmissiveTextureEnabled(): boolean;
  29138. static set EmissiveTextureEnabled(value: boolean);
  29139. private static _SpecularTextureEnabled;
  29140. /**
  29141. * Are specular textures enabled in the application.
  29142. */
  29143. static get SpecularTextureEnabled(): boolean;
  29144. static set SpecularTextureEnabled(value: boolean);
  29145. private static _BumpTextureEnabled;
  29146. /**
  29147. * Are bump textures enabled in the application.
  29148. */
  29149. static get BumpTextureEnabled(): boolean;
  29150. static set BumpTextureEnabled(value: boolean);
  29151. private static _LightmapTextureEnabled;
  29152. /**
  29153. * Are lightmap textures enabled in the application.
  29154. */
  29155. static get LightmapTextureEnabled(): boolean;
  29156. static set LightmapTextureEnabled(value: boolean);
  29157. private static _RefractionTextureEnabled;
  29158. /**
  29159. * Are refraction textures enabled in the application.
  29160. */
  29161. static get RefractionTextureEnabled(): boolean;
  29162. static set RefractionTextureEnabled(value: boolean);
  29163. private static _ColorGradingTextureEnabled;
  29164. /**
  29165. * Are color grading textures enabled in the application.
  29166. */
  29167. static get ColorGradingTextureEnabled(): boolean;
  29168. static set ColorGradingTextureEnabled(value: boolean);
  29169. private static _FresnelEnabled;
  29170. /**
  29171. * Are fresnels enabled in the application.
  29172. */
  29173. static get FresnelEnabled(): boolean;
  29174. static set FresnelEnabled(value: boolean);
  29175. private static _ClearCoatTextureEnabled;
  29176. /**
  29177. * Are clear coat textures enabled in the application.
  29178. */
  29179. static get ClearCoatTextureEnabled(): boolean;
  29180. static set ClearCoatTextureEnabled(value: boolean);
  29181. private static _ClearCoatBumpTextureEnabled;
  29182. /**
  29183. * Are clear coat bump textures enabled in the application.
  29184. */
  29185. static get ClearCoatBumpTextureEnabled(): boolean;
  29186. static set ClearCoatBumpTextureEnabled(value: boolean);
  29187. private static _ClearCoatTintTextureEnabled;
  29188. /**
  29189. * Are clear coat tint textures enabled in the application.
  29190. */
  29191. static get ClearCoatTintTextureEnabled(): boolean;
  29192. static set ClearCoatTintTextureEnabled(value: boolean);
  29193. private static _SheenTextureEnabled;
  29194. /**
  29195. * Are sheen textures enabled in the application.
  29196. */
  29197. static get SheenTextureEnabled(): boolean;
  29198. static set SheenTextureEnabled(value: boolean);
  29199. private static _AnisotropicTextureEnabled;
  29200. /**
  29201. * Are anisotropic textures enabled in the application.
  29202. */
  29203. static get AnisotropicTextureEnabled(): boolean;
  29204. static set AnisotropicTextureEnabled(value: boolean);
  29205. private static _ThicknessTextureEnabled;
  29206. /**
  29207. * Are thickness textures enabled in the application.
  29208. */
  29209. static get ThicknessTextureEnabled(): boolean;
  29210. static set ThicknessTextureEnabled(value: boolean);
  29211. }
  29212. }
  29213. declare module BABYLON {
  29214. /** @hidden */
  29215. export var defaultFragmentDeclaration: {
  29216. name: string;
  29217. shader: string;
  29218. };
  29219. }
  29220. declare module BABYLON {
  29221. /** @hidden */
  29222. export var defaultUboDeclaration: {
  29223. name: string;
  29224. shader: string;
  29225. };
  29226. }
  29227. declare module BABYLON {
  29228. /** @hidden */
  29229. export var lightFragmentDeclaration: {
  29230. name: string;
  29231. shader: string;
  29232. };
  29233. }
  29234. declare module BABYLON {
  29235. /** @hidden */
  29236. export var lightUboDeclaration: {
  29237. name: string;
  29238. shader: string;
  29239. };
  29240. }
  29241. declare module BABYLON {
  29242. /** @hidden */
  29243. export var lightsFragmentFunctions: {
  29244. name: string;
  29245. shader: string;
  29246. };
  29247. }
  29248. declare module BABYLON {
  29249. /** @hidden */
  29250. export var shadowsFragmentFunctions: {
  29251. name: string;
  29252. shader: string;
  29253. };
  29254. }
  29255. declare module BABYLON {
  29256. /** @hidden */
  29257. export var fresnelFunction: {
  29258. name: string;
  29259. shader: string;
  29260. };
  29261. }
  29262. declare module BABYLON {
  29263. /** @hidden */
  29264. export var bumpFragmentMainFunctions: {
  29265. name: string;
  29266. shader: string;
  29267. };
  29268. }
  29269. declare module BABYLON {
  29270. /** @hidden */
  29271. export var bumpFragmentFunctions: {
  29272. name: string;
  29273. shader: string;
  29274. };
  29275. }
  29276. declare module BABYLON {
  29277. /** @hidden */
  29278. export var logDepthDeclaration: {
  29279. name: string;
  29280. shader: string;
  29281. };
  29282. }
  29283. declare module BABYLON {
  29284. /** @hidden */
  29285. export var bumpFragment: {
  29286. name: string;
  29287. shader: string;
  29288. };
  29289. }
  29290. declare module BABYLON {
  29291. /** @hidden */
  29292. export var depthPrePass: {
  29293. name: string;
  29294. shader: string;
  29295. };
  29296. }
  29297. declare module BABYLON {
  29298. /** @hidden */
  29299. export var lightFragment: {
  29300. name: string;
  29301. shader: string;
  29302. };
  29303. }
  29304. declare module BABYLON {
  29305. /** @hidden */
  29306. export var logDepthFragment: {
  29307. name: string;
  29308. shader: string;
  29309. };
  29310. }
  29311. declare module BABYLON {
  29312. /** @hidden */
  29313. export var defaultPixelShader: {
  29314. name: string;
  29315. shader: string;
  29316. };
  29317. }
  29318. declare module BABYLON {
  29319. /** @hidden */
  29320. export var defaultVertexDeclaration: {
  29321. name: string;
  29322. shader: string;
  29323. };
  29324. }
  29325. declare module BABYLON {
  29326. /** @hidden */
  29327. export var bumpVertexDeclaration: {
  29328. name: string;
  29329. shader: string;
  29330. };
  29331. }
  29332. declare module BABYLON {
  29333. /** @hidden */
  29334. export var bumpVertex: {
  29335. name: string;
  29336. shader: string;
  29337. };
  29338. }
  29339. declare module BABYLON {
  29340. /** @hidden */
  29341. export var fogVertex: {
  29342. name: string;
  29343. shader: string;
  29344. };
  29345. }
  29346. declare module BABYLON {
  29347. /** @hidden */
  29348. export var shadowsVertex: {
  29349. name: string;
  29350. shader: string;
  29351. };
  29352. }
  29353. declare module BABYLON {
  29354. /** @hidden */
  29355. export var pointCloudVertex: {
  29356. name: string;
  29357. shader: string;
  29358. };
  29359. }
  29360. declare module BABYLON {
  29361. /** @hidden */
  29362. export var logDepthVertex: {
  29363. name: string;
  29364. shader: string;
  29365. };
  29366. }
  29367. declare module BABYLON {
  29368. /** @hidden */
  29369. export var defaultVertexShader: {
  29370. name: string;
  29371. shader: string;
  29372. };
  29373. }
  29374. declare module BABYLON {
  29375. /**
  29376. * @hidden
  29377. */
  29378. export interface IMaterialDetailMapDefines {
  29379. DETAIL: boolean;
  29380. DETAILDIRECTUV: number;
  29381. DETAIL_NORMALBLENDMETHOD: number;
  29382. /** @hidden */
  29383. _areTexturesDirty: boolean;
  29384. }
  29385. /**
  29386. * Define the code related to the detail map parameters of a material
  29387. *
  29388. * Inspired from:
  29389. * 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
  29390. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  29391. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  29392. */
  29393. export class DetailMapConfiguration {
  29394. private _texture;
  29395. /**
  29396. * The detail texture of the material.
  29397. */
  29398. texture: Nullable<BaseTexture>;
  29399. /**
  29400. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  29401. * Bigger values mean stronger blending
  29402. */
  29403. diffuseBlendLevel: number;
  29404. /**
  29405. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  29406. * Bigger values mean stronger blending. Only used with PBR materials
  29407. */
  29408. roughnessBlendLevel: number;
  29409. /**
  29410. * Defines how strong the bump effect from the detail map is
  29411. * Bigger values mean stronger effect
  29412. */
  29413. bumpLevel: number;
  29414. private _normalBlendMethod;
  29415. /**
  29416. * The method used to blend the bump and detail normals together
  29417. */
  29418. normalBlendMethod: number;
  29419. private _isEnabled;
  29420. /**
  29421. * Enable or disable the detail map on this material
  29422. */
  29423. isEnabled: boolean;
  29424. /** @hidden */
  29425. private _internalMarkAllSubMeshesAsTexturesDirty;
  29426. /** @hidden */
  29427. _markAllSubMeshesAsTexturesDirty(): void;
  29428. /**
  29429. * Instantiate a new detail map
  29430. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  29431. */
  29432. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  29433. /**
  29434. * Gets whether the submesh is ready to be used or not.
  29435. * @param defines the list of "defines" to update.
  29436. * @param scene defines the scene the material belongs to.
  29437. * @returns - boolean indicating that the submesh is ready or not.
  29438. */
  29439. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  29440. /**
  29441. * Update the defines for detail map usage
  29442. * @param defines the list of "defines" to update.
  29443. * @param scene defines the scene the material belongs to.
  29444. */
  29445. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  29446. /**
  29447. * Binds the material data.
  29448. * @param uniformBuffer defines the Uniform buffer to fill in.
  29449. * @param scene defines the scene the material belongs to.
  29450. * @param isFrozen defines whether the material is frozen or not.
  29451. */
  29452. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  29453. /**
  29454. * Checks to see if a texture is used in the material.
  29455. * @param texture - Base texture to use.
  29456. * @returns - Boolean specifying if a texture is used in the material.
  29457. */
  29458. hasTexture(texture: BaseTexture): boolean;
  29459. /**
  29460. * Returns an array of the actively used textures.
  29461. * @param activeTextures Array of BaseTextures
  29462. */
  29463. getActiveTextures(activeTextures: BaseTexture[]): void;
  29464. /**
  29465. * Returns the animatable textures.
  29466. * @param animatables Array of animatable textures.
  29467. */
  29468. getAnimatables(animatables: IAnimatable[]): void;
  29469. /**
  29470. * Disposes the resources of the material.
  29471. * @param forceDisposeTextures - Forces the disposal of all textures.
  29472. */
  29473. dispose(forceDisposeTextures?: boolean): void;
  29474. /**
  29475. * Get the current class name useful for serialization or dynamic coding.
  29476. * @returns "DetailMap"
  29477. */
  29478. getClassName(): string;
  29479. /**
  29480. * Add the required uniforms to the current list.
  29481. * @param uniforms defines the current uniform list.
  29482. */
  29483. static AddUniforms(uniforms: string[]): void;
  29484. /**
  29485. * Add the required samplers to the current list.
  29486. * @param samplers defines the current sampler list.
  29487. */
  29488. static AddSamplers(samplers: string[]): void;
  29489. /**
  29490. * Add the required uniforms to the current buffer.
  29491. * @param uniformBuffer defines the current uniform buffer.
  29492. */
  29493. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  29494. /**
  29495. * Makes a duplicate of the current instance into another one.
  29496. * @param detailMap define the instance where to copy the info
  29497. */
  29498. copyTo(detailMap: DetailMapConfiguration): void;
  29499. /**
  29500. * Serializes this detail map instance
  29501. * @returns - An object with the serialized instance.
  29502. */
  29503. serialize(): any;
  29504. /**
  29505. * Parses a detail map setting from a serialized object.
  29506. * @param source - Serialized object.
  29507. * @param scene Defines the scene we are parsing for
  29508. * @param rootUrl Defines the rootUrl to load from
  29509. */
  29510. parse(source: any, scene: Scene, rootUrl: string): void;
  29511. }
  29512. }
  29513. declare module BABYLON {
  29514. /** @hidden */
  29515. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  29516. MAINUV1: boolean;
  29517. MAINUV2: boolean;
  29518. DIFFUSE: boolean;
  29519. DIFFUSEDIRECTUV: number;
  29520. DETAIL: boolean;
  29521. DETAILDIRECTUV: number;
  29522. DETAIL_NORMALBLENDMETHOD: number;
  29523. AMBIENT: boolean;
  29524. AMBIENTDIRECTUV: number;
  29525. OPACITY: boolean;
  29526. OPACITYDIRECTUV: number;
  29527. OPACITYRGB: boolean;
  29528. REFLECTION: boolean;
  29529. EMISSIVE: boolean;
  29530. EMISSIVEDIRECTUV: number;
  29531. SPECULAR: boolean;
  29532. SPECULARDIRECTUV: number;
  29533. BUMP: boolean;
  29534. BUMPDIRECTUV: number;
  29535. PARALLAX: boolean;
  29536. PARALLAXOCCLUSION: boolean;
  29537. SPECULAROVERALPHA: boolean;
  29538. CLIPPLANE: boolean;
  29539. CLIPPLANE2: boolean;
  29540. CLIPPLANE3: boolean;
  29541. CLIPPLANE4: boolean;
  29542. CLIPPLANE5: boolean;
  29543. CLIPPLANE6: boolean;
  29544. ALPHATEST: boolean;
  29545. DEPTHPREPASS: boolean;
  29546. ALPHAFROMDIFFUSE: boolean;
  29547. POINTSIZE: boolean;
  29548. FOG: boolean;
  29549. SPECULARTERM: boolean;
  29550. DIFFUSEFRESNEL: boolean;
  29551. OPACITYFRESNEL: boolean;
  29552. REFLECTIONFRESNEL: boolean;
  29553. REFRACTIONFRESNEL: boolean;
  29554. EMISSIVEFRESNEL: boolean;
  29555. FRESNEL: boolean;
  29556. NORMAL: boolean;
  29557. UV1: boolean;
  29558. UV2: boolean;
  29559. VERTEXCOLOR: boolean;
  29560. VERTEXALPHA: boolean;
  29561. NUM_BONE_INFLUENCERS: number;
  29562. BonesPerMesh: number;
  29563. BONETEXTURE: boolean;
  29564. INSTANCES: boolean;
  29565. THIN_INSTANCES: boolean;
  29566. GLOSSINESS: boolean;
  29567. ROUGHNESS: boolean;
  29568. EMISSIVEASILLUMINATION: boolean;
  29569. LINKEMISSIVEWITHDIFFUSE: boolean;
  29570. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29571. LIGHTMAP: boolean;
  29572. LIGHTMAPDIRECTUV: number;
  29573. OBJECTSPACE_NORMALMAP: boolean;
  29574. USELIGHTMAPASSHADOWMAP: boolean;
  29575. REFLECTIONMAP_3D: boolean;
  29576. REFLECTIONMAP_SPHERICAL: boolean;
  29577. REFLECTIONMAP_PLANAR: boolean;
  29578. REFLECTIONMAP_CUBIC: boolean;
  29579. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29580. REFLECTIONMAP_PROJECTION: boolean;
  29581. REFLECTIONMAP_SKYBOX: boolean;
  29582. REFLECTIONMAP_EXPLICIT: boolean;
  29583. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29584. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29585. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29586. INVERTCUBICMAP: boolean;
  29587. LOGARITHMICDEPTH: boolean;
  29588. REFRACTION: boolean;
  29589. REFRACTIONMAP_3D: boolean;
  29590. REFLECTIONOVERALPHA: boolean;
  29591. TWOSIDEDLIGHTING: boolean;
  29592. SHADOWFLOAT: boolean;
  29593. MORPHTARGETS: boolean;
  29594. MORPHTARGETS_NORMAL: boolean;
  29595. MORPHTARGETS_TANGENT: boolean;
  29596. MORPHTARGETS_UV: boolean;
  29597. NUM_MORPH_INFLUENCERS: number;
  29598. NONUNIFORMSCALING: boolean;
  29599. PREMULTIPLYALPHA: boolean;
  29600. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29601. ALPHABLEND: boolean;
  29602. RGBDLIGHTMAP: boolean;
  29603. RGBDREFLECTION: boolean;
  29604. RGBDREFRACTION: boolean;
  29605. IMAGEPROCESSING: boolean;
  29606. VIGNETTE: boolean;
  29607. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29608. VIGNETTEBLENDMODEOPAQUE: boolean;
  29609. TONEMAPPING: boolean;
  29610. TONEMAPPING_ACES: boolean;
  29611. CONTRAST: boolean;
  29612. COLORCURVES: boolean;
  29613. COLORGRADING: boolean;
  29614. COLORGRADING3D: boolean;
  29615. SAMPLER3DGREENDEPTH: boolean;
  29616. SAMPLER3DBGRMAP: boolean;
  29617. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29618. MULTIVIEW: boolean;
  29619. /**
  29620. * If the reflection texture on this material is in linear color space
  29621. * @hidden
  29622. */
  29623. IS_REFLECTION_LINEAR: boolean;
  29624. /**
  29625. * If the refraction texture on this material is in linear color space
  29626. * @hidden
  29627. */
  29628. IS_REFRACTION_LINEAR: boolean;
  29629. EXPOSURE: boolean;
  29630. constructor();
  29631. setReflectionMode(modeToEnable: string): void;
  29632. }
  29633. /**
  29634. * This is the default material used in Babylon. It is the best trade off between quality
  29635. * and performances.
  29636. * @see http://doc.babylonjs.com/babylon101/materials
  29637. */
  29638. export class StandardMaterial extends PushMaterial {
  29639. private _diffuseTexture;
  29640. /**
  29641. * The basic texture of the material as viewed under a light.
  29642. */
  29643. diffuseTexture: Nullable<BaseTexture>;
  29644. private _ambientTexture;
  29645. /**
  29646. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29647. */
  29648. ambientTexture: Nullable<BaseTexture>;
  29649. private _opacityTexture;
  29650. /**
  29651. * Define the transparency of the material from a texture.
  29652. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29653. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29654. */
  29655. opacityTexture: Nullable<BaseTexture>;
  29656. private _reflectionTexture;
  29657. /**
  29658. * Define the texture used to display the reflection.
  29659. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29660. */
  29661. reflectionTexture: Nullable<BaseTexture>;
  29662. private _emissiveTexture;
  29663. /**
  29664. * Define texture of the material as if self lit.
  29665. * This will be mixed in the final result even in the absence of light.
  29666. */
  29667. emissiveTexture: Nullable<BaseTexture>;
  29668. private _specularTexture;
  29669. /**
  29670. * Define how the color and intensity of the highlight given by the light in the material.
  29671. */
  29672. specularTexture: Nullable<BaseTexture>;
  29673. private _bumpTexture;
  29674. /**
  29675. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29676. * 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.
  29677. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  29678. */
  29679. bumpTexture: Nullable<BaseTexture>;
  29680. private _lightmapTexture;
  29681. /**
  29682. * Complex lighting can be computationally expensive to compute at runtime.
  29683. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29684. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  29685. */
  29686. lightmapTexture: Nullable<BaseTexture>;
  29687. private _refractionTexture;
  29688. /**
  29689. * Define the texture used to display the refraction.
  29690. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29691. */
  29692. refractionTexture: Nullable<BaseTexture>;
  29693. /**
  29694. * The color of the material lit by the environmental background lighting.
  29695. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29696. */
  29697. ambientColor: Color3;
  29698. /**
  29699. * The basic color of the material as viewed under a light.
  29700. */
  29701. diffuseColor: Color3;
  29702. /**
  29703. * Define how the color and intensity of the highlight given by the light in the material.
  29704. */
  29705. specularColor: Color3;
  29706. /**
  29707. * Define the color of the material as if self lit.
  29708. * This will be mixed in the final result even in the absence of light.
  29709. */
  29710. emissiveColor: Color3;
  29711. /**
  29712. * Defines how sharp are the highlights in the material.
  29713. * The bigger the value the sharper giving a more glossy feeling to the result.
  29714. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29715. */
  29716. specularPower: number;
  29717. private _useAlphaFromDiffuseTexture;
  29718. /**
  29719. * Does the transparency come from the diffuse texture alpha channel.
  29720. */
  29721. useAlphaFromDiffuseTexture: boolean;
  29722. private _useEmissiveAsIllumination;
  29723. /**
  29724. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29725. */
  29726. useEmissiveAsIllumination: boolean;
  29727. private _linkEmissiveWithDiffuse;
  29728. /**
  29729. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29730. * the emissive level when the final color is close to one.
  29731. */
  29732. linkEmissiveWithDiffuse: boolean;
  29733. private _useSpecularOverAlpha;
  29734. /**
  29735. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29736. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29737. */
  29738. useSpecularOverAlpha: boolean;
  29739. private _useReflectionOverAlpha;
  29740. /**
  29741. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29742. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29743. */
  29744. useReflectionOverAlpha: boolean;
  29745. private _disableLighting;
  29746. /**
  29747. * Does lights from the scene impacts this material.
  29748. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29749. */
  29750. disableLighting: boolean;
  29751. private _useObjectSpaceNormalMap;
  29752. /**
  29753. * Allows using an object space normal map (instead of tangent space).
  29754. */
  29755. useObjectSpaceNormalMap: boolean;
  29756. private _useParallax;
  29757. /**
  29758. * Is parallax enabled or not.
  29759. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29760. */
  29761. useParallax: boolean;
  29762. private _useParallaxOcclusion;
  29763. /**
  29764. * Is parallax occlusion enabled or not.
  29765. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29766. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  29767. */
  29768. useParallaxOcclusion: boolean;
  29769. /**
  29770. * 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.
  29771. */
  29772. parallaxScaleBias: number;
  29773. private _roughness;
  29774. /**
  29775. * Helps to define how blurry the reflections should appears in the material.
  29776. */
  29777. roughness: number;
  29778. /**
  29779. * In case of refraction, define the value of the index of refraction.
  29780. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29781. */
  29782. indexOfRefraction: number;
  29783. /**
  29784. * Invert the refraction texture alongside the y axis.
  29785. * It can be useful with procedural textures or probe for instance.
  29786. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29787. */
  29788. invertRefractionY: boolean;
  29789. /**
  29790. * Defines the alpha limits in alpha test mode.
  29791. */
  29792. alphaCutOff: number;
  29793. private _useLightmapAsShadowmap;
  29794. /**
  29795. * In case of light mapping, define whether the map contains light or shadow informations.
  29796. */
  29797. useLightmapAsShadowmap: boolean;
  29798. private _diffuseFresnelParameters;
  29799. /**
  29800. * Define the diffuse fresnel parameters of the material.
  29801. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29802. */
  29803. diffuseFresnelParameters: FresnelParameters;
  29804. private _opacityFresnelParameters;
  29805. /**
  29806. * Define the opacity fresnel parameters of the material.
  29807. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29808. */
  29809. opacityFresnelParameters: FresnelParameters;
  29810. private _reflectionFresnelParameters;
  29811. /**
  29812. * Define the reflection fresnel parameters of the material.
  29813. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29814. */
  29815. reflectionFresnelParameters: FresnelParameters;
  29816. private _refractionFresnelParameters;
  29817. /**
  29818. * Define the refraction fresnel parameters of the material.
  29819. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29820. */
  29821. refractionFresnelParameters: FresnelParameters;
  29822. private _emissiveFresnelParameters;
  29823. /**
  29824. * Define the emissive fresnel parameters of the material.
  29825. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29826. */
  29827. emissiveFresnelParameters: FresnelParameters;
  29828. private _useReflectionFresnelFromSpecular;
  29829. /**
  29830. * If true automatically deducts the fresnels values from the material specularity.
  29831. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29832. */
  29833. useReflectionFresnelFromSpecular: boolean;
  29834. private _useGlossinessFromSpecularMapAlpha;
  29835. /**
  29836. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29837. */
  29838. useGlossinessFromSpecularMapAlpha: boolean;
  29839. private _maxSimultaneousLights;
  29840. /**
  29841. * Defines the maximum number of lights that can be used in the material
  29842. */
  29843. maxSimultaneousLights: number;
  29844. private _invertNormalMapX;
  29845. /**
  29846. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29847. */
  29848. invertNormalMapX: boolean;
  29849. private _invertNormalMapY;
  29850. /**
  29851. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29852. */
  29853. invertNormalMapY: boolean;
  29854. private _twoSidedLighting;
  29855. /**
  29856. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29857. */
  29858. twoSidedLighting: boolean;
  29859. /**
  29860. * Default configuration related to image processing available in the standard Material.
  29861. */
  29862. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29863. /**
  29864. * Gets the image processing configuration used either in this material.
  29865. */
  29866. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29867. /**
  29868. * Sets the Default image processing configuration used either in the this material.
  29869. *
  29870. * If sets to null, the scene one is in use.
  29871. */
  29872. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29873. /**
  29874. * Keep track of the image processing observer to allow dispose and replace.
  29875. */
  29876. private _imageProcessingObserver;
  29877. /**
  29878. * Attaches a new image processing configuration to the Standard Material.
  29879. * @param configuration
  29880. */
  29881. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29882. /**
  29883. * Gets wether the color curves effect is enabled.
  29884. */
  29885. get cameraColorCurvesEnabled(): boolean;
  29886. /**
  29887. * Sets wether the color curves effect is enabled.
  29888. */
  29889. set cameraColorCurvesEnabled(value: boolean);
  29890. /**
  29891. * Gets wether the color grading effect is enabled.
  29892. */
  29893. get cameraColorGradingEnabled(): boolean;
  29894. /**
  29895. * Gets wether the color grading effect is enabled.
  29896. */
  29897. set cameraColorGradingEnabled(value: boolean);
  29898. /**
  29899. * Gets wether tonemapping is enabled or not.
  29900. */
  29901. get cameraToneMappingEnabled(): boolean;
  29902. /**
  29903. * Sets wether tonemapping is enabled or not
  29904. */
  29905. set cameraToneMappingEnabled(value: boolean);
  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. get cameraExposure(): number;
  29912. /**
  29913. * The camera exposure used on this material.
  29914. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29915. * This corresponds to a photographic exposure.
  29916. */
  29917. set cameraExposure(value: number);
  29918. /**
  29919. * Gets The camera contrast used on this material.
  29920. */
  29921. get cameraContrast(): number;
  29922. /**
  29923. * Sets The camera contrast used on this material.
  29924. */
  29925. set cameraContrast(value: number);
  29926. /**
  29927. * Gets the Color Grading 2D Lookup Texture.
  29928. */
  29929. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29930. /**
  29931. * Sets the Color Grading 2D Lookup Texture.
  29932. */
  29933. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29934. /**
  29935. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29936. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29937. * 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;
  29938. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29939. */
  29940. get cameraColorCurves(): Nullable<ColorCurves>;
  29941. /**
  29942. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29943. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29944. * 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;
  29945. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29946. */
  29947. set cameraColorCurves(value: Nullable<ColorCurves>);
  29948. /**
  29949. * Defines the detail map parameters for the material.
  29950. */
  29951. readonly detailMap: DetailMapConfiguration;
  29952. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29953. protected _worldViewProjectionMatrix: Matrix;
  29954. protected _globalAmbientColor: Color3;
  29955. protected _useLogarithmicDepth: boolean;
  29956. protected _rebuildInParallel: boolean;
  29957. /**
  29958. * Instantiates a new standard material.
  29959. * This is the default material used in Babylon. It is the best trade off between quality
  29960. * and performances.
  29961. * @see http://doc.babylonjs.com/babylon101/materials
  29962. * @param name Define the name of the material in the scene
  29963. * @param scene Define the scene the material belong to
  29964. */
  29965. constructor(name: string, scene: Scene);
  29966. /**
  29967. * Gets a boolean indicating that current material needs to register RTT
  29968. */
  29969. get hasRenderTargetTextures(): boolean;
  29970. /**
  29971. * Gets the current class name of the material e.g. "StandardMaterial"
  29972. * Mainly use in serialization.
  29973. * @returns the class name
  29974. */
  29975. getClassName(): string;
  29976. /**
  29977. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29978. * You can try switching to logarithmic depth.
  29979. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29980. */
  29981. get useLogarithmicDepth(): boolean;
  29982. set useLogarithmicDepth(value: boolean);
  29983. /**
  29984. * Specifies if the material will require alpha blending
  29985. * @returns a boolean specifying if alpha blending is needed
  29986. */
  29987. needAlphaBlending(): boolean;
  29988. /**
  29989. * Specifies if this material should be rendered in alpha test mode
  29990. * @returns a boolean specifying if an alpha test is needed.
  29991. */
  29992. needAlphaTesting(): boolean;
  29993. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29994. /**
  29995. * Get the texture used for alpha test purpose.
  29996. * @returns the diffuse texture in case of the standard material.
  29997. */
  29998. getAlphaTestTexture(): Nullable<BaseTexture>;
  29999. /**
  30000. * Get if the submesh is ready to be used and all its information available.
  30001. * Child classes can use it to update shaders
  30002. * @param mesh defines the mesh to check
  30003. * @param subMesh defines which submesh to check
  30004. * @param useInstances specifies that instances should be used
  30005. * @returns a boolean indicating that the submesh is ready or not
  30006. */
  30007. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30008. /**
  30009. * Builds the material UBO layouts.
  30010. * Used internally during the effect preparation.
  30011. */
  30012. buildUniformLayout(): void;
  30013. /**
  30014. * Unbinds the material from the mesh
  30015. */
  30016. unbind(): void;
  30017. /**
  30018. * Binds the submesh to this material by preparing the effect and shader to draw
  30019. * @param world defines the world transformation matrix
  30020. * @param mesh defines the mesh containing the submesh
  30021. * @param subMesh defines the submesh to bind the material to
  30022. */
  30023. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30024. /**
  30025. * Get the list of animatables in the material.
  30026. * @returns the list of animatables object used in the material
  30027. */
  30028. getAnimatables(): IAnimatable[];
  30029. /**
  30030. * Gets the active textures from the material
  30031. * @returns an array of textures
  30032. */
  30033. getActiveTextures(): BaseTexture[];
  30034. /**
  30035. * Specifies if the material uses a texture
  30036. * @param texture defines the texture to check against the material
  30037. * @returns a boolean specifying if the material uses the texture
  30038. */
  30039. hasTexture(texture: BaseTexture): boolean;
  30040. /**
  30041. * Disposes the material
  30042. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30043. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30044. */
  30045. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30046. /**
  30047. * Makes a duplicate of the material, and gives it a new name
  30048. * @param name defines the new name for the duplicated material
  30049. * @returns the cloned material
  30050. */
  30051. clone(name: string): StandardMaterial;
  30052. /**
  30053. * Serializes this material in a JSON representation
  30054. * @returns the serialized material object
  30055. */
  30056. serialize(): any;
  30057. /**
  30058. * Creates a standard material from parsed material data
  30059. * @param source defines the JSON representation of the material
  30060. * @param scene defines the hosting scene
  30061. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30062. * @returns a new standard material
  30063. */
  30064. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30065. /**
  30066. * Are diffuse textures enabled in the application.
  30067. */
  30068. static get DiffuseTextureEnabled(): boolean;
  30069. static set DiffuseTextureEnabled(value: boolean);
  30070. /**
  30071. * Are detail textures enabled in the application.
  30072. */
  30073. static get DetailTextureEnabled(): boolean;
  30074. static set DetailTextureEnabled(value: boolean);
  30075. /**
  30076. * Are ambient textures enabled in the application.
  30077. */
  30078. static get AmbientTextureEnabled(): boolean;
  30079. static set AmbientTextureEnabled(value: boolean);
  30080. /**
  30081. * Are opacity textures enabled in the application.
  30082. */
  30083. static get OpacityTextureEnabled(): boolean;
  30084. static set OpacityTextureEnabled(value: boolean);
  30085. /**
  30086. * Are reflection textures enabled in the application.
  30087. */
  30088. static get ReflectionTextureEnabled(): boolean;
  30089. static set ReflectionTextureEnabled(value: boolean);
  30090. /**
  30091. * Are emissive textures enabled in the application.
  30092. */
  30093. static get EmissiveTextureEnabled(): boolean;
  30094. static set EmissiveTextureEnabled(value: boolean);
  30095. /**
  30096. * Are specular textures enabled in the application.
  30097. */
  30098. static get SpecularTextureEnabled(): boolean;
  30099. static set SpecularTextureEnabled(value: boolean);
  30100. /**
  30101. * Are bump textures enabled in the application.
  30102. */
  30103. static get BumpTextureEnabled(): boolean;
  30104. static set BumpTextureEnabled(value: boolean);
  30105. /**
  30106. * Are lightmap textures enabled in the application.
  30107. */
  30108. static get LightmapTextureEnabled(): boolean;
  30109. static set LightmapTextureEnabled(value: boolean);
  30110. /**
  30111. * Are refraction textures enabled in the application.
  30112. */
  30113. static get RefractionTextureEnabled(): boolean;
  30114. static set RefractionTextureEnabled(value: boolean);
  30115. /**
  30116. * Are color grading textures enabled in the application.
  30117. */
  30118. static get ColorGradingTextureEnabled(): boolean;
  30119. static set ColorGradingTextureEnabled(value: boolean);
  30120. /**
  30121. * Are fresnels enabled in the application.
  30122. */
  30123. static get FresnelEnabled(): boolean;
  30124. static set FresnelEnabled(value: boolean);
  30125. }
  30126. }
  30127. declare module BABYLON {
  30128. /**
  30129. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30130. *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.
  30131. * The SPS is also a particle system. It provides some methods to manage the particles.
  30132. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30133. *
  30134. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  30135. */
  30136. export class SolidParticleSystem implements IDisposable {
  30137. /**
  30138. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30139. * Example : var p = SPS.particles[i];
  30140. */
  30141. particles: SolidParticle[];
  30142. /**
  30143. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30144. */
  30145. nbParticles: number;
  30146. /**
  30147. * If the particles must ever face the camera (default false). Useful for planar particles.
  30148. */
  30149. billboard: boolean;
  30150. /**
  30151. * Recompute normals when adding a shape
  30152. */
  30153. recomputeNormals: boolean;
  30154. /**
  30155. * This a counter ofr your own usage. It's not set by any SPS functions.
  30156. */
  30157. counter: number;
  30158. /**
  30159. * The SPS name. This name is also given to the underlying mesh.
  30160. */
  30161. name: string;
  30162. /**
  30163. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30164. */
  30165. mesh: Mesh;
  30166. /**
  30167. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30168. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30169. */
  30170. vars: any;
  30171. /**
  30172. * This array is populated when the SPS is set as 'pickable'.
  30173. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30174. * Each element of this array is an object `{idx: int, faceId: int}`.
  30175. * `idx` is the picked particle index in the `SPS.particles` array
  30176. * `faceId` is the picked face index counted within this particle.
  30177. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30178. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30179. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30180. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30181. */
  30182. pickedParticles: {
  30183. idx: number;
  30184. faceId: number;
  30185. }[];
  30186. /**
  30187. * This array is populated when the SPS is set as 'pickable'
  30188. * Each key of this array is a submesh index.
  30189. * Each element of this array is a second array defined like this :
  30190. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30191. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30192. * `idx` is the picked particle index in the `SPS.particles` array
  30193. * `faceId` is the picked face index counted within this particle.
  30194. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30195. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30196. */
  30197. pickedBySubMesh: {
  30198. idx: number;
  30199. faceId: number;
  30200. }[][];
  30201. /**
  30202. * This array is populated when `enableDepthSort` is set to true.
  30203. * Each element of this array is an instance of the class DepthSortedParticle.
  30204. */
  30205. depthSortedParticles: DepthSortedParticle[];
  30206. /**
  30207. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30208. * @hidden
  30209. */
  30210. _bSphereOnly: boolean;
  30211. /**
  30212. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30213. * @hidden
  30214. */
  30215. _bSphereRadiusFactor: number;
  30216. private _scene;
  30217. private _positions;
  30218. private _indices;
  30219. private _normals;
  30220. private _colors;
  30221. private _uvs;
  30222. private _indices32;
  30223. private _positions32;
  30224. private _normals32;
  30225. private _fixedNormal32;
  30226. private _colors32;
  30227. private _uvs32;
  30228. private _index;
  30229. private _updatable;
  30230. private _pickable;
  30231. private _isVisibilityBoxLocked;
  30232. private _alwaysVisible;
  30233. private _depthSort;
  30234. private _expandable;
  30235. private _shapeCounter;
  30236. private _copy;
  30237. private _color;
  30238. private _computeParticleColor;
  30239. private _computeParticleTexture;
  30240. private _computeParticleRotation;
  30241. private _computeParticleVertex;
  30242. private _computeBoundingBox;
  30243. private _depthSortParticles;
  30244. private _camera;
  30245. private _mustUnrotateFixedNormals;
  30246. private _particlesIntersect;
  30247. private _needs32Bits;
  30248. private _isNotBuilt;
  30249. private _lastParticleId;
  30250. private _idxOfId;
  30251. private _multimaterialEnabled;
  30252. private _useModelMaterial;
  30253. private _indicesByMaterial;
  30254. private _materialIndexes;
  30255. private _depthSortFunction;
  30256. private _materialSortFunction;
  30257. private _materials;
  30258. private _multimaterial;
  30259. private _materialIndexesById;
  30260. private _defaultMaterial;
  30261. private _autoUpdateSubMeshes;
  30262. private _tmpVertex;
  30263. /**
  30264. * Creates a SPS (Solid Particle System) object.
  30265. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30266. * @param scene (Scene) is the scene in which the SPS is added.
  30267. * @param options defines the options of the sps e.g.
  30268. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30269. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30270. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30271. * * 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.
  30272. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30273. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30274. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30275. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30276. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30277. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30278. */
  30279. constructor(name: string, scene: Scene, options?: {
  30280. updatable?: boolean;
  30281. isPickable?: boolean;
  30282. enableDepthSort?: boolean;
  30283. particleIntersection?: boolean;
  30284. boundingSphereOnly?: boolean;
  30285. bSphereRadiusFactor?: number;
  30286. expandable?: boolean;
  30287. useModelMaterial?: boolean;
  30288. enableMultiMaterial?: boolean;
  30289. });
  30290. /**
  30291. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30292. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30293. * @returns the created mesh
  30294. */
  30295. buildMesh(): Mesh;
  30296. /**
  30297. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30298. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30299. * Thus the particles generated from `digest()` have their property `position` set yet.
  30300. * @param mesh ( Mesh ) is the mesh to be digested
  30301. * @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
  30302. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30303. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30304. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30305. * @returns the current SPS
  30306. */
  30307. digest(mesh: Mesh, options?: {
  30308. facetNb?: number;
  30309. number?: number;
  30310. delta?: number;
  30311. storage?: [];
  30312. }): SolidParticleSystem;
  30313. /**
  30314. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30315. * @hidden
  30316. */
  30317. private _unrotateFixedNormals;
  30318. /**
  30319. * Resets the temporary working copy particle
  30320. * @hidden
  30321. */
  30322. private _resetCopy;
  30323. /**
  30324. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30325. * @param p the current index in the positions array to be updated
  30326. * @param ind the current index in the indices array
  30327. * @param shape a Vector3 array, the shape geometry
  30328. * @param positions the positions array to be updated
  30329. * @param meshInd the shape indices array
  30330. * @param indices the indices array to be updated
  30331. * @param meshUV the shape uv array
  30332. * @param uvs the uv array to be updated
  30333. * @param meshCol the shape color array
  30334. * @param colors the color array to be updated
  30335. * @param meshNor the shape normals array
  30336. * @param normals the normals array to be updated
  30337. * @param idx the particle index
  30338. * @param idxInShape the particle index in its shape
  30339. * @param options the addShape() method passed options
  30340. * @model the particle model
  30341. * @hidden
  30342. */
  30343. private _meshBuilder;
  30344. /**
  30345. * Returns a shape Vector3 array from positions float array
  30346. * @param positions float array
  30347. * @returns a vector3 array
  30348. * @hidden
  30349. */
  30350. private _posToShape;
  30351. /**
  30352. * Returns a shapeUV array from a float uvs (array deep copy)
  30353. * @param uvs as a float array
  30354. * @returns a shapeUV array
  30355. * @hidden
  30356. */
  30357. private _uvsToShapeUV;
  30358. /**
  30359. * Adds a new particle object in the particles array
  30360. * @param idx particle index in particles array
  30361. * @param id particle id
  30362. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30363. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30364. * @param model particle ModelShape object
  30365. * @param shapeId model shape identifier
  30366. * @param idxInShape index of the particle in the current model
  30367. * @param bInfo model bounding info object
  30368. * @param storage target storage array, if any
  30369. * @hidden
  30370. */
  30371. private _addParticle;
  30372. /**
  30373. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30374. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30375. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30376. * @param nb (positive integer) the number of particles to be created from this model
  30377. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30378. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30379. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30380. * @returns the number of shapes in the system
  30381. */
  30382. addShape(mesh: Mesh, nb: number, options?: {
  30383. positionFunction?: any;
  30384. vertexFunction?: any;
  30385. storage?: [];
  30386. }): number;
  30387. /**
  30388. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30389. * @hidden
  30390. */
  30391. private _rebuildParticle;
  30392. /**
  30393. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30394. * @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.
  30395. * @returns the SPS.
  30396. */
  30397. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30398. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30399. * Returns an array with the removed particles.
  30400. * 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.
  30401. * The SPS can't be empty so at least one particle needs to remain in place.
  30402. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30403. * @param start index of the first particle to remove
  30404. * @param end index of the last particle to remove (included)
  30405. * @returns an array populated with the removed particles
  30406. */
  30407. removeParticles(start: number, end: number): SolidParticle[];
  30408. /**
  30409. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30410. * @param solidParticleArray an array populated with Solid Particles objects
  30411. * @returns the SPS
  30412. */
  30413. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30414. /**
  30415. * Creates a new particle and modifies the SPS mesh geometry :
  30416. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30417. * - calls _addParticle() to populate the particle array
  30418. * factorized code from addShape() and insertParticlesFromArray()
  30419. * @param idx particle index in the particles array
  30420. * @param i particle index in its shape
  30421. * @param modelShape particle ModelShape object
  30422. * @param shape shape vertex array
  30423. * @param meshInd shape indices array
  30424. * @param meshUV shape uv array
  30425. * @param meshCol shape color array
  30426. * @param meshNor shape normals array
  30427. * @param bbInfo shape bounding info
  30428. * @param storage target particle storage
  30429. * @options addShape() passed options
  30430. * @hidden
  30431. */
  30432. private _insertNewParticle;
  30433. /**
  30434. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30435. * This method calls `updateParticle()` for each particle of the SPS.
  30436. * For an animated SPS, it is usually called within the render loop.
  30437. * 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.
  30438. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30439. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30440. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30441. * @returns the SPS.
  30442. */
  30443. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30444. /**
  30445. * Disposes the SPS.
  30446. */
  30447. dispose(): void;
  30448. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30449. * idx is the particle index in the SPS
  30450. * faceId is the picked face index counted within this particle.
  30451. * Returns null if the pickInfo can't identify a picked particle.
  30452. * @param pickingInfo (PickingInfo object)
  30453. * @returns {idx: number, faceId: number} or null
  30454. */
  30455. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30456. idx: number;
  30457. faceId: number;
  30458. }>;
  30459. /**
  30460. * Returns a SolidParticle object from its identifier : particle.id
  30461. * @param id (integer) the particle Id
  30462. * @returns the searched particle or null if not found in the SPS.
  30463. */
  30464. getParticleById(id: number): Nullable<SolidParticle>;
  30465. /**
  30466. * Returns a new array populated with the particles having the passed shapeId.
  30467. * @param shapeId (integer) the shape identifier
  30468. * @returns a new solid particle array
  30469. */
  30470. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30471. /**
  30472. * Populates the passed array "ref" with the particles having the passed shapeId.
  30473. * @param shapeId the shape identifier
  30474. * @returns the SPS
  30475. * @param ref
  30476. */
  30477. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30478. /**
  30479. * Computes the required SubMeshes according the materials assigned to the particles.
  30480. * @returns the solid particle system.
  30481. * Does nothing if called before the SPS mesh is built.
  30482. */
  30483. computeSubMeshes(): SolidParticleSystem;
  30484. /**
  30485. * Sorts the solid particles by material when MultiMaterial is enabled.
  30486. * Updates the indices32 array.
  30487. * Updates the indicesByMaterial array.
  30488. * Updates the mesh indices array.
  30489. * @returns the SPS
  30490. * @hidden
  30491. */
  30492. private _sortParticlesByMaterial;
  30493. /**
  30494. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30495. * @hidden
  30496. */
  30497. private _setMaterialIndexesById;
  30498. /**
  30499. * Returns an array with unique values of Materials from the passed array
  30500. * @param array the material array to be checked and filtered
  30501. * @hidden
  30502. */
  30503. private _filterUniqueMaterialId;
  30504. /**
  30505. * Sets a new Standard Material as _defaultMaterial if not already set.
  30506. * @hidden
  30507. */
  30508. private _setDefaultMaterial;
  30509. /**
  30510. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30511. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30512. * @returns the SPS.
  30513. */
  30514. refreshVisibleSize(): SolidParticleSystem;
  30515. /**
  30516. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30517. * @param size the size (float) of the visibility box
  30518. * note : this doesn't lock the SPS mesh bounding box.
  30519. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30520. */
  30521. setVisibilityBox(size: number): void;
  30522. /**
  30523. * Gets whether the SPS as always visible or not
  30524. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30525. */
  30526. get isAlwaysVisible(): boolean;
  30527. /**
  30528. * Sets the SPS as always visible or not
  30529. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30530. */
  30531. set isAlwaysVisible(val: boolean);
  30532. /**
  30533. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30534. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30535. */
  30536. set isVisibilityBoxLocked(val: boolean);
  30537. /**
  30538. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30539. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30540. */
  30541. get isVisibilityBoxLocked(): boolean;
  30542. /**
  30543. * Tells to `setParticles()` to compute the particle rotations or not.
  30544. * Default value : true. The SPS is faster when it's set to false.
  30545. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30546. */
  30547. set computeParticleRotation(val: boolean);
  30548. /**
  30549. * Tells to `setParticles()` to compute the particle colors or not.
  30550. * Default value : true. The SPS is faster when it's set to false.
  30551. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30552. */
  30553. set computeParticleColor(val: boolean);
  30554. set computeParticleTexture(val: boolean);
  30555. /**
  30556. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30557. * Default value : false. The SPS is faster when it's set to false.
  30558. * Note : the particle custom vertex positions aren't stored values.
  30559. */
  30560. set computeParticleVertex(val: boolean);
  30561. /**
  30562. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30563. */
  30564. set computeBoundingBox(val: boolean);
  30565. /**
  30566. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30567. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30568. * Default : `true`
  30569. */
  30570. set depthSortParticles(val: boolean);
  30571. /**
  30572. * Gets if `setParticles()` computes the particle rotations or not.
  30573. * Default value : true. The SPS is faster when it's set to false.
  30574. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30575. */
  30576. get computeParticleRotation(): boolean;
  30577. /**
  30578. * Gets if `setParticles()` computes the particle colors or not.
  30579. * Default value : true. The SPS is faster when it's set to false.
  30580. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30581. */
  30582. get computeParticleColor(): boolean;
  30583. /**
  30584. * Gets if `setParticles()` computes the particle textures or not.
  30585. * Default value : true. The SPS is faster when it's set to false.
  30586. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30587. */
  30588. get computeParticleTexture(): boolean;
  30589. /**
  30590. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30591. * Default value : false. The SPS is faster when it's set to false.
  30592. * Note : the particle custom vertex positions aren't stored values.
  30593. */
  30594. get computeParticleVertex(): boolean;
  30595. /**
  30596. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30597. */
  30598. get computeBoundingBox(): boolean;
  30599. /**
  30600. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30601. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30602. * Default : `true`
  30603. */
  30604. get depthSortParticles(): boolean;
  30605. /**
  30606. * Gets if the SPS is created as expandable at construction time.
  30607. * Default : `false`
  30608. */
  30609. get expandable(): boolean;
  30610. /**
  30611. * Gets if the SPS supports the Multi Materials
  30612. */
  30613. get multimaterialEnabled(): boolean;
  30614. /**
  30615. * Gets if the SPS uses the model materials for its own multimaterial.
  30616. */
  30617. get useModelMaterial(): boolean;
  30618. /**
  30619. * The SPS used material array.
  30620. */
  30621. get materials(): Material[];
  30622. /**
  30623. * Sets the SPS MultiMaterial from the passed materials.
  30624. * Note : the passed array is internally copied and not used then by reference.
  30625. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30626. */
  30627. setMultiMaterial(materials: Material[]): void;
  30628. /**
  30629. * The SPS computed multimaterial object
  30630. */
  30631. get multimaterial(): MultiMaterial;
  30632. set multimaterial(mm: MultiMaterial);
  30633. /**
  30634. * If the subMeshes must be updated on the next call to setParticles()
  30635. */
  30636. get autoUpdateSubMeshes(): boolean;
  30637. set autoUpdateSubMeshes(val: boolean);
  30638. /**
  30639. * This function does nothing. It may be overwritten to set all the particle first values.
  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. */
  30643. initParticles(): void;
  30644. /**
  30645. * This function does nothing. It may be overwritten to recycle a particle.
  30646. * The SPS doesn't call this function, you may have to call it by your own.
  30647. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30648. * @param particle The particle to recycle
  30649. * @returns the recycled particle
  30650. */
  30651. recycleParticle(particle: SolidParticle): SolidParticle;
  30652. /**
  30653. * Updates a particle : this function should be overwritten by the user.
  30654. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30655. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30656. * @example : just set a particle position or velocity and recycle conditions
  30657. * @param particle The particle to update
  30658. * @returns the updated particle
  30659. */
  30660. updateParticle(particle: SolidParticle): SolidParticle;
  30661. /**
  30662. * Updates a vertex of a particle : it can be overwritten by the user.
  30663. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30664. * @param particle the current particle
  30665. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30666. * @param pt the index of the current vertex in the particle shape
  30667. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30668. * @example : just set a vertex particle position or color
  30669. * @returns the sps
  30670. */
  30671. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30672. /**
  30673. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30674. * This does nothing and may be overwritten by the user.
  30675. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30676. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30677. * @param update the boolean update value actually passed to setParticles()
  30678. */
  30679. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30680. /**
  30681. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30682. * This will be passed three parameters.
  30683. * This does nothing and may be overwritten by the user.
  30684. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30685. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30686. * @param update the boolean update value actually passed to setParticles()
  30687. */
  30688. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30689. }
  30690. }
  30691. declare module BABYLON {
  30692. /**
  30693. * Represents one particle of a solid particle system.
  30694. */
  30695. export class SolidParticle {
  30696. /**
  30697. * particle global index
  30698. */
  30699. idx: number;
  30700. /**
  30701. * particle identifier
  30702. */
  30703. id: number;
  30704. /**
  30705. * The color of the particle
  30706. */
  30707. color: Nullable<Color4>;
  30708. /**
  30709. * The world space position of the particle.
  30710. */
  30711. position: Vector3;
  30712. /**
  30713. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30714. */
  30715. rotation: Vector3;
  30716. /**
  30717. * The world space rotation quaternion of the particle.
  30718. */
  30719. rotationQuaternion: Nullable<Quaternion>;
  30720. /**
  30721. * The scaling of the particle.
  30722. */
  30723. scaling: Vector3;
  30724. /**
  30725. * The uvs of the particle.
  30726. */
  30727. uvs: Vector4;
  30728. /**
  30729. * The current speed of the particle.
  30730. */
  30731. velocity: Vector3;
  30732. /**
  30733. * The pivot point in the particle local space.
  30734. */
  30735. pivot: Vector3;
  30736. /**
  30737. * Must the particle be translated from its pivot point in its local space ?
  30738. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30739. * Default : false
  30740. */
  30741. translateFromPivot: boolean;
  30742. /**
  30743. * Is the particle active or not ?
  30744. */
  30745. alive: boolean;
  30746. /**
  30747. * Is the particle visible or not ?
  30748. */
  30749. isVisible: boolean;
  30750. /**
  30751. * Index of this particle in the global "positions" array (Internal use)
  30752. * @hidden
  30753. */
  30754. _pos: number;
  30755. /**
  30756. * @hidden Index of this particle in the global "indices" array (Internal use)
  30757. */
  30758. _ind: number;
  30759. /**
  30760. * @hidden ModelShape of this particle (Internal use)
  30761. */
  30762. _model: ModelShape;
  30763. /**
  30764. * ModelShape id of this particle
  30765. */
  30766. shapeId: number;
  30767. /**
  30768. * Index of the particle in its shape id
  30769. */
  30770. idxInShape: number;
  30771. /**
  30772. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30773. */
  30774. _modelBoundingInfo: BoundingInfo;
  30775. /**
  30776. * @hidden Particle BoundingInfo object (Internal use)
  30777. */
  30778. _boundingInfo: BoundingInfo;
  30779. /**
  30780. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30781. */
  30782. _sps: SolidParticleSystem;
  30783. /**
  30784. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30785. */
  30786. _stillInvisible: boolean;
  30787. /**
  30788. * @hidden Last computed particle rotation matrix
  30789. */
  30790. _rotationMatrix: number[];
  30791. /**
  30792. * Parent particle Id, if any.
  30793. * Default null.
  30794. */
  30795. parentId: Nullable<number>;
  30796. /**
  30797. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30798. */
  30799. materialIndex: Nullable<number>;
  30800. /**
  30801. * Custom object or properties.
  30802. */
  30803. props: Nullable<any>;
  30804. /**
  30805. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30806. * The possible values are :
  30807. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30808. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30809. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30810. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30811. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30812. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30813. * */
  30814. cullingStrategy: number;
  30815. /**
  30816. * @hidden Internal global position in the SPS.
  30817. */
  30818. _globalPosition: Vector3;
  30819. /**
  30820. * Creates a Solid Particle object.
  30821. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30822. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30823. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30824. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30825. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30826. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30827. * @param shapeId (integer) is the model shape identifier in the SPS.
  30828. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30829. * @param sps defines the sps it is associated to
  30830. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30831. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30832. */
  30833. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30834. /**
  30835. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30836. * @param target the particle target
  30837. * @returns the current particle
  30838. */
  30839. copyToRef(target: SolidParticle): SolidParticle;
  30840. /**
  30841. * Legacy support, changed scale to scaling
  30842. */
  30843. get scale(): Vector3;
  30844. /**
  30845. * Legacy support, changed scale to scaling
  30846. */
  30847. set scale(scale: Vector3);
  30848. /**
  30849. * Legacy support, changed quaternion to rotationQuaternion
  30850. */
  30851. get quaternion(): Nullable<Quaternion>;
  30852. /**
  30853. * Legacy support, changed quaternion to rotationQuaternion
  30854. */
  30855. set quaternion(q: Nullable<Quaternion>);
  30856. /**
  30857. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30858. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30859. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30860. * @returns true if it intersects
  30861. */
  30862. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30863. /**
  30864. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30865. * A particle is in the frustum if its bounding box intersects the frustum
  30866. * @param frustumPlanes defines the frustum to test
  30867. * @returns true if the particle is in the frustum planes
  30868. */
  30869. isInFrustum(frustumPlanes: Plane[]): boolean;
  30870. /**
  30871. * get the rotation matrix of the particle
  30872. * @hidden
  30873. */
  30874. getRotationMatrix(m: Matrix): void;
  30875. }
  30876. /**
  30877. * Represents the shape of the model used by one particle of a solid particle system.
  30878. * SPS internal tool, don't use it manually.
  30879. */
  30880. export class ModelShape {
  30881. /**
  30882. * The shape id
  30883. * @hidden
  30884. */
  30885. shapeID: number;
  30886. /**
  30887. * flat array of model positions (internal use)
  30888. * @hidden
  30889. */
  30890. _shape: Vector3[];
  30891. /**
  30892. * flat array of model UVs (internal use)
  30893. * @hidden
  30894. */
  30895. _shapeUV: number[];
  30896. /**
  30897. * color array of the model
  30898. * @hidden
  30899. */
  30900. _shapeColors: number[];
  30901. /**
  30902. * indices array of the model
  30903. * @hidden
  30904. */
  30905. _indices: number[];
  30906. /**
  30907. * normals array of the model
  30908. * @hidden
  30909. */
  30910. _normals: number[];
  30911. /**
  30912. * length of the shape in the model indices array (internal use)
  30913. * @hidden
  30914. */
  30915. _indicesLength: number;
  30916. /**
  30917. * Custom position function (internal use)
  30918. * @hidden
  30919. */
  30920. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30921. /**
  30922. * Custom vertex function (internal use)
  30923. * @hidden
  30924. */
  30925. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30926. /**
  30927. * Model material (internal use)
  30928. * @hidden
  30929. */
  30930. _material: Nullable<Material>;
  30931. /**
  30932. * 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.
  30933. * SPS internal tool, don't use it manually.
  30934. * @hidden
  30935. */
  30936. 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>);
  30937. }
  30938. /**
  30939. * Represents a Depth Sorted Particle in the solid particle system.
  30940. * @hidden
  30941. */
  30942. export class DepthSortedParticle {
  30943. /**
  30944. * Particle index
  30945. */
  30946. idx: number;
  30947. /**
  30948. * Index of the particle in the "indices" array
  30949. */
  30950. ind: number;
  30951. /**
  30952. * Length of the particle shape in the "indices" array
  30953. */
  30954. indicesLength: number;
  30955. /**
  30956. * Squared distance from the particle to the camera
  30957. */
  30958. sqDistance: number;
  30959. /**
  30960. * Material index when used with MultiMaterials
  30961. */
  30962. materialIndex: number;
  30963. /**
  30964. * Creates a new sorted particle
  30965. * @param materialIndex
  30966. */
  30967. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30968. }
  30969. /**
  30970. * Represents a solid particle vertex
  30971. */
  30972. export class SolidParticleVertex {
  30973. /**
  30974. * Vertex position
  30975. */
  30976. position: Vector3;
  30977. /**
  30978. * Vertex color
  30979. */
  30980. color: Color4;
  30981. /**
  30982. * Vertex UV
  30983. */
  30984. uv: Vector2;
  30985. /**
  30986. * Creates a new solid particle vertex
  30987. */
  30988. constructor();
  30989. /** Vertex x coordinate */
  30990. get x(): number;
  30991. set x(val: number);
  30992. /** Vertex y coordinate */
  30993. get y(): number;
  30994. set y(val: number);
  30995. /** Vertex z coordinate */
  30996. get z(): number;
  30997. set z(val: number);
  30998. }
  30999. }
  31000. declare module BABYLON {
  31001. /**
  31002. * @hidden
  31003. */
  31004. export class _MeshCollisionData {
  31005. _checkCollisions: boolean;
  31006. _collisionMask: number;
  31007. _collisionGroup: number;
  31008. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31009. _collider: Nullable<Collider>;
  31010. _oldPositionForCollisions: Vector3;
  31011. _diffPositionForCollisions: Vector3;
  31012. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31013. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31014. }
  31015. }
  31016. declare module BABYLON {
  31017. /** @hidden */
  31018. class _FacetDataStorage {
  31019. facetPositions: Vector3[];
  31020. facetNormals: Vector3[];
  31021. facetPartitioning: number[][];
  31022. facetNb: number;
  31023. partitioningSubdivisions: number;
  31024. partitioningBBoxRatio: number;
  31025. facetDataEnabled: boolean;
  31026. facetParameters: any;
  31027. bbSize: Vector3;
  31028. subDiv: {
  31029. max: number;
  31030. X: number;
  31031. Y: number;
  31032. Z: number;
  31033. };
  31034. facetDepthSort: boolean;
  31035. facetDepthSortEnabled: boolean;
  31036. depthSortedIndices: IndicesArray;
  31037. depthSortedFacets: {
  31038. ind: number;
  31039. sqDistance: number;
  31040. }[];
  31041. facetDepthSortFunction: (f1: {
  31042. ind: number;
  31043. sqDistance: number;
  31044. }, f2: {
  31045. ind: number;
  31046. sqDistance: number;
  31047. }) => number;
  31048. facetDepthSortFrom: Vector3;
  31049. facetDepthSortOrigin: Vector3;
  31050. invertedMatrix: Matrix;
  31051. }
  31052. /**
  31053. * @hidden
  31054. **/
  31055. class _InternalAbstractMeshDataInfo {
  31056. _hasVertexAlpha: boolean;
  31057. _useVertexColors: boolean;
  31058. _numBoneInfluencers: number;
  31059. _applyFog: boolean;
  31060. _receiveShadows: boolean;
  31061. _facetData: _FacetDataStorage;
  31062. _visibility: number;
  31063. _skeleton: Nullable<Skeleton>;
  31064. _layerMask: number;
  31065. _computeBonesUsingShaders: boolean;
  31066. _isActive: boolean;
  31067. _onlyForInstances: boolean;
  31068. _isActiveIntermediate: boolean;
  31069. _onlyForInstancesIntermediate: boolean;
  31070. _actAsRegularMesh: boolean;
  31071. }
  31072. /**
  31073. * Class used to store all common mesh properties
  31074. */
  31075. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31076. /** No occlusion */
  31077. static OCCLUSION_TYPE_NONE: number;
  31078. /** Occlusion set to optimisitic */
  31079. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31080. /** Occlusion set to strict */
  31081. static OCCLUSION_TYPE_STRICT: number;
  31082. /** Use an accurante occlusion algorithm */
  31083. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31084. /** Use a conservative occlusion algorithm */
  31085. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31086. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31087. * Test order :
  31088. * Is the bounding sphere outside the frustum ?
  31089. * If not, are the bounding box vertices outside the frustum ?
  31090. * It not, then the cullable object is in the frustum.
  31091. */
  31092. static readonly CULLINGSTRATEGY_STANDARD: number;
  31093. /** Culling strategy : Bounding Sphere Only.
  31094. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31095. * It's also less accurate than the standard because some not visible objects can still be selected.
  31096. * Test : is the bounding sphere outside the frustum ?
  31097. * If not, then the cullable object is in the frustum.
  31098. */
  31099. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31100. /** Culling strategy : Optimistic Inclusion.
  31101. * This in an inclusion test first, then the standard exclusion test.
  31102. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31103. * 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.
  31104. * Anyway, it's as accurate as the standard strategy.
  31105. * Test :
  31106. * Is the cullable object bounding sphere center in the frustum ?
  31107. * If not, apply the default culling strategy.
  31108. */
  31109. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31110. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31111. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31112. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31113. * 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.
  31114. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31115. * Test :
  31116. * Is the cullable object bounding sphere center in the frustum ?
  31117. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31118. */
  31119. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31120. /**
  31121. * No billboard
  31122. */
  31123. static get BILLBOARDMODE_NONE(): number;
  31124. /** Billboard on X axis */
  31125. static get BILLBOARDMODE_X(): number;
  31126. /** Billboard on Y axis */
  31127. static get BILLBOARDMODE_Y(): number;
  31128. /** Billboard on Z axis */
  31129. static get BILLBOARDMODE_Z(): number;
  31130. /** Billboard on all axes */
  31131. static get BILLBOARDMODE_ALL(): number;
  31132. /** Billboard on using position instead of orientation */
  31133. static get BILLBOARDMODE_USE_POSITION(): number;
  31134. /** @hidden */
  31135. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31136. /**
  31137. * The culling strategy to use to check whether the mesh must be rendered or not.
  31138. * This value can be changed at any time and will be used on the next render mesh selection.
  31139. * The possible values are :
  31140. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31141. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31142. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31143. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31144. * Please read each static variable documentation to get details about the culling process.
  31145. * */
  31146. cullingStrategy: number;
  31147. /**
  31148. * Gets the number of facets in the mesh
  31149. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31150. */
  31151. get facetNb(): number;
  31152. /**
  31153. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31155. */
  31156. get partitioningSubdivisions(): number;
  31157. set partitioningSubdivisions(nb: number);
  31158. /**
  31159. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31160. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31161. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31162. */
  31163. get partitioningBBoxRatio(): number;
  31164. set partitioningBBoxRatio(ratio: number);
  31165. /**
  31166. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31167. * Works only for updatable meshes.
  31168. * Doesn't work with multi-materials
  31169. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31170. */
  31171. get mustDepthSortFacets(): boolean;
  31172. set mustDepthSortFacets(sort: boolean);
  31173. /**
  31174. * The location (Vector3) where the facet depth sort must be computed from.
  31175. * By default, the active camera position.
  31176. * Used only when facet depth sort is enabled
  31177. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31178. */
  31179. get facetDepthSortFrom(): Vector3;
  31180. set facetDepthSortFrom(location: Vector3);
  31181. /**
  31182. * gets a boolean indicating if facetData is enabled
  31183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31184. */
  31185. get isFacetDataEnabled(): boolean;
  31186. /** @hidden */
  31187. _updateNonUniformScalingState(value: boolean): boolean;
  31188. /**
  31189. * An event triggered when this mesh collides with another one
  31190. */
  31191. onCollideObservable: Observable<AbstractMesh>;
  31192. /** Set a function to call when this mesh collides with another one */
  31193. set onCollide(callback: () => void);
  31194. /**
  31195. * An event triggered when the collision's position changes
  31196. */
  31197. onCollisionPositionChangeObservable: Observable<Vector3>;
  31198. /** Set a function to call when the collision's position changes */
  31199. set onCollisionPositionChange(callback: () => void);
  31200. /**
  31201. * An event triggered when material is changed
  31202. */
  31203. onMaterialChangedObservable: Observable<AbstractMesh>;
  31204. /**
  31205. * Gets or sets the orientation for POV movement & rotation
  31206. */
  31207. definedFacingForward: boolean;
  31208. /** @hidden */
  31209. _occlusionQuery: Nullable<WebGLQuery>;
  31210. /** @hidden */
  31211. _renderingGroup: Nullable<RenderingGroup>;
  31212. /**
  31213. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31214. */
  31215. get visibility(): number;
  31216. /**
  31217. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31218. */
  31219. set visibility(value: number);
  31220. /** Gets or sets the alpha index used to sort transparent meshes
  31221. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31222. */
  31223. alphaIndex: number;
  31224. /**
  31225. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31226. */
  31227. isVisible: boolean;
  31228. /**
  31229. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31230. */
  31231. isPickable: boolean;
  31232. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31233. showSubMeshesBoundingBox: boolean;
  31234. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31235. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31236. */
  31237. isBlocker: boolean;
  31238. /**
  31239. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31240. */
  31241. enablePointerMoveEvents: boolean;
  31242. /**
  31243. * Specifies the rendering group id for this mesh (0 by default)
  31244. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31245. */
  31246. renderingGroupId: number;
  31247. private _material;
  31248. /** Gets or sets current material */
  31249. get material(): Nullable<Material>;
  31250. set material(value: Nullable<Material>);
  31251. /**
  31252. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31253. * @see http://doc.babylonjs.com/babylon101/shadows
  31254. */
  31255. get receiveShadows(): boolean;
  31256. set receiveShadows(value: boolean);
  31257. /** Defines color to use when rendering outline */
  31258. outlineColor: Color3;
  31259. /** Define width to use when rendering outline */
  31260. outlineWidth: number;
  31261. /** Defines color to use when rendering overlay */
  31262. overlayColor: Color3;
  31263. /** Defines alpha to use when rendering overlay */
  31264. overlayAlpha: number;
  31265. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31266. get hasVertexAlpha(): boolean;
  31267. set hasVertexAlpha(value: boolean);
  31268. /** 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) */
  31269. get useVertexColors(): boolean;
  31270. set useVertexColors(value: boolean);
  31271. /**
  31272. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31273. */
  31274. get computeBonesUsingShaders(): boolean;
  31275. set computeBonesUsingShaders(value: boolean);
  31276. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31277. get numBoneInfluencers(): number;
  31278. set numBoneInfluencers(value: number);
  31279. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31280. get applyFog(): boolean;
  31281. set applyFog(value: boolean);
  31282. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31283. useOctreeForRenderingSelection: boolean;
  31284. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31285. useOctreeForPicking: boolean;
  31286. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31287. useOctreeForCollisions: boolean;
  31288. /**
  31289. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31290. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31291. */
  31292. get layerMask(): number;
  31293. set layerMask(value: number);
  31294. /**
  31295. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31296. */
  31297. alwaysSelectAsActiveMesh: boolean;
  31298. /**
  31299. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31300. */
  31301. doNotSyncBoundingInfo: boolean;
  31302. /**
  31303. * Gets or sets the current action manager
  31304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31305. */
  31306. actionManager: Nullable<AbstractActionManager>;
  31307. private _meshCollisionData;
  31308. /**
  31309. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31310. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31311. */
  31312. ellipsoid: Vector3;
  31313. /**
  31314. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31316. */
  31317. ellipsoidOffset: Vector3;
  31318. /**
  31319. * Gets or sets a collision mask used to mask collisions (default is -1).
  31320. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31321. */
  31322. get collisionMask(): number;
  31323. set collisionMask(mask: number);
  31324. /**
  31325. * Gets or sets the current collision group mask (-1 by default).
  31326. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31327. */
  31328. get collisionGroup(): number;
  31329. set collisionGroup(mask: number);
  31330. /**
  31331. * Gets or sets current surrounding meshes (null by default).
  31332. *
  31333. * By default collision detection is tested against every mesh in the scene.
  31334. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31335. * meshes will be tested for the collision.
  31336. *
  31337. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31338. */
  31339. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31340. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31341. /**
  31342. * Defines edge width used when edgesRenderer is enabled
  31343. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31344. */
  31345. edgesWidth: number;
  31346. /**
  31347. * Defines edge color used when edgesRenderer is enabled
  31348. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31349. */
  31350. edgesColor: Color4;
  31351. /** @hidden */
  31352. _edgesRenderer: Nullable<IEdgesRenderer>;
  31353. /** @hidden */
  31354. _masterMesh: Nullable<AbstractMesh>;
  31355. /** @hidden */
  31356. _boundingInfo: Nullable<BoundingInfo>;
  31357. /** @hidden */
  31358. _renderId: number;
  31359. /**
  31360. * Gets or sets the list of subMeshes
  31361. * @see http://doc.babylonjs.com/how_to/multi_materials
  31362. */
  31363. subMeshes: SubMesh[];
  31364. /** @hidden */
  31365. _intersectionsInProgress: AbstractMesh[];
  31366. /** @hidden */
  31367. _unIndexed: boolean;
  31368. /** @hidden */
  31369. _lightSources: Light[];
  31370. /** Gets the list of lights affecting that mesh */
  31371. get lightSources(): Light[];
  31372. /** @hidden */
  31373. get _positions(): Nullable<Vector3[]>;
  31374. /** @hidden */
  31375. _waitingData: {
  31376. lods: Nullable<any>;
  31377. actions: Nullable<any>;
  31378. freezeWorldMatrix: Nullable<boolean>;
  31379. };
  31380. /** @hidden */
  31381. _bonesTransformMatrices: Nullable<Float32Array>;
  31382. /** @hidden */
  31383. _transformMatrixTexture: Nullable<RawTexture>;
  31384. /**
  31385. * Gets or sets a skeleton to apply skining transformations
  31386. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31387. */
  31388. set skeleton(value: Nullable<Skeleton>);
  31389. get skeleton(): Nullable<Skeleton>;
  31390. /**
  31391. * An event triggered when the mesh is rebuilt.
  31392. */
  31393. onRebuildObservable: Observable<AbstractMesh>;
  31394. /**
  31395. * Creates a new AbstractMesh
  31396. * @param name defines the name of the mesh
  31397. * @param scene defines the hosting scene
  31398. */
  31399. constructor(name: string, scene?: Nullable<Scene>);
  31400. /**
  31401. * Returns the string "AbstractMesh"
  31402. * @returns "AbstractMesh"
  31403. */
  31404. getClassName(): string;
  31405. /**
  31406. * Gets a string representation of the current mesh
  31407. * @param fullDetails defines a boolean indicating if full details must be included
  31408. * @returns a string representation of the current mesh
  31409. */
  31410. toString(fullDetails?: boolean): string;
  31411. /**
  31412. * @hidden
  31413. */
  31414. protected _getEffectiveParent(): Nullable<Node>;
  31415. /** @hidden */
  31416. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31417. /** @hidden */
  31418. _rebuild(): void;
  31419. /** @hidden */
  31420. _resyncLightSources(): void;
  31421. /** @hidden */
  31422. _resyncLightSource(light: Light): void;
  31423. /** @hidden */
  31424. _unBindEffect(): void;
  31425. /** @hidden */
  31426. _removeLightSource(light: Light, dispose: boolean): void;
  31427. private _markSubMeshesAsDirty;
  31428. /** @hidden */
  31429. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31430. /** @hidden */
  31431. _markSubMeshesAsAttributesDirty(): void;
  31432. /** @hidden */
  31433. _markSubMeshesAsMiscDirty(): void;
  31434. /**
  31435. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31436. */
  31437. get scaling(): Vector3;
  31438. set scaling(newScaling: Vector3);
  31439. /**
  31440. * Returns true if the mesh is blocked. Implemented by child classes
  31441. */
  31442. get isBlocked(): boolean;
  31443. /**
  31444. * Returns the mesh itself by default. Implemented by child classes
  31445. * @param camera defines the camera to use to pick the right LOD level
  31446. * @returns the currentAbstractMesh
  31447. */
  31448. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31449. /**
  31450. * Returns 0 by default. Implemented by child classes
  31451. * @returns an integer
  31452. */
  31453. getTotalVertices(): number;
  31454. /**
  31455. * Returns a positive integer : the total number of indices in this mesh geometry.
  31456. * @returns the numner of indices or zero if the mesh has no geometry.
  31457. */
  31458. getTotalIndices(): number;
  31459. /**
  31460. * Returns null by default. Implemented by child classes
  31461. * @returns null
  31462. */
  31463. getIndices(): Nullable<IndicesArray>;
  31464. /**
  31465. * Returns the array of the requested vertex data kind. Implemented by child classes
  31466. * @param kind defines the vertex data kind to use
  31467. * @returns null
  31468. */
  31469. getVerticesData(kind: string): Nullable<FloatArray>;
  31470. /**
  31471. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31472. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31473. * Note that a new underlying VertexBuffer object is created each call.
  31474. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31475. * @param kind defines vertex data kind:
  31476. * * VertexBuffer.PositionKind
  31477. * * VertexBuffer.UVKind
  31478. * * VertexBuffer.UV2Kind
  31479. * * VertexBuffer.UV3Kind
  31480. * * VertexBuffer.UV4Kind
  31481. * * VertexBuffer.UV5Kind
  31482. * * VertexBuffer.UV6Kind
  31483. * * VertexBuffer.ColorKind
  31484. * * VertexBuffer.MatricesIndicesKind
  31485. * * VertexBuffer.MatricesIndicesExtraKind
  31486. * * VertexBuffer.MatricesWeightsKind
  31487. * * VertexBuffer.MatricesWeightsExtraKind
  31488. * @param data defines the data source
  31489. * @param updatable defines if the data must be flagged as updatable (or static)
  31490. * @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
  31491. * @returns the current mesh
  31492. */
  31493. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31494. /**
  31495. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31496. * If the mesh has no geometry, it is simply returned as it is.
  31497. * @param kind defines vertex data kind:
  31498. * * VertexBuffer.PositionKind
  31499. * * VertexBuffer.UVKind
  31500. * * VertexBuffer.UV2Kind
  31501. * * VertexBuffer.UV3Kind
  31502. * * VertexBuffer.UV4Kind
  31503. * * VertexBuffer.UV5Kind
  31504. * * VertexBuffer.UV6Kind
  31505. * * VertexBuffer.ColorKind
  31506. * * VertexBuffer.MatricesIndicesKind
  31507. * * VertexBuffer.MatricesIndicesExtraKind
  31508. * * VertexBuffer.MatricesWeightsKind
  31509. * * VertexBuffer.MatricesWeightsExtraKind
  31510. * @param data defines the data source
  31511. * @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
  31512. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31513. * @returns the current mesh
  31514. */
  31515. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31516. /**
  31517. * Sets the mesh indices,
  31518. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31519. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31520. * @param totalVertices Defines the total number of vertices
  31521. * @returns the current mesh
  31522. */
  31523. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31524. /**
  31525. * Gets a boolean indicating if specific vertex data is present
  31526. * @param kind defines the vertex data kind to use
  31527. * @returns true is data kind is present
  31528. */
  31529. isVerticesDataPresent(kind: string): boolean;
  31530. /**
  31531. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31532. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31533. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31534. * @returns a BoundingInfo
  31535. */
  31536. getBoundingInfo(): BoundingInfo;
  31537. /**
  31538. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31539. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31540. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31541. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31542. * @returns the current mesh
  31543. */
  31544. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31545. /**
  31546. * Overwrite the current bounding info
  31547. * @param boundingInfo defines the new bounding info
  31548. * @returns the current mesh
  31549. */
  31550. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31551. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31552. get useBones(): boolean;
  31553. /** @hidden */
  31554. _preActivate(): void;
  31555. /** @hidden */
  31556. _preActivateForIntermediateRendering(renderId: number): void;
  31557. /** @hidden */
  31558. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31559. /** @hidden */
  31560. _postActivate(): void;
  31561. /** @hidden */
  31562. _freeze(): void;
  31563. /** @hidden */
  31564. _unFreeze(): void;
  31565. /**
  31566. * Gets the current world matrix
  31567. * @returns a Matrix
  31568. */
  31569. getWorldMatrix(): Matrix;
  31570. /** @hidden */
  31571. _getWorldMatrixDeterminant(): number;
  31572. /**
  31573. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31574. */
  31575. get isAnInstance(): boolean;
  31576. /**
  31577. * Gets a boolean indicating if this mesh has instances
  31578. */
  31579. get hasInstances(): boolean;
  31580. /**
  31581. * Gets a boolean indicating if this mesh has thin instances
  31582. */
  31583. get hasThinInstances(): boolean;
  31584. /**
  31585. * Perform relative position change from the point of view of behind the front of the mesh.
  31586. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31587. * Supports definition of mesh facing forward or backward
  31588. * @param amountRight defines the distance on the right axis
  31589. * @param amountUp defines the distance on the up axis
  31590. * @param amountForward defines the distance on the forward axis
  31591. * @returns the current mesh
  31592. */
  31593. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31594. /**
  31595. * Calculate relative position change from the point of view of behind the front of the mesh.
  31596. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31597. * Supports definition of mesh facing forward or backward
  31598. * @param amountRight defines the distance on the right axis
  31599. * @param amountUp defines the distance on the up axis
  31600. * @param amountForward defines the distance on the forward axis
  31601. * @returns the new displacement vector
  31602. */
  31603. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31604. /**
  31605. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31606. * Supports definition of mesh facing forward or backward
  31607. * @param flipBack defines the flip
  31608. * @param twirlClockwise defines the twirl
  31609. * @param tiltRight defines the tilt
  31610. * @returns the current mesh
  31611. */
  31612. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31613. /**
  31614. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31615. * Supports definition of mesh facing forward or backward.
  31616. * @param flipBack defines the flip
  31617. * @param twirlClockwise defines the twirl
  31618. * @param tiltRight defines the tilt
  31619. * @returns the new rotation vector
  31620. */
  31621. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31622. /**
  31623. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31624. * This means the mesh underlying bounding box and sphere are recomputed.
  31625. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31626. * @returns the current mesh
  31627. */
  31628. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31629. /** @hidden */
  31630. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31631. /** @hidden */
  31632. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31633. /** @hidden */
  31634. _updateBoundingInfo(): AbstractMesh;
  31635. /** @hidden */
  31636. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31637. /** @hidden */
  31638. protected _afterComputeWorldMatrix(): void;
  31639. /** @hidden */
  31640. get _effectiveMesh(): AbstractMesh;
  31641. /**
  31642. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31643. * A mesh is in the frustum if its bounding box intersects the frustum
  31644. * @param frustumPlanes defines the frustum to test
  31645. * @returns true if the mesh is in the frustum planes
  31646. */
  31647. isInFrustum(frustumPlanes: Plane[]): boolean;
  31648. /**
  31649. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31650. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31651. * @param frustumPlanes defines the frustum to test
  31652. * @returns true if the mesh is completely in the frustum planes
  31653. */
  31654. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31655. /**
  31656. * True if the mesh intersects another mesh or a SolidParticle object
  31657. * @param mesh defines a target mesh or SolidParticle to test
  31658. * @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)
  31659. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31660. * @returns true if there is an intersection
  31661. */
  31662. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31663. /**
  31664. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31665. * @param point defines the point to test
  31666. * @returns true if there is an intersection
  31667. */
  31668. intersectsPoint(point: Vector3): boolean;
  31669. /**
  31670. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31671. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31672. */
  31673. get checkCollisions(): boolean;
  31674. set checkCollisions(collisionEnabled: boolean);
  31675. /**
  31676. * Gets Collider object used to compute collisions (not physics)
  31677. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31678. */
  31679. get collider(): Nullable<Collider>;
  31680. /**
  31681. * Move the mesh using collision engine
  31682. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31683. * @param displacement defines the requested displacement vector
  31684. * @returns the current mesh
  31685. */
  31686. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31687. private _onCollisionPositionChange;
  31688. /** @hidden */
  31689. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31690. /** @hidden */
  31691. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31692. /** @hidden */
  31693. _checkCollision(collider: Collider): AbstractMesh;
  31694. /** @hidden */
  31695. _generatePointsArray(): boolean;
  31696. /**
  31697. * Checks if the passed Ray intersects with the mesh
  31698. * @param ray defines the ray to use
  31699. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31700. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31701. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31702. * @returns the picking info
  31703. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31704. */
  31705. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31706. /**
  31707. * Clones the current mesh
  31708. * @param name defines the mesh name
  31709. * @param newParent defines the new mesh parent
  31710. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31711. * @returns the new mesh
  31712. */
  31713. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31714. /**
  31715. * Disposes all the submeshes of the current meshnp
  31716. * @returns the current mesh
  31717. */
  31718. releaseSubMeshes(): AbstractMesh;
  31719. /**
  31720. * Releases resources associated with this abstract mesh.
  31721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31723. */
  31724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31725. /**
  31726. * Adds the passed mesh as a child to the current mesh
  31727. * @param mesh defines the child mesh
  31728. * @returns the current mesh
  31729. */
  31730. addChild(mesh: AbstractMesh): AbstractMesh;
  31731. /**
  31732. * Removes the passed mesh from the current mesh children list
  31733. * @param mesh defines the child mesh
  31734. * @returns the current mesh
  31735. */
  31736. removeChild(mesh: AbstractMesh): AbstractMesh;
  31737. /** @hidden */
  31738. private _initFacetData;
  31739. /**
  31740. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31741. * This method can be called within the render loop.
  31742. * 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
  31743. * @returns the current mesh
  31744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31745. */
  31746. updateFacetData(): AbstractMesh;
  31747. /**
  31748. * Returns the facetLocalNormals array.
  31749. * The normals are expressed in the mesh local spac
  31750. * @returns an array of Vector3
  31751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31752. */
  31753. getFacetLocalNormals(): Vector3[];
  31754. /**
  31755. * Returns the facetLocalPositions array.
  31756. * The facet positions are expressed in the mesh local space
  31757. * @returns an array of Vector3
  31758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31759. */
  31760. getFacetLocalPositions(): Vector3[];
  31761. /**
  31762. * Returns the facetLocalPartioning array
  31763. * @returns an array of array of numbers
  31764. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31765. */
  31766. getFacetLocalPartitioning(): number[][];
  31767. /**
  31768. * Returns the i-th facet position in the world system.
  31769. * This method allocates a new Vector3 per call
  31770. * @param i defines the facet index
  31771. * @returns a new Vector3
  31772. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31773. */
  31774. getFacetPosition(i: number): Vector3;
  31775. /**
  31776. * Sets the reference Vector3 with the i-th facet position in the world system
  31777. * @param i defines the facet index
  31778. * @param ref defines the target vector
  31779. * @returns the current mesh
  31780. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31781. */
  31782. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31783. /**
  31784. * Returns the i-th facet normal in the world system.
  31785. * This method allocates a new Vector3 per call
  31786. * @param i defines the facet index
  31787. * @returns a new Vector3
  31788. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31789. */
  31790. getFacetNormal(i: number): Vector3;
  31791. /**
  31792. * Sets the reference Vector3 with the i-th facet normal in the world system
  31793. * @param i defines the facet index
  31794. * @param ref defines the target vector
  31795. * @returns the current mesh
  31796. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31797. */
  31798. getFacetNormalToRef(i: number, ref: Vector3): this;
  31799. /**
  31800. * 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)
  31801. * @param x defines x coordinate
  31802. * @param y defines y coordinate
  31803. * @param z defines z coordinate
  31804. * @returns the array of facet indexes
  31805. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31806. */
  31807. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31808. /**
  31809. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31810. * @param projected sets as the (x,y,z) world projection on the facet
  31811. * @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
  31812. * @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
  31813. * @param x defines x coordinate
  31814. * @param y defines y coordinate
  31815. * @param z defines z coordinate
  31816. * @returns the face index if found (or null instead)
  31817. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31818. */
  31819. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31820. /**
  31821. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31822. * @param projected sets as the (x,y,z) local projection on the facet
  31823. * @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
  31824. * @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
  31825. * @param x defines x coordinate
  31826. * @param y defines y coordinate
  31827. * @param z defines z coordinate
  31828. * @returns the face index if found (or null instead)
  31829. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31830. */
  31831. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31832. /**
  31833. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31834. * @returns the parameters
  31835. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31836. */
  31837. getFacetDataParameters(): any;
  31838. /**
  31839. * Disables the feature FacetData and frees the related memory
  31840. * @returns the current mesh
  31841. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  31842. */
  31843. disableFacetData(): AbstractMesh;
  31844. /**
  31845. * Updates the AbstractMesh indices array
  31846. * @param indices defines the data source
  31847. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31848. * @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)
  31849. * @returns the current mesh
  31850. */
  31851. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31852. /**
  31853. * Creates new normals data for the mesh
  31854. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31855. * @returns the current mesh
  31856. */
  31857. createNormals(updatable: boolean): AbstractMesh;
  31858. /**
  31859. * Align the mesh with a normal
  31860. * @param normal defines the normal to use
  31861. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31862. * @returns the current mesh
  31863. */
  31864. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31865. /** @hidden */
  31866. _checkOcclusionQuery(): boolean;
  31867. /**
  31868. * Disables the mesh edge rendering mode
  31869. * @returns the currentAbstractMesh
  31870. */
  31871. disableEdgesRendering(): AbstractMesh;
  31872. /**
  31873. * Enables the edge rendering mode on the mesh.
  31874. * This mode makes the mesh edges visible
  31875. * @param epsilon defines the maximal distance between two angles to detect a face
  31876. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31877. * @returns the currentAbstractMesh
  31878. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31879. */
  31880. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31881. }
  31882. }
  31883. declare module BABYLON {
  31884. /**
  31885. * Interface used to define ActionEvent
  31886. */
  31887. export interface IActionEvent {
  31888. /** The mesh or sprite that triggered the action */
  31889. source: any;
  31890. /** The X mouse cursor position at the time of the event */
  31891. pointerX: number;
  31892. /** The Y mouse cursor position at the time of the event */
  31893. pointerY: number;
  31894. /** The mesh that is currently pointed at (can be null) */
  31895. meshUnderPointer: Nullable<AbstractMesh>;
  31896. /** the original (browser) event that triggered the ActionEvent */
  31897. sourceEvent?: any;
  31898. /** additional data for the event */
  31899. additionalData?: any;
  31900. }
  31901. /**
  31902. * ActionEvent is the event being sent when an action is triggered.
  31903. */
  31904. export class ActionEvent implements IActionEvent {
  31905. /** The mesh or sprite that triggered the action */
  31906. source: any;
  31907. /** The X mouse cursor position at the time of the event */
  31908. pointerX: number;
  31909. /** The Y mouse cursor position at the time of the event */
  31910. pointerY: number;
  31911. /** The mesh that is currently pointed at (can be null) */
  31912. meshUnderPointer: Nullable<AbstractMesh>;
  31913. /** the original (browser) event that triggered the ActionEvent */
  31914. sourceEvent?: any;
  31915. /** additional data for the event */
  31916. additionalData?: any;
  31917. /**
  31918. * Creates a new ActionEvent
  31919. * @param source The mesh or sprite that triggered the action
  31920. * @param pointerX The X mouse cursor position at the time of the event
  31921. * @param pointerY The Y mouse cursor position at the time of the event
  31922. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31923. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31924. * @param additionalData additional data for the event
  31925. */
  31926. constructor(
  31927. /** The mesh or sprite that triggered the action */
  31928. source: any,
  31929. /** The X mouse cursor position at the time of the event */
  31930. pointerX: number,
  31931. /** The Y mouse cursor position at the time of the event */
  31932. pointerY: number,
  31933. /** The mesh that is currently pointed at (can be null) */
  31934. meshUnderPointer: Nullable<AbstractMesh>,
  31935. /** the original (browser) event that triggered the ActionEvent */
  31936. sourceEvent?: any,
  31937. /** additional data for the event */
  31938. additionalData?: any);
  31939. /**
  31940. * Helper function to auto-create an ActionEvent from a source mesh.
  31941. * @param source The source mesh that triggered the event
  31942. * @param evt The original (browser) event
  31943. * @param additionalData additional data for the event
  31944. * @returns the new ActionEvent
  31945. */
  31946. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31947. /**
  31948. * Helper function to auto-create an ActionEvent from a source sprite
  31949. * @param source The source sprite that triggered the event
  31950. * @param scene Scene associated with the sprite
  31951. * @param evt The original (browser) event
  31952. * @param additionalData additional data for the event
  31953. * @returns the new ActionEvent
  31954. */
  31955. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31956. /**
  31957. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31958. * @param scene the scene where the event occurred
  31959. * @param evt The original (browser) event
  31960. * @returns the new ActionEvent
  31961. */
  31962. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31963. /**
  31964. * Helper function to auto-create an ActionEvent from a primitive
  31965. * @param prim defines the target primitive
  31966. * @param pointerPos defines the pointer position
  31967. * @param evt The original (browser) event
  31968. * @param additionalData additional data for the event
  31969. * @returns the new ActionEvent
  31970. */
  31971. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31972. }
  31973. }
  31974. declare module BABYLON {
  31975. /**
  31976. * Abstract class used to decouple action Manager from scene and meshes.
  31977. * Do not instantiate.
  31978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31979. */
  31980. export abstract class AbstractActionManager implements IDisposable {
  31981. /** Gets the list of active triggers */
  31982. static Triggers: {
  31983. [key: string]: number;
  31984. };
  31985. /** Gets the cursor to use when hovering items */
  31986. hoverCursor: string;
  31987. /** Gets the list of actions */
  31988. actions: IAction[];
  31989. /**
  31990. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31991. */
  31992. isRecursive: boolean;
  31993. /**
  31994. * Releases all associated resources
  31995. */
  31996. abstract dispose(): void;
  31997. /**
  31998. * Does this action manager has pointer triggers
  31999. */
  32000. abstract get hasPointerTriggers(): boolean;
  32001. /**
  32002. * Does this action manager has pick triggers
  32003. */
  32004. abstract get hasPickTriggers(): boolean;
  32005. /**
  32006. * Process a specific trigger
  32007. * @param trigger defines the trigger to process
  32008. * @param evt defines the event details to be processed
  32009. */
  32010. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32011. /**
  32012. * Does this action manager handles actions of any of the given triggers
  32013. * @param triggers defines the triggers to be tested
  32014. * @return a boolean indicating whether one (or more) of the triggers is handled
  32015. */
  32016. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32017. /**
  32018. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32019. * speed.
  32020. * @param triggerA defines the trigger to be tested
  32021. * @param triggerB defines the trigger to be tested
  32022. * @return a boolean indicating whether one (or more) of the triggers is handled
  32023. */
  32024. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32025. /**
  32026. * Does this action manager handles actions of a given trigger
  32027. * @param trigger defines the trigger to be tested
  32028. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32029. * @return whether the trigger is handled
  32030. */
  32031. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32032. /**
  32033. * Serialize this manager to a JSON object
  32034. * @param name defines the property name to store this manager
  32035. * @returns a JSON representation of this manager
  32036. */
  32037. abstract serialize(name: string): any;
  32038. /**
  32039. * Registers an action to this action manager
  32040. * @param action defines the action to be registered
  32041. * @return the action amended (prepared) after registration
  32042. */
  32043. abstract registerAction(action: IAction): Nullable<IAction>;
  32044. /**
  32045. * Unregisters an action to this action manager
  32046. * @param action defines the action to be unregistered
  32047. * @return a boolean indicating whether the action has been unregistered
  32048. */
  32049. abstract unregisterAction(action: IAction): Boolean;
  32050. /**
  32051. * Does exist one action manager with at least one trigger
  32052. **/
  32053. static get HasTriggers(): boolean;
  32054. /**
  32055. * Does exist one action manager with at least one pick trigger
  32056. **/
  32057. static get HasPickTriggers(): boolean;
  32058. /**
  32059. * Does exist one action manager that handles actions of a given trigger
  32060. * @param trigger defines the trigger to be tested
  32061. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32062. **/
  32063. static HasSpecificTrigger(trigger: number): boolean;
  32064. }
  32065. }
  32066. declare module BABYLON {
  32067. /**
  32068. * Defines how a node can be built from a string name.
  32069. */
  32070. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32071. /**
  32072. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32073. */
  32074. export class Node implements IBehaviorAware<Node> {
  32075. /** @hidden */
  32076. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32077. private static _NodeConstructors;
  32078. /**
  32079. * Add a new node constructor
  32080. * @param type defines the type name of the node to construct
  32081. * @param constructorFunc defines the constructor function
  32082. */
  32083. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32084. /**
  32085. * Returns a node constructor based on type name
  32086. * @param type defines the type name
  32087. * @param name defines the new node name
  32088. * @param scene defines the hosting scene
  32089. * @param options defines optional options to transmit to constructors
  32090. * @returns the new constructor or null
  32091. */
  32092. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32093. /**
  32094. * Gets or sets the name of the node
  32095. */
  32096. name: string;
  32097. /**
  32098. * Gets or sets the id of the node
  32099. */
  32100. id: string;
  32101. /**
  32102. * Gets or sets the unique id of the node
  32103. */
  32104. uniqueId: number;
  32105. /**
  32106. * Gets or sets a string used to store user defined state for the node
  32107. */
  32108. state: string;
  32109. /**
  32110. * Gets or sets an object used to store user defined information for the node
  32111. */
  32112. metadata: any;
  32113. /**
  32114. * For internal use only. Please do not use.
  32115. */
  32116. reservedDataStore: any;
  32117. /**
  32118. * List of inspectable custom properties (used by the Inspector)
  32119. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32120. */
  32121. inspectableCustomProperties: IInspectable[];
  32122. private _doNotSerialize;
  32123. /**
  32124. * Gets or sets a boolean used to define if the node must be serialized
  32125. */
  32126. get doNotSerialize(): boolean;
  32127. set doNotSerialize(value: boolean);
  32128. /** @hidden */
  32129. _isDisposed: boolean;
  32130. /**
  32131. * Gets a list of Animations associated with the node
  32132. */
  32133. animations: Animation[];
  32134. protected _ranges: {
  32135. [name: string]: Nullable<AnimationRange>;
  32136. };
  32137. /**
  32138. * Callback raised when the node is ready to be used
  32139. */
  32140. onReady: Nullable<(node: Node) => void>;
  32141. private _isEnabled;
  32142. private _isParentEnabled;
  32143. private _isReady;
  32144. /** @hidden */
  32145. _currentRenderId: number;
  32146. private _parentUpdateId;
  32147. /** @hidden */
  32148. _childUpdateId: number;
  32149. /** @hidden */
  32150. _waitingParentId: Nullable<string>;
  32151. /** @hidden */
  32152. _scene: Scene;
  32153. /** @hidden */
  32154. _cache: any;
  32155. private _parentNode;
  32156. private _children;
  32157. /** @hidden */
  32158. _worldMatrix: Matrix;
  32159. /** @hidden */
  32160. _worldMatrixDeterminant: number;
  32161. /** @hidden */
  32162. _worldMatrixDeterminantIsDirty: boolean;
  32163. /** @hidden */
  32164. private _sceneRootNodesIndex;
  32165. /**
  32166. * Gets a boolean indicating if the node has been disposed
  32167. * @returns true if the node was disposed
  32168. */
  32169. isDisposed(): boolean;
  32170. /**
  32171. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32172. * @see https://doc.babylonjs.com/how_to/parenting
  32173. */
  32174. set parent(parent: Nullable<Node>);
  32175. get parent(): Nullable<Node>;
  32176. /** @hidden */
  32177. _addToSceneRootNodes(): void;
  32178. /** @hidden */
  32179. _removeFromSceneRootNodes(): void;
  32180. private _animationPropertiesOverride;
  32181. /**
  32182. * Gets or sets the animation properties override
  32183. */
  32184. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32185. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32186. /**
  32187. * Gets a string idenfifying the name of the class
  32188. * @returns "Node" string
  32189. */
  32190. getClassName(): string;
  32191. /** @hidden */
  32192. readonly _isNode: boolean;
  32193. /**
  32194. * An event triggered when the mesh is disposed
  32195. */
  32196. onDisposeObservable: Observable<Node>;
  32197. private _onDisposeObserver;
  32198. /**
  32199. * Sets a callback that will be raised when the node will be disposed
  32200. */
  32201. set onDispose(callback: () => void);
  32202. /**
  32203. * Creates a new Node
  32204. * @param name the name and id to be given to this node
  32205. * @param scene the scene this node will be added to
  32206. */
  32207. constructor(name: string, scene?: Nullable<Scene>);
  32208. /**
  32209. * Gets the scene of the node
  32210. * @returns a scene
  32211. */
  32212. getScene(): Scene;
  32213. /**
  32214. * Gets the engine of the node
  32215. * @returns a Engine
  32216. */
  32217. getEngine(): Engine;
  32218. private _behaviors;
  32219. /**
  32220. * Attach a behavior to the node
  32221. * @see http://doc.babylonjs.com/features/behaviour
  32222. * @param behavior defines the behavior to attach
  32223. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32224. * @returns the current Node
  32225. */
  32226. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32227. /**
  32228. * Remove an attached behavior
  32229. * @see http://doc.babylonjs.com/features/behaviour
  32230. * @param behavior defines the behavior to attach
  32231. * @returns the current Node
  32232. */
  32233. removeBehavior(behavior: Behavior<Node>): Node;
  32234. /**
  32235. * Gets the list of attached behaviors
  32236. * @see http://doc.babylonjs.com/features/behaviour
  32237. */
  32238. get behaviors(): Behavior<Node>[];
  32239. /**
  32240. * Gets an attached behavior by name
  32241. * @param name defines the name of the behavior to look for
  32242. * @see http://doc.babylonjs.com/features/behaviour
  32243. * @returns null if behavior was not found else the requested behavior
  32244. */
  32245. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32246. /**
  32247. * Returns the latest update of the World matrix
  32248. * @returns a Matrix
  32249. */
  32250. getWorldMatrix(): Matrix;
  32251. /** @hidden */
  32252. _getWorldMatrixDeterminant(): number;
  32253. /**
  32254. * Returns directly the latest state of the mesh World matrix.
  32255. * A Matrix is returned.
  32256. */
  32257. get worldMatrixFromCache(): Matrix;
  32258. /** @hidden */
  32259. _initCache(): void;
  32260. /** @hidden */
  32261. updateCache(force?: boolean): void;
  32262. /** @hidden */
  32263. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32264. /** @hidden */
  32265. _updateCache(ignoreParentClass?: boolean): void;
  32266. /** @hidden */
  32267. _isSynchronized(): boolean;
  32268. /** @hidden */
  32269. _markSyncedWithParent(): void;
  32270. /** @hidden */
  32271. isSynchronizedWithParent(): boolean;
  32272. /** @hidden */
  32273. isSynchronized(): boolean;
  32274. /**
  32275. * Is this node ready to be used/rendered
  32276. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32277. * @return true if the node is ready
  32278. */
  32279. isReady(completeCheck?: boolean): boolean;
  32280. /**
  32281. * Is this node enabled?
  32282. * 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
  32283. * @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
  32284. * @return whether this node (and its parent) is enabled
  32285. */
  32286. isEnabled(checkAncestors?: boolean): boolean;
  32287. /** @hidden */
  32288. protected _syncParentEnabledState(): void;
  32289. /**
  32290. * Set the enabled state of this node
  32291. * @param value defines the new enabled state
  32292. */
  32293. setEnabled(value: boolean): void;
  32294. /**
  32295. * Is this node a descendant of the given node?
  32296. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32297. * @param ancestor defines the parent node to inspect
  32298. * @returns a boolean indicating if this node is a descendant of the given node
  32299. */
  32300. isDescendantOf(ancestor: Node): boolean;
  32301. /** @hidden */
  32302. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32303. /**
  32304. * Will return all nodes that have this node as ascendant
  32305. * @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
  32306. * @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
  32307. * @return all children nodes of all types
  32308. */
  32309. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32310. /**
  32311. * Get all child-meshes of this node
  32312. * @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)
  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. * @returns an array of AbstractMesh
  32315. */
  32316. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32317. /**
  32318. * Get all direct children of this node
  32319. * @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
  32320. * @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)
  32321. * @returns an array of Node
  32322. */
  32323. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32324. /** @hidden */
  32325. _setReady(state: boolean): void;
  32326. /**
  32327. * Get an animation by name
  32328. * @param name defines the name of the animation to look for
  32329. * @returns null if not found else the requested animation
  32330. */
  32331. getAnimationByName(name: string): Nullable<Animation>;
  32332. /**
  32333. * Creates an animation range for this node
  32334. * @param name defines the name of the range
  32335. * @param from defines the starting key
  32336. * @param to defines the end key
  32337. */
  32338. createAnimationRange(name: string, from: number, to: number): void;
  32339. /**
  32340. * Delete a specific animation range
  32341. * @param name defines the name of the range to delete
  32342. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32343. */
  32344. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32345. /**
  32346. * Get an animation range by name
  32347. * @param name defines the name of the animation range to look for
  32348. * @returns null if not found else the requested animation range
  32349. */
  32350. getAnimationRange(name: string): Nullable<AnimationRange>;
  32351. /**
  32352. * Gets the list of all animation ranges defined on this node
  32353. * @returns an array
  32354. */
  32355. getAnimationRanges(): Nullable<AnimationRange>[];
  32356. /**
  32357. * Will start the animation sequence
  32358. * @param name defines the range frames for animation sequence
  32359. * @param loop defines if the animation should loop (false by default)
  32360. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32361. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32362. * @returns the object created for this animation. If range does not exist, it will return null
  32363. */
  32364. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32365. /**
  32366. * Serialize animation ranges into a JSON compatible object
  32367. * @returns serialization object
  32368. */
  32369. serializeAnimationRanges(): any;
  32370. /**
  32371. * Computes the world matrix of the node
  32372. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32373. * @returns the world matrix
  32374. */
  32375. computeWorldMatrix(force?: boolean): Matrix;
  32376. /**
  32377. * Releases resources associated with this node.
  32378. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32379. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32380. */
  32381. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32382. /**
  32383. * Parse animation range data from a serialization object and store them into a given node
  32384. * @param node defines where to store the animation ranges
  32385. * @param parsedNode defines the serialization object to read data from
  32386. * @param scene defines the hosting scene
  32387. */
  32388. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32389. /**
  32390. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32391. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32392. * @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
  32393. * @returns the new bounding vectors
  32394. */
  32395. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32396. min: Vector3;
  32397. max: Vector3;
  32398. };
  32399. }
  32400. }
  32401. declare module BABYLON {
  32402. /**
  32403. * @hidden
  32404. */
  32405. export class _IAnimationState {
  32406. key: number;
  32407. repeatCount: number;
  32408. workValue?: any;
  32409. loopMode?: number;
  32410. offsetValue?: any;
  32411. highLimitValue?: any;
  32412. }
  32413. /**
  32414. * Class used to store any kind of animation
  32415. */
  32416. export class Animation {
  32417. /**Name of the animation */
  32418. name: string;
  32419. /**Property to animate */
  32420. targetProperty: string;
  32421. /**The frames per second of the animation */
  32422. framePerSecond: number;
  32423. /**The data type of the animation */
  32424. dataType: number;
  32425. /**The loop mode of the animation */
  32426. loopMode?: number | undefined;
  32427. /**Specifies if blending should be enabled */
  32428. enableBlending?: boolean | undefined;
  32429. /**
  32430. * Use matrix interpolation instead of using direct key value when animating matrices
  32431. */
  32432. static AllowMatricesInterpolation: boolean;
  32433. /**
  32434. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32435. */
  32436. static AllowMatrixDecomposeForInterpolation: boolean;
  32437. /** Define the Url to load snippets */
  32438. static SnippetUrl: string;
  32439. /** Snippet ID if the animation was created from the snippet server */
  32440. snippetId: string;
  32441. /**
  32442. * Stores the key frames of the animation
  32443. */
  32444. private _keys;
  32445. /**
  32446. * Stores the easing function of the animation
  32447. */
  32448. private _easingFunction;
  32449. /**
  32450. * @hidden Internal use only
  32451. */
  32452. _runtimeAnimations: RuntimeAnimation[];
  32453. /**
  32454. * The set of event that will be linked to this animation
  32455. */
  32456. private _events;
  32457. /**
  32458. * Stores an array of target property paths
  32459. */
  32460. targetPropertyPath: string[];
  32461. /**
  32462. * Stores the blending speed of the animation
  32463. */
  32464. blendingSpeed: number;
  32465. /**
  32466. * Stores the animation ranges for the animation
  32467. */
  32468. private _ranges;
  32469. /**
  32470. * @hidden Internal use
  32471. */
  32472. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32473. /**
  32474. * Sets up an animation
  32475. * @param property The property to animate
  32476. * @param animationType The animation type to apply
  32477. * @param framePerSecond The frames per second of the animation
  32478. * @param easingFunction The easing function used in the animation
  32479. * @returns The created animation
  32480. */
  32481. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32482. /**
  32483. * Create and start an animation on a node
  32484. * @param name defines the name of the global animation that will be run on all nodes
  32485. * @param node defines the root node where the animation will take place
  32486. * @param targetProperty defines property to animate
  32487. * @param framePerSecond defines the number of frame per second yo use
  32488. * @param totalFrame defines the number of frames in total
  32489. * @param from defines the initial value
  32490. * @param to defines the final value
  32491. * @param loopMode defines which loop mode you want to use (off by default)
  32492. * @param easingFunction defines the easing function to use (linear by default)
  32493. * @param onAnimationEnd defines the callback to call when animation end
  32494. * @returns the animatable created for this animation
  32495. */
  32496. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32497. /**
  32498. * Create and start an animation on a node and its descendants
  32499. * @param name defines the name of the global animation that will be run on all nodes
  32500. * @param node defines the root node where the animation will take place
  32501. * @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
  32502. * @param targetProperty defines property to animate
  32503. * @param framePerSecond defines the number of frame per second to use
  32504. * @param totalFrame defines the number of frames in total
  32505. * @param from defines the initial value
  32506. * @param to defines the final value
  32507. * @param loopMode defines which loop mode you want to use (off by default)
  32508. * @param easingFunction defines the easing function to use (linear by default)
  32509. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32510. * @returns the list of animatables created for all nodes
  32511. * @example https://www.babylonjs-playground.com/#MH0VLI
  32512. */
  32513. 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[]>;
  32514. /**
  32515. * Creates a new animation, merges it with the existing animations and starts it
  32516. * @param name Name of the animation
  32517. * @param node Node which contains the scene that begins the animations
  32518. * @param targetProperty Specifies which property to animate
  32519. * @param framePerSecond The frames per second of the animation
  32520. * @param totalFrame The total number of frames
  32521. * @param from The frame at the beginning of the animation
  32522. * @param to The frame at the end of the animation
  32523. * @param loopMode Specifies the loop mode of the animation
  32524. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32525. * @param onAnimationEnd Callback to run once the animation is complete
  32526. * @returns Nullable animation
  32527. */
  32528. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32529. /**
  32530. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32531. * @param sourceAnimation defines the Animation containing keyframes to convert
  32532. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32533. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32534. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32535. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32536. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32537. */
  32538. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32539. /**
  32540. * Transition property of an host to the target Value
  32541. * @param property The property to transition
  32542. * @param targetValue The target Value of the property
  32543. * @param host The object where the property to animate belongs
  32544. * @param scene Scene used to run the animation
  32545. * @param frameRate Framerate (in frame/s) to use
  32546. * @param transition The transition type we want to use
  32547. * @param duration The duration of the animation, in milliseconds
  32548. * @param onAnimationEnd Callback trigger at the end of the animation
  32549. * @returns Nullable animation
  32550. */
  32551. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32552. /**
  32553. * Return the array of runtime animations currently using this animation
  32554. */
  32555. get runtimeAnimations(): RuntimeAnimation[];
  32556. /**
  32557. * Specifies if any of the runtime animations are currently running
  32558. */
  32559. get hasRunningRuntimeAnimations(): boolean;
  32560. /**
  32561. * Initializes the animation
  32562. * @param name Name of the animation
  32563. * @param targetProperty Property to animate
  32564. * @param framePerSecond The frames per second of the animation
  32565. * @param dataType The data type of the animation
  32566. * @param loopMode The loop mode of the animation
  32567. * @param enableBlending Specifies if blending should be enabled
  32568. */
  32569. constructor(
  32570. /**Name of the animation */
  32571. name: string,
  32572. /**Property to animate */
  32573. targetProperty: string,
  32574. /**The frames per second of the animation */
  32575. framePerSecond: number,
  32576. /**The data type of the animation */
  32577. dataType: number,
  32578. /**The loop mode of the animation */
  32579. loopMode?: number | undefined,
  32580. /**Specifies if blending should be enabled */
  32581. enableBlending?: boolean | undefined);
  32582. /**
  32583. * Converts the animation to a string
  32584. * @param fullDetails support for multiple levels of logging within scene loading
  32585. * @returns String form of the animation
  32586. */
  32587. toString(fullDetails?: boolean): string;
  32588. /**
  32589. * Add an event to this animation
  32590. * @param event Event to add
  32591. */
  32592. addEvent(event: AnimationEvent): void;
  32593. /**
  32594. * Remove all events found at the given frame
  32595. * @param frame The frame to remove events from
  32596. */
  32597. removeEvents(frame: number): void;
  32598. /**
  32599. * Retrieves all the events from the animation
  32600. * @returns Events from the animation
  32601. */
  32602. getEvents(): AnimationEvent[];
  32603. /**
  32604. * Creates an animation range
  32605. * @param name Name of the animation range
  32606. * @param from Starting frame of the animation range
  32607. * @param to Ending frame of the animation
  32608. */
  32609. createRange(name: string, from: number, to: number): void;
  32610. /**
  32611. * Deletes an animation range by name
  32612. * @param name Name of the animation range to delete
  32613. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32614. */
  32615. deleteRange(name: string, deleteFrames?: boolean): void;
  32616. /**
  32617. * Gets the animation range by name, or null if not defined
  32618. * @param name Name of the animation range
  32619. * @returns Nullable animation range
  32620. */
  32621. getRange(name: string): Nullable<AnimationRange>;
  32622. /**
  32623. * Gets the key frames from the animation
  32624. * @returns The key frames of the animation
  32625. */
  32626. getKeys(): Array<IAnimationKey>;
  32627. /**
  32628. * Gets the highest frame rate of the animation
  32629. * @returns Highest frame rate of the animation
  32630. */
  32631. getHighestFrame(): number;
  32632. /**
  32633. * Gets the easing function of the animation
  32634. * @returns Easing function of the animation
  32635. */
  32636. getEasingFunction(): IEasingFunction;
  32637. /**
  32638. * Sets the easing function of the animation
  32639. * @param easingFunction A custom mathematical formula for animation
  32640. */
  32641. setEasingFunction(easingFunction: EasingFunction): void;
  32642. /**
  32643. * Interpolates a scalar linearly
  32644. * @param startValue Start value of the animation curve
  32645. * @param endValue End value of the animation curve
  32646. * @param gradient Scalar amount to interpolate
  32647. * @returns Interpolated scalar value
  32648. */
  32649. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32650. /**
  32651. * Interpolates a scalar cubically
  32652. * @param startValue Start value of the animation curve
  32653. * @param outTangent End tangent of the animation
  32654. * @param endValue End value of the animation curve
  32655. * @param inTangent Start tangent of the animation curve
  32656. * @param gradient Scalar amount to interpolate
  32657. * @returns Interpolated scalar value
  32658. */
  32659. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32660. /**
  32661. * Interpolates a quaternion using a spherical linear interpolation
  32662. * @param startValue Start value of the animation curve
  32663. * @param endValue End value of the animation curve
  32664. * @param gradient Scalar amount to interpolate
  32665. * @returns Interpolated quaternion value
  32666. */
  32667. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32668. /**
  32669. * Interpolates a quaternion cubically
  32670. * @param startValue Start value of the animation curve
  32671. * @param outTangent End tangent of the animation curve
  32672. * @param endValue End value of the animation curve
  32673. * @param inTangent Start tangent of the animation curve
  32674. * @param gradient Scalar amount to interpolate
  32675. * @returns Interpolated quaternion value
  32676. */
  32677. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32678. /**
  32679. * Interpolates a Vector3 linearl
  32680. * @param startValue Start value of the animation curve
  32681. * @param endValue End value of the animation curve
  32682. * @param gradient Scalar amount to interpolate
  32683. * @returns Interpolated scalar value
  32684. */
  32685. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32686. /**
  32687. * Interpolates a Vector3 cubically
  32688. * @param startValue Start value of the animation curve
  32689. * @param outTangent End tangent of the animation
  32690. * @param endValue End value of the animation curve
  32691. * @param inTangent Start tangent of the animation curve
  32692. * @param gradient Scalar amount to interpolate
  32693. * @returns InterpolatedVector3 value
  32694. */
  32695. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32696. /**
  32697. * Interpolates a Vector2 linearly
  32698. * @param startValue Start value of the animation curve
  32699. * @param endValue End value of the animation curve
  32700. * @param gradient Scalar amount to interpolate
  32701. * @returns Interpolated Vector2 value
  32702. */
  32703. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32704. /**
  32705. * Interpolates a Vector2 cubically
  32706. * @param startValue Start value of the animation curve
  32707. * @param outTangent End tangent of the animation
  32708. * @param endValue End value of the animation curve
  32709. * @param inTangent Start tangent of the animation curve
  32710. * @param gradient Scalar amount to interpolate
  32711. * @returns Interpolated Vector2 value
  32712. */
  32713. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32714. /**
  32715. * Interpolates a size linearly
  32716. * @param startValue Start value of the animation curve
  32717. * @param endValue End value of the animation curve
  32718. * @param gradient Scalar amount to interpolate
  32719. * @returns Interpolated Size value
  32720. */
  32721. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32722. /**
  32723. * Interpolates a Color3 linearly
  32724. * @param startValue Start value of the animation curve
  32725. * @param endValue End value of the animation curve
  32726. * @param gradient Scalar amount to interpolate
  32727. * @returns Interpolated Color3 value
  32728. */
  32729. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32730. /**
  32731. * Interpolates a Color4 linearly
  32732. * @param startValue Start value of the animation curve
  32733. * @param endValue End value of the animation curve
  32734. * @param gradient Scalar amount to interpolate
  32735. * @returns Interpolated Color3 value
  32736. */
  32737. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32738. /**
  32739. * @hidden Internal use only
  32740. */
  32741. _getKeyValue(value: any): any;
  32742. /**
  32743. * @hidden Internal use only
  32744. */
  32745. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32746. /**
  32747. * Defines the function to use to interpolate matrices
  32748. * @param startValue defines the start matrix
  32749. * @param endValue defines the end matrix
  32750. * @param gradient defines the gradient between both matrices
  32751. * @param result defines an optional target matrix where to store the interpolation
  32752. * @returns the interpolated matrix
  32753. */
  32754. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32755. /**
  32756. * Makes a copy of the animation
  32757. * @returns Cloned animation
  32758. */
  32759. clone(): Animation;
  32760. /**
  32761. * Sets the key frames of the animation
  32762. * @param values The animation key frames to set
  32763. */
  32764. setKeys(values: Array<IAnimationKey>): void;
  32765. /**
  32766. * Serializes the animation to an object
  32767. * @returns Serialized object
  32768. */
  32769. serialize(): any;
  32770. /**
  32771. * Float animation type
  32772. */
  32773. static readonly ANIMATIONTYPE_FLOAT: number;
  32774. /**
  32775. * Vector3 animation type
  32776. */
  32777. static readonly ANIMATIONTYPE_VECTOR3: number;
  32778. /**
  32779. * Quaternion animation type
  32780. */
  32781. static readonly ANIMATIONTYPE_QUATERNION: number;
  32782. /**
  32783. * Matrix animation type
  32784. */
  32785. static readonly ANIMATIONTYPE_MATRIX: number;
  32786. /**
  32787. * Color3 animation type
  32788. */
  32789. static readonly ANIMATIONTYPE_COLOR3: number;
  32790. /**
  32791. * Color3 animation type
  32792. */
  32793. static readonly ANIMATIONTYPE_COLOR4: number;
  32794. /**
  32795. * Vector2 animation type
  32796. */
  32797. static readonly ANIMATIONTYPE_VECTOR2: number;
  32798. /**
  32799. * Size animation type
  32800. */
  32801. static readonly ANIMATIONTYPE_SIZE: number;
  32802. /**
  32803. * Relative Loop Mode
  32804. */
  32805. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32806. /**
  32807. * Cycle Loop Mode
  32808. */
  32809. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32810. /**
  32811. * Constant Loop Mode
  32812. */
  32813. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32814. /** @hidden */
  32815. static _UniversalLerp(left: any, right: any, amount: number): any;
  32816. /**
  32817. * Parses an animation object and creates an animation
  32818. * @param parsedAnimation Parsed animation object
  32819. * @returns Animation object
  32820. */
  32821. static Parse(parsedAnimation: any): Animation;
  32822. /**
  32823. * Appends the serialized animations from the source animations
  32824. * @param source Source containing the animations
  32825. * @param destination Target to store the animations
  32826. */
  32827. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32828. /**
  32829. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32830. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32831. * @param url defines the url to load from
  32832. * @returns a promise that will resolve to the new animation or an array of animations
  32833. */
  32834. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32835. /**
  32836. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32837. * @param snippetId defines the snippet to load
  32838. * @returns a promise that will resolve to the new animation or a new array of animations
  32839. */
  32840. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32841. }
  32842. }
  32843. declare module BABYLON {
  32844. /**
  32845. * Interface containing an array of animations
  32846. */
  32847. export interface IAnimatable {
  32848. /**
  32849. * Array of animations
  32850. */
  32851. animations: Nullable<Array<Animation>>;
  32852. }
  32853. }
  32854. declare module BABYLON {
  32855. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32856. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32857. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32858. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32859. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32860. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32861. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32862. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32863. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32864. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32865. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32866. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32867. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32868. /**
  32869. * Decorator used to define property that can be serialized as reference to a camera
  32870. * @param sourceName defines the name of the property to decorate
  32871. */
  32872. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32873. /**
  32874. * Class used to help serialization objects
  32875. */
  32876. export class SerializationHelper {
  32877. /** @hidden */
  32878. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32879. /** @hidden */
  32880. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32881. /** @hidden */
  32882. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32883. /** @hidden */
  32884. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32885. /**
  32886. * Appends the serialized animations from the source animations
  32887. * @param source Source containing the animations
  32888. * @param destination Target to store the animations
  32889. */
  32890. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32891. /**
  32892. * Static function used to serialized a specific entity
  32893. * @param entity defines the entity to serialize
  32894. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32895. * @returns a JSON compatible object representing the serialization of the entity
  32896. */
  32897. static Serialize<T>(entity: T, serializationObject?: any): any;
  32898. /**
  32899. * Creates a new entity from a serialization data object
  32900. * @param creationFunction defines a function used to instanciated the new entity
  32901. * @param source defines the source serialization data
  32902. * @param scene defines the hosting scene
  32903. * @param rootUrl defines the root url for resources
  32904. * @returns a new entity
  32905. */
  32906. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32907. /**
  32908. * Clones an object
  32909. * @param creationFunction defines the function used to instanciate the new object
  32910. * @param source defines the source object
  32911. * @returns the cloned object
  32912. */
  32913. static Clone<T>(creationFunction: () => T, source: T): T;
  32914. /**
  32915. * Instanciates a new object based on a source one (some data will be shared between both object)
  32916. * @param creationFunction defines the function used to instanciate the new object
  32917. * @param source defines the source object
  32918. * @returns the new object
  32919. */
  32920. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32921. }
  32922. }
  32923. declare module BABYLON {
  32924. /**
  32925. * Base class of all the textures in babylon.
  32926. * It groups all the common properties the materials, post process, lights... might need
  32927. * in order to make a correct use of the texture.
  32928. */
  32929. export class BaseTexture implements IAnimatable {
  32930. /**
  32931. * Default anisotropic filtering level for the application.
  32932. * It is set to 4 as a good tradeoff between perf and quality.
  32933. */
  32934. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32935. /**
  32936. * Gets or sets the unique id of the texture
  32937. */
  32938. uniqueId: number;
  32939. /**
  32940. * Define the name of the texture.
  32941. */
  32942. name: string;
  32943. /**
  32944. * Gets or sets an object used to store user defined information.
  32945. */
  32946. metadata: any;
  32947. /**
  32948. * For internal use only. Please do not use.
  32949. */
  32950. reservedDataStore: any;
  32951. private _hasAlpha;
  32952. /**
  32953. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32954. */
  32955. set hasAlpha(value: boolean);
  32956. get hasAlpha(): boolean;
  32957. /**
  32958. * Defines if the alpha value should be determined via the rgb values.
  32959. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32960. */
  32961. getAlphaFromRGB: boolean;
  32962. /**
  32963. * Intensity or strength of the texture.
  32964. * It is commonly used by materials to fine tune the intensity of the texture
  32965. */
  32966. level: number;
  32967. /**
  32968. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32969. * This is part of the texture as textures usually maps to one uv set.
  32970. */
  32971. coordinatesIndex: number;
  32972. private _coordinatesMode;
  32973. /**
  32974. * How a texture is mapped.
  32975. *
  32976. * | Value | Type | Description |
  32977. * | ----- | ----------------------------------- | ----------- |
  32978. * | 0 | EXPLICIT_MODE | |
  32979. * | 1 | SPHERICAL_MODE | |
  32980. * | 2 | PLANAR_MODE | |
  32981. * | 3 | CUBIC_MODE | |
  32982. * | 4 | PROJECTION_MODE | |
  32983. * | 5 | SKYBOX_MODE | |
  32984. * | 6 | INVCUBIC_MODE | |
  32985. * | 7 | EQUIRECTANGULAR_MODE | |
  32986. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32987. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32988. */
  32989. set coordinatesMode(value: number);
  32990. get coordinatesMode(): number;
  32991. /**
  32992. * | Value | Type | Description |
  32993. * | ----- | ------------------ | ----------- |
  32994. * | 0 | CLAMP_ADDRESSMODE | |
  32995. * | 1 | WRAP_ADDRESSMODE | |
  32996. * | 2 | MIRROR_ADDRESSMODE | |
  32997. */
  32998. wrapU: number;
  32999. /**
  33000. * | Value | Type | Description |
  33001. * | ----- | ------------------ | ----------- |
  33002. * | 0 | CLAMP_ADDRESSMODE | |
  33003. * | 1 | WRAP_ADDRESSMODE | |
  33004. * | 2 | MIRROR_ADDRESSMODE | |
  33005. */
  33006. wrapV: number;
  33007. /**
  33008. * | Value | Type | Description |
  33009. * | ----- | ------------------ | ----------- |
  33010. * | 0 | CLAMP_ADDRESSMODE | |
  33011. * | 1 | WRAP_ADDRESSMODE | |
  33012. * | 2 | MIRROR_ADDRESSMODE | |
  33013. */
  33014. wrapR: number;
  33015. /**
  33016. * With compliant hardware and browser (supporting anisotropic filtering)
  33017. * this defines the level of anisotropic filtering in the texture.
  33018. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33019. */
  33020. anisotropicFilteringLevel: number;
  33021. /**
  33022. * Define if the texture is a cube texture or if false a 2d texture.
  33023. */
  33024. get isCube(): boolean;
  33025. set isCube(value: boolean);
  33026. /**
  33027. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33028. */
  33029. get is3D(): boolean;
  33030. set is3D(value: boolean);
  33031. /**
  33032. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33033. */
  33034. get is2DArray(): boolean;
  33035. set is2DArray(value: boolean);
  33036. /**
  33037. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33038. * HDR texture are usually stored in linear space.
  33039. * This only impacts the PBR and Background materials
  33040. */
  33041. gammaSpace: boolean;
  33042. /**
  33043. * Gets or sets whether or not the texture contains RGBD data.
  33044. */
  33045. get isRGBD(): boolean;
  33046. set isRGBD(value: boolean);
  33047. /**
  33048. * Is Z inverted in the texture (useful in a cube texture).
  33049. */
  33050. invertZ: boolean;
  33051. /**
  33052. * Are mip maps generated for this texture or not.
  33053. */
  33054. get noMipmap(): boolean;
  33055. /**
  33056. * @hidden
  33057. */
  33058. lodLevelInAlpha: boolean;
  33059. /**
  33060. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33061. */
  33062. get lodGenerationOffset(): number;
  33063. set lodGenerationOffset(value: number);
  33064. /**
  33065. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33066. */
  33067. get lodGenerationScale(): number;
  33068. set lodGenerationScale(value: number);
  33069. /**
  33070. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33071. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33072. * average roughness values.
  33073. */
  33074. get linearSpecularLOD(): boolean;
  33075. set linearSpecularLOD(value: boolean);
  33076. /**
  33077. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33078. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33079. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33080. */
  33081. get irradianceTexture(): Nullable<BaseTexture>;
  33082. set irradianceTexture(value: Nullable<BaseTexture>);
  33083. /**
  33084. * Define if the texture is a render target.
  33085. */
  33086. isRenderTarget: boolean;
  33087. /**
  33088. * Define the unique id of the texture in the scene.
  33089. */
  33090. get uid(): string;
  33091. /** @hidden */
  33092. _prefiltered: boolean;
  33093. /**
  33094. * Return a string representation of the texture.
  33095. * @returns the texture as a string
  33096. */
  33097. toString(): string;
  33098. /**
  33099. * Get the class name of the texture.
  33100. * @returns "BaseTexture"
  33101. */
  33102. getClassName(): string;
  33103. /**
  33104. * Define the list of animation attached to the texture.
  33105. */
  33106. animations: Animation[];
  33107. /**
  33108. * An event triggered when the texture is disposed.
  33109. */
  33110. onDisposeObservable: Observable<BaseTexture>;
  33111. private _onDisposeObserver;
  33112. /**
  33113. * Callback triggered when the texture has been disposed.
  33114. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33115. */
  33116. set onDispose(callback: () => void);
  33117. /**
  33118. * Define the current state of the loading sequence when in delayed load mode.
  33119. */
  33120. delayLoadState: number;
  33121. private _scene;
  33122. private _engine;
  33123. /** @hidden */
  33124. _texture: Nullable<InternalTexture>;
  33125. private _uid;
  33126. /**
  33127. * Define if the texture is preventinga material to render or not.
  33128. * If not and the texture is not ready, the engine will use a default black texture instead.
  33129. */
  33130. get isBlocking(): boolean;
  33131. /**
  33132. * Instantiates a new BaseTexture.
  33133. * Base class of all the textures in babylon.
  33134. * It groups all the common properties the materials, post process, lights... might need
  33135. * in order to make a correct use of the texture.
  33136. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33137. */
  33138. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33139. /**
  33140. * Get the scene the texture belongs to.
  33141. * @returns the scene or null if undefined
  33142. */
  33143. getScene(): Nullable<Scene>;
  33144. /** @hidden */
  33145. protected _getEngine(): Nullable<ThinEngine>;
  33146. /**
  33147. * Get the texture transform matrix used to offset tile the texture for istance.
  33148. * @returns the transformation matrix
  33149. */
  33150. getTextureMatrix(): Matrix;
  33151. /**
  33152. * Get the texture reflection matrix used to rotate/transform the reflection.
  33153. * @returns the reflection matrix
  33154. */
  33155. getReflectionTextureMatrix(): Matrix;
  33156. /**
  33157. * Get the underlying lower level texture from Babylon.
  33158. * @returns the insternal texture
  33159. */
  33160. getInternalTexture(): Nullable<InternalTexture>;
  33161. /**
  33162. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33163. * @returns true if ready or not blocking
  33164. */
  33165. isReadyOrNotBlocking(): boolean;
  33166. /**
  33167. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33168. * @returns true if fully ready
  33169. */
  33170. isReady(): boolean;
  33171. private _cachedSize;
  33172. /**
  33173. * Get the size of the texture.
  33174. * @returns the texture size.
  33175. */
  33176. getSize(): ISize;
  33177. /**
  33178. * Get the base size of the texture.
  33179. * It can be different from the size if the texture has been resized for POT for instance
  33180. * @returns the base size
  33181. */
  33182. getBaseSize(): ISize;
  33183. /**
  33184. * Update the sampling mode of the texture.
  33185. * Default is Trilinear mode.
  33186. *
  33187. * | Value | Type | Description |
  33188. * | ----- | ------------------ | ----------- |
  33189. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33190. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33191. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33192. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33193. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33194. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33195. * | 7 | NEAREST_LINEAR | |
  33196. * | 8 | NEAREST_NEAREST | |
  33197. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33198. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33199. * | 11 | LINEAR_LINEAR | |
  33200. * | 12 | LINEAR_NEAREST | |
  33201. *
  33202. * > _mag_: magnification filter (close to the viewer)
  33203. * > _min_: minification filter (far from the viewer)
  33204. * > _mip_: filter used between mip map levels
  33205. *@param samplingMode Define the new sampling mode of the texture
  33206. */
  33207. updateSamplingMode(samplingMode: number): void;
  33208. /**
  33209. * Scales the texture if is `canRescale()`
  33210. * @param ratio the resize factor we want to use to rescale
  33211. */
  33212. scale(ratio: number): void;
  33213. /**
  33214. * Get if the texture can rescale.
  33215. */
  33216. get canRescale(): boolean;
  33217. /** @hidden */
  33218. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33219. /** @hidden */
  33220. _rebuild(): void;
  33221. /**
  33222. * Triggers the load sequence in delayed load mode.
  33223. */
  33224. delayLoad(): void;
  33225. /**
  33226. * Clones the texture.
  33227. * @returns the cloned texture
  33228. */
  33229. clone(): Nullable<BaseTexture>;
  33230. /**
  33231. * Get the texture underlying type (INT, FLOAT...)
  33232. */
  33233. get textureType(): number;
  33234. /**
  33235. * Get the texture underlying format (RGB, RGBA...)
  33236. */
  33237. get textureFormat(): number;
  33238. /**
  33239. * Indicates that textures need to be re-calculated for all materials
  33240. */
  33241. protected _markAllSubMeshesAsTexturesDirty(): void;
  33242. /**
  33243. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33244. * This will returns an RGBA array buffer containing either in values (0-255) or
  33245. * float values (0-1) depending of the underlying buffer type.
  33246. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33247. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33248. * @param buffer defines a user defined buffer to fill with data (can be null)
  33249. * @returns The Array buffer containing the pixels data.
  33250. */
  33251. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33252. /**
  33253. * Release and destroy the underlying lower level texture aka internalTexture.
  33254. */
  33255. releaseInternalTexture(): void;
  33256. /** @hidden */
  33257. get _lodTextureHigh(): Nullable<BaseTexture>;
  33258. /** @hidden */
  33259. get _lodTextureMid(): Nullable<BaseTexture>;
  33260. /** @hidden */
  33261. get _lodTextureLow(): Nullable<BaseTexture>;
  33262. /**
  33263. * Dispose the texture and release its associated resources.
  33264. */
  33265. dispose(): void;
  33266. /**
  33267. * Serialize the texture into a JSON representation that can be parsed later on.
  33268. * @returns the JSON representation of the texture
  33269. */
  33270. serialize(): any;
  33271. /**
  33272. * Helper function to be called back once a list of texture contains only ready textures.
  33273. * @param textures Define the list of textures to wait for
  33274. * @param callback Define the callback triggered once the entire list will be ready
  33275. */
  33276. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33277. private static _isScene;
  33278. }
  33279. }
  33280. declare module BABYLON {
  33281. /**
  33282. * Options to be used when creating an effect.
  33283. */
  33284. export interface IEffectCreationOptions {
  33285. /**
  33286. * Atrributes that will be used in the shader.
  33287. */
  33288. attributes: string[];
  33289. /**
  33290. * Uniform varible names that will be set in the shader.
  33291. */
  33292. uniformsNames: string[];
  33293. /**
  33294. * Uniform buffer variable names that will be set in the shader.
  33295. */
  33296. uniformBuffersNames: string[];
  33297. /**
  33298. * Sampler texture variable names that will be set in the shader.
  33299. */
  33300. samplers: string[];
  33301. /**
  33302. * Define statements that will be set in the shader.
  33303. */
  33304. defines: any;
  33305. /**
  33306. * Possible fallbacks for this effect to improve performance when needed.
  33307. */
  33308. fallbacks: Nullable<IEffectFallbacks>;
  33309. /**
  33310. * Callback that will be called when the shader is compiled.
  33311. */
  33312. onCompiled: Nullable<(effect: Effect) => void>;
  33313. /**
  33314. * Callback that will be called if an error occurs during shader compilation.
  33315. */
  33316. onError: Nullable<(effect: Effect, errors: string) => void>;
  33317. /**
  33318. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33319. */
  33320. indexParameters?: any;
  33321. /**
  33322. * Max number of lights that can be used in the shader.
  33323. */
  33324. maxSimultaneousLights?: number;
  33325. /**
  33326. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33327. */
  33328. transformFeedbackVaryings?: Nullable<string[]>;
  33329. /**
  33330. * 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
  33331. */
  33332. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33333. }
  33334. /**
  33335. * Effect containing vertex and fragment shader that can be executed on an object.
  33336. */
  33337. export class Effect implements IDisposable {
  33338. /**
  33339. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33340. */
  33341. static ShadersRepository: string;
  33342. /**
  33343. * Enable logging of the shader code when a compilation error occurs
  33344. */
  33345. static LogShaderCodeOnCompilationError: boolean;
  33346. /**
  33347. * Name of the effect.
  33348. */
  33349. name: any;
  33350. /**
  33351. * String container all the define statements that should be set on the shader.
  33352. */
  33353. defines: string;
  33354. /**
  33355. * Callback that will be called when the shader is compiled.
  33356. */
  33357. onCompiled: Nullable<(effect: Effect) => void>;
  33358. /**
  33359. * Callback that will be called if an error occurs during shader compilation.
  33360. */
  33361. onError: Nullable<(effect: Effect, errors: string) => void>;
  33362. /**
  33363. * Callback that will be called when effect is bound.
  33364. */
  33365. onBind: Nullable<(effect: Effect) => void>;
  33366. /**
  33367. * Unique ID of the effect.
  33368. */
  33369. uniqueId: number;
  33370. /**
  33371. * Observable that will be called when the shader is compiled.
  33372. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33373. */
  33374. onCompileObservable: Observable<Effect>;
  33375. /**
  33376. * Observable that will be called if an error occurs during shader compilation.
  33377. */
  33378. onErrorObservable: Observable<Effect>;
  33379. /** @hidden */
  33380. _onBindObservable: Nullable<Observable<Effect>>;
  33381. /**
  33382. * @hidden
  33383. * Specifies if the effect was previously ready
  33384. */
  33385. _wasPreviouslyReady: boolean;
  33386. /**
  33387. * Observable that will be called when effect is bound.
  33388. */
  33389. get onBindObservable(): Observable<Effect>;
  33390. /** @hidden */
  33391. _bonesComputationForcedToCPU: boolean;
  33392. private static _uniqueIdSeed;
  33393. private _engine;
  33394. private _uniformBuffersNames;
  33395. private _uniformBuffersNamesList;
  33396. private _uniformsNames;
  33397. private _samplerList;
  33398. private _samplers;
  33399. private _isReady;
  33400. private _compilationError;
  33401. private _allFallbacksProcessed;
  33402. private _attributesNames;
  33403. private _attributes;
  33404. private _attributeLocationByName;
  33405. private _uniforms;
  33406. /**
  33407. * Key for the effect.
  33408. * @hidden
  33409. */
  33410. _key: string;
  33411. private _indexParameters;
  33412. private _fallbacks;
  33413. private _vertexSourceCode;
  33414. private _fragmentSourceCode;
  33415. private _vertexSourceCodeOverride;
  33416. private _fragmentSourceCodeOverride;
  33417. private _transformFeedbackVaryings;
  33418. /**
  33419. * Compiled shader to webGL program.
  33420. * @hidden
  33421. */
  33422. _pipelineContext: Nullable<IPipelineContext>;
  33423. private _valueCache;
  33424. private static _baseCache;
  33425. /**
  33426. * Instantiates an effect.
  33427. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33428. * @param baseName Name of the effect.
  33429. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33430. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33431. * @param samplers List of sampler variables that will be passed to the shader.
  33432. * @param engine Engine to be used to render the effect
  33433. * @param defines Define statements to be added to the shader.
  33434. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33435. * @param onCompiled Callback that will be called when the shader is compiled.
  33436. * @param onError Callback that will be called if an error occurs during shader compilation.
  33437. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33438. */
  33439. 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);
  33440. private _useFinalCode;
  33441. /**
  33442. * Unique key for this effect
  33443. */
  33444. get key(): string;
  33445. /**
  33446. * If the effect has been compiled and prepared.
  33447. * @returns if the effect is compiled and prepared.
  33448. */
  33449. isReady(): boolean;
  33450. private _isReadyInternal;
  33451. /**
  33452. * The engine the effect was initialized with.
  33453. * @returns the engine.
  33454. */
  33455. getEngine(): Engine;
  33456. /**
  33457. * The pipeline context for this effect
  33458. * @returns the associated pipeline context
  33459. */
  33460. getPipelineContext(): Nullable<IPipelineContext>;
  33461. /**
  33462. * The set of names of attribute variables for the shader.
  33463. * @returns An array of attribute names.
  33464. */
  33465. getAttributesNames(): string[];
  33466. /**
  33467. * Returns the attribute at the given index.
  33468. * @param index The index of the attribute.
  33469. * @returns The location of the attribute.
  33470. */
  33471. getAttributeLocation(index: number): number;
  33472. /**
  33473. * Returns the attribute based on the name of the variable.
  33474. * @param name of the attribute to look up.
  33475. * @returns the attribute location.
  33476. */
  33477. getAttributeLocationByName(name: string): number;
  33478. /**
  33479. * The number of attributes.
  33480. * @returns the numnber of attributes.
  33481. */
  33482. getAttributesCount(): number;
  33483. /**
  33484. * Gets the index of a uniform variable.
  33485. * @param uniformName of the uniform to look up.
  33486. * @returns the index.
  33487. */
  33488. getUniformIndex(uniformName: string): number;
  33489. /**
  33490. * Returns the attribute based on the name of the variable.
  33491. * @param uniformName of the uniform to look up.
  33492. * @returns the location of the uniform.
  33493. */
  33494. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33495. /**
  33496. * Returns an array of sampler variable names
  33497. * @returns The array of sampler variable names.
  33498. */
  33499. getSamplers(): string[];
  33500. /**
  33501. * Returns an array of uniform variable names
  33502. * @returns The array of uniform variable names.
  33503. */
  33504. getUniformNames(): string[];
  33505. /**
  33506. * Returns an array of uniform buffer variable names
  33507. * @returns The array of uniform buffer variable names.
  33508. */
  33509. getUniformBuffersNames(): string[];
  33510. /**
  33511. * Returns the index parameters used to create the effect
  33512. * @returns The index parameters object
  33513. */
  33514. getIndexParameters(): any;
  33515. /**
  33516. * The error from the last compilation.
  33517. * @returns the error string.
  33518. */
  33519. getCompilationError(): string;
  33520. /**
  33521. * Gets a boolean indicating that all fallbacks were used during compilation
  33522. * @returns true if all fallbacks were used
  33523. */
  33524. allFallbacksProcessed(): boolean;
  33525. /**
  33526. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33527. * @param func The callback to be used.
  33528. */
  33529. executeWhenCompiled(func: (effect: Effect) => void): void;
  33530. private _checkIsReady;
  33531. private _loadShader;
  33532. /**
  33533. * Gets the vertex shader source code of this effect
  33534. */
  33535. get vertexSourceCode(): string;
  33536. /**
  33537. * Gets the fragment shader source code of this effect
  33538. */
  33539. get fragmentSourceCode(): string;
  33540. /**
  33541. * Recompiles the webGL program
  33542. * @param vertexSourceCode The source code for the vertex shader.
  33543. * @param fragmentSourceCode The source code for the fragment shader.
  33544. * @param onCompiled Callback called when completed.
  33545. * @param onError Callback called on error.
  33546. * @hidden
  33547. */
  33548. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33549. /**
  33550. * Prepares the effect
  33551. * @hidden
  33552. */
  33553. _prepareEffect(): void;
  33554. private _getShaderCodeAndErrorLine;
  33555. private _processCompilationErrors;
  33556. /**
  33557. * Checks if the effect is supported. (Must be called after compilation)
  33558. */
  33559. get isSupported(): boolean;
  33560. /**
  33561. * Binds a texture to the engine to be used as output of the shader.
  33562. * @param channel Name of the output variable.
  33563. * @param texture Texture to bind.
  33564. * @hidden
  33565. */
  33566. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33567. /**
  33568. * Sets a texture 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. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33573. /**
  33574. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33575. * @param channel Name of the sampler variable.
  33576. * @param texture Texture to set.
  33577. */
  33578. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33579. /**
  33580. * Sets an array of textures on the engine to be used in the shader.
  33581. * @param channel Name of the variable.
  33582. * @param textures Textures to set.
  33583. */
  33584. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33585. /**
  33586. * 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)
  33587. * @param channel Name of the sampler variable.
  33588. * @param postProcess Post process to get the input texture from.
  33589. */
  33590. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33591. /**
  33592. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33593. * 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)
  33594. * @param channel Name of the sampler variable.
  33595. * @param postProcess Post process to get the output texture from.
  33596. */
  33597. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33598. /** @hidden */
  33599. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33600. /** @hidden */
  33601. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33602. /** @hidden */
  33603. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33604. /** @hidden */
  33605. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33606. /**
  33607. * Binds a buffer to a uniform.
  33608. * @param buffer Buffer to bind.
  33609. * @param name Name of the uniform variable to bind to.
  33610. */
  33611. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33612. /**
  33613. * Binds block to a uniform.
  33614. * @param blockName Name of the block to bind.
  33615. * @param index Index to bind.
  33616. */
  33617. bindUniformBlock(blockName: string, index: number): void;
  33618. /**
  33619. * Sets an interger value on a uniform variable.
  33620. * @param uniformName Name of the variable.
  33621. * @param value Value to be set.
  33622. * @returns this effect.
  33623. */
  33624. setInt(uniformName: string, value: number): Effect;
  33625. /**
  33626. * Sets an int array on a uniform variable.
  33627. * @param uniformName Name of the variable.
  33628. * @param array array to be set.
  33629. * @returns this effect.
  33630. */
  33631. setIntArray(uniformName: string, array: Int32Array): Effect;
  33632. /**
  33633. * 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)
  33634. * @param uniformName Name of the variable.
  33635. * @param array array to be set.
  33636. * @returns this effect.
  33637. */
  33638. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33639. /**
  33640. * 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)
  33641. * @param uniformName Name of the variable.
  33642. * @param array array to be set.
  33643. * @returns this effect.
  33644. */
  33645. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33646. /**
  33647. * 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)
  33648. * @param uniformName Name of the variable.
  33649. * @param array array to be set.
  33650. * @returns this effect.
  33651. */
  33652. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33653. /**
  33654. * Sets an float array on a uniform variable.
  33655. * @param uniformName Name of the variable.
  33656. * @param array array to be set.
  33657. * @returns this effect.
  33658. */
  33659. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33660. /**
  33661. * 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)
  33662. * @param uniformName Name of the variable.
  33663. * @param array array to be set.
  33664. * @returns this effect.
  33665. */
  33666. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33667. /**
  33668. * 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)
  33669. * @param uniformName Name of the variable.
  33670. * @param array array to be set.
  33671. * @returns this effect.
  33672. */
  33673. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33674. /**
  33675. * 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)
  33676. * @param uniformName Name of the variable.
  33677. * @param array array to be set.
  33678. * @returns this effect.
  33679. */
  33680. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33681. /**
  33682. * Sets an array on a uniform variable.
  33683. * @param uniformName Name of the variable.
  33684. * @param array array to be set.
  33685. * @returns this effect.
  33686. */
  33687. setArray(uniformName: string, array: number[]): Effect;
  33688. /**
  33689. * 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)
  33690. * @param uniformName Name of the variable.
  33691. * @param array array to be set.
  33692. * @returns this effect.
  33693. */
  33694. setArray2(uniformName: string, array: number[]): Effect;
  33695. /**
  33696. * 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)
  33697. * @param uniformName Name of the variable.
  33698. * @param array array to be set.
  33699. * @returns this effect.
  33700. */
  33701. setArray3(uniformName: string, array: number[]): Effect;
  33702. /**
  33703. * 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)
  33704. * @param uniformName Name of the variable.
  33705. * @param array array to be set.
  33706. * @returns this effect.
  33707. */
  33708. setArray4(uniformName: string, array: number[]): Effect;
  33709. /**
  33710. * Sets matrices on a uniform variable.
  33711. * @param uniformName Name of the variable.
  33712. * @param matrices matrices to be set.
  33713. * @returns this effect.
  33714. */
  33715. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33716. /**
  33717. * Sets matrix on a uniform variable.
  33718. * @param uniformName Name of the variable.
  33719. * @param matrix matrix to be set.
  33720. * @returns this effect.
  33721. */
  33722. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33723. /**
  33724. * 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)
  33725. * @param uniformName Name of the variable.
  33726. * @param matrix matrix to be set.
  33727. * @returns this effect.
  33728. */
  33729. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33730. /**
  33731. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33732. * @param uniformName Name of the variable.
  33733. * @param matrix matrix to be set.
  33734. * @returns this effect.
  33735. */
  33736. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33737. /**
  33738. * Sets a float on a uniform variable.
  33739. * @param uniformName Name of the variable.
  33740. * @param value value to be set.
  33741. * @returns this effect.
  33742. */
  33743. setFloat(uniformName: string, value: number): Effect;
  33744. /**
  33745. * Sets a boolean on a uniform variable.
  33746. * @param uniformName Name of the variable.
  33747. * @param bool value to be set.
  33748. * @returns this effect.
  33749. */
  33750. setBool(uniformName: string, bool: boolean): Effect;
  33751. /**
  33752. * Sets a Vector2 on a uniform variable.
  33753. * @param uniformName Name of the variable.
  33754. * @param vector2 vector2 to be set.
  33755. * @returns this effect.
  33756. */
  33757. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33758. /**
  33759. * Sets a float2 on a uniform variable.
  33760. * @param uniformName Name of the variable.
  33761. * @param x First float in float2.
  33762. * @param y Second float in float2.
  33763. * @returns this effect.
  33764. */
  33765. setFloat2(uniformName: string, x: number, y: number): Effect;
  33766. /**
  33767. * Sets a Vector3 on a uniform variable.
  33768. * @param uniformName Name of the variable.
  33769. * @param vector3 Value to be set.
  33770. * @returns this effect.
  33771. */
  33772. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33773. /**
  33774. * Sets a float3 on a uniform variable.
  33775. * @param uniformName Name of the variable.
  33776. * @param x First float in float3.
  33777. * @param y Second float in float3.
  33778. * @param z Third float in float3.
  33779. * @returns this effect.
  33780. */
  33781. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33782. /**
  33783. * Sets a Vector4 on a uniform variable.
  33784. * @param uniformName Name of the variable.
  33785. * @param vector4 Value to be set.
  33786. * @returns this effect.
  33787. */
  33788. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33789. /**
  33790. * Sets a float4 on a uniform variable.
  33791. * @param uniformName Name of the variable.
  33792. * @param x First float in float4.
  33793. * @param y Second float in float4.
  33794. * @param z Third float in float4.
  33795. * @param w Fourth float in float4.
  33796. * @returns this effect.
  33797. */
  33798. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33799. /**
  33800. * Sets a Color3 on a uniform variable.
  33801. * @param uniformName Name of the variable.
  33802. * @param color3 Value to be set.
  33803. * @returns this effect.
  33804. */
  33805. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33806. /**
  33807. * Sets a Color4 on a uniform variable.
  33808. * @param uniformName Name of the variable.
  33809. * @param color3 Value to be set.
  33810. * @param alpha Alpha value to be set.
  33811. * @returns this effect.
  33812. */
  33813. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33814. /**
  33815. * Sets a Color4 on a uniform variable
  33816. * @param uniformName defines the name of the variable
  33817. * @param color4 defines the value to be set
  33818. * @returns this effect.
  33819. */
  33820. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33821. /** Release all associated resources */
  33822. dispose(): void;
  33823. /**
  33824. * This function will add a new shader to the shader store
  33825. * @param name the name of the shader
  33826. * @param pixelShader optional pixel shader content
  33827. * @param vertexShader optional vertex shader content
  33828. */
  33829. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33830. /**
  33831. * Store of each shader (The can be looked up using effect.key)
  33832. */
  33833. static ShadersStore: {
  33834. [key: string]: string;
  33835. };
  33836. /**
  33837. * Store of each included file for a shader (The can be looked up using effect.key)
  33838. */
  33839. static IncludesShadersStore: {
  33840. [key: string]: string;
  33841. };
  33842. /**
  33843. * Resets the cache of effects.
  33844. */
  33845. static ResetCache(): void;
  33846. }
  33847. }
  33848. declare module BABYLON {
  33849. /**
  33850. * Interface used to describe the capabilities of the engine relatively to the current browser
  33851. */
  33852. export interface EngineCapabilities {
  33853. /** Maximum textures units per fragment shader */
  33854. maxTexturesImageUnits: number;
  33855. /** Maximum texture units per vertex shader */
  33856. maxVertexTextureImageUnits: number;
  33857. /** Maximum textures units in the entire pipeline */
  33858. maxCombinedTexturesImageUnits: number;
  33859. /** Maximum texture size */
  33860. maxTextureSize: number;
  33861. /** Maximum texture samples */
  33862. maxSamples?: number;
  33863. /** Maximum cube texture size */
  33864. maxCubemapTextureSize: number;
  33865. /** Maximum render texture size */
  33866. maxRenderTextureSize: number;
  33867. /** Maximum number of vertex attributes */
  33868. maxVertexAttribs: number;
  33869. /** Maximum number of varyings */
  33870. maxVaryingVectors: number;
  33871. /** Maximum number of uniforms per vertex shader */
  33872. maxVertexUniformVectors: number;
  33873. /** Maximum number of uniforms per fragment shader */
  33874. maxFragmentUniformVectors: number;
  33875. /** Defines if standard derivates (dx/dy) are supported */
  33876. standardDerivatives: boolean;
  33877. /** Defines if s3tc texture compression is supported */
  33878. s3tc?: WEBGL_compressed_texture_s3tc;
  33879. /** Defines if pvrtc texture compression is supported */
  33880. pvrtc: any;
  33881. /** Defines if etc1 texture compression is supported */
  33882. etc1: any;
  33883. /** Defines if etc2 texture compression is supported */
  33884. etc2: any;
  33885. /** Defines if astc texture compression is supported */
  33886. astc: any;
  33887. /** Defines if float textures are supported */
  33888. textureFloat: boolean;
  33889. /** Defines if vertex array objects are supported */
  33890. vertexArrayObject: boolean;
  33891. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33892. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33893. /** Gets the maximum level of anisotropy supported */
  33894. maxAnisotropy: number;
  33895. /** Defines if instancing is supported */
  33896. instancedArrays: boolean;
  33897. /** Defines if 32 bits indices are supported */
  33898. uintIndices: boolean;
  33899. /** Defines if high precision shaders are supported */
  33900. highPrecisionShaderSupported: boolean;
  33901. /** Defines if depth reading in the fragment shader is supported */
  33902. fragmentDepthSupported: boolean;
  33903. /** Defines if float texture linear filtering is supported*/
  33904. textureFloatLinearFiltering: boolean;
  33905. /** Defines if rendering to float textures is supported */
  33906. textureFloatRender: boolean;
  33907. /** Defines if half float textures are supported*/
  33908. textureHalfFloat: boolean;
  33909. /** Defines if half float texture linear filtering is supported*/
  33910. textureHalfFloatLinearFiltering: boolean;
  33911. /** Defines if rendering to half float textures is supported */
  33912. textureHalfFloatRender: boolean;
  33913. /** Defines if textureLOD shader command is supported */
  33914. textureLOD: boolean;
  33915. /** Defines if draw buffers extension is supported */
  33916. drawBuffersExtension: boolean;
  33917. /** Defines if depth textures are supported */
  33918. depthTextureExtension: boolean;
  33919. /** Defines if float color buffer are supported */
  33920. colorBufferFloat: boolean;
  33921. /** Gets disjoint timer query extension (null if not supported) */
  33922. timerQuery?: EXT_disjoint_timer_query;
  33923. /** Defines if timestamp can be used with timer query */
  33924. canUseTimestampForTimerQuery: boolean;
  33925. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33926. multiview?: any;
  33927. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33928. oculusMultiview?: any;
  33929. /** Function used to let the system compiles shaders in background */
  33930. parallelShaderCompile?: {
  33931. COMPLETION_STATUS_KHR: number;
  33932. };
  33933. /** Max number of texture samples for MSAA */
  33934. maxMSAASamples: number;
  33935. /** Defines if the blend min max extension is supported */
  33936. blendMinMax: boolean;
  33937. }
  33938. }
  33939. declare module BABYLON {
  33940. /**
  33941. * @hidden
  33942. **/
  33943. export class DepthCullingState {
  33944. private _isDepthTestDirty;
  33945. private _isDepthMaskDirty;
  33946. private _isDepthFuncDirty;
  33947. private _isCullFaceDirty;
  33948. private _isCullDirty;
  33949. private _isZOffsetDirty;
  33950. private _isFrontFaceDirty;
  33951. private _depthTest;
  33952. private _depthMask;
  33953. private _depthFunc;
  33954. private _cull;
  33955. private _cullFace;
  33956. private _zOffset;
  33957. private _frontFace;
  33958. /**
  33959. * Initializes the state.
  33960. */
  33961. constructor();
  33962. get isDirty(): boolean;
  33963. get zOffset(): number;
  33964. set zOffset(value: number);
  33965. get cullFace(): Nullable<number>;
  33966. set cullFace(value: Nullable<number>);
  33967. get cull(): Nullable<boolean>;
  33968. set cull(value: Nullable<boolean>);
  33969. get depthFunc(): Nullable<number>;
  33970. set depthFunc(value: Nullable<number>);
  33971. get depthMask(): boolean;
  33972. set depthMask(value: boolean);
  33973. get depthTest(): boolean;
  33974. set depthTest(value: boolean);
  33975. get frontFace(): Nullable<number>;
  33976. set frontFace(value: Nullable<number>);
  33977. reset(): void;
  33978. apply(gl: WebGLRenderingContext): void;
  33979. }
  33980. }
  33981. declare module BABYLON {
  33982. /**
  33983. * @hidden
  33984. **/
  33985. export class StencilState {
  33986. /** 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 */
  33987. static readonly ALWAYS: number;
  33988. /** Passed to stencilOperation to specify that stencil value must be kept */
  33989. static readonly KEEP: number;
  33990. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33991. static readonly REPLACE: number;
  33992. private _isStencilTestDirty;
  33993. private _isStencilMaskDirty;
  33994. private _isStencilFuncDirty;
  33995. private _isStencilOpDirty;
  33996. private _stencilTest;
  33997. private _stencilMask;
  33998. private _stencilFunc;
  33999. private _stencilFuncRef;
  34000. private _stencilFuncMask;
  34001. private _stencilOpStencilFail;
  34002. private _stencilOpDepthFail;
  34003. private _stencilOpStencilDepthPass;
  34004. get isDirty(): boolean;
  34005. get stencilFunc(): number;
  34006. set stencilFunc(value: number);
  34007. get stencilFuncRef(): number;
  34008. set stencilFuncRef(value: number);
  34009. get stencilFuncMask(): number;
  34010. set stencilFuncMask(value: number);
  34011. get stencilOpStencilFail(): number;
  34012. set stencilOpStencilFail(value: number);
  34013. get stencilOpDepthFail(): number;
  34014. set stencilOpDepthFail(value: number);
  34015. get stencilOpStencilDepthPass(): number;
  34016. set stencilOpStencilDepthPass(value: number);
  34017. get stencilMask(): number;
  34018. set stencilMask(value: number);
  34019. get stencilTest(): boolean;
  34020. set stencilTest(value: boolean);
  34021. constructor();
  34022. reset(): void;
  34023. apply(gl: WebGLRenderingContext): void;
  34024. }
  34025. }
  34026. declare module BABYLON {
  34027. /**
  34028. * @hidden
  34029. **/
  34030. export class AlphaState {
  34031. private _isAlphaBlendDirty;
  34032. private _isBlendFunctionParametersDirty;
  34033. private _isBlendEquationParametersDirty;
  34034. private _isBlendConstantsDirty;
  34035. private _alphaBlend;
  34036. private _blendFunctionParameters;
  34037. private _blendEquationParameters;
  34038. private _blendConstants;
  34039. /**
  34040. * Initializes the state.
  34041. */
  34042. constructor();
  34043. get isDirty(): boolean;
  34044. get alphaBlend(): boolean;
  34045. set alphaBlend(value: boolean);
  34046. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34047. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34048. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34049. reset(): void;
  34050. apply(gl: WebGLRenderingContext): void;
  34051. }
  34052. }
  34053. declare module BABYLON {
  34054. /** @hidden */
  34055. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34056. attributeProcessor(attribute: string): string;
  34057. varyingProcessor(varying: string, isFragment: boolean): string;
  34058. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34059. }
  34060. }
  34061. declare module BABYLON {
  34062. /**
  34063. * Interface for attribute information associated with buffer instanciation
  34064. */
  34065. export interface InstancingAttributeInfo {
  34066. /**
  34067. * Name of the GLSL attribute
  34068. * if attribute index is not specified, this is used to retrieve the index from the effect
  34069. */
  34070. attributeName: string;
  34071. /**
  34072. * Index/offset of the attribute in the vertex shader
  34073. * if not specified, this will be computes from the name.
  34074. */
  34075. index?: number;
  34076. /**
  34077. * size of the attribute, 1, 2, 3 or 4
  34078. */
  34079. attributeSize: number;
  34080. /**
  34081. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34082. */
  34083. offset: number;
  34084. /**
  34085. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34086. * default to 1
  34087. */
  34088. divisor?: number;
  34089. /**
  34090. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34091. * default is FLOAT
  34092. */
  34093. attributeType?: number;
  34094. /**
  34095. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34096. */
  34097. normalized?: boolean;
  34098. }
  34099. }
  34100. declare module BABYLON {
  34101. interface ThinEngine {
  34102. /**
  34103. * Update a video texture
  34104. * @param texture defines the texture to update
  34105. * @param video defines the video element to use
  34106. * @param invertY defines if data must be stored with Y axis inverted
  34107. */
  34108. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34109. }
  34110. }
  34111. declare module BABYLON {
  34112. /**
  34113. * Settings for finer control over video usage
  34114. */
  34115. export interface VideoTextureSettings {
  34116. /**
  34117. * Applies `autoplay` to video, if specified
  34118. */
  34119. autoPlay?: boolean;
  34120. /**
  34121. * Applies `loop` to video, if specified
  34122. */
  34123. loop?: boolean;
  34124. /**
  34125. * Automatically updates internal texture from video at every frame in the render loop
  34126. */
  34127. autoUpdateTexture: boolean;
  34128. /**
  34129. * Image src displayed during the video loading or until the user interacts with the video.
  34130. */
  34131. poster?: string;
  34132. }
  34133. /**
  34134. * If you want to display a video in your scene, this is the special texture for that.
  34135. * This special texture works similar to other textures, with the exception of a few parameters.
  34136. * @see https://doc.babylonjs.com/how_to/video_texture
  34137. */
  34138. export class VideoTexture extends Texture {
  34139. /**
  34140. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34141. */
  34142. readonly autoUpdateTexture: boolean;
  34143. /**
  34144. * The video instance used by the texture internally
  34145. */
  34146. readonly video: HTMLVideoElement;
  34147. private _onUserActionRequestedObservable;
  34148. /**
  34149. * Event triggerd when a dom action is required by the user to play the video.
  34150. * This happens due to recent changes in browser policies preventing video to auto start.
  34151. */
  34152. get onUserActionRequestedObservable(): Observable<Texture>;
  34153. private _generateMipMaps;
  34154. private _stillImageCaptured;
  34155. private _displayingPosterTexture;
  34156. private _settings;
  34157. private _createInternalTextureOnEvent;
  34158. private _frameId;
  34159. private _currentSrc;
  34160. /**
  34161. * Creates a video texture.
  34162. * If you want to display a video in your scene, this is the special texture for that.
  34163. * This special texture works similar to other textures, with the exception of a few parameters.
  34164. * @see https://doc.babylonjs.com/how_to/video_texture
  34165. * @param name optional name, will detect from video source, if not defined
  34166. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34167. * @param scene is obviously the current scene.
  34168. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34169. * @param invertY is false by default but can be used to invert video on Y axis
  34170. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34171. * @param settings allows finer control over video usage
  34172. */
  34173. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34174. private _getName;
  34175. private _getVideo;
  34176. private _createInternalTexture;
  34177. private reset;
  34178. /**
  34179. * @hidden Internal method to initiate `update`.
  34180. */
  34181. _rebuild(): void;
  34182. /**
  34183. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34184. */
  34185. update(): void;
  34186. /**
  34187. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34188. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34189. */
  34190. updateTexture(isVisible: boolean): void;
  34191. protected _updateInternalTexture: () => void;
  34192. /**
  34193. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34194. * @param url New url.
  34195. */
  34196. updateURL(url: string): void;
  34197. /**
  34198. * Clones the texture.
  34199. * @returns the cloned texture
  34200. */
  34201. clone(): VideoTexture;
  34202. /**
  34203. * Dispose the texture and release its associated resources.
  34204. */
  34205. dispose(): void;
  34206. /**
  34207. * Creates a video texture straight from a stream.
  34208. * @param scene Define the scene the texture should be created in
  34209. * @param stream Define the stream the texture should be created from
  34210. * @returns The created video texture as a promise
  34211. */
  34212. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34213. /**
  34214. * Creates a video texture straight from your WebCam video feed.
  34215. * @param scene Define the scene the texture should be created in
  34216. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34217. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34218. * @returns The created video texture as a promise
  34219. */
  34220. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34221. minWidth: number;
  34222. maxWidth: number;
  34223. minHeight: number;
  34224. maxHeight: number;
  34225. deviceId: string;
  34226. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34227. /**
  34228. * Creates a video texture straight from your WebCam video feed.
  34229. * @param scene Define the scene the texture should be created in
  34230. * @param onReady Define a callback to triggered once the texture will be ready
  34231. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34232. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34233. */
  34234. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34235. minWidth: number;
  34236. maxWidth: number;
  34237. minHeight: number;
  34238. maxHeight: number;
  34239. deviceId: string;
  34240. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34241. }
  34242. }
  34243. declare module BABYLON {
  34244. /**
  34245. * Defines the interface used by objects working like Scene
  34246. * @hidden
  34247. */
  34248. export interface ISceneLike {
  34249. _addPendingData(data: any): void;
  34250. _removePendingData(data: any): void;
  34251. offlineProvider: IOfflineProvider;
  34252. }
  34253. /** Interface defining initialization parameters for Engine class */
  34254. export interface EngineOptions extends WebGLContextAttributes {
  34255. /**
  34256. * Defines if the engine should no exceed a specified device ratio
  34257. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34258. */
  34259. limitDeviceRatio?: number;
  34260. /**
  34261. * Defines if webvr should be enabled automatically
  34262. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34263. */
  34264. autoEnableWebVR?: boolean;
  34265. /**
  34266. * Defines if webgl2 should be turned off even if supported
  34267. * @see http://doc.babylonjs.com/features/webgl2
  34268. */
  34269. disableWebGL2Support?: boolean;
  34270. /**
  34271. * Defines if webaudio should be initialized as well
  34272. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34273. */
  34274. audioEngine?: boolean;
  34275. /**
  34276. * Defines if animations should run using a deterministic lock step
  34277. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34278. */
  34279. deterministicLockstep?: boolean;
  34280. /** Defines the maximum steps to use with deterministic lock step mode */
  34281. lockstepMaxSteps?: number;
  34282. /** Defines the seconds between each deterministic lock step */
  34283. timeStep?: number;
  34284. /**
  34285. * Defines that engine should ignore context lost events
  34286. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34287. */
  34288. doNotHandleContextLost?: boolean;
  34289. /**
  34290. * Defines that engine should ignore modifying touch action attribute and style
  34291. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34292. */
  34293. doNotHandleTouchAction?: boolean;
  34294. /**
  34295. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34296. */
  34297. useHighPrecisionFloats?: boolean;
  34298. /**
  34299. * Make the canvas XR Compatible for XR sessions
  34300. */
  34301. xrCompatible?: boolean;
  34302. }
  34303. /**
  34304. * The base engine class (root of all engines)
  34305. */
  34306. export class ThinEngine {
  34307. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34308. static ExceptionList: ({
  34309. key: string;
  34310. capture: string;
  34311. captureConstraint: number;
  34312. targets: string[];
  34313. } | {
  34314. key: string;
  34315. capture: null;
  34316. captureConstraint: null;
  34317. targets: string[];
  34318. })[];
  34319. /** @hidden */
  34320. static _TextureLoaders: IInternalTextureLoader[];
  34321. /**
  34322. * Returns the current npm package of the sdk
  34323. */
  34324. static get NpmPackage(): string;
  34325. /**
  34326. * Returns the current version of the framework
  34327. */
  34328. static get Version(): string;
  34329. /**
  34330. * Returns a string describing the current engine
  34331. */
  34332. get description(): string;
  34333. /**
  34334. * Gets or sets the epsilon value used by collision engine
  34335. */
  34336. static CollisionsEpsilon: number;
  34337. /**
  34338. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34339. */
  34340. static get ShadersRepository(): string;
  34341. static set ShadersRepository(value: string);
  34342. /** @hidden */
  34343. _shaderProcessor: IShaderProcessor;
  34344. /**
  34345. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34346. */
  34347. forcePOTTextures: boolean;
  34348. /**
  34349. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34350. */
  34351. isFullscreen: boolean;
  34352. /**
  34353. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34354. */
  34355. cullBackFaces: boolean;
  34356. /**
  34357. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34358. */
  34359. renderEvenInBackground: boolean;
  34360. /**
  34361. * Gets or sets a boolean indicating that cache can be kept between frames
  34362. */
  34363. preventCacheWipeBetweenFrames: boolean;
  34364. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34365. validateShaderPrograms: boolean;
  34366. /**
  34367. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34368. * This can provide greater z depth for distant objects.
  34369. */
  34370. useReverseDepthBuffer: boolean;
  34371. /**
  34372. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34373. */
  34374. disableUniformBuffers: boolean;
  34375. /** @hidden */
  34376. _uniformBuffers: UniformBuffer[];
  34377. /**
  34378. * Gets a boolean indicating that the engine supports uniform buffers
  34379. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34380. */
  34381. get supportsUniformBuffers(): boolean;
  34382. /** @hidden */
  34383. _gl: WebGLRenderingContext;
  34384. /** @hidden */
  34385. _webGLVersion: number;
  34386. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34387. protected _windowIsBackground: boolean;
  34388. protected _creationOptions: EngineOptions;
  34389. protected _highPrecisionShadersAllowed: boolean;
  34390. /** @hidden */
  34391. get _shouldUseHighPrecisionShader(): boolean;
  34392. /**
  34393. * Gets a boolean indicating that only power of 2 textures are supported
  34394. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34395. */
  34396. get needPOTTextures(): boolean;
  34397. /** @hidden */
  34398. _badOS: boolean;
  34399. /** @hidden */
  34400. _badDesktopOS: boolean;
  34401. private _hardwareScalingLevel;
  34402. /** @hidden */
  34403. _caps: EngineCapabilities;
  34404. private _isStencilEnable;
  34405. private _glVersion;
  34406. private _glRenderer;
  34407. private _glVendor;
  34408. /** @hidden */
  34409. _videoTextureSupported: boolean;
  34410. protected _renderingQueueLaunched: boolean;
  34411. protected _activeRenderLoops: (() => void)[];
  34412. /**
  34413. * Observable signaled when a context lost event is raised
  34414. */
  34415. onContextLostObservable: Observable<ThinEngine>;
  34416. /**
  34417. * Observable signaled when a context restored event is raised
  34418. */
  34419. onContextRestoredObservable: Observable<ThinEngine>;
  34420. private _onContextLost;
  34421. private _onContextRestored;
  34422. protected _contextWasLost: boolean;
  34423. /** @hidden */
  34424. _doNotHandleContextLost: boolean;
  34425. /**
  34426. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34427. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34428. */
  34429. get doNotHandleContextLost(): boolean;
  34430. set doNotHandleContextLost(value: boolean);
  34431. /**
  34432. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34433. */
  34434. disableVertexArrayObjects: boolean;
  34435. /** @hidden */
  34436. protected _colorWrite: boolean;
  34437. /** @hidden */
  34438. protected _colorWriteChanged: boolean;
  34439. /** @hidden */
  34440. protected _depthCullingState: DepthCullingState;
  34441. /** @hidden */
  34442. protected _stencilState: StencilState;
  34443. /** @hidden */
  34444. _alphaState: AlphaState;
  34445. /** @hidden */
  34446. _alphaMode: number;
  34447. /** @hidden */
  34448. _alphaEquation: number;
  34449. /** @hidden */
  34450. _internalTexturesCache: InternalTexture[];
  34451. /** @hidden */
  34452. protected _activeChannel: number;
  34453. private _currentTextureChannel;
  34454. /** @hidden */
  34455. protected _boundTexturesCache: {
  34456. [key: string]: Nullable<InternalTexture>;
  34457. };
  34458. /** @hidden */
  34459. protected _currentEffect: Nullable<Effect>;
  34460. /** @hidden */
  34461. protected _currentProgram: Nullable<WebGLProgram>;
  34462. private _compiledEffects;
  34463. private _vertexAttribArraysEnabled;
  34464. /** @hidden */
  34465. protected _cachedViewport: Nullable<IViewportLike>;
  34466. private _cachedVertexArrayObject;
  34467. /** @hidden */
  34468. protected _cachedVertexBuffers: any;
  34469. /** @hidden */
  34470. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34471. /** @hidden */
  34472. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34473. /** @hidden */
  34474. _currentRenderTarget: Nullable<InternalTexture>;
  34475. private _uintIndicesCurrentlySet;
  34476. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34477. /** @hidden */
  34478. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34479. /** @hidden */
  34480. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34481. private _currentBufferPointers;
  34482. private _currentInstanceLocations;
  34483. private _currentInstanceBuffers;
  34484. private _textureUnits;
  34485. /** @hidden */
  34486. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34487. /** @hidden */
  34488. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34489. /** @hidden */
  34490. _boundRenderFunction: any;
  34491. private _vaoRecordInProgress;
  34492. private _mustWipeVertexAttributes;
  34493. private _emptyTexture;
  34494. private _emptyCubeTexture;
  34495. private _emptyTexture3D;
  34496. private _emptyTexture2DArray;
  34497. /** @hidden */
  34498. _frameHandler: number;
  34499. private _nextFreeTextureSlots;
  34500. private _maxSimultaneousTextures;
  34501. private _activeRequests;
  34502. /** @hidden */
  34503. _transformTextureUrl: Nullable<(url: string) => string>;
  34504. protected get _supportsHardwareTextureRescaling(): boolean;
  34505. private _framebufferDimensionsObject;
  34506. /**
  34507. * sets the object from which width and height will be taken from when getting render width and height
  34508. * Will fallback to the gl object
  34509. * @param dimensions the framebuffer width and height that will be used.
  34510. */
  34511. set framebufferDimensionsObject(dimensions: Nullable<{
  34512. framebufferWidth: number;
  34513. framebufferHeight: number;
  34514. }>);
  34515. /**
  34516. * Gets the current viewport
  34517. */
  34518. get currentViewport(): Nullable<IViewportLike>;
  34519. /**
  34520. * Gets the default empty texture
  34521. */
  34522. get emptyTexture(): InternalTexture;
  34523. /**
  34524. * Gets the default empty 3D texture
  34525. */
  34526. get emptyTexture3D(): InternalTexture;
  34527. /**
  34528. * Gets the default empty 2D array texture
  34529. */
  34530. get emptyTexture2DArray(): InternalTexture;
  34531. /**
  34532. * Gets the default empty cube texture
  34533. */
  34534. get emptyCubeTexture(): InternalTexture;
  34535. /**
  34536. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34537. */
  34538. readonly premultipliedAlpha: boolean;
  34539. /**
  34540. * Observable event triggered before each texture is initialized
  34541. */
  34542. onBeforeTextureInitObservable: Observable<Texture>;
  34543. /**
  34544. * Creates a new engine
  34545. * @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
  34546. * @param antialias defines enable antialiasing (default: false)
  34547. * @param options defines further options to be sent to the getContext() function
  34548. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34549. */
  34550. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34551. private _rebuildInternalTextures;
  34552. private _rebuildEffects;
  34553. /**
  34554. * Gets a boolean indicating if all created effects are ready
  34555. * @returns true if all effects are ready
  34556. */
  34557. areAllEffectsReady(): boolean;
  34558. protected _rebuildBuffers(): void;
  34559. protected _initGLContext(): void;
  34560. /**
  34561. * Gets version of the current webGL context
  34562. */
  34563. get webGLVersion(): number;
  34564. /**
  34565. * Gets a string idenfifying the name of the class
  34566. * @returns "Engine" string
  34567. */
  34568. getClassName(): string;
  34569. /**
  34570. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34571. */
  34572. get isStencilEnable(): boolean;
  34573. /** @hidden */
  34574. _prepareWorkingCanvas(): void;
  34575. /**
  34576. * Reset the texture cache to empty state
  34577. */
  34578. resetTextureCache(): void;
  34579. /**
  34580. * Gets an object containing information about the current webGL context
  34581. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34582. */
  34583. getGlInfo(): {
  34584. vendor: string;
  34585. renderer: string;
  34586. version: string;
  34587. };
  34588. /**
  34589. * Defines the hardware scaling level.
  34590. * By default the hardware scaling level is computed from the window device ratio.
  34591. * 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.
  34592. * @param level defines the level to use
  34593. */
  34594. setHardwareScalingLevel(level: number): void;
  34595. /**
  34596. * Gets the current hardware scaling level.
  34597. * By default the hardware scaling level is computed from the window device ratio.
  34598. * 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.
  34599. * @returns a number indicating the current hardware scaling level
  34600. */
  34601. getHardwareScalingLevel(): number;
  34602. /**
  34603. * Gets the list of loaded textures
  34604. * @returns an array containing all loaded textures
  34605. */
  34606. getLoadedTexturesCache(): InternalTexture[];
  34607. /**
  34608. * Gets the object containing all engine capabilities
  34609. * @returns the EngineCapabilities object
  34610. */
  34611. getCaps(): EngineCapabilities;
  34612. /**
  34613. * stop executing a render loop function and remove it from the execution array
  34614. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34615. */
  34616. stopRenderLoop(renderFunction?: () => void): void;
  34617. /** @hidden */
  34618. _renderLoop(): void;
  34619. /**
  34620. * Gets the HTML canvas attached with the current webGL context
  34621. * @returns a HTML canvas
  34622. */
  34623. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34624. /**
  34625. * Gets host window
  34626. * @returns the host window object
  34627. */
  34628. getHostWindow(): Nullable<Window>;
  34629. /**
  34630. * Gets the current render width
  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 width
  34633. */
  34634. getRenderWidth(useScreen?: boolean): number;
  34635. /**
  34636. * Gets the current render height
  34637. * @param useScreen defines if screen size must be used (or the current render target if any)
  34638. * @returns a number defining the current render height
  34639. */
  34640. getRenderHeight(useScreen?: boolean): number;
  34641. /**
  34642. * Can be used to override the current requestAnimationFrame requester.
  34643. * @hidden
  34644. */
  34645. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34646. /**
  34647. * Register and execute a render loop. The engine can have more than one render function
  34648. * @param renderFunction defines the function to continuously execute
  34649. */
  34650. runRenderLoop(renderFunction: () => void): void;
  34651. /**
  34652. * Clear the current render buffer or the current render target (if any is set up)
  34653. * @param color defines the color to use
  34654. * @param backBuffer defines if the back buffer must be cleared
  34655. * @param depth defines if the depth buffer must be cleared
  34656. * @param stencil defines if the stencil buffer must be cleared
  34657. */
  34658. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34659. private _viewportCached;
  34660. /** @hidden */
  34661. _viewport(x: number, y: number, width: number, height: number): void;
  34662. /**
  34663. * Set the WebGL's viewport
  34664. * @param viewport defines the viewport element to be used
  34665. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34666. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34667. */
  34668. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34669. /**
  34670. * Begin a new frame
  34671. */
  34672. beginFrame(): void;
  34673. /**
  34674. * Enf the current frame
  34675. */
  34676. endFrame(): void;
  34677. /**
  34678. * Resize the view according to the canvas' size
  34679. */
  34680. resize(): void;
  34681. /**
  34682. * Force a specific size of the canvas
  34683. * @param width defines the new canvas' width
  34684. * @param height defines the new canvas' height
  34685. */
  34686. setSize(width: number, height: number): void;
  34687. /**
  34688. * Binds the frame buffer to the specified texture.
  34689. * @param texture The texture to render to or null for the default canvas
  34690. * @param faceIndex The face of the texture to render to in case of cube texture
  34691. * @param requiredWidth The width of the target to render to
  34692. * @param requiredHeight The height of the target to render to
  34693. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34694. * @param lodLevel defines the lod level to bind to the frame buffer
  34695. * @param layer defines the 2d array index to bind to frame buffer to
  34696. */
  34697. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34698. /** @hidden */
  34699. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34700. /**
  34701. * Unbind the current render target texture from the webGL context
  34702. * @param texture defines the render target texture to unbind
  34703. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34704. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34705. */
  34706. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34707. /**
  34708. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34709. */
  34710. flushFramebuffer(): void;
  34711. /**
  34712. * Unbind the current render target and bind the default framebuffer
  34713. */
  34714. restoreDefaultFramebuffer(): void;
  34715. /** @hidden */
  34716. protected _resetVertexBufferBinding(): void;
  34717. /**
  34718. * Creates a vertex buffer
  34719. * @param data the data for the vertex buffer
  34720. * @returns the new WebGL static buffer
  34721. */
  34722. createVertexBuffer(data: DataArray): DataBuffer;
  34723. private _createVertexBuffer;
  34724. /**
  34725. * Creates a dynamic vertex buffer
  34726. * @param data the data for the dynamic vertex buffer
  34727. * @returns the new WebGL dynamic buffer
  34728. */
  34729. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34730. protected _resetIndexBufferBinding(): void;
  34731. /**
  34732. * Creates a new index buffer
  34733. * @param indices defines the content of the index buffer
  34734. * @param updatable defines if the index buffer must be updatable
  34735. * @returns a new webGL buffer
  34736. */
  34737. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34738. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34739. /**
  34740. * Bind a webGL buffer to the webGL context
  34741. * @param buffer defines the buffer to bind
  34742. */
  34743. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34744. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34745. private bindBuffer;
  34746. /**
  34747. * update the bound buffer with the given data
  34748. * @param data defines the data to update
  34749. */
  34750. updateArrayBuffer(data: Float32Array): void;
  34751. private _vertexAttribPointer;
  34752. /** @hidden */
  34753. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34754. private _bindVertexBuffersAttributes;
  34755. /**
  34756. * Records a vertex array object
  34757. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34758. * @param vertexBuffers defines the list of vertex buffers to store
  34759. * @param indexBuffer defines the index buffer to store
  34760. * @param effect defines the effect to store
  34761. * @returns the new vertex array object
  34762. */
  34763. recordVertexArrayObject(vertexBuffers: {
  34764. [key: string]: VertexBuffer;
  34765. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34766. /**
  34767. * Bind a specific vertex array object
  34768. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34769. * @param vertexArrayObject defines the vertex array object to bind
  34770. * @param indexBuffer defines the index buffer to bind
  34771. */
  34772. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34773. /**
  34774. * Bind webGl buffers directly to the webGL context
  34775. * @param vertexBuffer defines the vertex buffer to bind
  34776. * @param indexBuffer defines the index buffer to bind
  34777. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34778. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34779. * @param effect defines the effect associated with the vertex buffer
  34780. */
  34781. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34782. private _unbindVertexArrayObject;
  34783. /**
  34784. * Bind a list of vertex buffers to the webGL context
  34785. * @param vertexBuffers defines the list of vertex buffers to bind
  34786. * @param indexBuffer defines the index buffer to bind
  34787. * @param effect defines the effect associated with the vertex buffers
  34788. */
  34789. bindBuffers(vertexBuffers: {
  34790. [key: string]: Nullable<VertexBuffer>;
  34791. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34792. /**
  34793. * Unbind all instance attributes
  34794. */
  34795. unbindInstanceAttributes(): void;
  34796. /**
  34797. * Release and free the memory of a vertex array object
  34798. * @param vao defines the vertex array object to delete
  34799. */
  34800. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34801. /** @hidden */
  34802. _releaseBuffer(buffer: DataBuffer): boolean;
  34803. protected _deleteBuffer(buffer: DataBuffer): void;
  34804. /**
  34805. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34806. * @param instancesBuffer defines the webGL buffer to update and bind
  34807. * @param data defines the data to store in the buffer
  34808. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34809. */
  34810. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34811. /**
  34812. * Bind the content of a webGL buffer used with instantiation
  34813. * @param instancesBuffer defines the webGL buffer to bind
  34814. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34815. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34816. */
  34817. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34818. /**
  34819. * Disable the instance attribute corresponding to the name in parameter
  34820. * @param name defines the name of the attribute to disable
  34821. */
  34822. disableInstanceAttributeByName(name: string): void;
  34823. /**
  34824. * Disable the instance attribute corresponding to the location in parameter
  34825. * @param attributeLocation defines the attribute location of the attribute to disable
  34826. */
  34827. disableInstanceAttribute(attributeLocation: number): void;
  34828. /**
  34829. * Disable the attribute corresponding to the location in parameter
  34830. * @param attributeLocation defines the attribute location of the attribute to disable
  34831. */
  34832. disableAttributeByIndex(attributeLocation: number): void;
  34833. /**
  34834. * Send a draw order
  34835. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34836. * @param indexStart defines the starting index
  34837. * @param indexCount defines the number of index to draw
  34838. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34839. */
  34840. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34841. /**
  34842. * Draw a list of points
  34843. * @param verticesStart defines the index of first vertex to draw
  34844. * @param verticesCount defines the count of vertices to draw
  34845. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34846. */
  34847. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34848. /**
  34849. * Draw a list of unindexed primitives
  34850. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34851. * @param verticesStart defines the index of first vertex to draw
  34852. * @param verticesCount defines the count of vertices to draw
  34853. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34854. */
  34855. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34856. /**
  34857. * Draw a list of indexed primitives
  34858. * @param fillMode defines the primitive to use
  34859. * @param indexStart defines the starting index
  34860. * @param indexCount defines the number of index to draw
  34861. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34862. */
  34863. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34864. /**
  34865. * Draw a list of unindexed primitives
  34866. * @param fillMode defines the primitive to use
  34867. * @param verticesStart defines the index of first vertex to draw
  34868. * @param verticesCount defines the count of vertices to draw
  34869. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34870. */
  34871. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34872. private _drawMode;
  34873. /** @hidden */
  34874. protected _reportDrawCall(): void;
  34875. /** @hidden */
  34876. _releaseEffect(effect: Effect): void;
  34877. /** @hidden */
  34878. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34879. /**
  34880. * Create a new effect (used to store vertex/fragment shaders)
  34881. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34882. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34883. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34884. * @param samplers defines an array of string used to represent textures
  34885. * @param defines defines the string containing the defines to use to compile the shaders
  34886. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34887. * @param onCompiled defines a function to call when the effect creation is successful
  34888. * @param onError defines a function to call when the effect creation has failed
  34889. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34890. * @returns the new Effect
  34891. */
  34892. 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;
  34893. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34894. private _compileShader;
  34895. private _compileRawShader;
  34896. /** @hidden */
  34897. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34898. /**
  34899. * Directly creates a webGL program
  34900. * @param pipelineContext defines the pipeline context to attach to
  34901. * @param vertexCode defines the vertex shader code to use
  34902. * @param fragmentCode defines the fragment shader code to use
  34903. * @param context defines the webGL context to use (if not set, the current one will be used)
  34904. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34905. * @returns the new webGL program
  34906. */
  34907. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34908. /**
  34909. * Creates a webGL program
  34910. * @param pipelineContext defines the pipeline context to attach to
  34911. * @param vertexCode defines the vertex shader code to use
  34912. * @param fragmentCode defines the fragment shader code to use
  34913. * @param defines defines the string containing the defines to use to compile the shaders
  34914. * @param context defines the webGL context to use (if not set, the current one will be used)
  34915. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34916. * @returns the new webGL program
  34917. */
  34918. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34919. /**
  34920. * Creates a new pipeline context
  34921. * @returns the new pipeline
  34922. */
  34923. createPipelineContext(): IPipelineContext;
  34924. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34925. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34926. /** @hidden */
  34927. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34928. /** @hidden */
  34929. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34930. /** @hidden */
  34931. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34932. /**
  34933. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34934. * @param pipelineContext defines the pipeline context to use
  34935. * @param uniformsNames defines the list of uniform names
  34936. * @returns an array of webGL uniform locations
  34937. */
  34938. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34939. /**
  34940. * Gets the lsit of active attributes for a given webGL program
  34941. * @param pipelineContext defines the pipeline context to use
  34942. * @param attributesNames defines the list of attribute names to get
  34943. * @returns an array of indices indicating the offset of each attribute
  34944. */
  34945. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34946. /**
  34947. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34948. * @param effect defines the effect to activate
  34949. */
  34950. enableEffect(effect: Nullable<Effect>): void;
  34951. /**
  34952. * Set the value of an uniform to a number (int)
  34953. * @param uniform defines the webGL uniform location where to store the value
  34954. * @param value defines the int number to store
  34955. */
  34956. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34957. /**
  34958. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34963. /**
  34964. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34969. /**
  34970. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34975. /**
  34976. * Set the value of an uniform to an array of int32 (stored as vec4)
  34977. * @param uniform defines the webGL uniform location where to store the value
  34978. * @param array defines the array of int32 to store
  34979. */
  34980. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34981. /**
  34982. * Set the value of an uniform to an array of number
  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. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34987. /**
  34988. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34993. /**
  34994. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  34999. /**
  35000. * Set the value of an uniform to an array of number (stored as vec4)
  35001. * @param uniform defines the webGL uniform location where to store the value
  35002. * @param array defines the array of number to store
  35003. */
  35004. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35005. /**
  35006. * Set the value of an uniform to an array of float32 (stored as matrices)
  35007. * @param uniform defines the webGL uniform location where to store the value
  35008. * @param matrices defines the array of float32 to store
  35009. */
  35010. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35011. /**
  35012. * Set the value of an uniform to a matrix (3x3)
  35013. * @param uniform defines the webGL uniform location where to store the value
  35014. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35015. */
  35016. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35017. /**
  35018. * Set the value of an uniform to a matrix (2x2)
  35019. * @param uniform defines the webGL uniform location where to store the value
  35020. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35021. */
  35022. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35023. /**
  35024. * Set the value of an uniform to a number (float)
  35025. * @param uniform defines the webGL uniform location where to store the value
  35026. * @param value defines the float number to store
  35027. */
  35028. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35029. /**
  35030. * Set the value of an uniform to a vec2
  35031. * @param uniform defines the webGL uniform location where to store the value
  35032. * @param x defines the 1st component of the value
  35033. * @param y defines the 2nd component of the value
  35034. */
  35035. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35036. /**
  35037. * Set the value of an uniform to a vec3
  35038. * @param uniform defines the webGL uniform location where to store the value
  35039. * @param x defines the 1st component of the value
  35040. * @param y defines the 2nd component of the value
  35041. * @param z defines the 3rd component of the value
  35042. */
  35043. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35044. /**
  35045. * Set the value of an uniform to a vec4
  35046. * @param uniform defines the webGL uniform location where to store the value
  35047. * @param x defines the 1st component of the value
  35048. * @param y defines the 2nd component of the value
  35049. * @param z defines the 3rd component of the value
  35050. * @param w defines the 4th component of the value
  35051. */
  35052. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35053. /**
  35054. * Apply all cached states (depth, culling, stencil and alpha)
  35055. */
  35056. applyStates(): void;
  35057. /**
  35058. * Enable or disable color writing
  35059. * @param enable defines the state to set
  35060. */
  35061. setColorWrite(enable: boolean): void;
  35062. /**
  35063. * Gets a boolean indicating if color writing is enabled
  35064. * @returns the current color writing state
  35065. */
  35066. getColorWrite(): boolean;
  35067. /**
  35068. * Gets the depth culling state manager
  35069. */
  35070. get depthCullingState(): DepthCullingState;
  35071. /**
  35072. * Gets the alpha state manager
  35073. */
  35074. get alphaState(): AlphaState;
  35075. /**
  35076. * Gets the stencil state manager
  35077. */
  35078. get stencilState(): StencilState;
  35079. /**
  35080. * Clears the list of texture accessible through engine.
  35081. * This can help preventing texture load conflict due to name collision.
  35082. */
  35083. clearInternalTexturesCache(): void;
  35084. /**
  35085. * Force the entire cache to be cleared
  35086. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35087. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35088. */
  35089. wipeCaches(bruteForce?: boolean): void;
  35090. /** @hidden */
  35091. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35092. min: number;
  35093. mag: number;
  35094. };
  35095. /** @hidden */
  35096. _createTexture(): WebGLTexture;
  35097. /**
  35098. * Usually called from Texture.ts.
  35099. * Passed information to create a WebGLTexture
  35100. * @param url defines a value which contains one of the following:
  35101. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35102. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35103. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35104. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35105. * @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)
  35106. * @param scene needed for loading to the correct scene
  35107. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35108. * @param onLoad optional callback to be called upon successful completion
  35109. * @param onError optional callback to be called upon failure
  35110. * @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
  35111. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35112. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35113. * @param forcedExtension defines the extension to use to pick the right loader
  35114. * @param mimeType defines an optional mime type
  35115. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35116. */
  35117. 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;
  35118. /**
  35119. * Loads an image as an HTMLImageElement.
  35120. * @param input url string, ArrayBuffer, or Blob to load
  35121. * @param onLoad callback called when the image successfully loads
  35122. * @param onError callback called when the image fails to load
  35123. * @param offlineProvider offline provider for caching
  35124. * @param mimeType optional mime type
  35125. * @returns the HTMLImageElement of the loaded image
  35126. * @hidden
  35127. */
  35128. 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>;
  35129. /**
  35130. * @hidden
  35131. */
  35132. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35133. private _unpackFlipYCached;
  35134. /**
  35135. * In case you are sharing the context with other applications, it might
  35136. * be interested to not cache the unpack flip y state to ensure a consistent
  35137. * value would be set.
  35138. */
  35139. enableUnpackFlipYCached: boolean;
  35140. /** @hidden */
  35141. _unpackFlipY(value: boolean): void;
  35142. /** @hidden */
  35143. _getUnpackAlignement(): number;
  35144. private _getTextureTarget;
  35145. /**
  35146. * Update the sampling mode of a given texture
  35147. * @param samplingMode defines the required sampling mode
  35148. * @param texture defines the texture to update
  35149. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35150. */
  35151. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35152. /**
  35153. * Update the sampling mode of a given texture
  35154. * @param texture defines the texture to update
  35155. * @param wrapU defines the texture wrap mode of the u coordinates
  35156. * @param wrapV defines the texture wrap mode of the v coordinates
  35157. * @param wrapR defines the texture wrap mode of the r coordinates
  35158. */
  35159. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35160. /** @hidden */
  35161. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35162. width: number;
  35163. height: number;
  35164. layers?: number;
  35165. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35166. /** @hidden */
  35167. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35168. /** @hidden */
  35169. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35170. /**
  35171. * Update a portion of an internal texture
  35172. * @param texture defines the texture to update
  35173. * @param imageData defines the data to store into the texture
  35174. * @param xOffset defines the x coordinates of the update rectangle
  35175. * @param yOffset defines the y coordinates of the update rectangle
  35176. * @param width defines the width of the update rectangle
  35177. * @param height defines the height of the update rectangle
  35178. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35179. * @param lod defines the lod level to update (0 by default)
  35180. */
  35181. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35182. /** @hidden */
  35183. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35184. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35185. private _prepareWebGLTexture;
  35186. /** @hidden */
  35187. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35188. private _getDepthStencilBuffer;
  35189. /** @hidden */
  35190. _releaseFramebufferObjects(texture: InternalTexture): void;
  35191. /** @hidden */
  35192. _releaseTexture(texture: InternalTexture): void;
  35193. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35194. protected _setProgram(program: WebGLProgram): void;
  35195. protected _boundUniforms: {
  35196. [key: number]: WebGLUniformLocation;
  35197. };
  35198. /**
  35199. * Binds an effect to the webGL context
  35200. * @param effect defines the effect to bind
  35201. */
  35202. bindSamplers(effect: Effect): void;
  35203. private _activateCurrentTexture;
  35204. /** @hidden */
  35205. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35206. /** @hidden */
  35207. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35208. /**
  35209. * Unbind all textures from the webGL context
  35210. */
  35211. unbindAllTextures(): void;
  35212. /**
  35213. * Sets a texture to the according uniform.
  35214. * @param channel The texture channel
  35215. * @param uniform The uniform to set
  35216. * @param texture The texture to apply
  35217. */
  35218. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35219. private _bindSamplerUniformToChannel;
  35220. private _getTextureWrapMode;
  35221. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35222. /**
  35223. * Sets an array of texture to the webGL context
  35224. * @param channel defines the channel where the texture array must be set
  35225. * @param uniform defines the associated uniform location
  35226. * @param textures defines the array of textures to bind
  35227. */
  35228. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35229. /** @hidden */
  35230. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35231. private _setTextureParameterFloat;
  35232. private _setTextureParameterInteger;
  35233. /**
  35234. * Unbind all vertex attributes from the webGL context
  35235. */
  35236. unbindAllAttributes(): void;
  35237. /**
  35238. * 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
  35239. */
  35240. releaseEffects(): void;
  35241. /**
  35242. * Dispose and release all associated resources
  35243. */
  35244. dispose(): void;
  35245. /**
  35246. * Attach a new callback raised when context lost event is fired
  35247. * @param callback defines the callback to call
  35248. */
  35249. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35250. /**
  35251. * Attach a new callback raised when context restored event is fired
  35252. * @param callback defines the callback to call
  35253. */
  35254. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35255. /**
  35256. * Get the current error code of the webGL context
  35257. * @returns the error code
  35258. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35259. */
  35260. getError(): number;
  35261. private _canRenderToFloatFramebuffer;
  35262. private _canRenderToHalfFloatFramebuffer;
  35263. private _canRenderToFramebuffer;
  35264. /** @hidden */
  35265. _getWebGLTextureType(type: number): number;
  35266. /** @hidden */
  35267. _getInternalFormat(format: number): number;
  35268. /** @hidden */
  35269. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35270. /** @hidden */
  35271. _getRGBAMultiSampleBufferFormat(type: number): number;
  35272. /** @hidden */
  35273. _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;
  35274. /**
  35275. * Loads a file from a url
  35276. * @param url url to load
  35277. * @param onSuccess callback called when the file successfully loads
  35278. * @param onProgress callback called while file is loading (if the server supports this mode)
  35279. * @param offlineProvider defines the offline provider for caching
  35280. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35281. * @param onError callback called when the file fails to load
  35282. * @returns a file request object
  35283. * @hidden
  35284. */
  35285. 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;
  35286. /**
  35287. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35288. * @param x defines the x coordinate of the rectangle where pixels must be read
  35289. * @param y defines the y coordinate of the rectangle where pixels must be read
  35290. * @param width defines the width of the rectangle where pixels must be read
  35291. * @param height defines the height of the rectangle where pixels must be read
  35292. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35293. * @returns a Uint8Array containing RGBA colors
  35294. */
  35295. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35296. private static _isSupported;
  35297. /**
  35298. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35299. * @returns true if the engine can be created
  35300. * @ignorenaming
  35301. */
  35302. static isSupported(): boolean;
  35303. /**
  35304. * Find the next highest power of two.
  35305. * @param x Number to start search from.
  35306. * @return Next highest power of two.
  35307. */
  35308. static CeilingPOT(x: number): number;
  35309. /**
  35310. * Find the next lowest power of two.
  35311. * @param x Number to start search from.
  35312. * @return Next lowest power of two.
  35313. */
  35314. static FloorPOT(x: number): number;
  35315. /**
  35316. * Find the nearest power of two.
  35317. * @param x Number to start search from.
  35318. * @return Next nearest power of two.
  35319. */
  35320. static NearestPOT(x: number): number;
  35321. /**
  35322. * Get the closest exponent of two
  35323. * @param value defines the value to approximate
  35324. * @param max defines the maximum value to return
  35325. * @param mode defines how to define the closest value
  35326. * @returns closest exponent of two of the given value
  35327. */
  35328. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35329. /**
  35330. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35331. * @param func - the function to be called
  35332. * @param requester - the object that will request the next frame. Falls back to window.
  35333. * @returns frame number
  35334. */
  35335. static QueueNewFrame(func: () => void, requester?: any): number;
  35336. /**
  35337. * Gets host document
  35338. * @returns the host document object
  35339. */
  35340. getHostDocument(): Nullable<Document>;
  35341. }
  35342. }
  35343. declare module BABYLON {
  35344. /**
  35345. * Class representing spherical harmonics coefficients to the 3rd degree
  35346. */
  35347. export class SphericalHarmonics {
  35348. /**
  35349. * Defines whether or not the harmonics have been prescaled for rendering.
  35350. */
  35351. preScaled: boolean;
  35352. /**
  35353. * The l0,0 coefficients of the spherical harmonics
  35354. */
  35355. l00: Vector3;
  35356. /**
  35357. * The l1,-1 coefficients of the spherical harmonics
  35358. */
  35359. l1_1: Vector3;
  35360. /**
  35361. * The l1,0 coefficients of the spherical harmonics
  35362. */
  35363. l10: Vector3;
  35364. /**
  35365. * The l1,1 coefficients of the spherical harmonics
  35366. */
  35367. l11: Vector3;
  35368. /**
  35369. * The l2,-2 coefficients of the spherical harmonics
  35370. */
  35371. l2_2: Vector3;
  35372. /**
  35373. * The l2,-1 coefficients of the spherical harmonics
  35374. */
  35375. l2_1: Vector3;
  35376. /**
  35377. * The l2,0 coefficients of the spherical harmonics
  35378. */
  35379. l20: Vector3;
  35380. /**
  35381. * The l2,1 coefficients of the spherical harmonics
  35382. */
  35383. l21: Vector3;
  35384. /**
  35385. * The l2,2 coefficients of the spherical harmonics
  35386. */
  35387. l22: Vector3;
  35388. /**
  35389. * Adds a light to the spherical harmonics
  35390. * @param direction the direction of the light
  35391. * @param color the color of the light
  35392. * @param deltaSolidAngle the delta solid angle of the light
  35393. */
  35394. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35395. /**
  35396. * Scales the spherical harmonics by the given amount
  35397. * @param scale the amount to scale
  35398. */
  35399. scaleInPlace(scale: number): void;
  35400. /**
  35401. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35402. *
  35403. * ```
  35404. * E_lm = A_l * L_lm
  35405. * ```
  35406. *
  35407. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35408. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35409. * the scaling factors are given in equation 9.
  35410. */
  35411. convertIncidentRadianceToIrradiance(): void;
  35412. /**
  35413. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35414. *
  35415. * ```
  35416. * L = (1/pi) * E * rho
  35417. * ```
  35418. *
  35419. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35420. */
  35421. convertIrradianceToLambertianRadiance(): void;
  35422. /**
  35423. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35424. * required operations at run time.
  35425. *
  35426. * This is simply done by scaling back the SH with Ylm constants parameter.
  35427. * The trigonometric part being applied by the shader at run time.
  35428. */
  35429. preScaleForRendering(): void;
  35430. /**
  35431. * Constructs a spherical harmonics from an array.
  35432. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35433. * @returns the spherical harmonics
  35434. */
  35435. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35436. /**
  35437. * Gets the spherical harmonics from polynomial
  35438. * @param polynomial the spherical polynomial
  35439. * @returns the spherical harmonics
  35440. */
  35441. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35442. }
  35443. /**
  35444. * Class representing spherical polynomial coefficients to the 3rd degree
  35445. */
  35446. export class SphericalPolynomial {
  35447. private _harmonics;
  35448. /**
  35449. * The spherical harmonics used to create the polynomials.
  35450. */
  35451. get preScaledHarmonics(): SphericalHarmonics;
  35452. /**
  35453. * The x coefficients of the spherical polynomial
  35454. */
  35455. x: Vector3;
  35456. /**
  35457. * The y coefficients of the spherical polynomial
  35458. */
  35459. y: Vector3;
  35460. /**
  35461. * The z coefficients of the spherical polynomial
  35462. */
  35463. z: Vector3;
  35464. /**
  35465. * The xx coefficients of the spherical polynomial
  35466. */
  35467. xx: Vector3;
  35468. /**
  35469. * The yy coefficients of the spherical polynomial
  35470. */
  35471. yy: Vector3;
  35472. /**
  35473. * The zz coefficients of the spherical polynomial
  35474. */
  35475. zz: Vector3;
  35476. /**
  35477. * The xy coefficients of the spherical polynomial
  35478. */
  35479. xy: Vector3;
  35480. /**
  35481. * The yz coefficients of the spherical polynomial
  35482. */
  35483. yz: Vector3;
  35484. /**
  35485. * The zx coefficients of the spherical polynomial
  35486. */
  35487. zx: Vector3;
  35488. /**
  35489. * Adds an ambient color to the spherical polynomial
  35490. * @param color the color to add
  35491. */
  35492. addAmbient(color: Color3): void;
  35493. /**
  35494. * Scales the spherical polynomial by the given amount
  35495. * @param scale the amount to scale
  35496. */
  35497. scaleInPlace(scale: number): void;
  35498. /**
  35499. * Gets the spherical polynomial from harmonics
  35500. * @param harmonics the spherical harmonics
  35501. * @returns the spherical polynomial
  35502. */
  35503. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35504. /**
  35505. * Constructs a spherical polynomial from an array.
  35506. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35507. * @returns the spherical polynomial
  35508. */
  35509. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35510. }
  35511. }
  35512. declare module BABYLON {
  35513. /**
  35514. * Defines the source of the internal texture
  35515. */
  35516. export enum InternalTextureSource {
  35517. /**
  35518. * The source of the texture data is unknown
  35519. */
  35520. Unknown = 0,
  35521. /**
  35522. * Texture data comes from an URL
  35523. */
  35524. Url = 1,
  35525. /**
  35526. * Texture data is only used for temporary storage
  35527. */
  35528. Temp = 2,
  35529. /**
  35530. * Texture data comes from raw data (ArrayBuffer)
  35531. */
  35532. Raw = 3,
  35533. /**
  35534. * Texture content is dynamic (video or dynamic texture)
  35535. */
  35536. Dynamic = 4,
  35537. /**
  35538. * Texture content is generated by rendering to it
  35539. */
  35540. RenderTarget = 5,
  35541. /**
  35542. * Texture content is part of a multi render target process
  35543. */
  35544. MultiRenderTarget = 6,
  35545. /**
  35546. * Texture data comes from a cube data file
  35547. */
  35548. Cube = 7,
  35549. /**
  35550. * Texture data comes from a raw cube data
  35551. */
  35552. CubeRaw = 8,
  35553. /**
  35554. * Texture data come from a prefiltered cube data file
  35555. */
  35556. CubePrefiltered = 9,
  35557. /**
  35558. * Texture content is raw 3D data
  35559. */
  35560. Raw3D = 10,
  35561. /**
  35562. * Texture content is raw 2D array data
  35563. */
  35564. Raw2DArray = 11,
  35565. /**
  35566. * Texture content is a depth texture
  35567. */
  35568. Depth = 12,
  35569. /**
  35570. * Texture data comes from a raw cube data encoded with RGBD
  35571. */
  35572. CubeRawRGBD = 13
  35573. }
  35574. /**
  35575. * Class used to store data associated with WebGL texture data for the engine
  35576. * This class should not be used directly
  35577. */
  35578. export class InternalTexture {
  35579. /** @hidden */
  35580. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35581. /**
  35582. * Defines if the texture is ready
  35583. */
  35584. isReady: boolean;
  35585. /**
  35586. * Defines if the texture is a cube texture
  35587. */
  35588. isCube: boolean;
  35589. /**
  35590. * Defines if the texture contains 3D data
  35591. */
  35592. is3D: boolean;
  35593. /**
  35594. * Defines if the texture contains 2D array data
  35595. */
  35596. is2DArray: boolean;
  35597. /**
  35598. * Defines if the texture contains multiview data
  35599. */
  35600. isMultiview: boolean;
  35601. /**
  35602. * Gets the URL used to load this texture
  35603. */
  35604. url: string;
  35605. /**
  35606. * Gets the sampling mode of the texture
  35607. */
  35608. samplingMode: number;
  35609. /**
  35610. * Gets a boolean indicating if the texture needs mipmaps generation
  35611. */
  35612. generateMipMaps: boolean;
  35613. /**
  35614. * Gets the number of samples used by the texture (WebGL2+ only)
  35615. */
  35616. samples: number;
  35617. /**
  35618. * Gets the type of the texture (int, float...)
  35619. */
  35620. type: number;
  35621. /**
  35622. * Gets the format of the texture (RGB, RGBA...)
  35623. */
  35624. format: number;
  35625. /**
  35626. * Observable called when the texture is loaded
  35627. */
  35628. onLoadedObservable: Observable<InternalTexture>;
  35629. /**
  35630. * Gets the width of the texture
  35631. */
  35632. width: number;
  35633. /**
  35634. * Gets the height of the texture
  35635. */
  35636. height: number;
  35637. /**
  35638. * Gets the depth of the texture
  35639. */
  35640. depth: number;
  35641. /**
  35642. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35643. */
  35644. baseWidth: number;
  35645. /**
  35646. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35647. */
  35648. baseHeight: number;
  35649. /**
  35650. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35651. */
  35652. baseDepth: number;
  35653. /**
  35654. * Gets a boolean indicating if the texture is inverted on Y axis
  35655. */
  35656. invertY: boolean;
  35657. /** @hidden */
  35658. _invertVScale: boolean;
  35659. /** @hidden */
  35660. _associatedChannel: number;
  35661. /** @hidden */
  35662. _source: InternalTextureSource;
  35663. /** @hidden */
  35664. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35665. /** @hidden */
  35666. _bufferView: Nullable<ArrayBufferView>;
  35667. /** @hidden */
  35668. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35669. /** @hidden */
  35670. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35671. /** @hidden */
  35672. _size: number;
  35673. /** @hidden */
  35674. _extension: string;
  35675. /** @hidden */
  35676. _files: Nullable<string[]>;
  35677. /** @hidden */
  35678. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35679. /** @hidden */
  35680. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35681. /** @hidden */
  35682. _framebuffer: Nullable<WebGLFramebuffer>;
  35683. /** @hidden */
  35684. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35685. /** @hidden */
  35686. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35687. /** @hidden */
  35688. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35689. /** @hidden */
  35690. _attachments: Nullable<number[]>;
  35691. /** @hidden */
  35692. _cachedCoordinatesMode: Nullable<number>;
  35693. /** @hidden */
  35694. _cachedWrapU: Nullable<number>;
  35695. /** @hidden */
  35696. _cachedWrapV: Nullable<number>;
  35697. /** @hidden */
  35698. _cachedWrapR: Nullable<number>;
  35699. /** @hidden */
  35700. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35701. /** @hidden */
  35702. _isDisabled: boolean;
  35703. /** @hidden */
  35704. _compression: Nullable<string>;
  35705. /** @hidden */
  35706. _generateStencilBuffer: boolean;
  35707. /** @hidden */
  35708. _generateDepthBuffer: boolean;
  35709. /** @hidden */
  35710. _comparisonFunction: number;
  35711. /** @hidden */
  35712. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35713. /** @hidden */
  35714. _lodGenerationScale: number;
  35715. /** @hidden */
  35716. _lodGenerationOffset: number;
  35717. /** @hidden */
  35718. _depthStencilTexture: Nullable<InternalTexture>;
  35719. /** @hidden */
  35720. _colorTextureArray: Nullable<WebGLTexture>;
  35721. /** @hidden */
  35722. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35723. /** @hidden */
  35724. _lodTextureHigh: Nullable<BaseTexture>;
  35725. /** @hidden */
  35726. _lodTextureMid: Nullable<BaseTexture>;
  35727. /** @hidden */
  35728. _lodTextureLow: Nullable<BaseTexture>;
  35729. /** @hidden */
  35730. _isRGBD: boolean;
  35731. /** @hidden */
  35732. _linearSpecularLOD: boolean;
  35733. /** @hidden */
  35734. _irradianceTexture: Nullable<BaseTexture>;
  35735. /** @hidden */
  35736. _webGLTexture: Nullable<WebGLTexture>;
  35737. /** @hidden */
  35738. _references: number;
  35739. private _engine;
  35740. /**
  35741. * Gets the Engine the texture belongs to.
  35742. * @returns The babylon engine
  35743. */
  35744. getEngine(): ThinEngine;
  35745. /**
  35746. * Gets the data source type of the texture
  35747. */
  35748. get source(): InternalTextureSource;
  35749. /**
  35750. * Creates a new InternalTexture
  35751. * @param engine defines the engine to use
  35752. * @param source defines the type of data that will be used
  35753. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35754. */
  35755. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35756. /**
  35757. * Increments the number of references (ie. the number of Texture that point to it)
  35758. */
  35759. incrementReferences(): void;
  35760. /**
  35761. * Change the size of the texture (not the size of the content)
  35762. * @param width defines the new width
  35763. * @param height defines the new height
  35764. * @param depth defines the new depth (1 by default)
  35765. */
  35766. updateSize(width: int, height: int, depth?: int): void;
  35767. /** @hidden */
  35768. _rebuild(): void;
  35769. /** @hidden */
  35770. _swapAndDie(target: InternalTexture): void;
  35771. /**
  35772. * Dispose the current allocated resources
  35773. */
  35774. dispose(): void;
  35775. }
  35776. }
  35777. declare module BABYLON {
  35778. /**
  35779. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35780. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35781. */
  35782. export class Analyser {
  35783. /**
  35784. * Gets or sets the smoothing
  35785. * @ignorenaming
  35786. */
  35787. SMOOTHING: number;
  35788. /**
  35789. * Gets or sets the FFT table size
  35790. * @ignorenaming
  35791. */
  35792. FFT_SIZE: number;
  35793. /**
  35794. * Gets or sets the bar graph amplitude
  35795. * @ignorenaming
  35796. */
  35797. BARGRAPHAMPLITUDE: number;
  35798. /**
  35799. * Gets or sets the position of the debug canvas
  35800. * @ignorenaming
  35801. */
  35802. DEBUGCANVASPOS: {
  35803. x: number;
  35804. y: number;
  35805. };
  35806. /**
  35807. * Gets or sets the debug canvas size
  35808. * @ignorenaming
  35809. */
  35810. DEBUGCANVASSIZE: {
  35811. width: number;
  35812. height: number;
  35813. };
  35814. private _byteFreqs;
  35815. private _byteTime;
  35816. private _floatFreqs;
  35817. private _webAudioAnalyser;
  35818. private _debugCanvas;
  35819. private _debugCanvasContext;
  35820. private _scene;
  35821. private _registerFunc;
  35822. private _audioEngine;
  35823. /**
  35824. * Creates a new analyser
  35825. * @param scene defines hosting scene
  35826. */
  35827. constructor(scene: Scene);
  35828. /**
  35829. * Get the number of data values you will have to play with for the visualization
  35830. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35831. * @returns a number
  35832. */
  35833. getFrequencyBinCount(): number;
  35834. /**
  35835. * Gets the current frequency data as a byte array
  35836. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35837. * @returns a Uint8Array
  35838. */
  35839. getByteFrequencyData(): Uint8Array;
  35840. /**
  35841. * Gets the current waveform as a byte array
  35842. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35843. * @returns a Uint8Array
  35844. */
  35845. getByteTimeDomainData(): Uint8Array;
  35846. /**
  35847. * Gets the current frequency data as a float array
  35848. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35849. * @returns a Float32Array
  35850. */
  35851. getFloatFrequencyData(): Float32Array;
  35852. /**
  35853. * Renders the debug canvas
  35854. */
  35855. drawDebugCanvas(): void;
  35856. /**
  35857. * Stops rendering the debug canvas and removes it
  35858. */
  35859. stopDebugCanvas(): void;
  35860. /**
  35861. * Connects two audio nodes
  35862. * @param inputAudioNode defines first node to connect
  35863. * @param outputAudioNode defines second node to connect
  35864. */
  35865. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35866. /**
  35867. * Releases all associated resources
  35868. */
  35869. dispose(): void;
  35870. }
  35871. }
  35872. declare module BABYLON {
  35873. /**
  35874. * This represents an audio engine and it is responsible
  35875. * to play, synchronize and analyse sounds throughout the application.
  35876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35877. */
  35878. export interface IAudioEngine extends IDisposable {
  35879. /**
  35880. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35881. */
  35882. readonly canUseWebAudio: boolean;
  35883. /**
  35884. * Gets the current AudioContext if available.
  35885. */
  35886. readonly audioContext: Nullable<AudioContext>;
  35887. /**
  35888. * The master gain node defines the global audio volume of your audio engine.
  35889. */
  35890. readonly masterGain: GainNode;
  35891. /**
  35892. * Gets whether or not mp3 are supported by your browser.
  35893. */
  35894. readonly isMP3supported: boolean;
  35895. /**
  35896. * Gets whether or not ogg are supported by your browser.
  35897. */
  35898. readonly isOGGsupported: boolean;
  35899. /**
  35900. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35901. * @ignoreNaming
  35902. */
  35903. WarnedWebAudioUnsupported: boolean;
  35904. /**
  35905. * Defines if the audio engine relies on a custom unlocked button.
  35906. * In this case, the embedded button will not be displayed.
  35907. */
  35908. useCustomUnlockedButton: boolean;
  35909. /**
  35910. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35911. */
  35912. readonly unlocked: boolean;
  35913. /**
  35914. * Event raised when audio has been unlocked on the browser.
  35915. */
  35916. onAudioUnlockedObservable: Observable<AudioEngine>;
  35917. /**
  35918. * Event raised when audio has been locked on the browser.
  35919. */
  35920. onAudioLockedObservable: Observable<AudioEngine>;
  35921. /**
  35922. * Flags the audio engine in Locked state.
  35923. * This happens due to new browser policies preventing audio to autoplay.
  35924. */
  35925. lock(): void;
  35926. /**
  35927. * Unlocks the audio engine once a user action has been done on the dom.
  35928. * This is helpful to resume play once browser policies have been satisfied.
  35929. */
  35930. unlock(): void;
  35931. /**
  35932. * Gets the global volume sets on the master gain.
  35933. * @returns the global volume if set or -1 otherwise
  35934. */
  35935. getGlobalVolume(): number;
  35936. /**
  35937. * Sets the global volume of your experience (sets on the master gain).
  35938. * @param newVolume Defines the new global volume of the application
  35939. */
  35940. setGlobalVolume(newVolume: number): void;
  35941. /**
  35942. * Connect the audio engine to an audio analyser allowing some amazing
  35943. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35944. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35945. * @param analyser The analyser to connect to the engine
  35946. */
  35947. connectToAnalyser(analyser: Analyser): void;
  35948. }
  35949. /**
  35950. * This represents the default audio engine used in babylon.
  35951. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35953. */
  35954. export class AudioEngine implements IAudioEngine {
  35955. private _audioContext;
  35956. private _audioContextInitialized;
  35957. private _muteButton;
  35958. private _hostElement;
  35959. /**
  35960. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35961. */
  35962. canUseWebAudio: boolean;
  35963. /**
  35964. * The master gain node defines the global audio volume of your audio engine.
  35965. */
  35966. masterGain: GainNode;
  35967. /**
  35968. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35969. * @ignoreNaming
  35970. */
  35971. WarnedWebAudioUnsupported: boolean;
  35972. /**
  35973. * Gets whether or not mp3 are supported by your browser.
  35974. */
  35975. isMP3supported: boolean;
  35976. /**
  35977. * Gets whether or not ogg are supported by your browser.
  35978. */
  35979. isOGGsupported: boolean;
  35980. /**
  35981. * Gets whether audio has been unlocked on the device.
  35982. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  35983. * a user interaction has happened.
  35984. */
  35985. unlocked: boolean;
  35986. /**
  35987. * Defines if the audio engine relies on a custom unlocked button.
  35988. * In this case, the embedded button will not be displayed.
  35989. */
  35990. useCustomUnlockedButton: boolean;
  35991. /**
  35992. * Event raised when audio has been unlocked on the browser.
  35993. */
  35994. onAudioUnlockedObservable: Observable<AudioEngine>;
  35995. /**
  35996. * Event raised when audio has been locked on the browser.
  35997. */
  35998. onAudioLockedObservable: Observable<AudioEngine>;
  35999. /**
  36000. * Gets the current AudioContext if available.
  36001. */
  36002. get audioContext(): Nullable<AudioContext>;
  36003. private _connectedAnalyser;
  36004. /**
  36005. * Instantiates a new audio engine.
  36006. *
  36007. * There should be only one per page as some browsers restrict the number
  36008. * of audio contexts you can create.
  36009. * @param hostElement defines the host element where to display the mute icon if necessary
  36010. */
  36011. constructor(hostElement?: Nullable<HTMLElement>);
  36012. /**
  36013. * Flags the audio engine in Locked state.
  36014. * This happens due to new browser policies preventing audio to autoplay.
  36015. */
  36016. lock(): void;
  36017. /**
  36018. * Unlocks the audio engine once a user action has been done on the dom.
  36019. * This is helpful to resume play once browser policies have been satisfied.
  36020. */
  36021. unlock(): void;
  36022. private _resumeAudioContext;
  36023. private _initializeAudioContext;
  36024. private _tryToRun;
  36025. private _triggerRunningState;
  36026. private _triggerSuspendedState;
  36027. private _displayMuteButton;
  36028. private _moveButtonToTopLeft;
  36029. private _onResize;
  36030. private _hideMuteButton;
  36031. /**
  36032. * Destroy and release the resources associated with the audio ccontext.
  36033. */
  36034. dispose(): void;
  36035. /**
  36036. * Gets the global volume sets on the master gain.
  36037. * @returns the global volume if set or -1 otherwise
  36038. */
  36039. getGlobalVolume(): number;
  36040. /**
  36041. * Sets the global volume of your experience (sets on the master gain).
  36042. * @param newVolume Defines the new global volume of the application
  36043. */
  36044. setGlobalVolume(newVolume: number): void;
  36045. /**
  36046. * Connect the audio engine to an audio analyser allowing some amazing
  36047. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36049. * @param analyser The analyser to connect to the engine
  36050. */
  36051. connectToAnalyser(analyser: Analyser): void;
  36052. }
  36053. }
  36054. declare module BABYLON {
  36055. /**
  36056. * Interface used to present a loading screen while loading a scene
  36057. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36058. */
  36059. export interface ILoadingScreen {
  36060. /**
  36061. * Function called to display the loading screen
  36062. */
  36063. displayLoadingUI: () => void;
  36064. /**
  36065. * Function called to hide the loading screen
  36066. */
  36067. hideLoadingUI: () => void;
  36068. /**
  36069. * Gets or sets the color to use for the background
  36070. */
  36071. loadingUIBackgroundColor: string;
  36072. /**
  36073. * Gets or sets the text to display while loading
  36074. */
  36075. loadingUIText: string;
  36076. }
  36077. /**
  36078. * Class used for the default loading screen
  36079. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36080. */
  36081. export class DefaultLoadingScreen implements ILoadingScreen {
  36082. private _renderingCanvas;
  36083. private _loadingText;
  36084. private _loadingDivBackgroundColor;
  36085. private _loadingDiv;
  36086. private _loadingTextDiv;
  36087. /** Gets or sets the logo url to use for the default loading screen */
  36088. static DefaultLogoUrl: string;
  36089. /** Gets or sets the spinner url to use for the default loading screen */
  36090. static DefaultSpinnerUrl: string;
  36091. /**
  36092. * Creates a new default loading screen
  36093. * @param _renderingCanvas defines the canvas used to render the scene
  36094. * @param _loadingText defines the default text to display
  36095. * @param _loadingDivBackgroundColor defines the default background color
  36096. */
  36097. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36098. /**
  36099. * Function called to display the loading screen
  36100. */
  36101. displayLoadingUI(): void;
  36102. /**
  36103. * Function called to hide the loading screen
  36104. */
  36105. hideLoadingUI(): void;
  36106. /**
  36107. * Gets or sets the text to display while loading
  36108. */
  36109. set loadingUIText(text: string);
  36110. get loadingUIText(): string;
  36111. /**
  36112. * Gets or sets the color to use for the background
  36113. */
  36114. get loadingUIBackgroundColor(): string;
  36115. set loadingUIBackgroundColor(color: string);
  36116. private _resizeLoadingUI;
  36117. }
  36118. }
  36119. declare module BABYLON {
  36120. /**
  36121. * Interface for any object that can request an animation frame
  36122. */
  36123. export interface ICustomAnimationFrameRequester {
  36124. /**
  36125. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36126. */
  36127. renderFunction?: Function;
  36128. /**
  36129. * Called to request the next frame to render to
  36130. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36131. */
  36132. requestAnimationFrame: Function;
  36133. /**
  36134. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36135. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36136. */
  36137. requestID?: number;
  36138. }
  36139. }
  36140. declare module BABYLON {
  36141. /**
  36142. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36143. */
  36144. export class PerformanceMonitor {
  36145. private _enabled;
  36146. private _rollingFrameTime;
  36147. private _lastFrameTimeMs;
  36148. /**
  36149. * constructor
  36150. * @param frameSampleSize The number of samples required to saturate the sliding window
  36151. */
  36152. constructor(frameSampleSize?: number);
  36153. /**
  36154. * Samples current frame
  36155. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36156. */
  36157. sampleFrame(timeMs?: number): void;
  36158. /**
  36159. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36160. */
  36161. get averageFrameTime(): number;
  36162. /**
  36163. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36164. */
  36165. get averageFrameTimeVariance(): number;
  36166. /**
  36167. * Returns the frame time of the most recent frame
  36168. */
  36169. get instantaneousFrameTime(): number;
  36170. /**
  36171. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36172. */
  36173. get averageFPS(): number;
  36174. /**
  36175. * Returns the average framerate in frames per second using the most recent frame time
  36176. */
  36177. get instantaneousFPS(): number;
  36178. /**
  36179. * Returns true if enough samples have been taken to completely fill the sliding window
  36180. */
  36181. get isSaturated(): boolean;
  36182. /**
  36183. * Enables contributions to the sliding window sample set
  36184. */
  36185. enable(): void;
  36186. /**
  36187. * Disables contributions to the sliding window sample set
  36188. * Samples will not be interpolated over the disabled period
  36189. */
  36190. disable(): void;
  36191. /**
  36192. * Returns true if sampling is enabled
  36193. */
  36194. get isEnabled(): boolean;
  36195. /**
  36196. * Resets performance monitor
  36197. */
  36198. reset(): void;
  36199. }
  36200. /**
  36201. * RollingAverage
  36202. *
  36203. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36204. */
  36205. export class RollingAverage {
  36206. /**
  36207. * Current average
  36208. */
  36209. average: number;
  36210. /**
  36211. * Current variance
  36212. */
  36213. variance: number;
  36214. protected _samples: Array<number>;
  36215. protected _sampleCount: number;
  36216. protected _pos: number;
  36217. protected _m2: number;
  36218. /**
  36219. * constructor
  36220. * @param length The number of samples required to saturate the sliding window
  36221. */
  36222. constructor(length: number);
  36223. /**
  36224. * Adds a sample to the sample set
  36225. * @param v The sample value
  36226. */
  36227. add(v: number): void;
  36228. /**
  36229. * Returns previously added values or null if outside of history or outside the sliding window domain
  36230. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36231. * @return Value previously recorded with add() or null if outside of range
  36232. */
  36233. history(i: number): number;
  36234. /**
  36235. * Returns true if enough samples have been taken to completely fill the sliding window
  36236. * @return true if sample-set saturated
  36237. */
  36238. isSaturated(): boolean;
  36239. /**
  36240. * Resets the rolling average (equivalent to 0 samples taken so far)
  36241. */
  36242. reset(): void;
  36243. /**
  36244. * Wraps a value around the sample range boundaries
  36245. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36246. * @return Wrapped position in sample range
  36247. */
  36248. protected _wrapPosition(i: number): number;
  36249. }
  36250. }
  36251. declare module BABYLON {
  36252. /**
  36253. * This class is used to track a performance counter which is number based.
  36254. * The user has access to many properties which give statistics of different nature.
  36255. *
  36256. * The implementer can track two kinds of Performance Counter: time and count.
  36257. * 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.
  36258. * 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.
  36259. */
  36260. export class PerfCounter {
  36261. /**
  36262. * Gets or sets a global boolean to turn on and off all the counters
  36263. */
  36264. static Enabled: boolean;
  36265. /**
  36266. * Returns the smallest value ever
  36267. */
  36268. get min(): number;
  36269. /**
  36270. * Returns the biggest value ever
  36271. */
  36272. get max(): number;
  36273. /**
  36274. * Returns the average value since the performance counter is running
  36275. */
  36276. get average(): number;
  36277. /**
  36278. * Returns the average value of the last second the counter was monitored
  36279. */
  36280. get lastSecAverage(): number;
  36281. /**
  36282. * Returns the current value
  36283. */
  36284. get current(): number;
  36285. /**
  36286. * Gets the accumulated total
  36287. */
  36288. get total(): number;
  36289. /**
  36290. * Gets the total value count
  36291. */
  36292. get count(): number;
  36293. /**
  36294. * Creates a new counter
  36295. */
  36296. constructor();
  36297. /**
  36298. * Call this method to start monitoring a new frame.
  36299. * 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.
  36300. */
  36301. fetchNewFrame(): void;
  36302. /**
  36303. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36304. * @param newCount the count value to add to the monitored count
  36305. * @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.
  36306. */
  36307. addCount(newCount: number, fetchResult: boolean): void;
  36308. /**
  36309. * Start monitoring this performance counter
  36310. */
  36311. beginMonitoring(): void;
  36312. /**
  36313. * Compute the time lapsed since the previous beginMonitoring() call.
  36314. * @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
  36315. */
  36316. endMonitoring(newFrame?: boolean): void;
  36317. private _fetchResult;
  36318. private _startMonitoringTime;
  36319. private _min;
  36320. private _max;
  36321. private _average;
  36322. private _current;
  36323. private _totalValueCount;
  36324. private _totalAccumulated;
  36325. private _lastSecAverage;
  36326. private _lastSecAccumulated;
  36327. private _lastSecTime;
  36328. private _lastSecValueCount;
  36329. }
  36330. }
  36331. declare module BABYLON {
  36332. interface ThinEngine {
  36333. /**
  36334. * Sets alpha constants used by some alpha blending modes
  36335. * @param r defines the red component
  36336. * @param g defines the green component
  36337. * @param b defines the blue component
  36338. * @param a defines the alpha component
  36339. */
  36340. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36341. /**
  36342. * Sets the current alpha mode
  36343. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36344. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36345. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36346. */
  36347. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36348. /**
  36349. * Gets the current alpha mode
  36350. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36351. * @returns the current alpha mode
  36352. */
  36353. getAlphaMode(): number;
  36354. /**
  36355. * Sets the current alpha equation
  36356. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36357. */
  36358. setAlphaEquation(equation: number): void;
  36359. /**
  36360. * Gets the current alpha equation.
  36361. * @returns the current alpha equation
  36362. */
  36363. getAlphaEquation(): number;
  36364. }
  36365. }
  36366. declare module BABYLON {
  36367. interface ThinEngine {
  36368. /** @hidden */
  36369. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36370. }
  36371. }
  36372. declare module BABYLON {
  36373. /**
  36374. * Defines the interface used by display changed events
  36375. */
  36376. export interface IDisplayChangedEventArgs {
  36377. /** Gets the vrDisplay object (if any) */
  36378. vrDisplay: Nullable<any>;
  36379. /** Gets a boolean indicating if webVR is supported */
  36380. vrSupported: boolean;
  36381. }
  36382. /**
  36383. * Defines the interface used by objects containing a viewport (like a camera)
  36384. */
  36385. interface IViewportOwnerLike {
  36386. /**
  36387. * Gets or sets the viewport
  36388. */
  36389. viewport: IViewportLike;
  36390. }
  36391. /**
  36392. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36393. */
  36394. export class Engine extends ThinEngine {
  36395. /** Defines that alpha blending is disabled */
  36396. static readonly ALPHA_DISABLE: number;
  36397. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36398. static readonly ALPHA_ADD: number;
  36399. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36400. static readonly ALPHA_COMBINE: number;
  36401. /** Defines that alpha blending to DEST - SRC * DEST */
  36402. static readonly ALPHA_SUBTRACT: number;
  36403. /** Defines that alpha blending to SRC * DEST */
  36404. static readonly ALPHA_MULTIPLY: number;
  36405. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36406. static readonly ALPHA_MAXIMIZED: number;
  36407. /** Defines that alpha blending to SRC + DEST */
  36408. static readonly ALPHA_ONEONE: number;
  36409. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36410. static readonly ALPHA_PREMULTIPLIED: number;
  36411. /**
  36412. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36413. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36414. */
  36415. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36416. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36417. static readonly ALPHA_INTERPOLATE: number;
  36418. /**
  36419. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36420. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36421. */
  36422. static readonly ALPHA_SCREENMODE: number;
  36423. /** Defines that the ressource is not delayed*/
  36424. static readonly DELAYLOADSTATE_NONE: number;
  36425. /** Defines that the ressource was successfully delay loaded */
  36426. static readonly DELAYLOADSTATE_LOADED: number;
  36427. /** Defines that the ressource is currently delay loading */
  36428. static readonly DELAYLOADSTATE_LOADING: number;
  36429. /** Defines that the ressource is delayed and has not started loading */
  36430. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36431. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36432. static readonly NEVER: number;
  36433. /** 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 */
  36434. static readonly ALWAYS: number;
  36435. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36436. static readonly LESS: number;
  36437. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36438. static readonly EQUAL: number;
  36439. /** 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 */
  36440. static readonly LEQUAL: number;
  36441. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36442. static readonly GREATER: number;
  36443. /** 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 */
  36444. static readonly GEQUAL: number;
  36445. /** 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 */
  36446. static readonly NOTEQUAL: number;
  36447. /** Passed to stencilOperation to specify that stencil value must be kept */
  36448. static readonly KEEP: number;
  36449. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36450. static readonly REPLACE: number;
  36451. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36452. static readonly INCR: number;
  36453. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36454. static readonly DECR: number;
  36455. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36456. static readonly INVERT: number;
  36457. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36458. static readonly INCR_WRAP: number;
  36459. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36460. static readonly DECR_WRAP: number;
  36461. /** Texture is not repeating outside of 0..1 UVs */
  36462. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36463. /** Texture is repeating outside of 0..1 UVs */
  36464. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36465. /** Texture is repeating and mirrored */
  36466. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36467. /** ALPHA */
  36468. static readonly TEXTUREFORMAT_ALPHA: number;
  36469. /** LUMINANCE */
  36470. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36471. /** LUMINANCE_ALPHA */
  36472. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36473. /** RGB */
  36474. static readonly TEXTUREFORMAT_RGB: number;
  36475. /** RGBA */
  36476. static readonly TEXTUREFORMAT_RGBA: number;
  36477. /** RED */
  36478. static readonly TEXTUREFORMAT_RED: number;
  36479. /** RED (2nd reference) */
  36480. static readonly TEXTUREFORMAT_R: number;
  36481. /** RG */
  36482. static readonly TEXTUREFORMAT_RG: number;
  36483. /** RED_INTEGER */
  36484. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36485. /** RED_INTEGER (2nd reference) */
  36486. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36487. /** RG_INTEGER */
  36488. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36489. /** RGB_INTEGER */
  36490. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36491. /** RGBA_INTEGER */
  36492. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36493. /** UNSIGNED_BYTE */
  36494. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36495. /** UNSIGNED_BYTE (2nd reference) */
  36496. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36497. /** FLOAT */
  36498. static readonly TEXTURETYPE_FLOAT: number;
  36499. /** HALF_FLOAT */
  36500. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36501. /** BYTE */
  36502. static readonly TEXTURETYPE_BYTE: number;
  36503. /** SHORT */
  36504. static readonly TEXTURETYPE_SHORT: number;
  36505. /** UNSIGNED_SHORT */
  36506. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36507. /** INT */
  36508. static readonly TEXTURETYPE_INT: number;
  36509. /** UNSIGNED_INT */
  36510. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36511. /** UNSIGNED_SHORT_4_4_4_4 */
  36512. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36513. /** UNSIGNED_SHORT_5_5_5_1 */
  36514. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36515. /** UNSIGNED_SHORT_5_6_5 */
  36516. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36517. /** UNSIGNED_INT_2_10_10_10_REV */
  36518. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36519. /** UNSIGNED_INT_24_8 */
  36520. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36521. /** UNSIGNED_INT_10F_11F_11F_REV */
  36522. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36523. /** UNSIGNED_INT_5_9_9_9_REV */
  36524. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36525. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36526. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36527. /** nearest is mag = nearest and min = nearest and mip = linear */
  36528. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36529. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36530. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36531. /** Trilinear is mag = linear and min = linear and mip = linear */
  36532. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36533. /** nearest is mag = nearest and min = nearest and mip = linear */
  36534. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36535. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36536. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36537. /** Trilinear is mag = linear and min = linear and mip = linear */
  36538. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36539. /** mag = nearest and min = nearest and mip = nearest */
  36540. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36541. /** mag = nearest and min = linear and mip = nearest */
  36542. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36543. /** mag = nearest and min = linear and mip = linear */
  36544. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36545. /** mag = nearest and min = linear and mip = none */
  36546. static readonly TEXTURE_NEAREST_LINEAR: number;
  36547. /** mag = nearest and min = nearest and mip = none */
  36548. static readonly TEXTURE_NEAREST_NEAREST: number;
  36549. /** mag = linear and min = nearest and mip = nearest */
  36550. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36551. /** mag = linear and min = nearest and mip = linear */
  36552. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36553. /** mag = linear and min = linear and mip = none */
  36554. static readonly TEXTURE_LINEAR_LINEAR: number;
  36555. /** mag = linear and min = nearest and mip = none */
  36556. static readonly TEXTURE_LINEAR_NEAREST: number;
  36557. /** Explicit coordinates mode */
  36558. static readonly TEXTURE_EXPLICIT_MODE: number;
  36559. /** Spherical coordinates mode */
  36560. static readonly TEXTURE_SPHERICAL_MODE: number;
  36561. /** Planar coordinates mode */
  36562. static readonly TEXTURE_PLANAR_MODE: number;
  36563. /** Cubic coordinates mode */
  36564. static readonly TEXTURE_CUBIC_MODE: number;
  36565. /** Projection coordinates mode */
  36566. static readonly TEXTURE_PROJECTION_MODE: number;
  36567. /** Skybox coordinates mode */
  36568. static readonly TEXTURE_SKYBOX_MODE: number;
  36569. /** Inverse Cubic coordinates mode */
  36570. static readonly TEXTURE_INVCUBIC_MODE: number;
  36571. /** Equirectangular coordinates mode */
  36572. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36573. /** Equirectangular Fixed coordinates mode */
  36574. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36575. /** Equirectangular Fixed Mirrored coordinates mode */
  36576. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36577. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36578. static readonly SCALEMODE_FLOOR: number;
  36579. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36580. static readonly SCALEMODE_NEAREST: number;
  36581. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36582. static readonly SCALEMODE_CEILING: number;
  36583. /**
  36584. * Returns the current npm package of the sdk
  36585. */
  36586. static get NpmPackage(): string;
  36587. /**
  36588. * Returns the current version of the framework
  36589. */
  36590. static get Version(): string;
  36591. /** Gets the list of created engines */
  36592. static get Instances(): Engine[];
  36593. /**
  36594. * Gets the latest created engine
  36595. */
  36596. static get LastCreatedEngine(): Nullable<Engine>;
  36597. /**
  36598. * Gets the latest created scene
  36599. */
  36600. static get LastCreatedScene(): Nullable<Scene>;
  36601. /**
  36602. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36603. * @param flag defines which part of the materials must be marked as dirty
  36604. * @param predicate defines a predicate used to filter which materials should be affected
  36605. */
  36606. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36607. /**
  36608. * Method called to create the default loading screen.
  36609. * This can be overriden in your own app.
  36610. * @param canvas The rendering canvas element
  36611. * @returns The loading screen
  36612. */
  36613. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36614. /**
  36615. * Method called to create the default rescale post process on each engine.
  36616. */
  36617. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36618. /**
  36619. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36620. **/
  36621. enableOfflineSupport: boolean;
  36622. /**
  36623. * 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)
  36624. **/
  36625. disableManifestCheck: boolean;
  36626. /**
  36627. * Gets the list of created scenes
  36628. */
  36629. scenes: Scene[];
  36630. /**
  36631. * Event raised when a new scene is created
  36632. */
  36633. onNewSceneAddedObservable: Observable<Scene>;
  36634. /**
  36635. * Gets the list of created postprocesses
  36636. */
  36637. postProcesses: PostProcess[];
  36638. /**
  36639. * Gets a boolean indicating if the pointer is currently locked
  36640. */
  36641. isPointerLock: boolean;
  36642. /**
  36643. * Observable event triggered each time the rendering canvas is resized
  36644. */
  36645. onResizeObservable: Observable<Engine>;
  36646. /**
  36647. * Observable event triggered each time the canvas loses focus
  36648. */
  36649. onCanvasBlurObservable: Observable<Engine>;
  36650. /**
  36651. * Observable event triggered each time the canvas gains focus
  36652. */
  36653. onCanvasFocusObservable: Observable<Engine>;
  36654. /**
  36655. * Observable event triggered each time the canvas receives pointerout event
  36656. */
  36657. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36658. /**
  36659. * Observable raised when the engine begins a new frame
  36660. */
  36661. onBeginFrameObservable: Observable<Engine>;
  36662. /**
  36663. * If set, will be used to request the next animation frame for the render loop
  36664. */
  36665. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36666. /**
  36667. * Observable raised when the engine ends the current frame
  36668. */
  36669. onEndFrameObservable: Observable<Engine>;
  36670. /**
  36671. * Observable raised when the engine is about to compile a shader
  36672. */
  36673. onBeforeShaderCompilationObservable: Observable<Engine>;
  36674. /**
  36675. * Observable raised when the engine has jsut compiled a shader
  36676. */
  36677. onAfterShaderCompilationObservable: Observable<Engine>;
  36678. /**
  36679. * Gets the audio engine
  36680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36681. * @ignorenaming
  36682. */
  36683. static audioEngine: IAudioEngine;
  36684. /**
  36685. * Default AudioEngine factory responsible of creating the Audio Engine.
  36686. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36687. */
  36688. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36689. /**
  36690. * Default offline support factory responsible of creating a tool used to store data locally.
  36691. * By default, this will create a Database object if the workload has been embedded.
  36692. */
  36693. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36694. private _loadingScreen;
  36695. private _pointerLockRequested;
  36696. private _rescalePostProcess;
  36697. private _deterministicLockstep;
  36698. private _lockstepMaxSteps;
  36699. private _timeStep;
  36700. protected get _supportsHardwareTextureRescaling(): boolean;
  36701. private _fps;
  36702. private _deltaTime;
  36703. /** @hidden */
  36704. _drawCalls: PerfCounter;
  36705. /** 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 */
  36706. canvasTabIndex: number;
  36707. /**
  36708. * Turn this value on if you want to pause FPS computation when in background
  36709. */
  36710. disablePerformanceMonitorInBackground: boolean;
  36711. private _performanceMonitor;
  36712. /**
  36713. * Gets the performance monitor attached to this engine
  36714. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36715. */
  36716. get performanceMonitor(): PerformanceMonitor;
  36717. private _onFocus;
  36718. private _onBlur;
  36719. private _onCanvasPointerOut;
  36720. private _onCanvasBlur;
  36721. private _onCanvasFocus;
  36722. private _onFullscreenChange;
  36723. private _onPointerLockChange;
  36724. /**
  36725. * Gets the HTML element used to attach event listeners
  36726. * @returns a HTML element
  36727. */
  36728. getInputElement(): Nullable<HTMLElement>;
  36729. /**
  36730. * Creates a new engine
  36731. * @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
  36732. * @param antialias defines enable antialiasing (default: false)
  36733. * @param options defines further options to be sent to the getContext() function
  36734. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36735. */
  36736. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36737. /**
  36738. * Gets current aspect ratio
  36739. * @param viewportOwner defines the camera to use to get the aspect ratio
  36740. * @param useScreen defines if screen size must be used (or the current render target if any)
  36741. * @returns a number defining the aspect ratio
  36742. */
  36743. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36744. /**
  36745. * Gets current screen aspect ratio
  36746. * @returns a number defining the aspect ratio
  36747. */
  36748. getScreenAspectRatio(): number;
  36749. /**
  36750. * Gets the client rect of the HTML canvas attached with the current webGL context
  36751. * @returns a client rectanglee
  36752. */
  36753. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36754. /**
  36755. * Gets the client rect of the HTML element used for events
  36756. * @returns a client rectanglee
  36757. */
  36758. getInputElementClientRect(): Nullable<ClientRect>;
  36759. /**
  36760. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36761. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36762. * @returns true if engine is in deterministic lock step mode
  36763. */
  36764. isDeterministicLockStep(): boolean;
  36765. /**
  36766. * Gets the max steps when engine is running in deterministic lock step
  36767. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36768. * @returns the max steps
  36769. */
  36770. getLockstepMaxSteps(): number;
  36771. /**
  36772. * Returns the time in ms between steps when using deterministic lock step.
  36773. * @returns time step in (ms)
  36774. */
  36775. getTimeStep(): number;
  36776. /**
  36777. * Force the mipmap generation for the given render target texture
  36778. * @param texture defines the render target texture to use
  36779. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36780. */
  36781. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36782. /** States */
  36783. /**
  36784. * Set various states to the webGL context
  36785. * @param culling defines backface culling state
  36786. * @param zOffset defines the value to apply to zOffset (0 by default)
  36787. * @param force defines if states must be applied even if cache is up to date
  36788. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36789. */
  36790. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36791. /**
  36792. * Set the z offset to apply to current rendering
  36793. * @param value defines the offset to apply
  36794. */
  36795. setZOffset(value: number): void;
  36796. /**
  36797. * Gets the current value of the zOffset
  36798. * @returns the current zOffset state
  36799. */
  36800. getZOffset(): number;
  36801. /**
  36802. * Enable or disable depth buffering
  36803. * @param enable defines the state to set
  36804. */
  36805. setDepthBuffer(enable: boolean): void;
  36806. /**
  36807. * Gets a boolean indicating if depth writing is enabled
  36808. * @returns the current depth writing state
  36809. */
  36810. getDepthWrite(): boolean;
  36811. /**
  36812. * Enable or disable depth writing
  36813. * @param enable defines the state to set
  36814. */
  36815. setDepthWrite(enable: boolean): void;
  36816. /**
  36817. * Gets a boolean indicating if stencil buffer is enabled
  36818. * @returns the current stencil buffer state
  36819. */
  36820. getStencilBuffer(): boolean;
  36821. /**
  36822. * Enable or disable the stencil buffer
  36823. * @param enable defines if the stencil buffer must be enabled or disabled
  36824. */
  36825. setStencilBuffer(enable: boolean): void;
  36826. /**
  36827. * Gets the current stencil mask
  36828. * @returns a number defining the new stencil mask to use
  36829. */
  36830. getStencilMask(): number;
  36831. /**
  36832. * Sets the current stencil mask
  36833. * @param mask defines the new stencil mask to use
  36834. */
  36835. setStencilMask(mask: number): void;
  36836. /**
  36837. * Gets the current stencil function
  36838. * @returns a number defining the stencil function to use
  36839. */
  36840. getStencilFunction(): number;
  36841. /**
  36842. * Gets the current stencil reference value
  36843. * @returns a number defining the stencil reference value to use
  36844. */
  36845. getStencilFunctionReference(): number;
  36846. /**
  36847. * Gets the current stencil mask
  36848. * @returns a number defining the stencil mask to use
  36849. */
  36850. getStencilFunctionMask(): number;
  36851. /**
  36852. * Sets the current stencil function
  36853. * @param stencilFunc defines the new stencil function to use
  36854. */
  36855. setStencilFunction(stencilFunc: number): void;
  36856. /**
  36857. * Sets the current stencil reference
  36858. * @param reference defines the new stencil reference to use
  36859. */
  36860. setStencilFunctionReference(reference: number): void;
  36861. /**
  36862. * Sets the current stencil mask
  36863. * @param mask defines the new stencil mask to use
  36864. */
  36865. setStencilFunctionMask(mask: number): void;
  36866. /**
  36867. * Gets the current stencil operation when stencil fails
  36868. * @returns a number defining stencil operation to use when stencil fails
  36869. */
  36870. getStencilOperationFail(): number;
  36871. /**
  36872. * Gets the current stencil operation when depth fails
  36873. * @returns a number defining stencil operation to use when depth fails
  36874. */
  36875. getStencilOperationDepthFail(): number;
  36876. /**
  36877. * Gets the current stencil operation when stencil passes
  36878. * @returns a number defining stencil operation to use when stencil passes
  36879. */
  36880. getStencilOperationPass(): number;
  36881. /**
  36882. * Sets the stencil operation to use when stencil fails
  36883. * @param operation defines the stencil operation to use when stencil fails
  36884. */
  36885. setStencilOperationFail(operation: number): void;
  36886. /**
  36887. * Sets the stencil operation to use when depth fails
  36888. * @param operation defines the stencil operation to use when depth fails
  36889. */
  36890. setStencilOperationDepthFail(operation: number): void;
  36891. /**
  36892. * Sets the stencil operation to use when stencil passes
  36893. * @param operation defines the stencil operation to use when stencil passes
  36894. */
  36895. setStencilOperationPass(operation: number): void;
  36896. /**
  36897. * Sets a boolean indicating if the dithering state is enabled or disabled
  36898. * @param value defines the dithering state
  36899. */
  36900. setDitheringState(value: boolean): void;
  36901. /**
  36902. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36903. * @param value defines the rasterizer state
  36904. */
  36905. setRasterizerState(value: boolean): void;
  36906. /**
  36907. * Gets the current depth function
  36908. * @returns a number defining the depth function
  36909. */
  36910. getDepthFunction(): Nullable<number>;
  36911. /**
  36912. * Sets the current depth function
  36913. * @param depthFunc defines the function to use
  36914. */
  36915. setDepthFunction(depthFunc: number): void;
  36916. /**
  36917. * Sets the current depth function to GREATER
  36918. */
  36919. setDepthFunctionToGreater(): void;
  36920. /**
  36921. * Sets the current depth function to GEQUAL
  36922. */
  36923. setDepthFunctionToGreaterOrEqual(): void;
  36924. /**
  36925. * Sets the current depth function to LESS
  36926. */
  36927. setDepthFunctionToLess(): void;
  36928. /**
  36929. * Sets the current depth function to LEQUAL
  36930. */
  36931. setDepthFunctionToLessOrEqual(): void;
  36932. private _cachedStencilBuffer;
  36933. private _cachedStencilFunction;
  36934. private _cachedStencilMask;
  36935. private _cachedStencilOperationPass;
  36936. private _cachedStencilOperationFail;
  36937. private _cachedStencilOperationDepthFail;
  36938. private _cachedStencilReference;
  36939. /**
  36940. * Caches the the state of the stencil buffer
  36941. */
  36942. cacheStencilState(): void;
  36943. /**
  36944. * Restores the state of the stencil buffer
  36945. */
  36946. restoreStencilState(): void;
  36947. /**
  36948. * Directly set the WebGL Viewport
  36949. * @param x defines the x coordinate of the viewport (in screen space)
  36950. * @param y defines the y coordinate of the viewport (in screen space)
  36951. * @param width defines the width of the viewport (in screen space)
  36952. * @param height defines the height of the viewport (in screen space)
  36953. * @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
  36954. */
  36955. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36956. /**
  36957. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36958. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36959. * @param y defines the y-coordinate of the corner of the clear rectangle
  36960. * @param width defines the width of the clear rectangle
  36961. * @param height defines the height of the clear rectangle
  36962. * @param clearColor defines the clear color
  36963. */
  36964. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  36965. /**
  36966. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  36967. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36968. * @param y defines the y-coordinate of the corner of the clear rectangle
  36969. * @param width defines the width of the clear rectangle
  36970. * @param height defines the height of the clear rectangle
  36971. */
  36972. enableScissor(x: number, y: number, width: number, height: number): void;
  36973. /**
  36974. * Disable previously set scissor test rectangle
  36975. */
  36976. disableScissor(): void;
  36977. protected _reportDrawCall(): void;
  36978. /**
  36979. * Initializes a webVR display and starts listening to display change events
  36980. * The onVRDisplayChangedObservable will be notified upon these changes
  36981. * @returns The onVRDisplayChangedObservable
  36982. */
  36983. initWebVR(): Observable<IDisplayChangedEventArgs>;
  36984. /** @hidden */
  36985. _prepareVRComponent(): void;
  36986. /** @hidden */
  36987. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  36988. /** @hidden */
  36989. _submitVRFrame(): void;
  36990. /**
  36991. * Call this function to leave webVR mode
  36992. * Will do nothing if webVR is not supported or if there is no webVR device
  36993. * @see http://doc.babylonjs.com/how_to/webvr_camera
  36994. */
  36995. disableVR(): void;
  36996. /**
  36997. * Gets a boolean indicating that the system is in VR mode and is presenting
  36998. * @returns true if VR mode is engaged
  36999. */
  37000. isVRPresenting(): boolean;
  37001. /** @hidden */
  37002. _requestVRFrame(): void;
  37003. /** @hidden */
  37004. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37005. /**
  37006. * Gets the source code of the vertex 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 vertex shader associated with the program
  37009. */
  37010. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37011. /**
  37012. * Gets the source code of the fragment shader associated with a specific webGL program
  37013. * @param program defines the program to use
  37014. * @returns a string containing the source code of the fragment shader associated with the program
  37015. */
  37016. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37017. /**
  37018. * Sets a depth stencil texture from a render target to the according uniform.
  37019. * @param channel The texture channel
  37020. * @param uniform The uniform to set
  37021. * @param texture The render target texture containing the depth stencil texture to apply
  37022. */
  37023. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37024. /**
  37025. * Sets a texture to the webGL context from a postprocess
  37026. * @param channel defines the channel to use
  37027. * @param postProcess defines the source postprocess
  37028. */
  37029. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37030. /**
  37031. * Binds the output of the passed in post process to the texture channel specified
  37032. * @param channel The channel the texture should be bound to
  37033. * @param postProcess The post process which's output should be bound
  37034. */
  37035. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37036. protected _rebuildBuffers(): void;
  37037. /** @hidden */
  37038. _renderFrame(): void;
  37039. _renderLoop(): void;
  37040. /** @hidden */
  37041. _renderViews(): boolean;
  37042. /**
  37043. * Toggle full screen mode
  37044. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37045. */
  37046. switchFullscreen(requestPointerLock: boolean): void;
  37047. /**
  37048. * Enters full screen mode
  37049. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37050. */
  37051. enterFullscreen(requestPointerLock: boolean): void;
  37052. /**
  37053. * Exits full screen mode
  37054. */
  37055. exitFullscreen(): void;
  37056. /**
  37057. * Enters Pointerlock mode
  37058. */
  37059. enterPointerlock(): void;
  37060. /**
  37061. * Exits Pointerlock mode
  37062. */
  37063. exitPointerlock(): void;
  37064. /**
  37065. * Begin a new frame
  37066. */
  37067. beginFrame(): void;
  37068. /**
  37069. * Enf the current frame
  37070. */
  37071. endFrame(): void;
  37072. resize(): void;
  37073. /**
  37074. * Force a specific size of the canvas
  37075. * @param width defines the new canvas' width
  37076. * @param height defines the new canvas' height
  37077. */
  37078. setSize(width: number, height: number): void;
  37079. /**
  37080. * Updates a dynamic vertex buffer.
  37081. * @param vertexBuffer the vertex buffer to update
  37082. * @param data the data used to update the vertex buffer
  37083. * @param byteOffset the byte offset of the data
  37084. * @param byteLength the byte length of the data
  37085. */
  37086. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37087. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37088. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37089. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37090. _releaseTexture(texture: InternalTexture): void;
  37091. /**
  37092. * @hidden
  37093. * Rescales a texture
  37094. * @param source input texutre
  37095. * @param destination destination texture
  37096. * @param scene scene to use to render the resize
  37097. * @param internalFormat format to use when resizing
  37098. * @param onComplete callback to be called when resize has completed
  37099. */
  37100. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37101. /**
  37102. * Gets the current framerate
  37103. * @returns a number representing the framerate
  37104. */
  37105. getFps(): number;
  37106. /**
  37107. * Gets the time spent between current and previous frame
  37108. * @returns a number representing the delta time in ms
  37109. */
  37110. getDeltaTime(): number;
  37111. private _measureFps;
  37112. /** @hidden */
  37113. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37114. /**
  37115. * Update a dynamic index buffer
  37116. * @param indexBuffer defines the target index buffer
  37117. * @param indices defines the data to update
  37118. * @param offset defines the offset in the target index buffer where update should start
  37119. */
  37120. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37121. /**
  37122. * Updates the sample count of a render target texture
  37123. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37124. * @param texture defines the texture to update
  37125. * @param samples defines the sample count to set
  37126. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37127. */
  37128. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37129. /**
  37130. * Updates a depth texture Comparison Mode and Function.
  37131. * If the comparison Function is equal to 0, the mode will be set to none.
  37132. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37133. * @param texture The texture to set the comparison function for
  37134. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37135. */
  37136. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37137. /**
  37138. * Creates a webGL buffer to use with instanciation
  37139. * @param capacity defines the size of the buffer
  37140. * @returns the webGL buffer
  37141. */
  37142. createInstancesBuffer(capacity: number): DataBuffer;
  37143. /**
  37144. * Delete a webGL buffer used with instanciation
  37145. * @param buffer defines the webGL buffer to delete
  37146. */
  37147. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37148. private _clientWaitAsync;
  37149. /** @hidden */
  37150. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37151. dispose(): void;
  37152. private _disableTouchAction;
  37153. /**
  37154. * Display the loading screen
  37155. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37156. */
  37157. displayLoadingUI(): void;
  37158. /**
  37159. * Hide the loading screen
  37160. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37161. */
  37162. hideLoadingUI(): void;
  37163. /**
  37164. * Gets the current loading screen object
  37165. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37166. */
  37167. get loadingScreen(): ILoadingScreen;
  37168. /**
  37169. * Sets the current loading screen object
  37170. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37171. */
  37172. set loadingScreen(loadingScreen: ILoadingScreen);
  37173. /**
  37174. * Sets the current loading screen text
  37175. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37176. */
  37177. set loadingUIText(text: string);
  37178. /**
  37179. * Sets the current loading screen background color
  37180. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37181. */
  37182. set loadingUIBackgroundColor(color: string);
  37183. /** Pointerlock and fullscreen */
  37184. /**
  37185. * Ask the browser to promote the current element to pointerlock mode
  37186. * @param element defines the DOM element to promote
  37187. */
  37188. static _RequestPointerlock(element: HTMLElement): void;
  37189. /**
  37190. * Asks the browser to exit pointerlock mode
  37191. */
  37192. static _ExitPointerlock(): void;
  37193. /**
  37194. * Ask the browser to promote the current element to fullscreen rendering mode
  37195. * @param element defines the DOM element to promote
  37196. */
  37197. static _RequestFullscreen(element: HTMLElement): void;
  37198. /**
  37199. * Asks the browser to exit fullscreen mode
  37200. */
  37201. static _ExitFullscreen(): void;
  37202. }
  37203. }
  37204. declare module BABYLON {
  37205. /**
  37206. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37207. * during the life time of the application.
  37208. */
  37209. export class EngineStore {
  37210. /** Gets the list of created engines */
  37211. static Instances: Engine[];
  37212. /** @hidden */
  37213. static _LastCreatedScene: Nullable<Scene>;
  37214. /**
  37215. * Gets the latest created engine
  37216. */
  37217. static get LastCreatedEngine(): Nullable<Engine>;
  37218. /**
  37219. * Gets the latest created scene
  37220. */
  37221. static get LastCreatedScene(): Nullable<Scene>;
  37222. /**
  37223. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37224. * @ignorenaming
  37225. */
  37226. static UseFallbackTexture: boolean;
  37227. /**
  37228. * Texture content used if a texture cannot loaded
  37229. * @ignorenaming
  37230. */
  37231. static FallbackTexture: string;
  37232. }
  37233. }
  37234. declare module BABYLON {
  37235. /**
  37236. * Helper class that provides a small promise polyfill
  37237. */
  37238. export class PromisePolyfill {
  37239. /**
  37240. * Static function used to check if the polyfill is required
  37241. * If this is the case then the function will inject the polyfill to window.Promise
  37242. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37243. */
  37244. static Apply(force?: boolean): void;
  37245. }
  37246. }
  37247. declare module BABYLON {
  37248. /**
  37249. * Interface for screenshot methods with describe argument called `size` as object with options
  37250. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37251. */
  37252. export interface IScreenshotSize {
  37253. /**
  37254. * number in pixels for canvas height
  37255. */
  37256. height?: number;
  37257. /**
  37258. * multiplier allowing render at a higher or lower resolution
  37259. * If value is defined then height and width will be ignored and taken from camera
  37260. */
  37261. precision?: number;
  37262. /**
  37263. * number in pixels for canvas width
  37264. */
  37265. width?: number;
  37266. }
  37267. }
  37268. declare module BABYLON {
  37269. interface IColor4Like {
  37270. r: float;
  37271. g: float;
  37272. b: float;
  37273. a: float;
  37274. }
  37275. /**
  37276. * Class containing a set of static utilities functions
  37277. */
  37278. export class Tools {
  37279. /**
  37280. * Gets or sets the base URL to use to load assets
  37281. */
  37282. static get BaseUrl(): string;
  37283. static set BaseUrl(value: string);
  37284. /**
  37285. * Enable/Disable Custom HTTP Request Headers globally.
  37286. * default = false
  37287. * @see CustomRequestHeaders
  37288. */
  37289. static UseCustomRequestHeaders: boolean;
  37290. /**
  37291. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37292. * i.e. when loading files, where the server/service expects an Authorization header
  37293. */
  37294. static CustomRequestHeaders: {
  37295. [key: string]: string;
  37296. };
  37297. /**
  37298. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37299. */
  37300. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37301. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37302. /**
  37303. * Default behaviour for cors in the application.
  37304. * It can be a string if the expected behavior is identical in the entire app.
  37305. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37306. */
  37307. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37308. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37309. /**
  37310. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37311. * @ignorenaming
  37312. */
  37313. static get UseFallbackTexture(): boolean;
  37314. static set UseFallbackTexture(value: boolean);
  37315. /**
  37316. * Use this object to register external classes like custom textures or material
  37317. * to allow the laoders to instantiate them
  37318. */
  37319. static get RegisteredExternalClasses(): {
  37320. [key: string]: Object;
  37321. };
  37322. static set RegisteredExternalClasses(classes: {
  37323. [key: string]: Object;
  37324. });
  37325. /**
  37326. * Texture content used if a texture cannot loaded
  37327. * @ignorenaming
  37328. */
  37329. static get fallbackTexture(): string;
  37330. static set fallbackTexture(value: string);
  37331. /**
  37332. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37333. * @param u defines the coordinate on X axis
  37334. * @param v defines the coordinate on Y axis
  37335. * @param width defines the width of the source data
  37336. * @param height defines the height of the source data
  37337. * @param pixels defines the source byte array
  37338. * @param color defines the output color
  37339. */
  37340. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37341. /**
  37342. * Interpolates between a and b via alpha
  37343. * @param a The lower value (returned when alpha = 0)
  37344. * @param b The upper value (returned when alpha = 1)
  37345. * @param alpha The interpolation-factor
  37346. * @return The mixed value
  37347. */
  37348. static Mix(a: number, b: number, alpha: number): number;
  37349. /**
  37350. * Tries to instantiate a new object from a given class name
  37351. * @param className defines the class name to instantiate
  37352. * @returns the new object or null if the system was not able to do the instantiation
  37353. */
  37354. static Instantiate(className: string): any;
  37355. /**
  37356. * Provides a slice function that will work even on IE
  37357. * @param data defines the array to slice
  37358. * @param start defines the start of the data (optional)
  37359. * @param end defines the end of the data (optional)
  37360. * @returns the new sliced array
  37361. */
  37362. static Slice<T>(data: T, start?: number, end?: number): T;
  37363. /**
  37364. * Polyfill for setImmediate
  37365. * @param action defines the action to execute after the current execution block
  37366. */
  37367. static SetImmediate(action: () => void): void;
  37368. /**
  37369. * Function indicating if a number is an exponent of 2
  37370. * @param value defines the value to test
  37371. * @returns true if the value is an exponent of 2
  37372. */
  37373. static IsExponentOfTwo(value: number): boolean;
  37374. private static _tmpFloatArray;
  37375. /**
  37376. * Returns the nearest 32-bit single precision float representation of a Number
  37377. * @param value A Number. If the parameter is of a different type, it will get converted
  37378. * to a number or to NaN if it cannot be converted
  37379. * @returns number
  37380. */
  37381. static FloatRound(value: number): number;
  37382. /**
  37383. * Extracts the filename from a path
  37384. * @param path defines the path to use
  37385. * @returns the filename
  37386. */
  37387. static GetFilename(path: string): string;
  37388. /**
  37389. * Extracts the "folder" part of a path (everything before the filename).
  37390. * @param uri The URI to extract the info from
  37391. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37392. * @returns The "folder" part of the path
  37393. */
  37394. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37395. /**
  37396. * Extracts text content from a DOM element hierarchy
  37397. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37398. */
  37399. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37400. /**
  37401. * Convert an angle in radians to degrees
  37402. * @param angle defines the angle to convert
  37403. * @returns the angle in degrees
  37404. */
  37405. static ToDegrees(angle: number): number;
  37406. /**
  37407. * Convert an angle in degrees to radians
  37408. * @param angle defines the angle to convert
  37409. * @returns the angle in radians
  37410. */
  37411. static ToRadians(angle: number): number;
  37412. /**
  37413. * Returns an array if obj is not an array
  37414. * @param obj defines the object to evaluate as an array
  37415. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37416. * @returns either obj directly if obj is an array or a new array containing obj
  37417. */
  37418. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37419. /**
  37420. * Gets the pointer prefix to use
  37421. * @param engine defines the engine we are finding the prefix for
  37422. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37423. */
  37424. static GetPointerPrefix(engine: Engine): string;
  37425. /**
  37426. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37427. * @param url define the url we are trying
  37428. * @param element define the dom element where to configure the cors policy
  37429. */
  37430. static SetCorsBehavior(url: string | string[], element: {
  37431. crossOrigin: string | null;
  37432. }): void;
  37433. /**
  37434. * Removes unwanted characters from an url
  37435. * @param url defines the url to clean
  37436. * @returns the cleaned url
  37437. */
  37438. static CleanUrl(url: string): string;
  37439. /**
  37440. * Gets or sets a function used to pre-process url before using them to load assets
  37441. */
  37442. static get PreprocessUrl(): (url: string) => string;
  37443. static set PreprocessUrl(processor: (url: string) => string);
  37444. /**
  37445. * Loads an image as an HTMLImageElement.
  37446. * @param input url string, ArrayBuffer, or Blob to load
  37447. * @param onLoad callback called when the image successfully loads
  37448. * @param onError callback called when the image fails to load
  37449. * @param offlineProvider offline provider for caching
  37450. * @param mimeType optional mime type
  37451. * @returns the HTMLImageElement of the loaded image
  37452. */
  37453. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37454. /**
  37455. * Loads a file from a url
  37456. * @param url url string, ArrayBuffer, or Blob to load
  37457. * @param onSuccess callback called when the file successfully loads
  37458. * @param onProgress callback called while file is loading (if the server supports this mode)
  37459. * @param offlineProvider defines the offline provider for caching
  37460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37461. * @param onError callback called when the file fails to load
  37462. * @returns a file request object
  37463. */
  37464. 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;
  37465. /**
  37466. * Loads a file from a url
  37467. * @param url the file url to load
  37468. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37469. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37470. */
  37471. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37472. /**
  37473. * Load a script (identified by an url). When the url returns, the
  37474. * content of this file is added into a new script element, attached to the DOM (body element)
  37475. * @param scriptUrl defines the url of the script to laod
  37476. * @param onSuccess defines the callback called when the script is loaded
  37477. * @param onError defines the callback to call if an error occurs
  37478. * @param scriptId defines the id of the script element
  37479. */
  37480. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37481. /**
  37482. * Load an asynchronous script (identified by an url). When the url returns, the
  37483. * content of this file is added into a new script element, attached to the DOM (body element)
  37484. * @param scriptUrl defines the url of the script to laod
  37485. * @param scriptId defines the id of the script element
  37486. * @returns a promise request object
  37487. */
  37488. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37489. /**
  37490. * Loads a file from a blob
  37491. * @param fileToLoad defines the blob to use
  37492. * @param callback defines the callback to call when data is loaded
  37493. * @param progressCallback defines the callback to call during loading process
  37494. * @returns a file request object
  37495. */
  37496. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37497. /**
  37498. * Reads a file from a File object
  37499. * @param file defines the file to load
  37500. * @param onSuccess defines the callback to call when data is loaded
  37501. * @param onProgress defines the callback to call during loading process
  37502. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37503. * @param onError defines the callback to call when an error occurs
  37504. * @returns a file request object
  37505. */
  37506. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37507. /**
  37508. * Creates a data url from a given string content
  37509. * @param content defines the content to convert
  37510. * @returns the new data url link
  37511. */
  37512. static FileAsURL(content: string): string;
  37513. /**
  37514. * Format the given number to a specific decimal format
  37515. * @param value defines the number to format
  37516. * @param decimals defines the number of decimals to use
  37517. * @returns the formatted string
  37518. */
  37519. static Format(value: number, decimals?: number): string;
  37520. /**
  37521. * Tries to copy an object by duplicating every property
  37522. * @param source defines the source object
  37523. * @param destination defines the target object
  37524. * @param doNotCopyList defines a list of properties to avoid
  37525. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37526. */
  37527. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37528. /**
  37529. * Gets a boolean indicating if the given object has no own property
  37530. * @param obj defines the object to test
  37531. * @returns true if object has no own property
  37532. */
  37533. static IsEmpty(obj: any): boolean;
  37534. /**
  37535. * Function used to register events at window level
  37536. * @param windowElement defines the Window object to use
  37537. * @param events defines the events to register
  37538. */
  37539. static RegisterTopRootEvents(windowElement: Window, events: {
  37540. name: string;
  37541. handler: Nullable<(e: FocusEvent) => any>;
  37542. }[]): void;
  37543. /**
  37544. * Function used to unregister events from window level
  37545. * @param windowElement defines the Window object to use
  37546. * @param events defines the events to unregister
  37547. */
  37548. static UnregisterTopRootEvents(windowElement: Window, events: {
  37549. name: string;
  37550. handler: Nullable<(e: FocusEvent) => any>;
  37551. }[]): void;
  37552. /**
  37553. * @ignore
  37554. */
  37555. static _ScreenshotCanvas: HTMLCanvasElement;
  37556. /**
  37557. * Dumps the current bound framebuffer
  37558. * @param width defines the rendering width
  37559. * @param height defines the rendering height
  37560. * @param engine defines the hosting engine
  37561. * @param successCallback defines the callback triggered once the data are available
  37562. * @param mimeType defines the mime type of the result
  37563. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37564. */
  37565. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37566. /**
  37567. * Converts the canvas data to blob.
  37568. * This acts as a polyfill for browsers not supporting the to blob function.
  37569. * @param canvas Defines the canvas to extract the data from
  37570. * @param successCallback Defines the callback triggered once the data are available
  37571. * @param mimeType Defines the mime type of the result
  37572. */
  37573. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37574. /**
  37575. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37576. * @param successCallback defines the callback triggered once the data are available
  37577. * @param mimeType defines the mime type of the result
  37578. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37579. */
  37580. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37581. /**
  37582. * Downloads a blob in the browser
  37583. * @param blob defines the blob to download
  37584. * @param fileName defines the name of the downloaded file
  37585. */
  37586. static Download(blob: Blob, fileName: string): void;
  37587. /**
  37588. * Captures a screenshot of the current rendering
  37589. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37590. * @param engine defines the rendering engine
  37591. * @param camera defines the source camera
  37592. * @param size This parameter can be set to a single number or to an object with the
  37593. * following (optional) properties: precision, width, height. If a single number is passed,
  37594. * it will be used for both width and height. If an object is passed, the screenshot size
  37595. * will be derived from the parameters. The precision property is a multiplier allowing
  37596. * rendering at a higher or lower resolution
  37597. * @param successCallback defines the callback receives a single parameter which contains the
  37598. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37599. * src parameter of an <img> to display it
  37600. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37601. * Check your browser for supported MIME types
  37602. */
  37603. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37604. /**
  37605. * Captures a screenshot of the current rendering
  37606. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37607. * @param engine defines the rendering engine
  37608. * @param camera defines the source camera
  37609. * @param size This parameter can be set to a single number or to an object with the
  37610. * following (optional) properties: precision, width, height. If a single number is passed,
  37611. * it will be used for both width and height. If an object is passed, the screenshot size
  37612. * will be derived from the parameters. The precision property is a multiplier allowing
  37613. * rendering at a higher or lower resolution
  37614. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37615. * Check your browser for supported MIME types
  37616. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37617. * to the src parameter of an <img> to display it
  37618. */
  37619. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37620. /**
  37621. * Generates an image screenshot from the specified camera.
  37622. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37623. * @param engine The engine to use for rendering
  37624. * @param camera The camera to use for rendering
  37625. * @param size This parameter can be set to a single number or to an object with the
  37626. * following (optional) properties: precision, width, height. If a single number is passed,
  37627. * it will be used for both width and height. If an object is passed, the screenshot size
  37628. * will be derived from the parameters. The precision property is a multiplier allowing
  37629. * rendering at a higher or lower resolution
  37630. * @param successCallback The callback receives a single parameter which contains the
  37631. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37632. * src parameter of an <img> to display it
  37633. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37634. * Check your browser for supported MIME types
  37635. * @param samples Texture samples (default: 1)
  37636. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37637. * @param fileName A name for for the downloaded file.
  37638. */
  37639. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37640. /**
  37641. * Generates an image screenshot from the specified camera.
  37642. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  37643. * @param engine The engine to use for rendering
  37644. * @param camera The camera to use for rendering
  37645. * @param size This parameter can be set to a single number or to an object with the
  37646. * following (optional) properties: precision, width, height. If a single number is passed,
  37647. * it will be used for both width and height. If an object is passed, the screenshot size
  37648. * will be derived from the parameters. The precision property is a multiplier allowing
  37649. * rendering at a higher or lower resolution
  37650. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37651. * Check your browser for supported MIME types
  37652. * @param samples Texture samples (default: 1)
  37653. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37654. * @param fileName A name for for the downloaded file.
  37655. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37656. * to the src parameter of an <img> to display it
  37657. */
  37658. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37659. /**
  37660. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37661. * Be aware Math.random() could cause collisions, but:
  37662. * "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"
  37663. * @returns a pseudo random id
  37664. */
  37665. static RandomId(): string;
  37666. /**
  37667. * Test if the given uri is a base64 string
  37668. * @param uri The uri to test
  37669. * @return True if the uri is a base64 string or false otherwise
  37670. */
  37671. static IsBase64(uri: string): boolean;
  37672. /**
  37673. * Decode the given base64 uri.
  37674. * @param uri The uri to decode
  37675. * @return The decoded base64 data.
  37676. */
  37677. static DecodeBase64(uri: string): ArrayBuffer;
  37678. /**
  37679. * Gets the absolute url.
  37680. * @param url the input url
  37681. * @return the absolute url
  37682. */
  37683. static GetAbsoluteUrl(url: string): string;
  37684. /**
  37685. * No log
  37686. */
  37687. static readonly NoneLogLevel: number;
  37688. /**
  37689. * Only message logs
  37690. */
  37691. static readonly MessageLogLevel: number;
  37692. /**
  37693. * Only warning logs
  37694. */
  37695. static readonly WarningLogLevel: number;
  37696. /**
  37697. * Only error logs
  37698. */
  37699. static readonly ErrorLogLevel: number;
  37700. /**
  37701. * All logs
  37702. */
  37703. static readonly AllLogLevel: number;
  37704. /**
  37705. * Gets a value indicating the number of loading errors
  37706. * @ignorenaming
  37707. */
  37708. static get errorsCount(): number;
  37709. /**
  37710. * Callback called when a new log is added
  37711. */
  37712. static OnNewCacheEntry: (entry: string) => void;
  37713. /**
  37714. * Log a message to the console
  37715. * @param message defines the message to log
  37716. */
  37717. static Log(message: string): void;
  37718. /**
  37719. * Write a warning message to the console
  37720. * @param message defines the message to log
  37721. */
  37722. static Warn(message: string): void;
  37723. /**
  37724. * Write an error message to the console
  37725. * @param message defines the message to log
  37726. */
  37727. static Error(message: string): void;
  37728. /**
  37729. * Gets current log cache (list of logs)
  37730. */
  37731. static get LogCache(): string;
  37732. /**
  37733. * Clears the log cache
  37734. */
  37735. static ClearLogCache(): void;
  37736. /**
  37737. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37738. */
  37739. static set LogLevels(level: number);
  37740. /**
  37741. * Checks if the window object exists
  37742. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37743. */
  37744. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37745. /**
  37746. * No performance log
  37747. */
  37748. static readonly PerformanceNoneLogLevel: number;
  37749. /**
  37750. * Use user marks to log performance
  37751. */
  37752. static readonly PerformanceUserMarkLogLevel: number;
  37753. /**
  37754. * Log performance to the console
  37755. */
  37756. static readonly PerformanceConsoleLogLevel: number;
  37757. private static _performance;
  37758. /**
  37759. * Sets the current performance log level
  37760. */
  37761. static set PerformanceLogLevel(level: number);
  37762. private static _StartPerformanceCounterDisabled;
  37763. private static _EndPerformanceCounterDisabled;
  37764. private static _StartUserMark;
  37765. private static _EndUserMark;
  37766. private static _StartPerformanceConsole;
  37767. private static _EndPerformanceConsole;
  37768. /**
  37769. * Starts a performance counter
  37770. */
  37771. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37772. /**
  37773. * Ends a specific performance coutner
  37774. */
  37775. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37776. /**
  37777. * Gets either window.performance.now() if supported or Date.now() else
  37778. */
  37779. static get Now(): number;
  37780. /**
  37781. * This method will return the name of the class used to create the instance of the given object.
  37782. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37783. * @param object the object to get the class name from
  37784. * @param isType defines if the object is actually a type
  37785. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37786. */
  37787. static GetClassName(object: any, isType?: boolean): string;
  37788. /**
  37789. * Gets the first element of an array satisfying a given predicate
  37790. * @param array defines the array to browse
  37791. * @param predicate defines the predicate to use
  37792. * @returns null if not found or the element
  37793. */
  37794. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37795. /**
  37796. * This method will return the name of the full name of the class, including its owning module (if any).
  37797. * 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).
  37798. * @param object the object to get the class name from
  37799. * @param isType defines if the object is actually a type
  37800. * @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.
  37801. * @ignorenaming
  37802. */
  37803. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37804. /**
  37805. * Returns a promise that resolves after the given amount of time.
  37806. * @param delay Number of milliseconds to delay
  37807. * @returns Promise that resolves after the given amount of time
  37808. */
  37809. static DelayAsync(delay: number): Promise<void>;
  37810. /**
  37811. * Utility function to detect if the current user agent is Safari
  37812. * @returns whether or not the current user agent is safari
  37813. */
  37814. static IsSafari(): boolean;
  37815. }
  37816. /**
  37817. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37818. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37819. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37820. * @param name The name of the class, case should be preserved
  37821. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37822. */
  37823. export function className(name: string, module?: string): (target: Object) => void;
  37824. /**
  37825. * An implementation of a loop for asynchronous functions.
  37826. */
  37827. export class AsyncLoop {
  37828. /**
  37829. * Defines the number of iterations for the loop
  37830. */
  37831. iterations: number;
  37832. /**
  37833. * Defines the current index of the loop.
  37834. */
  37835. index: number;
  37836. private _done;
  37837. private _fn;
  37838. private _successCallback;
  37839. /**
  37840. * Constructor.
  37841. * @param iterations the number of iterations.
  37842. * @param func the function to run each iteration
  37843. * @param successCallback the callback that will be called upon succesful execution
  37844. * @param offset starting offset.
  37845. */
  37846. constructor(
  37847. /**
  37848. * Defines the number of iterations for the loop
  37849. */
  37850. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37851. /**
  37852. * Execute the next iteration. Must be called after the last iteration was finished.
  37853. */
  37854. executeNext(): void;
  37855. /**
  37856. * Break the loop and run the success callback.
  37857. */
  37858. breakLoop(): void;
  37859. /**
  37860. * Create and run an async loop.
  37861. * @param iterations the number of iterations.
  37862. * @param fn the function to run each iteration
  37863. * @param successCallback the callback that will be called upon succesful execution
  37864. * @param offset starting offset.
  37865. * @returns the created async loop object
  37866. */
  37867. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37868. /**
  37869. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37870. * @param iterations total number of iterations
  37871. * @param syncedIterations number of synchronous iterations in each async iteration.
  37872. * @param fn the function to call each iteration.
  37873. * @param callback a success call back that will be called when iterating stops.
  37874. * @param breakFunction a break condition (optional)
  37875. * @param timeout timeout settings for the setTimeout function. default - 0.
  37876. * @returns the created async loop object
  37877. */
  37878. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37879. }
  37880. }
  37881. declare module BABYLON {
  37882. /**
  37883. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37884. * The underlying implementation relies on an associative array to ensure the best performances.
  37885. * The value can be anything including 'null' but except 'undefined'
  37886. */
  37887. export class StringDictionary<T> {
  37888. /**
  37889. * This will clear this dictionary and copy the content from the 'source' one.
  37890. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37891. * @param source the dictionary to take the content from and copy to this dictionary
  37892. */
  37893. copyFrom(source: StringDictionary<T>): void;
  37894. /**
  37895. * Get a value based from its key
  37896. * @param key the given key to get the matching value from
  37897. * @return the value if found, otherwise undefined is returned
  37898. */
  37899. get(key: string): T | undefined;
  37900. /**
  37901. * Get a value from its key or add it if it doesn't exist.
  37902. * This method will ensure you that a given key/data will be present in the dictionary.
  37903. * @param key the given key to get the matching value from
  37904. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37905. * The factory will only be invoked if there's no data for the given key.
  37906. * @return the value corresponding to the key.
  37907. */
  37908. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37909. /**
  37910. * Get a value from its key if present in the dictionary otherwise add it
  37911. * @param key the key to get the value from
  37912. * @param val if there's no such key/value pair in the dictionary add it with this value
  37913. * @return the value corresponding to the key
  37914. */
  37915. getOrAdd(key: string, val: T): T;
  37916. /**
  37917. * Check if there's a given key in the dictionary
  37918. * @param key the key to check for
  37919. * @return true if the key is present, false otherwise
  37920. */
  37921. contains(key: string): boolean;
  37922. /**
  37923. * Add a new key and its corresponding value
  37924. * @param key the key to add
  37925. * @param value the value corresponding to the key
  37926. * @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
  37927. */
  37928. add(key: string, value: T): boolean;
  37929. /**
  37930. * Update a specific value associated to a key
  37931. * @param key defines the key to use
  37932. * @param value defines the value to store
  37933. * @returns true if the value was updated (or false if the key was not found)
  37934. */
  37935. set(key: string, value: T): boolean;
  37936. /**
  37937. * Get the element of the given key and remove it from the dictionary
  37938. * @param key defines the key to search
  37939. * @returns the value associated with the key or null if not found
  37940. */
  37941. getAndRemove(key: string): Nullable<T>;
  37942. /**
  37943. * Remove a key/value from the dictionary.
  37944. * @param key the key to remove
  37945. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37946. */
  37947. remove(key: string): boolean;
  37948. /**
  37949. * Clear the whole content of the dictionary
  37950. */
  37951. clear(): void;
  37952. /**
  37953. * Gets the current count
  37954. */
  37955. get count(): number;
  37956. /**
  37957. * Execute a callback on each key/val of the dictionary.
  37958. * Note that you can remove any element in this dictionary in the callback implementation
  37959. * @param callback the callback to execute on a given key/value pair
  37960. */
  37961. forEach(callback: (key: string, val: T) => void): void;
  37962. /**
  37963. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  37964. * If the callback returns null or undefined the method will iterate to the next key/value pair
  37965. * Note that you can remove any element in this dictionary in the callback implementation
  37966. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  37967. * @returns the first item
  37968. */
  37969. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  37970. private _count;
  37971. private _data;
  37972. }
  37973. }
  37974. declare module BABYLON {
  37975. /** @hidden */
  37976. export interface ICollisionCoordinator {
  37977. createCollider(): Collider;
  37978. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37979. init(scene: Scene): void;
  37980. }
  37981. /** @hidden */
  37982. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  37983. private _scene;
  37984. private _scaledPosition;
  37985. private _scaledVelocity;
  37986. private _finalPosition;
  37987. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  37988. createCollider(): Collider;
  37989. init(scene: Scene): void;
  37990. private _collideWithWorld;
  37991. }
  37992. }
  37993. declare module BABYLON {
  37994. /**
  37995. * Class used to manage all inputs for the scene.
  37996. */
  37997. export class InputManager {
  37998. /** The distance in pixel that you have to move to prevent some events */
  37999. static DragMovementThreshold: number;
  38000. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38001. static LongPressDelay: number;
  38002. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38003. static DoubleClickDelay: number;
  38004. /** If you need to check double click without raising a single click at first click, enable this flag */
  38005. static ExclusiveDoubleClickMode: boolean;
  38006. private _wheelEventName;
  38007. private _onPointerMove;
  38008. private _onPointerDown;
  38009. private _onPointerUp;
  38010. private _initClickEvent;
  38011. private _initActionManager;
  38012. private _delayedSimpleClick;
  38013. private _delayedSimpleClickTimeout;
  38014. private _previousDelayedSimpleClickTimeout;
  38015. private _meshPickProceed;
  38016. private _previousButtonPressed;
  38017. private _currentPickResult;
  38018. private _previousPickResult;
  38019. private _totalPointersPressed;
  38020. private _doubleClickOccured;
  38021. private _pointerOverMesh;
  38022. private _pickedDownMesh;
  38023. private _pickedUpMesh;
  38024. private _pointerX;
  38025. private _pointerY;
  38026. private _unTranslatedPointerX;
  38027. private _unTranslatedPointerY;
  38028. private _startingPointerPosition;
  38029. private _previousStartingPointerPosition;
  38030. private _startingPointerTime;
  38031. private _previousStartingPointerTime;
  38032. private _pointerCaptures;
  38033. private _onKeyDown;
  38034. private _onKeyUp;
  38035. private _onCanvasFocusObserver;
  38036. private _onCanvasBlurObserver;
  38037. private _scene;
  38038. /**
  38039. * Creates a new InputManager
  38040. * @param scene defines the hosting scene
  38041. */
  38042. constructor(scene: Scene);
  38043. /**
  38044. * Gets the mesh that is currently under the pointer
  38045. */
  38046. get meshUnderPointer(): Nullable<AbstractMesh>;
  38047. /**
  38048. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38049. */
  38050. get unTranslatedPointer(): Vector2;
  38051. /**
  38052. * Gets or sets the current on-screen X position of the pointer
  38053. */
  38054. get pointerX(): number;
  38055. set pointerX(value: number);
  38056. /**
  38057. * Gets or sets the current on-screen Y position of the pointer
  38058. */
  38059. get pointerY(): number;
  38060. set pointerY(value: number);
  38061. private _updatePointerPosition;
  38062. private _processPointerMove;
  38063. private _setRayOnPointerInfo;
  38064. private _checkPrePointerObservable;
  38065. /**
  38066. * Use this method to simulate a pointer move on a mesh
  38067. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38068. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38069. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38070. */
  38071. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38072. /**
  38073. * Use this method to simulate a pointer down on a mesh
  38074. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38075. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38076. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38077. */
  38078. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38079. private _processPointerDown;
  38080. /** @hidden */
  38081. _isPointerSwiping(): boolean;
  38082. /**
  38083. * Use this method to simulate a pointer up on a mesh
  38084. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38085. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38086. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38087. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38088. */
  38089. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38090. private _processPointerUp;
  38091. /**
  38092. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38093. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38094. * @returns true if the pointer was captured
  38095. */
  38096. isPointerCaptured(pointerId?: number): boolean;
  38097. /**
  38098. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38099. * @param attachUp defines if you want to attach events to pointerup
  38100. * @param attachDown defines if you want to attach events to pointerdown
  38101. * @param attachMove defines if you want to attach events to pointermove
  38102. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38103. */
  38104. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38105. /**
  38106. * Detaches all event handlers
  38107. */
  38108. detachControl(): void;
  38109. /**
  38110. * Force the value of meshUnderPointer
  38111. * @param mesh defines the mesh to use
  38112. */
  38113. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38114. /**
  38115. * Gets the mesh under the pointer
  38116. * @returns a Mesh or null if no mesh is under the pointer
  38117. */
  38118. getPointerOverMesh(): Nullable<AbstractMesh>;
  38119. }
  38120. }
  38121. declare module BABYLON {
  38122. /**
  38123. * This class defines the direct association between an animation and a target
  38124. */
  38125. export class TargetedAnimation {
  38126. /**
  38127. * Animation to perform
  38128. */
  38129. animation: Animation;
  38130. /**
  38131. * Target to animate
  38132. */
  38133. target: any;
  38134. /**
  38135. * Returns the string "TargetedAnimation"
  38136. * @returns "TargetedAnimation"
  38137. */
  38138. getClassName(): string;
  38139. /**
  38140. * Serialize the object
  38141. * @returns the JSON object representing the current entity
  38142. */
  38143. serialize(): any;
  38144. }
  38145. /**
  38146. * Use this class to create coordinated animations on multiple targets
  38147. */
  38148. export class AnimationGroup implements IDisposable {
  38149. /** The name of the animation group */
  38150. name: string;
  38151. private _scene;
  38152. private _targetedAnimations;
  38153. private _animatables;
  38154. private _from;
  38155. private _to;
  38156. private _isStarted;
  38157. private _isPaused;
  38158. private _speedRatio;
  38159. private _loopAnimation;
  38160. private _isAdditive;
  38161. /**
  38162. * Gets or sets the unique id of the node
  38163. */
  38164. uniqueId: number;
  38165. /**
  38166. * This observable will notify when one animation have ended
  38167. */
  38168. onAnimationEndObservable: Observable<TargetedAnimation>;
  38169. /**
  38170. * Observer raised when one animation loops
  38171. */
  38172. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38173. /**
  38174. * Observer raised when all animations have looped
  38175. */
  38176. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38177. /**
  38178. * This observable will notify when all animations have ended.
  38179. */
  38180. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38181. /**
  38182. * This observable will notify when all animations have paused.
  38183. */
  38184. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38185. /**
  38186. * This observable will notify when all animations are playing.
  38187. */
  38188. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38189. /**
  38190. * Gets the first frame
  38191. */
  38192. get from(): number;
  38193. /**
  38194. * Gets the last frame
  38195. */
  38196. get to(): number;
  38197. /**
  38198. * Define if the animations are started
  38199. */
  38200. get isStarted(): boolean;
  38201. /**
  38202. * Gets a value indicating that the current group is playing
  38203. */
  38204. get isPlaying(): boolean;
  38205. /**
  38206. * Gets or sets the speed ratio to use for all animations
  38207. */
  38208. get speedRatio(): number;
  38209. /**
  38210. * Gets or sets the speed ratio to use for all animations
  38211. */
  38212. set speedRatio(value: number);
  38213. /**
  38214. * Gets or sets if all animations should loop or not
  38215. */
  38216. get loopAnimation(): boolean;
  38217. set loopAnimation(value: boolean);
  38218. /**
  38219. * Gets or sets if all animations should be evaluated additively
  38220. */
  38221. get isAdditive(): boolean;
  38222. set isAdditive(value: boolean);
  38223. /**
  38224. * Gets the targeted animations for this animation group
  38225. */
  38226. get targetedAnimations(): Array<TargetedAnimation>;
  38227. /**
  38228. * returning the list of animatables controlled by this animation group.
  38229. */
  38230. get animatables(): Array<Animatable>;
  38231. /**
  38232. * Gets the list of target animations
  38233. */
  38234. get children(): TargetedAnimation[];
  38235. /**
  38236. * Instantiates a new Animation Group.
  38237. * This helps managing several animations at once.
  38238. * @see http://doc.babylonjs.com/how_to/group
  38239. * @param name Defines the name of the group
  38240. * @param scene Defines the scene the group belongs to
  38241. */
  38242. constructor(
  38243. /** The name of the animation group */
  38244. name: string, scene?: Nullable<Scene>);
  38245. /**
  38246. * Add an animation (with its target) in the group
  38247. * @param animation defines the animation we want to add
  38248. * @param target defines the target of the animation
  38249. * @returns the TargetedAnimation object
  38250. */
  38251. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38252. /**
  38253. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38254. * It can add constant keys at begin or end
  38255. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38256. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38257. * @returns the animation group
  38258. */
  38259. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38260. private _animationLoopCount;
  38261. private _animationLoopFlags;
  38262. private _processLoop;
  38263. /**
  38264. * Start all animations on given targets
  38265. * @param loop defines if animations must loop
  38266. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38267. * @param from defines the from key (optional)
  38268. * @param to defines the to key (optional)
  38269. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38270. * @returns the current animation group
  38271. */
  38272. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38273. /**
  38274. * Pause all animations
  38275. * @returns the animation group
  38276. */
  38277. pause(): AnimationGroup;
  38278. /**
  38279. * Play all animations to initial state
  38280. * This function will start() the animations if they were not started or will restart() them if they were paused
  38281. * @param loop defines if animations must loop
  38282. * @returns the animation group
  38283. */
  38284. play(loop?: boolean): AnimationGroup;
  38285. /**
  38286. * Reset all animations to initial state
  38287. * @returns the animation group
  38288. */
  38289. reset(): AnimationGroup;
  38290. /**
  38291. * Restart animations from key 0
  38292. * @returns the animation group
  38293. */
  38294. restart(): AnimationGroup;
  38295. /**
  38296. * Stop all animations
  38297. * @returns the animation group
  38298. */
  38299. stop(): AnimationGroup;
  38300. /**
  38301. * Set animation weight for all animatables
  38302. * @param weight defines the weight to use
  38303. * @return the animationGroup
  38304. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38305. */
  38306. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38307. /**
  38308. * Synchronize and normalize all animatables with a source animatable
  38309. * @param root defines the root animatable to synchronize with
  38310. * @return the animationGroup
  38311. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  38312. */
  38313. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38314. /**
  38315. * Goes to a specific frame in this animation group
  38316. * @param frame the frame number to go to
  38317. * @return the animationGroup
  38318. */
  38319. goToFrame(frame: number): AnimationGroup;
  38320. /**
  38321. * Dispose all associated resources
  38322. */
  38323. dispose(): void;
  38324. private _checkAnimationGroupEnded;
  38325. /**
  38326. * Clone the current animation group and returns a copy
  38327. * @param newName defines the name of the new group
  38328. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38329. * @returns the new aniamtion group
  38330. */
  38331. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38332. /**
  38333. * Serializes the animationGroup to an object
  38334. * @returns Serialized object
  38335. */
  38336. serialize(): any;
  38337. /**
  38338. * Returns a new AnimationGroup object parsed from the source provided.
  38339. * @param parsedAnimationGroup defines the source
  38340. * @param scene defines the scene that will receive the animationGroup
  38341. * @returns a new AnimationGroup
  38342. */
  38343. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38344. /**
  38345. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38346. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38347. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38348. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38349. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38350. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38351. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38352. */
  38353. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38354. /**
  38355. * Returns the string "AnimationGroup"
  38356. * @returns "AnimationGroup"
  38357. */
  38358. getClassName(): string;
  38359. /**
  38360. * Creates a detailled string about the object
  38361. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38362. * @returns a string representing the object
  38363. */
  38364. toString(fullDetails?: boolean): string;
  38365. }
  38366. }
  38367. declare module BABYLON {
  38368. /**
  38369. * Define an interface for all classes that will hold resources
  38370. */
  38371. export interface IDisposable {
  38372. /**
  38373. * Releases all held resources
  38374. */
  38375. dispose(): void;
  38376. }
  38377. /** Interface defining initialization parameters for Scene class */
  38378. export interface SceneOptions {
  38379. /**
  38380. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38381. * It will improve performance when the number of geometries becomes important.
  38382. */
  38383. useGeometryUniqueIdsMap?: boolean;
  38384. /**
  38385. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38386. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38387. */
  38388. useMaterialMeshMap?: boolean;
  38389. /**
  38390. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38391. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38392. */
  38393. useClonedMeshMap?: boolean;
  38394. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38395. virtual?: boolean;
  38396. }
  38397. /**
  38398. * Represents a scene to be rendered by the engine.
  38399. * @see http://doc.babylonjs.com/features/scene
  38400. */
  38401. export class Scene extends AbstractScene implements IAnimatable {
  38402. /** The fog is deactivated */
  38403. static readonly FOGMODE_NONE: number;
  38404. /** The fog density is following an exponential function */
  38405. static readonly FOGMODE_EXP: number;
  38406. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38407. static readonly FOGMODE_EXP2: number;
  38408. /** The fog density is following a linear function. */
  38409. static readonly FOGMODE_LINEAR: number;
  38410. /**
  38411. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38412. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38413. */
  38414. static MinDeltaTime: number;
  38415. /**
  38416. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38417. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38418. */
  38419. static MaxDeltaTime: number;
  38420. /**
  38421. * Factory used to create the default material.
  38422. * @param name The name of the material to create
  38423. * @param scene The scene to create the material for
  38424. * @returns The default material
  38425. */
  38426. static DefaultMaterialFactory(scene: Scene): Material;
  38427. /**
  38428. * Factory used to create the a collision coordinator.
  38429. * @returns The collision coordinator
  38430. */
  38431. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38432. /** @hidden */
  38433. _inputManager: InputManager;
  38434. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38435. cameraToUseForPointers: Nullable<Camera>;
  38436. /** @hidden */
  38437. readonly _isScene: boolean;
  38438. /** @hidden */
  38439. _blockEntityCollection: boolean;
  38440. /**
  38441. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38442. */
  38443. autoClear: boolean;
  38444. /**
  38445. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38446. */
  38447. autoClearDepthAndStencil: boolean;
  38448. /**
  38449. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38450. */
  38451. clearColor: Color4;
  38452. /**
  38453. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38454. */
  38455. ambientColor: Color3;
  38456. /**
  38457. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38458. * It should only be one of the following (if not the default embedded one):
  38459. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38460. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38461. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38462. * The material properties need to be setup according to the type of texture in use.
  38463. */
  38464. environmentBRDFTexture: BaseTexture;
  38465. /** @hidden */
  38466. protected _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 reference from here than from all the materials.
  38471. */
  38472. get environmentTexture(): Nullable<BaseTexture>;
  38473. /**
  38474. * Texture used in all pbr material as the reflection texture.
  38475. * As in the majority of the scene they are the same (exception for multi room and so on),
  38476. * this is easier to set here than in all the materials.
  38477. */
  38478. set environmentTexture(value: Nullable<BaseTexture>);
  38479. /** @hidden */
  38480. protected _environmentIntensity: number;
  38481. /**
  38482. * Intensity of the environment in all pbr material.
  38483. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38484. * As in the majority of the scene they are the same (exception for multi room and so on),
  38485. * this is easier to reference from here than from all the materials.
  38486. */
  38487. get environmentIntensity(): number;
  38488. /**
  38489. * Intensity of the environment in all pbr material.
  38490. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38491. * As in the majority of the scene they are the same (exception for multi room and so on),
  38492. * this is easier to set here than in all the materials.
  38493. */
  38494. set environmentIntensity(value: number);
  38495. /** @hidden */
  38496. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38497. /**
  38498. * Default image processing configuration used either in the rendering
  38499. * Forward main pass or through the imageProcessingPostProcess if present.
  38500. * As in the majority of the scene they are the same (exception for multi camera),
  38501. * this is easier to reference from here than from all the materials and post process.
  38502. *
  38503. * No setter as we it is a shared configuration, you can set the values instead.
  38504. */
  38505. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38506. private _forceWireframe;
  38507. /**
  38508. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38509. */
  38510. set forceWireframe(value: boolean);
  38511. get forceWireframe(): boolean;
  38512. private _skipFrustumClipping;
  38513. /**
  38514. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38515. */
  38516. set skipFrustumClipping(value: boolean);
  38517. get skipFrustumClipping(): boolean;
  38518. private _forcePointsCloud;
  38519. /**
  38520. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38521. */
  38522. set forcePointsCloud(value: boolean);
  38523. get forcePointsCloud(): boolean;
  38524. /**
  38525. * Gets or sets the active clipplane 1
  38526. */
  38527. clipPlane: Nullable<Plane>;
  38528. /**
  38529. * Gets or sets the active clipplane 2
  38530. */
  38531. clipPlane2: Nullable<Plane>;
  38532. /**
  38533. * Gets or sets the active clipplane 3
  38534. */
  38535. clipPlane3: Nullable<Plane>;
  38536. /**
  38537. * Gets or sets the active clipplane 4
  38538. */
  38539. clipPlane4: Nullable<Plane>;
  38540. /**
  38541. * Gets or sets the active clipplane 5
  38542. */
  38543. clipPlane5: Nullable<Plane>;
  38544. /**
  38545. * Gets or sets the active clipplane 6
  38546. */
  38547. clipPlane6: Nullable<Plane>;
  38548. /**
  38549. * Gets or sets a boolean indicating if animations are enabled
  38550. */
  38551. animationsEnabled: boolean;
  38552. private _animationPropertiesOverride;
  38553. /**
  38554. * Gets or sets the animation properties override
  38555. */
  38556. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38557. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38558. /**
  38559. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38560. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38561. */
  38562. useConstantAnimationDeltaTime: boolean;
  38563. /**
  38564. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38565. * Please note that it requires to run a ray cast through the scene on every frame
  38566. */
  38567. constantlyUpdateMeshUnderPointer: boolean;
  38568. /**
  38569. * Defines the HTML cursor to use when hovering over interactive elements
  38570. */
  38571. hoverCursor: string;
  38572. /**
  38573. * Defines the HTML default cursor to use (empty by default)
  38574. */
  38575. defaultCursor: string;
  38576. /**
  38577. * Defines whether cursors are handled by the scene.
  38578. */
  38579. doNotHandleCursors: boolean;
  38580. /**
  38581. * This is used to call preventDefault() on pointer down
  38582. * in order to block unwanted artifacts like system double clicks
  38583. */
  38584. preventDefaultOnPointerDown: boolean;
  38585. /**
  38586. * This is used to call preventDefault() on pointer up
  38587. * in order to block unwanted artifacts like system double clicks
  38588. */
  38589. preventDefaultOnPointerUp: boolean;
  38590. /**
  38591. * Gets or sets user defined metadata
  38592. */
  38593. metadata: any;
  38594. /**
  38595. * For internal use only. Please do not use.
  38596. */
  38597. reservedDataStore: any;
  38598. /**
  38599. * Gets the name of the plugin used to load this scene (null by default)
  38600. */
  38601. loadingPluginName: string;
  38602. /**
  38603. * Use this array to add regular expressions used to disable offline support for specific urls
  38604. */
  38605. disableOfflineSupportExceptionRules: RegExp[];
  38606. /**
  38607. * An event triggered when the scene is disposed.
  38608. */
  38609. onDisposeObservable: Observable<Scene>;
  38610. private _onDisposeObserver;
  38611. /** Sets a function to be executed when this scene is disposed. */
  38612. set onDispose(callback: () => void);
  38613. /**
  38614. * An event triggered before rendering the scene (right after animations and physics)
  38615. */
  38616. onBeforeRenderObservable: Observable<Scene>;
  38617. private _onBeforeRenderObserver;
  38618. /** Sets a function to be executed before rendering this scene */
  38619. set beforeRender(callback: Nullable<() => void>);
  38620. /**
  38621. * An event triggered after rendering the scene
  38622. */
  38623. onAfterRenderObservable: Observable<Scene>;
  38624. /**
  38625. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38626. */
  38627. onAfterRenderCameraObservable: Observable<Camera>;
  38628. private _onAfterRenderObserver;
  38629. /** Sets a function to be executed after rendering this scene */
  38630. set afterRender(callback: Nullable<() => void>);
  38631. /**
  38632. * An event triggered before animating the scene
  38633. */
  38634. onBeforeAnimationsObservable: Observable<Scene>;
  38635. /**
  38636. * An event triggered after animations processing
  38637. */
  38638. onAfterAnimationsObservable: Observable<Scene>;
  38639. /**
  38640. * An event triggered before draw calls are ready to be sent
  38641. */
  38642. onBeforeDrawPhaseObservable: Observable<Scene>;
  38643. /**
  38644. * An event triggered after draw calls have been sent
  38645. */
  38646. onAfterDrawPhaseObservable: Observable<Scene>;
  38647. /**
  38648. * An event triggered when the scene is ready
  38649. */
  38650. onReadyObservable: Observable<Scene>;
  38651. /**
  38652. * An event triggered before rendering a camera
  38653. */
  38654. onBeforeCameraRenderObservable: Observable<Camera>;
  38655. private _onBeforeCameraRenderObserver;
  38656. /** Sets a function to be executed before rendering a camera*/
  38657. set beforeCameraRender(callback: () => void);
  38658. /**
  38659. * An event triggered after rendering a camera
  38660. */
  38661. onAfterCameraRenderObservable: Observable<Camera>;
  38662. private _onAfterCameraRenderObserver;
  38663. /** Sets a function to be executed after rendering a camera*/
  38664. set afterCameraRender(callback: () => void);
  38665. /**
  38666. * An event triggered when active meshes evaluation is about to start
  38667. */
  38668. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38669. /**
  38670. * An event triggered when active meshes evaluation is done
  38671. */
  38672. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38673. /**
  38674. * An event triggered when particles rendering is about to start
  38675. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38676. */
  38677. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38678. /**
  38679. * An event triggered when particles rendering is done
  38680. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38681. */
  38682. onAfterParticlesRenderingObservable: Observable<Scene>;
  38683. /**
  38684. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38685. */
  38686. onDataLoadedObservable: Observable<Scene>;
  38687. /**
  38688. * An event triggered when a camera is created
  38689. */
  38690. onNewCameraAddedObservable: Observable<Camera>;
  38691. /**
  38692. * An event triggered when a camera is removed
  38693. */
  38694. onCameraRemovedObservable: Observable<Camera>;
  38695. /**
  38696. * An event triggered when a light is created
  38697. */
  38698. onNewLightAddedObservable: Observable<Light>;
  38699. /**
  38700. * An event triggered when a light is removed
  38701. */
  38702. onLightRemovedObservable: Observable<Light>;
  38703. /**
  38704. * An event triggered when a geometry is created
  38705. */
  38706. onNewGeometryAddedObservable: Observable<Geometry>;
  38707. /**
  38708. * An event triggered when a geometry is removed
  38709. */
  38710. onGeometryRemovedObservable: Observable<Geometry>;
  38711. /**
  38712. * An event triggered when a transform node is created
  38713. */
  38714. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38715. /**
  38716. * An event triggered when a transform node is removed
  38717. */
  38718. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38719. /**
  38720. * An event triggered when a mesh is created
  38721. */
  38722. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38723. /**
  38724. * An event triggered when a mesh is removed
  38725. */
  38726. onMeshRemovedObservable: Observable<AbstractMesh>;
  38727. /**
  38728. * An event triggered when a skeleton is created
  38729. */
  38730. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38731. /**
  38732. * An event triggered when a skeleton is removed
  38733. */
  38734. onSkeletonRemovedObservable: Observable<Skeleton>;
  38735. /**
  38736. * An event triggered when a material is created
  38737. */
  38738. onNewMaterialAddedObservable: Observable<Material>;
  38739. /**
  38740. * An event triggered when a material is removed
  38741. */
  38742. onMaterialRemovedObservable: Observable<Material>;
  38743. /**
  38744. * An event triggered when a texture is created
  38745. */
  38746. onNewTextureAddedObservable: Observable<BaseTexture>;
  38747. /**
  38748. * An event triggered when a texture is removed
  38749. */
  38750. onTextureRemovedObservable: Observable<BaseTexture>;
  38751. /**
  38752. * An event triggered when render targets are about to be rendered
  38753. * Can happen multiple times per frame.
  38754. */
  38755. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38756. /**
  38757. * An event triggered when render targets were rendered.
  38758. * Can happen multiple times per frame.
  38759. */
  38760. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38761. /**
  38762. * An event triggered before calculating deterministic simulation step
  38763. */
  38764. onBeforeStepObservable: Observable<Scene>;
  38765. /**
  38766. * An event triggered after calculating deterministic simulation step
  38767. */
  38768. onAfterStepObservable: Observable<Scene>;
  38769. /**
  38770. * An event triggered when the activeCamera property is updated
  38771. */
  38772. onActiveCameraChanged: Observable<Scene>;
  38773. /**
  38774. * This Observable will be triggered before 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. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38779. /**
  38780. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38781. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38782. * 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)
  38783. */
  38784. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38785. /**
  38786. * This Observable will when a mesh has been imported into the scene.
  38787. */
  38788. onMeshImportedObservable: Observable<AbstractMesh>;
  38789. /**
  38790. * This Observable will when an animation file has been imported into the scene.
  38791. */
  38792. onAnimationFileImportedObservable: Observable<Scene>;
  38793. /**
  38794. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38795. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38796. */
  38797. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38798. /** @hidden */
  38799. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38800. /**
  38801. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38802. */
  38803. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38804. /**
  38805. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38806. */
  38807. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38808. /**
  38809. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38810. */
  38811. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38812. /** Callback called when a pointer move is detected */
  38813. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38814. /** Callback called when a pointer down is detected */
  38815. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38816. /** Callback called when a pointer up is detected */
  38817. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38818. /** Callback called when a pointer pick is detected */
  38819. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38820. /**
  38821. * 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).
  38822. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38823. */
  38824. onPrePointerObservable: Observable<PointerInfoPre>;
  38825. /**
  38826. * Observable event triggered each time an input event is received from the rendering canvas
  38827. */
  38828. onPointerObservable: Observable<PointerInfo>;
  38829. /**
  38830. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38831. */
  38832. get unTranslatedPointer(): Vector2;
  38833. /**
  38834. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38835. */
  38836. static get DragMovementThreshold(): number;
  38837. static set DragMovementThreshold(value: number);
  38838. /**
  38839. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38840. */
  38841. static get LongPressDelay(): number;
  38842. static set LongPressDelay(value: number);
  38843. /**
  38844. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38845. */
  38846. static get DoubleClickDelay(): number;
  38847. static set DoubleClickDelay(value: number);
  38848. /** If you need to check double click without raising a single click at first click, enable this flag */
  38849. static get ExclusiveDoubleClickMode(): boolean;
  38850. static set ExclusiveDoubleClickMode(value: boolean);
  38851. /** @hidden */
  38852. _mirroredCameraPosition: Nullable<Vector3>;
  38853. /**
  38854. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38855. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38856. */
  38857. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38858. /**
  38859. * Observable event triggered each time an keyboard event is received from the hosting window
  38860. */
  38861. onKeyboardObservable: Observable<KeyboardInfo>;
  38862. private _useRightHandedSystem;
  38863. /**
  38864. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38865. */
  38866. set useRightHandedSystem(value: boolean);
  38867. get useRightHandedSystem(): boolean;
  38868. private _timeAccumulator;
  38869. private _currentStepId;
  38870. private _currentInternalStep;
  38871. /**
  38872. * Sets the step Id used by deterministic lock step
  38873. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38874. * @param newStepId defines the step Id
  38875. */
  38876. setStepId(newStepId: number): void;
  38877. /**
  38878. * Gets the step Id used by deterministic lock step
  38879. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38880. * @returns the step Id
  38881. */
  38882. getStepId(): number;
  38883. /**
  38884. * Gets the internal step used by deterministic lock step
  38885. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38886. * @returns the internal step
  38887. */
  38888. getInternalStep(): number;
  38889. private _fogEnabled;
  38890. /**
  38891. * Gets or sets a boolean indicating if fog is enabled on this scene
  38892. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38893. * (Default is true)
  38894. */
  38895. set fogEnabled(value: boolean);
  38896. get fogEnabled(): boolean;
  38897. private _fogMode;
  38898. /**
  38899. * Gets or sets the fog mode to use
  38900. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38901. * | mode | value |
  38902. * | --- | --- |
  38903. * | FOGMODE_NONE | 0 |
  38904. * | FOGMODE_EXP | 1 |
  38905. * | FOGMODE_EXP2 | 2 |
  38906. * | FOGMODE_LINEAR | 3 |
  38907. */
  38908. set fogMode(value: number);
  38909. get fogMode(): number;
  38910. /**
  38911. * Gets or sets the fog color to use
  38912. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38913. * (Default is Color3(0.2, 0.2, 0.3))
  38914. */
  38915. fogColor: Color3;
  38916. /**
  38917. * Gets or sets the fog density to use
  38918. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38919. * (Default is 0.1)
  38920. */
  38921. fogDensity: number;
  38922. /**
  38923. * Gets or sets the fog start distance to use
  38924. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38925. * (Default is 0)
  38926. */
  38927. fogStart: number;
  38928. /**
  38929. * Gets or sets the fog end distance to use
  38930. * @see http://doc.babylonjs.com/babylon101/environment#fog
  38931. * (Default is 1000)
  38932. */
  38933. fogEnd: number;
  38934. private _shadowsEnabled;
  38935. /**
  38936. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38937. */
  38938. set shadowsEnabled(value: boolean);
  38939. get shadowsEnabled(): boolean;
  38940. private _lightsEnabled;
  38941. /**
  38942. * Gets or sets a boolean indicating if lights are enabled on this scene
  38943. */
  38944. set lightsEnabled(value: boolean);
  38945. get lightsEnabled(): boolean;
  38946. /** All of the active cameras added to this scene. */
  38947. activeCameras: Camera[];
  38948. /** @hidden */
  38949. _activeCamera: Nullable<Camera>;
  38950. /** Gets or sets the current active camera */
  38951. get activeCamera(): Nullable<Camera>;
  38952. set activeCamera(value: Nullable<Camera>);
  38953. private _defaultMaterial;
  38954. /** The default material used on meshes when no material is affected */
  38955. get defaultMaterial(): Material;
  38956. /** The default material used on meshes when no material is affected */
  38957. set defaultMaterial(value: Material);
  38958. private _texturesEnabled;
  38959. /**
  38960. * Gets or sets a boolean indicating if textures are enabled on this scene
  38961. */
  38962. set texturesEnabled(value: boolean);
  38963. get texturesEnabled(): boolean;
  38964. /**
  38965. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  38966. */
  38967. physicsEnabled: boolean;
  38968. /**
  38969. * Gets or sets a boolean indicating if particles are enabled on this scene
  38970. */
  38971. particlesEnabled: boolean;
  38972. /**
  38973. * Gets or sets a boolean indicating if sprites are enabled on this scene
  38974. */
  38975. spritesEnabled: boolean;
  38976. private _skeletonsEnabled;
  38977. /**
  38978. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  38979. */
  38980. set skeletonsEnabled(value: boolean);
  38981. get skeletonsEnabled(): boolean;
  38982. /**
  38983. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  38984. */
  38985. lensFlaresEnabled: boolean;
  38986. /**
  38987. * Gets or sets a boolean indicating if collisions are enabled on this scene
  38988. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38989. */
  38990. collisionsEnabled: boolean;
  38991. private _collisionCoordinator;
  38992. /** @hidden */
  38993. get collisionCoordinator(): ICollisionCoordinator;
  38994. /**
  38995. * Defines the gravity applied to this scene (used only for collisions)
  38996. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  38997. */
  38998. gravity: Vector3;
  38999. /**
  39000. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39001. */
  39002. postProcessesEnabled: boolean;
  39003. /**
  39004. * The list of postprocesses added to the scene
  39005. */
  39006. postProcesses: PostProcess[];
  39007. /**
  39008. * Gets the current postprocess manager
  39009. */
  39010. postProcessManager: PostProcessManager;
  39011. /**
  39012. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39013. */
  39014. renderTargetsEnabled: boolean;
  39015. /**
  39016. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39017. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39018. */
  39019. dumpNextRenderTargets: boolean;
  39020. /**
  39021. * The list of user defined render targets added to the scene
  39022. */
  39023. customRenderTargets: RenderTargetTexture[];
  39024. /**
  39025. * Defines if texture loading must be delayed
  39026. * If true, textures will only be loaded when they need to be rendered
  39027. */
  39028. useDelayedTextureLoading: boolean;
  39029. /**
  39030. * Gets the list of meshes imported to the scene through SceneLoader
  39031. */
  39032. importedMeshesFiles: String[];
  39033. /**
  39034. * Gets or sets a boolean indicating if probes are enabled on this scene
  39035. */
  39036. probesEnabled: boolean;
  39037. /**
  39038. * Gets or sets the current offline provider to use to store scene data
  39039. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39040. */
  39041. offlineProvider: IOfflineProvider;
  39042. /**
  39043. * Gets or sets the action manager associated with the scene
  39044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39045. */
  39046. actionManager: AbstractActionManager;
  39047. private _meshesForIntersections;
  39048. /**
  39049. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39050. */
  39051. proceduralTexturesEnabled: boolean;
  39052. private _engine;
  39053. private _totalVertices;
  39054. /** @hidden */
  39055. _activeIndices: PerfCounter;
  39056. /** @hidden */
  39057. _activeParticles: PerfCounter;
  39058. /** @hidden */
  39059. _activeBones: PerfCounter;
  39060. private _animationRatio;
  39061. /** @hidden */
  39062. _animationTimeLast: number;
  39063. /** @hidden */
  39064. _animationTime: number;
  39065. /**
  39066. * Gets or sets a general scale for animation speed
  39067. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39068. */
  39069. animationTimeScale: number;
  39070. /** @hidden */
  39071. _cachedMaterial: Nullable<Material>;
  39072. /** @hidden */
  39073. _cachedEffect: Nullable<Effect>;
  39074. /** @hidden */
  39075. _cachedVisibility: Nullable<number>;
  39076. private _renderId;
  39077. private _frameId;
  39078. private _executeWhenReadyTimeoutId;
  39079. private _intermediateRendering;
  39080. private _viewUpdateFlag;
  39081. private _projectionUpdateFlag;
  39082. /** @hidden */
  39083. _toBeDisposed: Nullable<IDisposable>[];
  39084. private _activeRequests;
  39085. /** @hidden */
  39086. _pendingData: any[];
  39087. private _isDisposed;
  39088. /**
  39089. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39090. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39091. */
  39092. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39093. private _activeMeshes;
  39094. private _processedMaterials;
  39095. private _renderTargets;
  39096. /** @hidden */
  39097. _activeParticleSystems: SmartArray<IParticleSystem>;
  39098. private _activeSkeletons;
  39099. private _softwareSkinnedMeshes;
  39100. private _renderingManager;
  39101. /** @hidden */
  39102. _activeAnimatables: Animatable[];
  39103. private _transformMatrix;
  39104. private _sceneUbo;
  39105. /** @hidden */
  39106. _viewMatrix: Matrix;
  39107. private _projectionMatrix;
  39108. /** @hidden */
  39109. _forcedViewPosition: Nullable<Vector3>;
  39110. /** @hidden */
  39111. _frustumPlanes: Plane[];
  39112. /**
  39113. * Gets the list of frustum planes (built from the active camera)
  39114. */
  39115. get frustumPlanes(): Plane[];
  39116. /**
  39117. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39118. * This is useful if there are more lights that the maximum simulteanous authorized
  39119. */
  39120. requireLightSorting: boolean;
  39121. /** @hidden */
  39122. readonly useMaterialMeshMap: boolean;
  39123. /** @hidden */
  39124. readonly useClonedMeshMap: boolean;
  39125. private _externalData;
  39126. private _uid;
  39127. /**
  39128. * @hidden
  39129. * Backing store of defined scene components.
  39130. */
  39131. _components: ISceneComponent[];
  39132. /**
  39133. * @hidden
  39134. * Backing store of defined scene components.
  39135. */
  39136. _serializableComponents: ISceneSerializableComponent[];
  39137. /**
  39138. * List of components to register on the next registration step.
  39139. */
  39140. private _transientComponents;
  39141. /**
  39142. * Registers the transient components if needed.
  39143. */
  39144. private _registerTransientComponents;
  39145. /**
  39146. * @hidden
  39147. * Add a component to the scene.
  39148. * Note that the ccomponent could be registered on th next frame if this is called after
  39149. * the register component stage.
  39150. * @param component Defines the component to add to the scene
  39151. */
  39152. _addComponent(component: ISceneComponent): void;
  39153. /**
  39154. * @hidden
  39155. * Gets a component from the scene.
  39156. * @param name defines the name of the component to retrieve
  39157. * @returns the component or null if not present
  39158. */
  39159. _getComponent(name: string): Nullable<ISceneComponent>;
  39160. /**
  39161. * @hidden
  39162. * Defines the actions happening before camera updates.
  39163. */
  39164. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39165. /**
  39166. * @hidden
  39167. * Defines the actions happening before clear the canvas.
  39168. */
  39169. _beforeClearStage: Stage<SimpleStageAction>;
  39170. /**
  39171. * @hidden
  39172. * Defines the actions when collecting render targets for the frame.
  39173. */
  39174. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39175. /**
  39176. * @hidden
  39177. * Defines the actions happening for one camera in the frame.
  39178. */
  39179. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39180. /**
  39181. * @hidden
  39182. * Defines the actions happening during the per mesh ready checks.
  39183. */
  39184. _isReadyForMeshStage: Stage<MeshStageAction>;
  39185. /**
  39186. * @hidden
  39187. * Defines the actions happening before evaluate active mesh checks.
  39188. */
  39189. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39190. /**
  39191. * @hidden
  39192. * Defines the actions happening during the evaluate sub mesh checks.
  39193. */
  39194. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39195. /**
  39196. * @hidden
  39197. * Defines the actions happening during the active mesh stage.
  39198. */
  39199. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39200. /**
  39201. * @hidden
  39202. * Defines the actions happening during the per camera render target step.
  39203. */
  39204. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39205. /**
  39206. * @hidden
  39207. * Defines the actions happening just before the active camera is drawing.
  39208. */
  39209. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39210. /**
  39211. * @hidden
  39212. * Defines the actions happening just before a render target is drawing.
  39213. */
  39214. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39215. /**
  39216. * @hidden
  39217. * Defines the actions happening just before a rendering group is drawing.
  39218. */
  39219. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39220. /**
  39221. * @hidden
  39222. * Defines the actions happening just before a mesh is drawing.
  39223. */
  39224. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39225. /**
  39226. * @hidden
  39227. * Defines the actions happening just after a mesh has been drawn.
  39228. */
  39229. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39230. /**
  39231. * @hidden
  39232. * Defines the actions happening just after a rendering group has been drawn.
  39233. */
  39234. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39235. /**
  39236. * @hidden
  39237. * Defines the actions happening just after the active camera has been drawn.
  39238. */
  39239. _afterCameraDrawStage: Stage<CameraStageAction>;
  39240. /**
  39241. * @hidden
  39242. * Defines the actions happening just after a render target has been drawn.
  39243. */
  39244. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39245. /**
  39246. * @hidden
  39247. * Defines the actions happening just after rendering all cameras and computing intersections.
  39248. */
  39249. _afterRenderStage: Stage<SimpleStageAction>;
  39250. /**
  39251. * @hidden
  39252. * Defines the actions happening when a pointer move event happens.
  39253. */
  39254. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39255. /**
  39256. * @hidden
  39257. * Defines the actions happening when a pointer down event happens.
  39258. */
  39259. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39260. /**
  39261. * @hidden
  39262. * Defines the actions happening when a pointer up event happens.
  39263. */
  39264. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39265. /**
  39266. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39267. */
  39268. private geometriesByUniqueId;
  39269. /**
  39270. * Creates a new Scene
  39271. * @param engine defines the engine to use to render this scene
  39272. * @param options defines the scene options
  39273. */
  39274. constructor(engine: Engine, options?: SceneOptions);
  39275. /**
  39276. * Gets a string idenfifying the name of the class
  39277. * @returns "Scene" string
  39278. */
  39279. getClassName(): string;
  39280. private _defaultMeshCandidates;
  39281. /**
  39282. * @hidden
  39283. */
  39284. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39285. private _defaultSubMeshCandidates;
  39286. /**
  39287. * @hidden
  39288. */
  39289. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39290. /**
  39291. * Sets the default candidate providers for the scene.
  39292. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39293. * and getCollidingSubMeshCandidates to their default function
  39294. */
  39295. setDefaultCandidateProviders(): void;
  39296. /**
  39297. * Gets the mesh that is currently under the pointer
  39298. */
  39299. get meshUnderPointer(): Nullable<AbstractMesh>;
  39300. /**
  39301. * Gets or sets the current on-screen X position of the pointer
  39302. */
  39303. get pointerX(): number;
  39304. set pointerX(value: number);
  39305. /**
  39306. * Gets or sets the current on-screen Y position of the pointer
  39307. */
  39308. get pointerY(): number;
  39309. set pointerY(value: number);
  39310. /**
  39311. * Gets the cached material (ie. the latest rendered one)
  39312. * @returns the cached material
  39313. */
  39314. getCachedMaterial(): Nullable<Material>;
  39315. /**
  39316. * Gets the cached effect (ie. the latest rendered one)
  39317. * @returns the cached effect
  39318. */
  39319. getCachedEffect(): Nullable<Effect>;
  39320. /**
  39321. * Gets the cached visibility state (ie. the latest rendered one)
  39322. * @returns the cached visibility state
  39323. */
  39324. getCachedVisibility(): Nullable<number>;
  39325. /**
  39326. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39327. * @param material defines the current material
  39328. * @param effect defines the current effect
  39329. * @param visibility defines the current visibility state
  39330. * @returns true if one parameter is not cached
  39331. */
  39332. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39333. /**
  39334. * Gets the engine associated with the scene
  39335. * @returns an Engine
  39336. */
  39337. getEngine(): Engine;
  39338. /**
  39339. * Gets the total number of vertices rendered per frame
  39340. * @returns the total number of vertices rendered per frame
  39341. */
  39342. getTotalVertices(): number;
  39343. /**
  39344. * Gets the performance counter for total vertices
  39345. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39346. */
  39347. get totalVerticesPerfCounter(): PerfCounter;
  39348. /**
  39349. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39350. * @returns the total number of active indices rendered per frame
  39351. */
  39352. getActiveIndices(): number;
  39353. /**
  39354. * Gets the performance counter for active indices
  39355. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39356. */
  39357. get totalActiveIndicesPerfCounter(): PerfCounter;
  39358. /**
  39359. * Gets the total number of active particles rendered per frame
  39360. * @returns the total number of active particles rendered per frame
  39361. */
  39362. getActiveParticles(): number;
  39363. /**
  39364. * Gets the performance counter for active particles
  39365. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39366. */
  39367. get activeParticlesPerfCounter(): PerfCounter;
  39368. /**
  39369. * Gets the total number of active bones rendered per frame
  39370. * @returns the total number of active bones rendered per frame
  39371. */
  39372. getActiveBones(): number;
  39373. /**
  39374. * Gets the performance counter for active bones
  39375. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39376. */
  39377. get activeBonesPerfCounter(): PerfCounter;
  39378. /**
  39379. * Gets the array of active meshes
  39380. * @returns an array of AbstractMesh
  39381. */
  39382. getActiveMeshes(): SmartArray<AbstractMesh>;
  39383. /**
  39384. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39385. * @returns a number
  39386. */
  39387. getAnimationRatio(): number;
  39388. /**
  39389. * Gets an unique Id for the current render phase
  39390. * @returns a number
  39391. */
  39392. getRenderId(): number;
  39393. /**
  39394. * Gets an unique Id for the current frame
  39395. * @returns a number
  39396. */
  39397. getFrameId(): number;
  39398. /** Call this function if you want to manually increment the render Id*/
  39399. incrementRenderId(): void;
  39400. private _createUbo;
  39401. /**
  39402. * Use this method to simulate a pointer move on a mesh
  39403. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39404. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39405. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39406. * @returns the current scene
  39407. */
  39408. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39409. /**
  39410. * Use this method to simulate a pointer down on a mesh
  39411. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39412. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39413. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39414. * @returns the current scene
  39415. */
  39416. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39417. /**
  39418. * Use this method to simulate a pointer up on a mesh
  39419. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39420. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39421. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39422. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39423. * @returns the current scene
  39424. */
  39425. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39426. /**
  39427. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39428. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39429. * @returns true if the pointer was captured
  39430. */
  39431. isPointerCaptured(pointerId?: number): boolean;
  39432. /**
  39433. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39434. * @param attachUp defines if you want to attach events to pointerup
  39435. * @param attachDown defines if you want to attach events to pointerdown
  39436. * @param attachMove defines if you want to attach events to pointermove
  39437. */
  39438. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39439. /** Detaches all event handlers*/
  39440. detachControl(): void;
  39441. /**
  39442. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39443. * Delay loaded resources are not taking in account
  39444. * @return true if all required resources are ready
  39445. */
  39446. isReady(): boolean;
  39447. /** Resets all cached information relative to material (including effect and visibility) */
  39448. resetCachedMaterial(): void;
  39449. /**
  39450. * Registers a function to be called before every frame render
  39451. * @param func defines the function to register
  39452. */
  39453. registerBeforeRender(func: () => void): void;
  39454. /**
  39455. * Unregisters a function called before every frame render
  39456. * @param func defines the function to unregister
  39457. */
  39458. unregisterBeforeRender(func: () => void): void;
  39459. /**
  39460. * Registers a function to be called after every frame render
  39461. * @param func defines the function to register
  39462. */
  39463. registerAfterRender(func: () => void): void;
  39464. /**
  39465. * Unregisters a function called after every frame render
  39466. * @param func defines the function to unregister
  39467. */
  39468. unregisterAfterRender(func: () => void): void;
  39469. private _executeOnceBeforeRender;
  39470. /**
  39471. * The provided function will run before render once and will be disposed afterwards.
  39472. * A timeout delay can be provided so that the function will be executed in N ms.
  39473. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39474. * @param func The function to be executed.
  39475. * @param timeout optional delay in ms
  39476. */
  39477. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39478. /** @hidden */
  39479. _addPendingData(data: any): void;
  39480. /** @hidden */
  39481. _removePendingData(data: any): void;
  39482. /**
  39483. * Returns the number of items waiting to be loaded
  39484. * @returns the number of items waiting to be loaded
  39485. */
  39486. getWaitingItemsCount(): number;
  39487. /**
  39488. * Returns a boolean indicating if the scene is still loading data
  39489. */
  39490. get isLoading(): boolean;
  39491. /**
  39492. * Registers a function to be executed when the scene is ready
  39493. * @param {Function} func - the function to be executed
  39494. */
  39495. executeWhenReady(func: () => void): void;
  39496. /**
  39497. * Returns a promise that resolves when the scene is ready
  39498. * @returns A promise that resolves when the scene is ready
  39499. */
  39500. whenReadyAsync(): Promise<void>;
  39501. /** @hidden */
  39502. _checkIsReady(): void;
  39503. /**
  39504. * Gets all animatable attached to the scene
  39505. */
  39506. get animatables(): Animatable[];
  39507. /**
  39508. * Resets the last animation time frame.
  39509. * Useful to override when animations start running when loading a scene for the first time.
  39510. */
  39511. resetLastAnimationTimeFrame(): void;
  39512. /**
  39513. * Gets the current view matrix
  39514. * @returns a Matrix
  39515. */
  39516. getViewMatrix(): Matrix;
  39517. /**
  39518. * Gets the current projection matrix
  39519. * @returns a Matrix
  39520. */
  39521. getProjectionMatrix(): Matrix;
  39522. /**
  39523. * Gets the current transform matrix
  39524. * @returns a Matrix made of View * Projection
  39525. */
  39526. getTransformMatrix(): Matrix;
  39527. /**
  39528. * Sets the current transform matrix
  39529. * @param viewL defines the View matrix to use
  39530. * @param projectionL defines the Projection matrix to use
  39531. * @param viewR defines the right View matrix to use (if provided)
  39532. * @param projectionR defines the right Projection matrix to use (if provided)
  39533. */
  39534. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39535. /**
  39536. * Gets the uniform buffer used to store scene data
  39537. * @returns a UniformBuffer
  39538. */
  39539. getSceneUniformBuffer(): UniformBuffer;
  39540. /**
  39541. * Gets an unique (relatively to the current scene) Id
  39542. * @returns an unique number for the scene
  39543. */
  39544. getUniqueId(): number;
  39545. /**
  39546. * Add a mesh to the list of scene's meshes
  39547. * @param newMesh defines the mesh to add
  39548. * @param recursive if all child meshes should also be added to the scene
  39549. */
  39550. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39551. /**
  39552. * Remove a mesh for the list of scene's meshes
  39553. * @param toRemove defines the mesh to remove
  39554. * @param recursive if all child meshes should also be removed from the scene
  39555. * @returns the index where the mesh was in the mesh list
  39556. */
  39557. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39558. /**
  39559. * Add a transform node to the list of scene's transform nodes
  39560. * @param newTransformNode defines the transform node to add
  39561. */
  39562. addTransformNode(newTransformNode: TransformNode): void;
  39563. /**
  39564. * Remove a transform node for the list of scene's transform nodes
  39565. * @param toRemove defines the transform node to remove
  39566. * @returns the index where the transform node was in the transform node list
  39567. */
  39568. removeTransformNode(toRemove: TransformNode): number;
  39569. /**
  39570. * Remove a skeleton for the list of scene's skeletons
  39571. * @param toRemove defines the skeleton to remove
  39572. * @returns the index where the skeleton was in the skeleton list
  39573. */
  39574. removeSkeleton(toRemove: Skeleton): number;
  39575. /**
  39576. * Remove a morph target for the list of scene's morph targets
  39577. * @param toRemove defines the morph target to remove
  39578. * @returns the index where the morph target was in the morph target list
  39579. */
  39580. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39581. /**
  39582. * Remove a light for the list of scene's lights
  39583. * @param toRemove defines the light to remove
  39584. * @returns the index where the light was in the light list
  39585. */
  39586. removeLight(toRemove: Light): number;
  39587. /**
  39588. * Remove a camera for the list of scene's cameras
  39589. * @param toRemove defines the camera to remove
  39590. * @returns the index where the camera was in the camera list
  39591. */
  39592. removeCamera(toRemove: Camera): number;
  39593. /**
  39594. * Remove a particle system for the list of scene's particle systems
  39595. * @param toRemove defines the particle system to remove
  39596. * @returns the index where the particle system was in the particle system list
  39597. */
  39598. removeParticleSystem(toRemove: IParticleSystem): number;
  39599. /**
  39600. * Remove a animation for the list of scene's animations
  39601. * @param toRemove defines the animation to remove
  39602. * @returns the index where the animation was in the animation list
  39603. */
  39604. removeAnimation(toRemove: Animation): number;
  39605. /**
  39606. * Will stop the animation of the given target
  39607. * @param target - the target
  39608. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39609. * @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)
  39610. */
  39611. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39612. /**
  39613. * Removes the given animation group from this scene.
  39614. * @param toRemove The animation group to remove
  39615. * @returns The index of the removed animation group
  39616. */
  39617. removeAnimationGroup(toRemove: AnimationGroup): number;
  39618. /**
  39619. * Removes the given multi-material from this scene.
  39620. * @param toRemove The multi-material to remove
  39621. * @returns The index of the removed multi-material
  39622. */
  39623. removeMultiMaterial(toRemove: MultiMaterial): number;
  39624. /**
  39625. * Removes the given material from this scene.
  39626. * @param toRemove The material to remove
  39627. * @returns The index of the removed material
  39628. */
  39629. removeMaterial(toRemove: Material): number;
  39630. /**
  39631. * Removes the given action manager from this scene.
  39632. * @param toRemove The action manager to remove
  39633. * @returns The index of the removed action manager
  39634. */
  39635. removeActionManager(toRemove: AbstractActionManager): number;
  39636. /**
  39637. * Removes the given texture from this scene.
  39638. * @param toRemove The texture to remove
  39639. * @returns The index of the removed texture
  39640. */
  39641. removeTexture(toRemove: BaseTexture): number;
  39642. /**
  39643. * Adds the given light to this scene
  39644. * @param newLight The light to add
  39645. */
  39646. addLight(newLight: Light): void;
  39647. /**
  39648. * Sorts the list list based on light priorities
  39649. */
  39650. sortLightsByPriority(): void;
  39651. /**
  39652. * Adds the given camera to this scene
  39653. * @param newCamera The camera to add
  39654. */
  39655. addCamera(newCamera: Camera): void;
  39656. /**
  39657. * Adds the given skeleton to this scene
  39658. * @param newSkeleton The skeleton to add
  39659. */
  39660. addSkeleton(newSkeleton: Skeleton): void;
  39661. /**
  39662. * Adds the given particle system to this scene
  39663. * @param newParticleSystem The particle system to add
  39664. */
  39665. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39666. /**
  39667. * Adds the given animation to this scene
  39668. * @param newAnimation The animation to add
  39669. */
  39670. addAnimation(newAnimation: Animation): void;
  39671. /**
  39672. * Adds the given animation group to this scene.
  39673. * @param newAnimationGroup The animation group to add
  39674. */
  39675. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39676. /**
  39677. * Adds the given multi-material to this scene
  39678. * @param newMultiMaterial The multi-material to add
  39679. */
  39680. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39681. /**
  39682. * Adds the given material to this scene
  39683. * @param newMaterial The material to add
  39684. */
  39685. addMaterial(newMaterial: Material): void;
  39686. /**
  39687. * Adds the given morph target to this scene
  39688. * @param newMorphTargetManager The morph target to add
  39689. */
  39690. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39691. /**
  39692. * Adds the given geometry to this scene
  39693. * @param newGeometry The geometry to add
  39694. */
  39695. addGeometry(newGeometry: Geometry): void;
  39696. /**
  39697. * Adds the given action manager to this scene
  39698. * @param newActionManager The action manager to add
  39699. */
  39700. addActionManager(newActionManager: AbstractActionManager): void;
  39701. /**
  39702. * Adds the given texture to this scene.
  39703. * @param newTexture The texture to add
  39704. */
  39705. addTexture(newTexture: BaseTexture): void;
  39706. /**
  39707. * Switch active camera
  39708. * @param newCamera defines the new active camera
  39709. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39710. */
  39711. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39712. /**
  39713. * sets the active camera of the scene using its ID
  39714. * @param id defines the camera's ID
  39715. * @return the new active camera or null if none found.
  39716. */
  39717. setActiveCameraByID(id: string): Nullable<Camera>;
  39718. /**
  39719. * sets the active camera of the scene using its name
  39720. * @param name defines the camera's name
  39721. * @returns the new active camera or null if none found.
  39722. */
  39723. setActiveCameraByName(name: string): Nullable<Camera>;
  39724. /**
  39725. * get an animation group using its name
  39726. * @param name defines the material's name
  39727. * @return the animation group or null if none found.
  39728. */
  39729. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39730. /**
  39731. * Get a material using its unique id
  39732. * @param uniqueId defines the material's unique id
  39733. * @return the material or null if none found.
  39734. */
  39735. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39736. /**
  39737. * get a material using its id
  39738. * @param id defines the material's ID
  39739. * @return the material or null if none found.
  39740. */
  39741. getMaterialByID(id: string): Nullable<Material>;
  39742. /**
  39743. * Gets a the last added material using a given id
  39744. * @param id defines the material's ID
  39745. * @return the last material with the given id or null if none found.
  39746. */
  39747. getLastMaterialByID(id: string): Nullable<Material>;
  39748. /**
  39749. * Gets a material using its name
  39750. * @param name defines the material's name
  39751. * @return the material or null if none found.
  39752. */
  39753. getMaterialByName(name: string): Nullable<Material>;
  39754. /**
  39755. * Get a texture using its unique id
  39756. * @param uniqueId defines the texture's unique id
  39757. * @return the texture or null if none found.
  39758. */
  39759. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39760. /**
  39761. * Gets a camera using its id
  39762. * @param id defines the id to look for
  39763. * @returns the camera or null if not found
  39764. */
  39765. getCameraByID(id: string): Nullable<Camera>;
  39766. /**
  39767. * Gets a camera using its unique id
  39768. * @param uniqueId defines the unique id to look for
  39769. * @returns the camera or null if not found
  39770. */
  39771. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39772. /**
  39773. * Gets a camera using its name
  39774. * @param name defines the camera's name
  39775. * @return the camera or null if none found.
  39776. */
  39777. getCameraByName(name: string): Nullable<Camera>;
  39778. /**
  39779. * Gets a bone using its id
  39780. * @param id defines the bone's id
  39781. * @return the bone or null if not found
  39782. */
  39783. getBoneByID(id: string): Nullable<Bone>;
  39784. /**
  39785. * Gets a bone using its id
  39786. * @param name defines the bone's name
  39787. * @return the bone or null if not found
  39788. */
  39789. getBoneByName(name: string): Nullable<Bone>;
  39790. /**
  39791. * Gets a light node using its name
  39792. * @param name defines the the light's name
  39793. * @return the light or null if none found.
  39794. */
  39795. getLightByName(name: string): Nullable<Light>;
  39796. /**
  39797. * Gets a light node using its id
  39798. * @param id defines the light's id
  39799. * @return the light or null if none found.
  39800. */
  39801. getLightByID(id: string): Nullable<Light>;
  39802. /**
  39803. * Gets a light node using its scene-generated unique ID
  39804. * @param uniqueId defines the light's unique id
  39805. * @return the light or null if none found.
  39806. */
  39807. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39808. /**
  39809. * Gets a particle system by id
  39810. * @param id defines the particle system id
  39811. * @return the corresponding system or null if none found
  39812. */
  39813. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39814. /**
  39815. * Gets a geometry using its ID
  39816. * @param id defines the geometry's id
  39817. * @return the geometry or null if none found.
  39818. */
  39819. getGeometryByID(id: string): Nullable<Geometry>;
  39820. private _getGeometryByUniqueID;
  39821. /**
  39822. * Add a new geometry to this scene
  39823. * @param geometry defines the geometry to be added to the scene.
  39824. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39825. * @return a boolean defining if the geometry was added or not
  39826. */
  39827. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39828. /**
  39829. * Removes an existing geometry
  39830. * @param geometry defines the geometry to be removed from the scene
  39831. * @return a boolean defining if the geometry was removed or not
  39832. */
  39833. removeGeometry(geometry: Geometry): boolean;
  39834. /**
  39835. * Gets the list of geometries attached to the scene
  39836. * @returns an array of Geometry
  39837. */
  39838. getGeometries(): Geometry[];
  39839. /**
  39840. * Gets the first added mesh found of a given ID
  39841. * @param id defines the id to search for
  39842. * @return the mesh found or null if not found at all
  39843. */
  39844. getMeshByID(id: string): Nullable<AbstractMesh>;
  39845. /**
  39846. * Gets a list of meshes using their id
  39847. * @param id defines the id to search for
  39848. * @returns a list of meshes
  39849. */
  39850. getMeshesByID(id: string): Array<AbstractMesh>;
  39851. /**
  39852. * Gets the first added transform node found of a given ID
  39853. * @param id defines the id to search for
  39854. * @return the found transform node or null if not found at all.
  39855. */
  39856. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39857. /**
  39858. * Gets a transform node with its auto-generated unique id
  39859. * @param uniqueId efines the unique id to search for
  39860. * @return the found transform node or null if not found at all.
  39861. */
  39862. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39863. /**
  39864. * Gets a list of transform nodes using their id
  39865. * @param id defines the id to search for
  39866. * @returns a list of transform nodes
  39867. */
  39868. getTransformNodesByID(id: string): Array<TransformNode>;
  39869. /**
  39870. * Gets a mesh with its auto-generated unique id
  39871. * @param uniqueId defines the unique id to search for
  39872. * @return the found mesh or null if not found at all.
  39873. */
  39874. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39875. /**
  39876. * Gets a the last added mesh using a given id
  39877. * @param id defines the id to search for
  39878. * @return the found mesh or null if not found at all.
  39879. */
  39880. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39881. /**
  39882. * Gets a the last added 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. getLastEntryByID(id: string): Nullable<Node>;
  39887. /**
  39888. * Gets a node (Mesh, Camera, Light) using a given id
  39889. * @param id defines the id to search for
  39890. * @return the found node or null if not found at all
  39891. */
  39892. getNodeByID(id: string): Nullable<Node>;
  39893. /**
  39894. * Gets a node (Mesh, Camera, Light) using a given name
  39895. * @param name defines the name to search for
  39896. * @return the found node or null if not found at all.
  39897. */
  39898. getNodeByName(name: string): Nullable<Node>;
  39899. /**
  39900. * Gets a mesh using a given name
  39901. * @param name defines the name to search for
  39902. * @return the found mesh or null if not found at all.
  39903. */
  39904. getMeshByName(name: string): Nullable<AbstractMesh>;
  39905. /**
  39906. * Gets a transform node using a given name
  39907. * @param name defines the name to search for
  39908. * @return the found transform node or null if not found at all.
  39909. */
  39910. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39911. /**
  39912. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39913. * @param id defines the id to search for
  39914. * @return the found skeleton or null if not found at all.
  39915. */
  39916. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39917. /**
  39918. * Gets a skeleton using a given auto generated unique id
  39919. * @param uniqueId defines the unique id to search for
  39920. * @return the found skeleton or null if not found at all.
  39921. */
  39922. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39923. /**
  39924. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39925. * @param id defines the id to search for
  39926. * @return the found skeleton or null if not found at all.
  39927. */
  39928. getSkeletonById(id: string): Nullable<Skeleton>;
  39929. /**
  39930. * Gets a skeleton using a given name
  39931. * @param name defines the name to search for
  39932. * @return the found skeleton or null if not found at all.
  39933. */
  39934. getSkeletonByName(name: string): Nullable<Skeleton>;
  39935. /**
  39936. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39937. * @param id defines the id to search for
  39938. * @return the found morph target manager or null if not found at all.
  39939. */
  39940. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39941. /**
  39942. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39943. * @param id defines the id to search for
  39944. * @return the found morph target or null if not found at all.
  39945. */
  39946. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39947. /**
  39948. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39949. * @param name defines the name to search for
  39950. * @return the found morph target or null if not found at all.
  39951. */
  39952. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39953. /**
  39954. * Gets a boolean indicating if the given mesh is active
  39955. * @param mesh defines the mesh to look for
  39956. * @returns true if the mesh is in the active list
  39957. */
  39958. isActiveMesh(mesh: AbstractMesh): boolean;
  39959. /**
  39960. * Return a unique id as a string which can serve as an identifier for the scene
  39961. */
  39962. get uid(): string;
  39963. /**
  39964. * Add an externaly attached data from its key.
  39965. * This method call will fail and return false, if such key already exists.
  39966. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  39967. * @param key the unique key that identifies the data
  39968. * @param data the data object to associate to the key for this Engine instance
  39969. * @return true if no such key were already present and the data was added successfully, false otherwise
  39970. */
  39971. addExternalData<T>(key: string, data: T): boolean;
  39972. /**
  39973. * Get an externaly attached data from its key
  39974. * @param key the unique key that identifies the data
  39975. * @return the associated data, if present (can be null), or undefined if not present
  39976. */
  39977. getExternalData<T>(key: string): Nullable<T>;
  39978. /**
  39979. * Get an externaly attached data from its key, create it using a factory if it's not already present
  39980. * @param key the unique key that identifies the data
  39981. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  39982. * @return the associated data, can be null if the factory returned null.
  39983. */
  39984. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  39985. /**
  39986. * Remove an externaly attached data from the Engine instance
  39987. * @param key the unique key that identifies the data
  39988. * @return true if the data was successfully removed, false if it doesn't exist
  39989. */
  39990. removeExternalData(key: string): boolean;
  39991. private _evaluateSubMesh;
  39992. /**
  39993. * Clear the processed materials smart array preventing retention point in material dispose.
  39994. */
  39995. freeProcessedMaterials(): void;
  39996. private _preventFreeActiveMeshesAndRenderingGroups;
  39997. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  39998. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  39999. * when disposing several meshes in a row or a hierarchy of meshes.
  40000. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40001. */
  40002. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40003. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40004. /**
  40005. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40006. */
  40007. freeActiveMeshes(): void;
  40008. /**
  40009. * Clear the info related to rendering groups preventing retention points during dispose.
  40010. */
  40011. freeRenderingGroups(): void;
  40012. /** @hidden */
  40013. _isInIntermediateRendering(): boolean;
  40014. /**
  40015. * Lambda returning the list of potentially active meshes.
  40016. */
  40017. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40018. /**
  40019. * Lambda returning the list of potentially active sub meshes.
  40020. */
  40021. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40022. /**
  40023. * Lambda returning the list of potentially intersecting sub meshes.
  40024. */
  40025. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40026. /**
  40027. * Lambda returning the list of potentially colliding sub meshes.
  40028. */
  40029. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40030. private _activeMeshesFrozen;
  40031. private _skipEvaluateActiveMeshesCompletely;
  40032. /**
  40033. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40034. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40035. * @returns the current scene
  40036. */
  40037. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40038. /**
  40039. * Use this function to restart evaluating active meshes on every frame
  40040. * @returns the current scene
  40041. */
  40042. unfreezeActiveMeshes(): Scene;
  40043. private _evaluateActiveMeshes;
  40044. private _activeMesh;
  40045. /**
  40046. * Update the transform matrix to update from the current active camera
  40047. * @param force defines a boolean used to force the update even if cache is up to date
  40048. */
  40049. updateTransformMatrix(force?: boolean): void;
  40050. private _bindFrameBuffer;
  40051. /** @hidden */
  40052. _allowPostProcessClearColor: boolean;
  40053. /** @hidden */
  40054. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40055. private _processSubCameras;
  40056. private _checkIntersections;
  40057. /** @hidden */
  40058. _advancePhysicsEngineStep(step: number): void;
  40059. /**
  40060. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40061. */
  40062. getDeterministicFrameTime: () => number;
  40063. /** @hidden */
  40064. _animate(): void;
  40065. /** Execute all animations (for a frame) */
  40066. animate(): void;
  40067. /**
  40068. * Render the scene
  40069. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40070. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40071. */
  40072. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40073. /**
  40074. * Freeze all materials
  40075. * A frozen material will not be updatable but should be faster to render
  40076. */
  40077. freezeMaterials(): void;
  40078. /**
  40079. * Unfreeze all materials
  40080. * A frozen material will not be updatable but should be faster to render
  40081. */
  40082. unfreezeMaterials(): void;
  40083. /**
  40084. * Releases all held ressources
  40085. */
  40086. dispose(): void;
  40087. /**
  40088. * Gets if the scene is already disposed
  40089. */
  40090. get isDisposed(): boolean;
  40091. /**
  40092. * Call this function to reduce memory footprint of the scene.
  40093. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40094. */
  40095. clearCachedVertexData(): void;
  40096. /**
  40097. * This function will remove the local cached buffer data from texture.
  40098. * It will save memory but will prevent the texture from being rebuilt
  40099. */
  40100. cleanCachedTextureBuffer(): void;
  40101. /**
  40102. * Get the world extend vectors with an optional filter
  40103. *
  40104. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40105. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40106. */
  40107. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40108. min: Vector3;
  40109. max: Vector3;
  40110. };
  40111. /**
  40112. * Creates a ray that can be used to pick in the scene
  40113. * @param x defines the x coordinate of the origin (on-screen)
  40114. * @param y defines the y coordinate of the origin (on-screen)
  40115. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40116. * @param camera defines the camera to use for the picking
  40117. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40118. * @returns a Ray
  40119. */
  40120. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40121. /**
  40122. * Creates a ray that can be used to pick in the scene
  40123. * @param x defines the x coordinate of the origin (on-screen)
  40124. * @param y defines the y coordinate of the origin (on-screen)
  40125. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40126. * @param result defines the ray where to store the picking ray
  40127. * @param camera defines the camera to use for the picking
  40128. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40129. * @returns the current scene
  40130. */
  40131. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40132. /**
  40133. * Creates a ray that can be used to pick in the scene
  40134. * @param x defines the x coordinate of the origin (on-screen)
  40135. * @param y defines the y coordinate of the origin (on-screen)
  40136. * @param camera defines the camera to use for the picking
  40137. * @returns a Ray
  40138. */
  40139. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40140. /**
  40141. * Creates a ray that can be used to pick in the scene
  40142. * @param x defines the x coordinate of the origin (on-screen)
  40143. * @param y defines the y coordinate of the origin (on-screen)
  40144. * @param result defines the ray where to store the picking ray
  40145. * @param camera defines the camera to use for the picking
  40146. * @returns the current scene
  40147. */
  40148. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40149. /** Launch a ray to try to pick a mesh in the scene
  40150. * @param x position on screen
  40151. * @param y position on screen
  40152. * @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
  40153. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40154. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40155. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40156. * @returns a PickingInfo
  40157. */
  40158. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40159. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40160. * @param x position on screen
  40161. * @param y position on screen
  40162. * @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
  40163. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40164. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40165. * @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)
  40166. */
  40167. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40168. /** Use the given ray to pick a mesh in the scene
  40169. * @param ray The ray to use to pick meshes
  40170. * @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
  40171. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40172. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40173. * @returns a PickingInfo
  40174. */
  40175. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40176. /**
  40177. * Launch a ray to try to pick a mesh in the scene
  40178. * @param x X position on screen
  40179. * @param y Y position on screen
  40180. * @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
  40181. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40182. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40183. * @returns an array of PickingInfo
  40184. */
  40185. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40186. /**
  40187. * Launch a ray to try to pick a mesh in the scene
  40188. * @param ray Ray to use
  40189. * @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
  40190. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40191. * @returns an array of PickingInfo
  40192. */
  40193. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40194. /**
  40195. * Force the value of meshUnderPointer
  40196. * @param mesh defines the mesh to use
  40197. */
  40198. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40199. /**
  40200. * Gets the mesh under the pointer
  40201. * @returns a Mesh or null if no mesh is under the pointer
  40202. */
  40203. getPointerOverMesh(): Nullable<AbstractMesh>;
  40204. /** @hidden */
  40205. _rebuildGeometries(): void;
  40206. /** @hidden */
  40207. _rebuildTextures(): void;
  40208. private _getByTags;
  40209. /**
  40210. * Get a list of meshes by tags
  40211. * @param tagsQuery defines the tags query to use
  40212. * @param forEach defines a predicate used to filter results
  40213. * @returns an array of Mesh
  40214. */
  40215. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40216. /**
  40217. * Get a list of cameras by tags
  40218. * @param tagsQuery defines the tags query to use
  40219. * @param forEach defines a predicate used to filter results
  40220. * @returns an array of Camera
  40221. */
  40222. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40223. /**
  40224. * Get a list of lights by tags
  40225. * @param tagsQuery defines the tags query to use
  40226. * @param forEach defines a predicate used to filter results
  40227. * @returns an array of Light
  40228. */
  40229. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40230. /**
  40231. * Get a list of materials by tags
  40232. * @param tagsQuery defines the tags query to use
  40233. * @param forEach defines a predicate used to filter results
  40234. * @returns an array of Material
  40235. */
  40236. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40237. /**
  40238. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40239. * This allowed control for front to back rendering or reversly depending of the special needs.
  40240. *
  40241. * @param renderingGroupId The rendering group id corresponding to its index
  40242. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40243. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40244. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40245. */
  40246. 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;
  40247. /**
  40248. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40249. *
  40250. * @param renderingGroupId The rendering group id corresponding to its index
  40251. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40252. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40253. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40254. */
  40255. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40256. /**
  40257. * Gets the current auto clear configuration for one rendering group of the rendering
  40258. * manager.
  40259. * @param index the rendering group index to get the information for
  40260. * @returns The auto clear setup for the requested rendering group
  40261. */
  40262. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40263. private _blockMaterialDirtyMechanism;
  40264. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40265. get blockMaterialDirtyMechanism(): boolean;
  40266. set blockMaterialDirtyMechanism(value: boolean);
  40267. /**
  40268. * Will flag all materials as dirty to trigger new shader compilation
  40269. * @param flag defines the flag used to specify which material part must be marked as dirty
  40270. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40271. */
  40272. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40273. /** @hidden */
  40274. _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;
  40275. /** @hidden */
  40276. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40277. /** @hidden */
  40278. _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;
  40279. /** @hidden */
  40280. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40281. /** @hidden */
  40282. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40283. /** @hidden */
  40284. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40285. }
  40286. }
  40287. declare module BABYLON {
  40288. /**
  40289. * Set of assets to keep when moving a scene into an asset container.
  40290. */
  40291. export class KeepAssets extends AbstractScene {
  40292. }
  40293. /**
  40294. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40295. */
  40296. export class InstantiatedEntries {
  40297. /**
  40298. * List of new root nodes (eg. nodes with no parent)
  40299. */
  40300. rootNodes: TransformNode[];
  40301. /**
  40302. * List of new skeletons
  40303. */
  40304. skeletons: Skeleton[];
  40305. /**
  40306. * List of new animation groups
  40307. */
  40308. animationGroups: AnimationGroup[];
  40309. }
  40310. /**
  40311. * Container with a set of assets that can be added or removed from a scene.
  40312. */
  40313. export class AssetContainer extends AbstractScene {
  40314. private _wasAddedToScene;
  40315. /**
  40316. * The scene the AssetContainer belongs to.
  40317. */
  40318. scene: Scene;
  40319. /**
  40320. * Instantiates an AssetContainer.
  40321. * @param scene The scene the AssetContainer belongs to.
  40322. */
  40323. constructor(scene: Scene);
  40324. /**
  40325. * Instantiate or clone all meshes and add the new ones to the scene.
  40326. * Skeletons and animation groups will all be cloned
  40327. * @param nameFunction defines an optional function used to get new names for clones
  40328. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40329. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40330. */
  40331. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40332. /**
  40333. * Adds all the assets from the container to the scene.
  40334. */
  40335. addAllToScene(): void;
  40336. /**
  40337. * Removes all the assets in the container from the scene
  40338. */
  40339. removeAllFromScene(): void;
  40340. /**
  40341. * Disposes all the assets in the container
  40342. */
  40343. dispose(): void;
  40344. private _moveAssets;
  40345. /**
  40346. * Removes all the assets contained in the scene and adds them to the container.
  40347. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40348. */
  40349. moveAllFromScene(keepAssets?: KeepAssets): void;
  40350. /**
  40351. * 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.
  40352. * @returns the root mesh
  40353. */
  40354. createRootMesh(): Mesh;
  40355. /**
  40356. * Merge animations (direct and animation groups) from this asset container into a scene
  40357. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40358. * @param animatables set of animatables to retarget to a node from the scene
  40359. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40360. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40361. */
  40362. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40363. }
  40364. }
  40365. declare module BABYLON {
  40366. /**
  40367. * Defines how the parser contract is defined.
  40368. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40369. */
  40370. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40371. /**
  40372. * Defines how the individual parser contract is defined.
  40373. * These parser can parse an individual asset
  40374. */
  40375. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40376. /**
  40377. * Base class of the scene acting as a container for the different elements composing a scene.
  40378. * This class is dynamically extended by the different components of the scene increasing
  40379. * flexibility and reducing coupling
  40380. */
  40381. export abstract class AbstractScene {
  40382. /**
  40383. * Stores the list of available parsers in the application.
  40384. */
  40385. private static _BabylonFileParsers;
  40386. /**
  40387. * Stores the list of available individual parsers in the application.
  40388. */
  40389. private static _IndividualBabylonFileParsers;
  40390. /**
  40391. * Adds a parser in the list of available ones
  40392. * @param name Defines the name of the parser
  40393. * @param parser Defines the parser to add
  40394. */
  40395. static AddParser(name: string, parser: BabylonFileParser): void;
  40396. /**
  40397. * Gets a general parser from the list of avaialble ones
  40398. * @param name Defines the name of the parser
  40399. * @returns the requested parser or null
  40400. */
  40401. static GetParser(name: string): Nullable<BabylonFileParser>;
  40402. /**
  40403. * Adds n individual parser in the list of available ones
  40404. * @param name Defines the name of the parser
  40405. * @param parser Defines the parser to add
  40406. */
  40407. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40408. /**
  40409. * Gets an individual parser from the list of avaialble ones
  40410. * @param name Defines the name of the parser
  40411. * @returns the requested parser or null
  40412. */
  40413. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40414. /**
  40415. * Parser json data and populate both a scene and its associated container object
  40416. * @param jsonData Defines the data to parse
  40417. * @param scene Defines the scene to parse the data for
  40418. * @param container Defines the container attached to the parsing sequence
  40419. * @param rootUrl Defines the root url of the data
  40420. */
  40421. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40422. /**
  40423. * Gets the list of root nodes (ie. nodes with no parent)
  40424. */
  40425. rootNodes: Node[];
  40426. /** All of the cameras added to this scene
  40427. * @see http://doc.babylonjs.com/babylon101/cameras
  40428. */
  40429. cameras: Camera[];
  40430. /**
  40431. * All of the lights added to this scene
  40432. * @see http://doc.babylonjs.com/babylon101/lights
  40433. */
  40434. lights: Light[];
  40435. /**
  40436. * All of the (abstract) meshes added to this scene
  40437. */
  40438. meshes: AbstractMesh[];
  40439. /**
  40440. * The list of skeletons added to the scene
  40441. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40442. */
  40443. skeletons: Skeleton[];
  40444. /**
  40445. * All of the particle systems added to this scene
  40446. * @see http://doc.babylonjs.com/babylon101/particles
  40447. */
  40448. particleSystems: IParticleSystem[];
  40449. /**
  40450. * Gets a list of Animations associated with the scene
  40451. */
  40452. animations: Animation[];
  40453. /**
  40454. * All of the animation groups added to this scene
  40455. * @see http://doc.babylonjs.com/how_to/group
  40456. */
  40457. animationGroups: AnimationGroup[];
  40458. /**
  40459. * All of the multi-materials added to this scene
  40460. * @see http://doc.babylonjs.com/how_to/multi_materials
  40461. */
  40462. multiMaterials: MultiMaterial[];
  40463. /**
  40464. * All of the materials added to this scene
  40465. * In the context of a Scene, it is not supposed to be modified manually.
  40466. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40467. * Note also that the order of the Material within the array is not significant and might change.
  40468. * @see http://doc.babylonjs.com/babylon101/materials
  40469. */
  40470. materials: Material[];
  40471. /**
  40472. * The list of morph target managers added to the scene
  40473. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40474. */
  40475. morphTargetManagers: MorphTargetManager[];
  40476. /**
  40477. * The list of geometries used in the scene.
  40478. */
  40479. geometries: Geometry[];
  40480. /**
  40481. * All of the tranform nodes added to this scene
  40482. * In the context of a Scene, it is not supposed to be modified manually.
  40483. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40484. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40485. * @see http://doc.babylonjs.com/how_to/transformnode
  40486. */
  40487. transformNodes: TransformNode[];
  40488. /**
  40489. * ActionManagers available on the scene.
  40490. */
  40491. actionManagers: AbstractActionManager[];
  40492. /**
  40493. * Textures to keep.
  40494. */
  40495. textures: BaseTexture[];
  40496. /**
  40497. * Environment texture for the scene
  40498. */
  40499. environmentTexture: Nullable<BaseTexture>;
  40500. /**
  40501. * @returns all meshes, lights, cameras, transformNodes and bones
  40502. */
  40503. getNodes(): Array<Node>;
  40504. }
  40505. }
  40506. declare module BABYLON {
  40507. /**
  40508. * Interface used to define options for Sound class
  40509. */
  40510. export interface ISoundOptions {
  40511. /**
  40512. * Does the sound autoplay once loaded.
  40513. */
  40514. autoplay?: boolean;
  40515. /**
  40516. * Does the sound loop after it finishes playing once.
  40517. */
  40518. loop?: boolean;
  40519. /**
  40520. * Sound's volume
  40521. */
  40522. volume?: number;
  40523. /**
  40524. * Is it a spatial sound?
  40525. */
  40526. spatialSound?: boolean;
  40527. /**
  40528. * Maximum distance to hear that sound
  40529. */
  40530. maxDistance?: number;
  40531. /**
  40532. * Uses user defined attenuation function
  40533. */
  40534. useCustomAttenuation?: boolean;
  40535. /**
  40536. * Define the roll off factor of spatial sounds.
  40537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40538. */
  40539. rolloffFactor?: number;
  40540. /**
  40541. * Define the reference distance the sound should be heard perfectly.
  40542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40543. */
  40544. refDistance?: number;
  40545. /**
  40546. * Define the distance attenuation model the sound will follow.
  40547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40548. */
  40549. distanceModel?: string;
  40550. /**
  40551. * Defines the playback speed (1 by default)
  40552. */
  40553. playbackRate?: number;
  40554. /**
  40555. * Defines if the sound is from a streaming source
  40556. */
  40557. streaming?: boolean;
  40558. /**
  40559. * Defines an optional length (in seconds) inside the sound file
  40560. */
  40561. length?: number;
  40562. /**
  40563. * Defines an optional offset (in seconds) inside the sound file
  40564. */
  40565. offset?: number;
  40566. /**
  40567. * If true, URLs will not be required to state the audio file codec to use.
  40568. */
  40569. skipCodecCheck?: boolean;
  40570. }
  40571. /**
  40572. * Defines a sound that can be played in the application.
  40573. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  40575. */
  40576. export class Sound {
  40577. /**
  40578. * The name of the sound in the scene.
  40579. */
  40580. name: string;
  40581. /**
  40582. * Does the sound autoplay once loaded.
  40583. */
  40584. autoplay: boolean;
  40585. /**
  40586. * Does the sound loop after it finishes playing once.
  40587. */
  40588. loop: boolean;
  40589. /**
  40590. * Does the sound use a custom attenuation curve to simulate the falloff
  40591. * happening when the source gets further away from the camera.
  40592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40593. */
  40594. useCustomAttenuation: boolean;
  40595. /**
  40596. * The sound track id this sound belongs to.
  40597. */
  40598. soundTrackId: number;
  40599. /**
  40600. * Is this sound currently played.
  40601. */
  40602. isPlaying: boolean;
  40603. /**
  40604. * Is this sound currently paused.
  40605. */
  40606. isPaused: boolean;
  40607. /**
  40608. * Does this sound enables spatial sound.
  40609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40610. */
  40611. spatialSound: boolean;
  40612. /**
  40613. * Define the reference distance the sound should be heard perfectly.
  40614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40615. */
  40616. refDistance: number;
  40617. /**
  40618. * Define the roll off factor of spatial sounds.
  40619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40620. */
  40621. rolloffFactor: number;
  40622. /**
  40623. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40625. */
  40626. maxDistance: number;
  40627. /**
  40628. * Define the distance attenuation model the sound will follow.
  40629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40630. */
  40631. distanceModel: string;
  40632. /**
  40633. * @hidden
  40634. * Back Compat
  40635. **/
  40636. onended: () => any;
  40637. /**
  40638. * Gets or sets an object used to store user defined information for the sound.
  40639. */
  40640. metadata: any;
  40641. /**
  40642. * Observable event when the current playing sound finishes.
  40643. */
  40644. onEndedObservable: Observable<Sound>;
  40645. private _panningModel;
  40646. private _playbackRate;
  40647. private _streaming;
  40648. private _startTime;
  40649. private _startOffset;
  40650. private _position;
  40651. /** @hidden */
  40652. _positionInEmitterSpace: boolean;
  40653. private _localDirection;
  40654. private _volume;
  40655. private _isReadyToPlay;
  40656. private _isDirectional;
  40657. private _readyToPlayCallback;
  40658. private _audioBuffer;
  40659. private _soundSource;
  40660. private _streamingSource;
  40661. private _soundPanner;
  40662. private _soundGain;
  40663. private _inputAudioNode;
  40664. private _outputAudioNode;
  40665. private _coneInnerAngle;
  40666. private _coneOuterAngle;
  40667. private _coneOuterGain;
  40668. private _scene;
  40669. private _connectedTransformNode;
  40670. private _customAttenuationFunction;
  40671. private _registerFunc;
  40672. private _isOutputConnected;
  40673. private _htmlAudioElement;
  40674. private _urlType;
  40675. private _length?;
  40676. private _offset?;
  40677. /** @hidden */
  40678. static _SceneComponentInitialization: (scene: Scene) => void;
  40679. /**
  40680. * Create a sound and attach it to a scene
  40681. * @param name Name of your sound
  40682. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40683. * @param scene defines the scene the sound belongs to
  40684. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40685. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40686. */
  40687. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40688. /**
  40689. * Release the sound and its associated resources
  40690. */
  40691. dispose(): void;
  40692. /**
  40693. * Gets if the sounds is ready to be played or not.
  40694. * @returns true if ready, otherwise false
  40695. */
  40696. isReady(): boolean;
  40697. private _soundLoaded;
  40698. /**
  40699. * Sets the data of the sound from an audiobuffer
  40700. * @param audioBuffer The audioBuffer containing the data
  40701. */
  40702. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40703. /**
  40704. * Updates the current sounds options such as maxdistance, loop...
  40705. * @param options A JSON object containing values named as the object properties
  40706. */
  40707. updateOptions(options: ISoundOptions): void;
  40708. private _createSpatialParameters;
  40709. private _updateSpatialParameters;
  40710. /**
  40711. * Switch the panning model to HRTF:
  40712. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40714. */
  40715. switchPanningModelToHRTF(): void;
  40716. /**
  40717. * Switch the panning model to Equal Power:
  40718. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40720. */
  40721. switchPanningModelToEqualPower(): void;
  40722. private _switchPanningModel;
  40723. /**
  40724. * Connect this sound to a sound track audio node like gain...
  40725. * @param soundTrackAudioNode the sound track audio node to connect to
  40726. */
  40727. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40728. /**
  40729. * Transform this sound into a directional source
  40730. * @param coneInnerAngle Size of the inner cone in degree
  40731. * @param coneOuterAngle Size of the outer cone in degree
  40732. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40733. */
  40734. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40735. /**
  40736. * Gets or sets the inner angle for the directional cone.
  40737. */
  40738. get directionalConeInnerAngle(): number;
  40739. /**
  40740. * Gets or sets the inner angle for the directional cone.
  40741. */
  40742. set directionalConeInnerAngle(value: number);
  40743. /**
  40744. * Gets or sets the outer angle for the directional cone.
  40745. */
  40746. get directionalConeOuterAngle(): number;
  40747. /**
  40748. * Gets or sets the outer angle for the directional cone.
  40749. */
  40750. set directionalConeOuterAngle(value: number);
  40751. /**
  40752. * Sets the position of the emitter if spatial sound is enabled
  40753. * @param newPosition Defines the new posisiton
  40754. */
  40755. setPosition(newPosition: Vector3): void;
  40756. /**
  40757. * Sets the local direction of the emitter if spatial sound is enabled
  40758. * @param newLocalDirection Defines the new local direction
  40759. */
  40760. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40761. private _updateDirection;
  40762. /** @hidden */
  40763. updateDistanceFromListener(): void;
  40764. /**
  40765. * Sets a new custom attenuation function for the sound.
  40766. * @param callback Defines the function used for the attenuation
  40767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40768. */
  40769. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40770. /**
  40771. * Play the sound
  40772. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40773. * @param offset (optional) Start the sound at a specific time in seconds
  40774. * @param length (optional) Sound duration (in seconds)
  40775. */
  40776. play(time?: number, offset?: number, length?: number): void;
  40777. private _onended;
  40778. /**
  40779. * Stop the sound
  40780. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40781. */
  40782. stop(time?: number): void;
  40783. /**
  40784. * Put the sound in pause
  40785. */
  40786. pause(): void;
  40787. /**
  40788. * Sets a dedicated volume for this sounds
  40789. * @param newVolume Define the new volume of the sound
  40790. * @param time Define time for gradual change to new volume
  40791. */
  40792. setVolume(newVolume: number, time?: number): void;
  40793. /**
  40794. * Set the sound play back rate
  40795. * @param newPlaybackRate Define the playback rate the sound should be played at
  40796. */
  40797. setPlaybackRate(newPlaybackRate: number): void;
  40798. /**
  40799. * Gets the volume of the sound.
  40800. * @returns the volume of the sound
  40801. */
  40802. getVolume(): number;
  40803. /**
  40804. * Attach the sound to a dedicated mesh
  40805. * @param transformNode The transform node to connect the sound with
  40806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40807. */
  40808. attachToMesh(transformNode: TransformNode): void;
  40809. /**
  40810. * Detach the sound from the previously attached mesh
  40811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40812. */
  40813. detachFromMesh(): void;
  40814. private _onRegisterAfterWorldMatrixUpdate;
  40815. /**
  40816. * Clone the current sound in the scene.
  40817. * @returns the new sound clone
  40818. */
  40819. clone(): Nullable<Sound>;
  40820. /**
  40821. * Gets the current underlying audio buffer containing the data
  40822. * @returns the audio buffer
  40823. */
  40824. getAudioBuffer(): Nullable<AudioBuffer>;
  40825. /**
  40826. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40827. * @returns the source node
  40828. */
  40829. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40830. /**
  40831. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40832. * @returns the gain node
  40833. */
  40834. getSoundGain(): Nullable<GainNode>;
  40835. /**
  40836. * Serializes the Sound in a JSON representation
  40837. * @returns the JSON representation of the sound
  40838. */
  40839. serialize(): any;
  40840. /**
  40841. * Parse a JSON representation of a sound to innstantiate in a given scene
  40842. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40843. * @param scene Define the scene the new parsed sound should be created in
  40844. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40845. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40846. * @returns the newly parsed sound
  40847. */
  40848. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40849. }
  40850. }
  40851. declare module BABYLON {
  40852. /**
  40853. * This defines an action helpful to play a defined sound on a triggered action.
  40854. */
  40855. export class PlaySoundAction extends Action {
  40856. private _sound;
  40857. /**
  40858. * Instantiate the action
  40859. * @param triggerOptions defines the trigger options
  40860. * @param sound defines the sound to play
  40861. * @param condition defines the trigger related conditions
  40862. */
  40863. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40864. /** @hidden */
  40865. _prepare(): void;
  40866. /**
  40867. * Execute the action and play the sound.
  40868. */
  40869. execute(): void;
  40870. /**
  40871. * Serializes the actions and its related information.
  40872. * @param parent defines the object to serialize in
  40873. * @returns the serialized object
  40874. */
  40875. serialize(parent: any): any;
  40876. }
  40877. /**
  40878. * This defines an action helpful to stop a defined sound on a triggered action.
  40879. */
  40880. export class StopSoundAction extends Action {
  40881. private _sound;
  40882. /**
  40883. * Instantiate the action
  40884. * @param triggerOptions defines the trigger options
  40885. * @param sound defines the sound to stop
  40886. * @param condition defines the trigger related conditions
  40887. */
  40888. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40889. /** @hidden */
  40890. _prepare(): void;
  40891. /**
  40892. * Execute the action and stop the sound.
  40893. */
  40894. execute(): void;
  40895. /**
  40896. * Serializes the actions and its related information.
  40897. * @param parent defines the object to serialize in
  40898. * @returns the serialized object
  40899. */
  40900. serialize(parent: any): any;
  40901. }
  40902. }
  40903. declare module BABYLON {
  40904. /**
  40905. * This defines an action responsible to change the value of a property
  40906. * by interpolating between its current value and the newly set one once triggered.
  40907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  40908. */
  40909. export class InterpolateValueAction extends Action {
  40910. /**
  40911. * Defines the path of the property where the value should be interpolated
  40912. */
  40913. propertyPath: string;
  40914. /**
  40915. * Defines the target value at the end of the interpolation.
  40916. */
  40917. value: any;
  40918. /**
  40919. * Defines the time it will take for the property to interpolate to the value.
  40920. */
  40921. duration: number;
  40922. /**
  40923. * Defines if the other scene animations should be stopped when the action has been triggered
  40924. */
  40925. stopOtherAnimations?: boolean;
  40926. /**
  40927. * Defines a callback raised once the interpolation animation has been done.
  40928. */
  40929. onInterpolationDone?: () => void;
  40930. /**
  40931. * Observable triggered once the interpolation animation has been done.
  40932. */
  40933. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40934. private _target;
  40935. private _effectiveTarget;
  40936. private _property;
  40937. /**
  40938. * Instantiate the action
  40939. * @param triggerOptions defines the trigger options
  40940. * @param target defines the object containing the value to interpolate
  40941. * @param propertyPath defines the path to the property in the target object
  40942. * @param value defines the target value at the end of the interpolation
  40943. * @param duration deines the time it will take for the property to interpolate to the value.
  40944. * @param condition defines the trigger related conditions
  40945. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40946. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40947. */
  40948. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40949. /** @hidden */
  40950. _prepare(): void;
  40951. /**
  40952. * Execute the action starts the value interpolation.
  40953. */
  40954. execute(): void;
  40955. /**
  40956. * Serializes the actions and its related information.
  40957. * @param parent defines the object to serialize in
  40958. * @returns the serialized object
  40959. */
  40960. serialize(parent: any): any;
  40961. }
  40962. }
  40963. declare module BABYLON {
  40964. /**
  40965. * Options allowed during the creation of a sound track.
  40966. */
  40967. export interface ISoundTrackOptions {
  40968. /**
  40969. * The volume the sound track should take during creation
  40970. */
  40971. volume?: number;
  40972. /**
  40973. * Define if the sound track is the main sound track of the scene
  40974. */
  40975. mainTrack?: boolean;
  40976. }
  40977. /**
  40978. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  40979. * It will be also used in a future release to apply effects on a specific track.
  40980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40981. */
  40982. export class SoundTrack {
  40983. /**
  40984. * The unique identifier of the sound track in the scene.
  40985. */
  40986. id: number;
  40987. /**
  40988. * The list of sounds included in the sound track.
  40989. */
  40990. soundCollection: Array<Sound>;
  40991. private _outputAudioNode;
  40992. private _scene;
  40993. private _connectedAnalyser;
  40994. private _options;
  40995. private _isInitialized;
  40996. /**
  40997. * Creates a new sound track.
  40998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  40999. * @param scene Define the scene the sound track belongs to
  41000. * @param options
  41001. */
  41002. constructor(scene: Scene, options?: ISoundTrackOptions);
  41003. private _initializeSoundTrackAudioGraph;
  41004. /**
  41005. * Release the sound track and its associated resources
  41006. */
  41007. dispose(): void;
  41008. /**
  41009. * Adds a sound to this sound track
  41010. * @param sound define the cound to add
  41011. * @ignoreNaming
  41012. */
  41013. AddSound(sound: Sound): void;
  41014. /**
  41015. * Removes a sound to this sound track
  41016. * @param sound define the cound to remove
  41017. * @ignoreNaming
  41018. */
  41019. RemoveSound(sound: Sound): void;
  41020. /**
  41021. * Set a global volume for the full sound track.
  41022. * @param newVolume Define the new volume of the sound track
  41023. */
  41024. setVolume(newVolume: number): void;
  41025. /**
  41026. * Switch the panning model to HRTF:
  41027. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41029. */
  41030. switchPanningModelToHRTF(): void;
  41031. /**
  41032. * Switch the panning model to Equal Power:
  41033. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41035. */
  41036. switchPanningModelToEqualPower(): void;
  41037. /**
  41038. * Connect the sound track to an audio analyser allowing some amazing
  41039. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41041. * @param analyser The analyser to connect to the engine
  41042. */
  41043. connectToAnalyser(analyser: Analyser): void;
  41044. }
  41045. }
  41046. declare module BABYLON {
  41047. interface AbstractScene {
  41048. /**
  41049. * The list of sounds used in the scene.
  41050. */
  41051. sounds: Nullable<Array<Sound>>;
  41052. }
  41053. interface Scene {
  41054. /**
  41055. * @hidden
  41056. * Backing field
  41057. */
  41058. _mainSoundTrack: SoundTrack;
  41059. /**
  41060. * The main sound track played by the scene.
  41061. * It cotains your primary collection of sounds.
  41062. */
  41063. mainSoundTrack: SoundTrack;
  41064. /**
  41065. * The list of sound tracks added to the scene
  41066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41067. */
  41068. soundTracks: Nullable<Array<SoundTrack>>;
  41069. /**
  41070. * Gets a sound using a given name
  41071. * @param name defines the name to search for
  41072. * @return the found sound or null if not found at all.
  41073. */
  41074. getSoundByName(name: string): Nullable<Sound>;
  41075. /**
  41076. * Gets or sets if audio support is enabled
  41077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41078. */
  41079. audioEnabled: boolean;
  41080. /**
  41081. * Gets or sets if audio will be output to headphones
  41082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41083. */
  41084. headphone: boolean;
  41085. /**
  41086. * Gets or sets custom audio listener position provider
  41087. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  41088. */
  41089. audioListenerPositionProvider: Nullable<() => Vector3>;
  41090. /**
  41091. * Gets or sets a refresh rate when using 3D audio positioning
  41092. */
  41093. audioPositioningRefreshRate: number;
  41094. }
  41095. /**
  41096. * Defines the sound scene component responsible to manage any sounds
  41097. * in a given scene.
  41098. */
  41099. export class AudioSceneComponent implements ISceneSerializableComponent {
  41100. /**
  41101. * The component name helpfull to identify the component in the list of scene components.
  41102. */
  41103. readonly name: string;
  41104. /**
  41105. * The scene the component belongs to.
  41106. */
  41107. scene: Scene;
  41108. private _audioEnabled;
  41109. /**
  41110. * Gets whether audio is enabled or not.
  41111. * Please use related enable/disable method to switch state.
  41112. */
  41113. get audioEnabled(): boolean;
  41114. private _headphone;
  41115. /**
  41116. * Gets whether audio is outputing to headphone or not.
  41117. * Please use the according Switch methods to change output.
  41118. */
  41119. get headphone(): boolean;
  41120. /**
  41121. * Gets or sets a refresh rate when using 3D audio positioning
  41122. */
  41123. audioPositioningRefreshRate: number;
  41124. private _audioListenerPositionProvider;
  41125. /**
  41126. * Gets the current audio listener position provider
  41127. */
  41128. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41129. /**
  41130. * Sets a custom listener position for all sounds in the scene
  41131. * By default, this is the position of the first active camera
  41132. */
  41133. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41134. /**
  41135. * Creates a new instance of the component for the given scene
  41136. * @param scene Defines the scene to register the component in
  41137. */
  41138. constructor(scene: Scene);
  41139. /**
  41140. * Registers the component in a given scene
  41141. */
  41142. register(): void;
  41143. /**
  41144. * Rebuilds the elements related to this component in case of
  41145. * context lost for instance.
  41146. */
  41147. rebuild(): void;
  41148. /**
  41149. * Serializes the component data to the specified json object
  41150. * @param serializationObject The object to serialize to
  41151. */
  41152. serialize(serializationObject: any): void;
  41153. /**
  41154. * Adds all the elements from the container to the scene
  41155. * @param container the container holding the elements
  41156. */
  41157. addFromContainer(container: AbstractScene): void;
  41158. /**
  41159. * Removes all the elements in the container from the scene
  41160. * @param container contains the elements to remove
  41161. * @param dispose if the removed element should be disposed (default: false)
  41162. */
  41163. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41164. /**
  41165. * Disposes the component and the associated ressources.
  41166. */
  41167. dispose(): void;
  41168. /**
  41169. * Disables audio in the associated scene.
  41170. */
  41171. disableAudio(): void;
  41172. /**
  41173. * Enables audio in the associated scene.
  41174. */
  41175. enableAudio(): void;
  41176. /**
  41177. * Switch audio to headphone output.
  41178. */
  41179. switchAudioModeForHeadphones(): void;
  41180. /**
  41181. * Switch audio to normal speakers.
  41182. */
  41183. switchAudioModeForNormalSpeakers(): void;
  41184. private _cachedCameraDirection;
  41185. private _cachedCameraPosition;
  41186. private _lastCheck;
  41187. private _afterRender;
  41188. }
  41189. }
  41190. declare module BABYLON {
  41191. /**
  41192. * Wraps one or more Sound objects and selects one with random weight for playback.
  41193. */
  41194. export class WeightedSound {
  41195. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41196. loop: boolean;
  41197. private _coneInnerAngle;
  41198. private _coneOuterAngle;
  41199. private _volume;
  41200. /** A Sound is currently playing. */
  41201. isPlaying: boolean;
  41202. /** A Sound is currently paused. */
  41203. isPaused: boolean;
  41204. private _sounds;
  41205. private _weights;
  41206. private _currentIndex?;
  41207. /**
  41208. * Creates a new WeightedSound from the list of sounds given.
  41209. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41210. * @param sounds Array of Sounds that will be selected from.
  41211. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41212. */
  41213. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41214. /**
  41215. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41216. */
  41217. get directionalConeInnerAngle(): number;
  41218. /**
  41219. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41220. */
  41221. set directionalConeInnerAngle(value: number);
  41222. /**
  41223. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41224. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41225. */
  41226. get directionalConeOuterAngle(): number;
  41227. /**
  41228. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41229. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41230. */
  41231. set directionalConeOuterAngle(value: number);
  41232. /**
  41233. * Playback volume.
  41234. */
  41235. get volume(): number;
  41236. /**
  41237. * Playback volume.
  41238. */
  41239. set volume(value: number);
  41240. private _onended;
  41241. /**
  41242. * Suspend playback
  41243. */
  41244. pause(): void;
  41245. /**
  41246. * Stop playback
  41247. */
  41248. stop(): void;
  41249. /**
  41250. * Start playback.
  41251. * @param startOffset Position the clip head at a specific time in seconds.
  41252. */
  41253. play(startOffset?: number): void;
  41254. }
  41255. }
  41256. declare module BABYLON {
  41257. /**
  41258. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41259. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41260. */
  41261. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41262. /**
  41263. * Gets the name of the behavior.
  41264. */
  41265. get name(): string;
  41266. /**
  41267. * The easing function used by animations
  41268. */
  41269. static EasingFunction: BackEase;
  41270. /**
  41271. * The easing mode used by animations
  41272. */
  41273. static EasingMode: number;
  41274. /**
  41275. * The duration of the animation, in milliseconds
  41276. */
  41277. transitionDuration: number;
  41278. /**
  41279. * Length of the distance animated by the transition when lower radius is reached
  41280. */
  41281. lowerRadiusTransitionRange: number;
  41282. /**
  41283. * Length of the distance animated by the transition when upper radius is reached
  41284. */
  41285. upperRadiusTransitionRange: number;
  41286. private _autoTransitionRange;
  41287. /**
  41288. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41289. */
  41290. get autoTransitionRange(): boolean;
  41291. /**
  41292. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41293. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41294. */
  41295. set autoTransitionRange(value: boolean);
  41296. private _attachedCamera;
  41297. private _onAfterCheckInputsObserver;
  41298. private _onMeshTargetChangedObserver;
  41299. /**
  41300. * Initializes the behavior.
  41301. */
  41302. init(): void;
  41303. /**
  41304. * Attaches the behavior to its arc rotate camera.
  41305. * @param camera Defines the camera to attach the behavior to
  41306. */
  41307. attach(camera: ArcRotateCamera): void;
  41308. /**
  41309. * Detaches the behavior from its current arc rotate camera.
  41310. */
  41311. detach(): void;
  41312. private _radiusIsAnimating;
  41313. private _radiusBounceTransition;
  41314. private _animatables;
  41315. private _cachedWheelPrecision;
  41316. /**
  41317. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41318. * @param radiusLimit The limit to check against.
  41319. * @return Bool to indicate if at limit.
  41320. */
  41321. private _isRadiusAtLimit;
  41322. /**
  41323. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41324. * @param radiusDelta The delta by which to animate to. Can be negative.
  41325. */
  41326. private _applyBoundRadiusAnimation;
  41327. /**
  41328. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41329. */
  41330. protected _clearAnimationLocks(): void;
  41331. /**
  41332. * Stops and removes all animations that have been applied to the camera
  41333. */
  41334. stopAllAnimations(): void;
  41335. }
  41336. }
  41337. declare module BABYLON {
  41338. /**
  41339. * 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.
  41340. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41341. */
  41342. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41343. /**
  41344. * Gets the name of the behavior.
  41345. */
  41346. get name(): string;
  41347. private _mode;
  41348. private _radiusScale;
  41349. private _positionScale;
  41350. private _defaultElevation;
  41351. private _elevationReturnTime;
  41352. private _elevationReturnWaitTime;
  41353. private _zoomStopsAnimation;
  41354. private _framingTime;
  41355. /**
  41356. * The easing function used by animations
  41357. */
  41358. static EasingFunction: ExponentialEase;
  41359. /**
  41360. * The easing mode used by animations
  41361. */
  41362. static EasingMode: number;
  41363. /**
  41364. * Sets the current mode used by the behavior
  41365. */
  41366. set mode(mode: number);
  41367. /**
  41368. * Gets current mode used by the behavior.
  41369. */
  41370. get mode(): number;
  41371. /**
  41372. * Sets the scale applied to the radius (1 by default)
  41373. */
  41374. set radiusScale(radius: number);
  41375. /**
  41376. * Gets the scale applied to the radius
  41377. */
  41378. get radiusScale(): number;
  41379. /**
  41380. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41381. */
  41382. set positionScale(scale: number);
  41383. /**
  41384. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41385. */
  41386. get positionScale(): number;
  41387. /**
  41388. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41389. * behaviour is triggered, in radians.
  41390. */
  41391. set defaultElevation(elevation: number);
  41392. /**
  41393. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41394. * behaviour is triggered, in radians.
  41395. */
  41396. get defaultElevation(): number;
  41397. /**
  41398. * Sets the time (in milliseconds) taken to return to the default beta position.
  41399. * Negative value indicates camera should not return to default.
  41400. */
  41401. set elevationReturnTime(speed: number);
  41402. /**
  41403. * Gets the time (in milliseconds) taken to return to the default beta position.
  41404. * Negative value indicates camera should not return to default.
  41405. */
  41406. get elevationReturnTime(): number;
  41407. /**
  41408. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41409. */
  41410. set elevationReturnWaitTime(time: number);
  41411. /**
  41412. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41413. */
  41414. get elevationReturnWaitTime(): number;
  41415. /**
  41416. * Sets the flag that indicates if user zooming should stop animation.
  41417. */
  41418. set zoomStopsAnimation(flag: boolean);
  41419. /**
  41420. * Gets the flag that indicates if user zooming should stop animation.
  41421. */
  41422. get zoomStopsAnimation(): boolean;
  41423. /**
  41424. * Sets the transition time when framing the mesh, in milliseconds
  41425. */
  41426. set framingTime(time: number);
  41427. /**
  41428. * Gets the transition time when framing the mesh, in milliseconds
  41429. */
  41430. get framingTime(): number;
  41431. /**
  41432. * Define if the behavior should automatically change the configured
  41433. * camera limits and sensibilities.
  41434. */
  41435. autoCorrectCameraLimitsAndSensibility: boolean;
  41436. private _onPrePointerObservableObserver;
  41437. private _onAfterCheckInputsObserver;
  41438. private _onMeshTargetChangedObserver;
  41439. private _attachedCamera;
  41440. private _isPointerDown;
  41441. private _lastInteractionTime;
  41442. /**
  41443. * Initializes the behavior.
  41444. */
  41445. init(): void;
  41446. /**
  41447. * Attaches the behavior to its arc rotate camera.
  41448. * @param camera Defines the camera to attach the behavior to
  41449. */
  41450. attach(camera: ArcRotateCamera): void;
  41451. /**
  41452. * Detaches the behavior from its current arc rotate camera.
  41453. */
  41454. detach(): void;
  41455. private _animatables;
  41456. private _betaIsAnimating;
  41457. private _betaTransition;
  41458. private _radiusTransition;
  41459. private _vectorTransition;
  41460. /**
  41461. * Targets the given mesh and updates zoom level accordingly.
  41462. * @param mesh The mesh to target.
  41463. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41464. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41465. */
  41466. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41467. /**
  41468. * Targets the given mesh with its children and updates zoom level accordingly.
  41469. * @param mesh The mesh to target.
  41470. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41471. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41472. */
  41473. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41474. /**
  41475. * Targets the given meshes with their children and updates zoom level accordingly.
  41476. * @param meshes The mesh to target.
  41477. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41478. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41479. */
  41480. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41481. /**
  41482. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41483. * @param minimumWorld Determines the smaller position of the bounding box extend
  41484. * @param maximumWorld Determines the bigger position of the bounding box extend
  41485. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41486. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41487. */
  41488. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41489. /**
  41490. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41491. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41492. * frustum width.
  41493. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41494. * to fully enclose the mesh in the viewing frustum.
  41495. */
  41496. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41497. /**
  41498. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41499. * is automatically returned to its default position (expected to be above ground plane).
  41500. */
  41501. private _maintainCameraAboveGround;
  41502. /**
  41503. * Returns the frustum slope based on the canvas ratio and camera FOV
  41504. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41505. */
  41506. private _getFrustumSlope;
  41507. /**
  41508. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41509. */
  41510. private _clearAnimationLocks;
  41511. /**
  41512. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41513. */
  41514. private _applyUserInteraction;
  41515. /**
  41516. * Stops and removes all animations that have been applied to the camera
  41517. */
  41518. stopAllAnimations(): void;
  41519. /**
  41520. * Gets a value indicating if the user is moving the camera
  41521. */
  41522. get isUserIsMoving(): boolean;
  41523. /**
  41524. * The camera can move all the way towards the mesh.
  41525. */
  41526. static IgnoreBoundsSizeMode: number;
  41527. /**
  41528. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41529. */
  41530. static FitFrustumSidesMode: number;
  41531. }
  41532. }
  41533. declare module BABYLON {
  41534. /**
  41535. * Base class for Camera Pointer Inputs.
  41536. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41537. * for example usage.
  41538. */
  41539. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41540. /**
  41541. * Defines the camera the input is attached to.
  41542. */
  41543. abstract camera: Camera;
  41544. /**
  41545. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41546. */
  41547. protected _altKey: boolean;
  41548. protected _ctrlKey: boolean;
  41549. protected _metaKey: boolean;
  41550. protected _shiftKey: boolean;
  41551. /**
  41552. * Which mouse buttons were pressed at time of last mouse event.
  41553. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41554. */
  41555. protected _buttonsPressed: number;
  41556. /**
  41557. * Defines the buttons associated with the input to handle camera move.
  41558. */
  41559. buttons: number[];
  41560. /**
  41561. * Attach the input controls to a specific dom element to get the input from.
  41562. * @param element Defines the element the controls should be listened from
  41563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41564. */
  41565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41566. /**
  41567. * Detach the current controls from the specified dom element.
  41568. * @param element Defines the element to stop listening the inputs from
  41569. */
  41570. detachControl(element: Nullable<HTMLElement>): void;
  41571. /**
  41572. * Gets the class name of the current input.
  41573. * @returns the class name
  41574. */
  41575. getClassName(): string;
  41576. /**
  41577. * Get the friendly name associated with the input class.
  41578. * @returns the input friendly name
  41579. */
  41580. getSimpleName(): string;
  41581. /**
  41582. * Called on pointer POINTERDOUBLETAP event.
  41583. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41584. */
  41585. protected onDoubleTap(type: string): void;
  41586. /**
  41587. * Called on pointer POINTERMOVE event if only a single touch is active.
  41588. * Override this method to provide functionality.
  41589. */
  41590. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41591. /**
  41592. * Called on pointer POINTERMOVE event if multiple touches are active.
  41593. * Override this method to provide functionality.
  41594. */
  41595. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41596. /**
  41597. * Called on JS contextmenu event.
  41598. * Override this method to provide functionality.
  41599. */
  41600. protected onContextMenu(evt: PointerEvent): void;
  41601. /**
  41602. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41603. * press.
  41604. * Override this method to provide functionality.
  41605. */
  41606. protected onButtonDown(evt: PointerEvent): void;
  41607. /**
  41608. * Called each time a new POINTERUP event occurs. Ie, for each button
  41609. * release.
  41610. * Override this method to provide functionality.
  41611. */
  41612. protected onButtonUp(evt: PointerEvent): void;
  41613. /**
  41614. * Called when window becomes inactive.
  41615. * Override this method to provide functionality.
  41616. */
  41617. protected onLostFocus(): void;
  41618. private _pointerInput;
  41619. private _observer;
  41620. private _onLostFocus;
  41621. private pointA;
  41622. private pointB;
  41623. }
  41624. }
  41625. declare module BABYLON {
  41626. /**
  41627. * Manage the pointers inputs to control an arc rotate camera.
  41628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41629. */
  41630. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41631. /**
  41632. * Defines the camera the input is attached to.
  41633. */
  41634. camera: ArcRotateCamera;
  41635. /**
  41636. * Gets the class name of the current input.
  41637. * @returns the class name
  41638. */
  41639. getClassName(): string;
  41640. /**
  41641. * Defines the buttons associated with the input to handle camera move.
  41642. */
  41643. buttons: number[];
  41644. /**
  41645. * Defines the pointer angular sensibility along the X axis or how fast is
  41646. * the camera rotating.
  41647. */
  41648. angularSensibilityX: number;
  41649. /**
  41650. * Defines the pointer angular sensibility along the Y axis or how fast is
  41651. * the camera rotating.
  41652. */
  41653. angularSensibilityY: number;
  41654. /**
  41655. * Defines the pointer pinch precision or how fast is the camera zooming.
  41656. */
  41657. pinchPrecision: number;
  41658. /**
  41659. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41660. * from 0.
  41661. * It defines the percentage of current camera.radius to use as delta when
  41662. * pinch zoom is used.
  41663. */
  41664. pinchDeltaPercentage: number;
  41665. /**
  41666. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41667. * that any object in the plane at the camera's target point will scale
  41668. * perfectly with finger motion.
  41669. * Overrides pinchDeltaPercentage and pinchPrecision.
  41670. */
  41671. useNaturalPinchZoom: boolean;
  41672. /**
  41673. * Defines the pointer panning sensibility or how fast is the camera moving.
  41674. */
  41675. panningSensibility: number;
  41676. /**
  41677. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41678. */
  41679. multiTouchPanning: boolean;
  41680. /**
  41681. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41682. * zoom (pinch) through multitouch.
  41683. */
  41684. multiTouchPanAndZoom: boolean;
  41685. /**
  41686. * Revers pinch action direction.
  41687. */
  41688. pinchInwards: boolean;
  41689. private _isPanClick;
  41690. private _twoFingerActivityCount;
  41691. private _isPinching;
  41692. /**
  41693. * Called on pointer POINTERMOVE event if only a single touch is active.
  41694. */
  41695. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41696. /**
  41697. * Called on pointer POINTERDOUBLETAP event.
  41698. */
  41699. protected onDoubleTap(type: string): void;
  41700. /**
  41701. * Called on pointer POINTERMOVE event if multiple touches are active.
  41702. */
  41703. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41704. /**
  41705. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41706. * press.
  41707. */
  41708. protected onButtonDown(evt: PointerEvent): void;
  41709. /**
  41710. * Called each time a new POINTERUP event occurs. Ie, for each button
  41711. * release.
  41712. */
  41713. protected onButtonUp(evt: PointerEvent): void;
  41714. /**
  41715. * Called when window becomes inactive.
  41716. */
  41717. protected onLostFocus(): void;
  41718. }
  41719. }
  41720. declare module BABYLON {
  41721. /**
  41722. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41724. */
  41725. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41726. /**
  41727. * Defines the camera the input is attached to.
  41728. */
  41729. camera: ArcRotateCamera;
  41730. /**
  41731. * Defines the list of key codes associated with the up action (increase alpha)
  41732. */
  41733. keysUp: number[];
  41734. /**
  41735. * Defines the list of key codes associated with the down action (decrease alpha)
  41736. */
  41737. keysDown: number[];
  41738. /**
  41739. * Defines the list of key codes associated with the left action (increase beta)
  41740. */
  41741. keysLeft: number[];
  41742. /**
  41743. * Defines the list of key codes associated with the right action (decrease beta)
  41744. */
  41745. keysRight: number[];
  41746. /**
  41747. * Defines the list of key codes associated with the reset action.
  41748. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41749. */
  41750. keysReset: number[];
  41751. /**
  41752. * Defines the panning sensibility of the inputs.
  41753. * (How fast is the camera panning)
  41754. */
  41755. panningSensibility: number;
  41756. /**
  41757. * Defines the zooming sensibility of the inputs.
  41758. * (How fast is the camera zooming)
  41759. */
  41760. zoomingSensibility: number;
  41761. /**
  41762. * Defines whether maintaining the alt key down switch the movement mode from
  41763. * orientation to zoom.
  41764. */
  41765. useAltToZoom: boolean;
  41766. /**
  41767. * Rotation speed of the camera
  41768. */
  41769. angularSpeed: number;
  41770. private _keys;
  41771. private _ctrlPressed;
  41772. private _altPressed;
  41773. private _onCanvasBlurObserver;
  41774. private _onKeyboardObserver;
  41775. private _engine;
  41776. private _scene;
  41777. /**
  41778. * Attach the input controls to a specific dom element to get the input from.
  41779. * @param element Defines the element the controls should be listened from
  41780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41781. */
  41782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41783. /**
  41784. * Detach the current controls from the specified dom element.
  41785. * @param element Defines the element to stop listening the inputs from
  41786. */
  41787. detachControl(element: Nullable<HTMLElement>): void;
  41788. /**
  41789. * Update the current camera state depending on the inputs that have been used this frame.
  41790. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41791. */
  41792. checkInputs(): void;
  41793. /**
  41794. * Gets the class name of the current intput.
  41795. * @returns the class name
  41796. */
  41797. getClassName(): string;
  41798. /**
  41799. * Get the friendly name associated with the input class.
  41800. * @returns the input friendly name
  41801. */
  41802. getSimpleName(): string;
  41803. }
  41804. }
  41805. declare module BABYLON {
  41806. /**
  41807. * Manage the mouse wheel inputs to control an arc rotate camera.
  41808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41809. */
  41810. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41811. /**
  41812. * Defines the camera the input is attached to.
  41813. */
  41814. camera: ArcRotateCamera;
  41815. /**
  41816. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41817. */
  41818. wheelPrecision: number;
  41819. /**
  41820. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41821. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41822. */
  41823. wheelDeltaPercentage: number;
  41824. private _wheel;
  41825. private _observer;
  41826. private computeDeltaFromMouseWheelLegacyEvent;
  41827. /**
  41828. * Attach the input controls to a specific dom element to get the input from.
  41829. * @param element Defines the element the controls should be listened from
  41830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41831. */
  41832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41833. /**
  41834. * Detach the current controls from the specified dom element.
  41835. * @param element Defines the element to stop listening the inputs from
  41836. */
  41837. detachControl(element: Nullable<HTMLElement>): void;
  41838. /**
  41839. * Gets the class name of the current intput.
  41840. * @returns the class name
  41841. */
  41842. getClassName(): string;
  41843. /**
  41844. * Get the friendly name associated with the input class.
  41845. * @returns the input friendly name
  41846. */
  41847. getSimpleName(): string;
  41848. }
  41849. }
  41850. declare module BABYLON {
  41851. /**
  41852. * Default Inputs manager for the ArcRotateCamera.
  41853. * It groups all the default supported inputs for ease of use.
  41854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41855. */
  41856. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41857. /**
  41858. * Instantiates a new ArcRotateCameraInputsManager.
  41859. * @param camera Defines the camera the inputs belong to
  41860. */
  41861. constructor(camera: ArcRotateCamera);
  41862. /**
  41863. * Add mouse wheel input support to the input manager.
  41864. * @returns the current input manager
  41865. */
  41866. addMouseWheel(): ArcRotateCameraInputsManager;
  41867. /**
  41868. * Add pointers input support to the input manager.
  41869. * @returns the current input manager
  41870. */
  41871. addPointers(): ArcRotateCameraInputsManager;
  41872. /**
  41873. * Add keyboard input support to the input manager.
  41874. * @returns the current input manager
  41875. */
  41876. addKeyboard(): ArcRotateCameraInputsManager;
  41877. }
  41878. }
  41879. declare module BABYLON {
  41880. /**
  41881. * This represents an orbital type of camera.
  41882. *
  41883. * 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.
  41884. * 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.
  41885. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41886. */
  41887. export class ArcRotateCamera extends TargetCamera {
  41888. /**
  41889. * Defines the rotation angle of the camera along the longitudinal axis.
  41890. */
  41891. alpha: number;
  41892. /**
  41893. * Defines the rotation angle of the camera along the latitudinal axis.
  41894. */
  41895. beta: number;
  41896. /**
  41897. * Defines the radius of the camera from it s target point.
  41898. */
  41899. radius: number;
  41900. protected _target: Vector3;
  41901. protected _targetHost: Nullable<AbstractMesh>;
  41902. /**
  41903. * Defines the target point of the camera.
  41904. * The camera looks towards it form the radius distance.
  41905. */
  41906. get target(): Vector3;
  41907. set target(value: Vector3);
  41908. /**
  41909. * Define the current local position of the camera in the scene
  41910. */
  41911. get position(): Vector3;
  41912. set position(newPosition: Vector3);
  41913. protected _upVector: Vector3;
  41914. protected _upToYMatrix: Matrix;
  41915. protected _YToUpMatrix: Matrix;
  41916. /**
  41917. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41918. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41919. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41920. */
  41921. set upVector(vec: Vector3);
  41922. get upVector(): Vector3;
  41923. /**
  41924. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41925. */
  41926. setMatUp(): void;
  41927. /**
  41928. * Current inertia value on the longitudinal axis.
  41929. * The bigger this number the longer it will take for the camera to stop.
  41930. */
  41931. inertialAlphaOffset: number;
  41932. /**
  41933. * Current inertia value on the latitudinal axis.
  41934. * The bigger this number the longer it will take for the camera to stop.
  41935. */
  41936. inertialBetaOffset: number;
  41937. /**
  41938. * Current inertia value on the radius axis.
  41939. * The bigger this number the longer it will take for the camera to stop.
  41940. */
  41941. inertialRadiusOffset: number;
  41942. /**
  41943. * Minimum allowed angle on the longitudinal axis.
  41944. * This can help limiting how the Camera is able to move in the scene.
  41945. */
  41946. lowerAlphaLimit: Nullable<number>;
  41947. /**
  41948. * Maximum allowed angle on the longitudinal axis.
  41949. * This can help limiting how the Camera is able to move in the scene.
  41950. */
  41951. upperAlphaLimit: Nullable<number>;
  41952. /**
  41953. * Minimum allowed angle on the latitudinal axis.
  41954. * This can help limiting how the Camera is able to move in the scene.
  41955. */
  41956. lowerBetaLimit: number;
  41957. /**
  41958. * Maximum allowed angle on the latitudinal axis.
  41959. * This can help limiting how the Camera is able to move in the scene.
  41960. */
  41961. upperBetaLimit: number;
  41962. /**
  41963. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  41964. * This can help limiting how the Camera is able to move in the scene.
  41965. */
  41966. lowerRadiusLimit: Nullable<number>;
  41967. /**
  41968. * Maximum allowed distance of the camera to the target (The camera can not get further).
  41969. * This can help limiting how the Camera is able to move in the scene.
  41970. */
  41971. upperRadiusLimit: Nullable<number>;
  41972. /**
  41973. * Defines the current inertia value used during panning of the camera along the X axis.
  41974. */
  41975. inertialPanningX: number;
  41976. /**
  41977. * Defines the current inertia value used during panning of the camera along the Y axis.
  41978. */
  41979. inertialPanningY: number;
  41980. /**
  41981. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  41982. * Basically if your fingers moves away from more than this distance you will be considered
  41983. * in pinch mode.
  41984. */
  41985. pinchToPanMaxDistance: number;
  41986. /**
  41987. * Defines the maximum distance the camera can pan.
  41988. * This could help keeping the cammera always in your scene.
  41989. */
  41990. panningDistanceLimit: Nullable<number>;
  41991. /**
  41992. * Defines the target of the camera before paning.
  41993. */
  41994. panningOriginTarget: Vector3;
  41995. /**
  41996. * Defines the value of the inertia used during panning.
  41997. * 0 would mean stop inertia and one would mean no decelleration at all.
  41998. */
  41999. panningInertia: number;
  42000. /**
  42001. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42002. */
  42003. get angularSensibilityX(): number;
  42004. set angularSensibilityX(value: number);
  42005. /**
  42006. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42007. */
  42008. get angularSensibilityY(): number;
  42009. set angularSensibilityY(value: number);
  42010. /**
  42011. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42012. */
  42013. get pinchPrecision(): number;
  42014. set pinchPrecision(value: number);
  42015. /**
  42016. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42017. * It will be used instead of pinchDeltaPrecision if different from 0.
  42018. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42019. */
  42020. get pinchDeltaPercentage(): number;
  42021. set pinchDeltaPercentage(value: number);
  42022. /**
  42023. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42024. * and pinch delta percentage.
  42025. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42026. * that any object in the plane at the camera's target point will scale
  42027. * perfectly with finger motion.
  42028. */
  42029. get useNaturalPinchZoom(): boolean;
  42030. set useNaturalPinchZoom(value: boolean);
  42031. /**
  42032. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42033. */
  42034. get panningSensibility(): number;
  42035. set panningSensibility(value: number);
  42036. /**
  42037. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42038. */
  42039. get keysUp(): number[];
  42040. set keysUp(value: number[]);
  42041. /**
  42042. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42043. */
  42044. get keysDown(): number[];
  42045. set keysDown(value: number[]);
  42046. /**
  42047. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42048. */
  42049. get keysLeft(): number[];
  42050. set keysLeft(value: number[]);
  42051. /**
  42052. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42053. */
  42054. get keysRight(): number[];
  42055. set keysRight(value: number[]);
  42056. /**
  42057. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42058. */
  42059. get wheelPrecision(): number;
  42060. set wheelPrecision(value: number);
  42061. /**
  42062. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42063. * It will be used instead of pinchDeltaPrecision if different from 0.
  42064. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42065. */
  42066. get wheelDeltaPercentage(): number;
  42067. set wheelDeltaPercentage(value: number);
  42068. /**
  42069. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42070. */
  42071. zoomOnFactor: number;
  42072. /**
  42073. * Defines a screen offset for the camera position.
  42074. */
  42075. targetScreenOffset: Vector2;
  42076. /**
  42077. * Allows the camera to be completely reversed.
  42078. * If false the camera can not arrive upside down.
  42079. */
  42080. allowUpsideDown: boolean;
  42081. /**
  42082. * Define if double tap/click is used to restore the previously saved state of the camera.
  42083. */
  42084. useInputToRestoreState: boolean;
  42085. /** @hidden */
  42086. _viewMatrix: Matrix;
  42087. /** @hidden */
  42088. _useCtrlForPanning: boolean;
  42089. /** @hidden */
  42090. _panningMouseButton: number;
  42091. /**
  42092. * Defines the input associated to the camera.
  42093. */
  42094. inputs: ArcRotateCameraInputsManager;
  42095. /** @hidden */
  42096. _reset: () => void;
  42097. /**
  42098. * Defines the allowed panning axis.
  42099. */
  42100. panningAxis: Vector3;
  42101. protected _localDirection: Vector3;
  42102. protected _transformedDirection: Vector3;
  42103. private _bouncingBehavior;
  42104. /**
  42105. * Gets the bouncing behavior of the camera if it has been enabled.
  42106. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42107. */
  42108. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42109. /**
  42110. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42111. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42112. */
  42113. get useBouncingBehavior(): boolean;
  42114. set useBouncingBehavior(value: boolean);
  42115. private _framingBehavior;
  42116. /**
  42117. * Gets the framing behavior of the camera if it has been enabled.
  42118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42119. */
  42120. get framingBehavior(): Nullable<FramingBehavior>;
  42121. /**
  42122. * Defines if the framing behavior of the camera is enabled on the camera.
  42123. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42124. */
  42125. get useFramingBehavior(): boolean;
  42126. set useFramingBehavior(value: boolean);
  42127. private _autoRotationBehavior;
  42128. /**
  42129. * Gets the auto rotation behavior of the camera if it has been enabled.
  42130. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42131. */
  42132. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42133. /**
  42134. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42135. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42136. */
  42137. get useAutoRotationBehavior(): boolean;
  42138. set useAutoRotationBehavior(value: boolean);
  42139. /**
  42140. * Observable triggered when the mesh target has been changed on the camera.
  42141. */
  42142. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42143. /**
  42144. * Event raised when the camera is colliding with a mesh.
  42145. */
  42146. onCollide: (collidedMesh: AbstractMesh) => void;
  42147. /**
  42148. * Defines whether the camera should check collision with the objects oh the scene.
  42149. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42150. */
  42151. checkCollisions: boolean;
  42152. /**
  42153. * Defines the collision radius of the camera.
  42154. * This simulates a sphere around the camera.
  42155. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42156. */
  42157. collisionRadius: Vector3;
  42158. protected _collider: Collider;
  42159. protected _previousPosition: Vector3;
  42160. protected _collisionVelocity: Vector3;
  42161. protected _newPosition: Vector3;
  42162. protected _previousAlpha: number;
  42163. protected _previousBeta: number;
  42164. protected _previousRadius: number;
  42165. protected _collisionTriggered: boolean;
  42166. protected _targetBoundingCenter: Nullable<Vector3>;
  42167. private _computationVector;
  42168. /**
  42169. * Instantiates a new ArcRotateCamera in a given scene
  42170. * @param name Defines the name of the camera
  42171. * @param alpha Defines the camera rotation along the logitudinal axis
  42172. * @param beta Defines the camera rotation along the latitudinal axis
  42173. * @param radius Defines the camera distance from its target
  42174. * @param target Defines the camera target
  42175. * @param scene Defines the scene the camera belongs to
  42176. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42177. */
  42178. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42179. /** @hidden */
  42180. _initCache(): void;
  42181. /** @hidden */
  42182. _updateCache(ignoreParentClass?: boolean): void;
  42183. protected _getTargetPosition(): Vector3;
  42184. private _storedAlpha;
  42185. private _storedBeta;
  42186. private _storedRadius;
  42187. private _storedTarget;
  42188. private _storedTargetScreenOffset;
  42189. /**
  42190. * Stores the current state of the camera (alpha, beta, radius and target)
  42191. * @returns the camera itself
  42192. */
  42193. storeState(): Camera;
  42194. /**
  42195. * @hidden
  42196. * Restored camera state. You must call storeState() first
  42197. */
  42198. _restoreStateValues(): boolean;
  42199. /** @hidden */
  42200. _isSynchronizedViewMatrix(): boolean;
  42201. /**
  42202. * Attached controls to the current camera.
  42203. * @param element Defines the element the controls should be listened from
  42204. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42205. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42206. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42207. */
  42208. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42209. /**
  42210. * Detach the current controls from the camera.
  42211. * The camera will stop reacting to inputs.
  42212. * @param element Defines the element to stop listening the inputs from
  42213. */
  42214. detachControl(element: HTMLElement): void;
  42215. /** @hidden */
  42216. _checkInputs(): void;
  42217. protected _checkLimits(): void;
  42218. /**
  42219. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42220. */
  42221. rebuildAnglesAndRadius(): void;
  42222. /**
  42223. * Use a position to define the current camera related information like alpha, beta and radius
  42224. * @param position Defines the position to set the camera at
  42225. */
  42226. setPosition(position: Vector3): void;
  42227. /**
  42228. * Defines the target the camera should look at.
  42229. * This will automatically adapt alpha beta and radius to fit within the new target.
  42230. * @param target Defines the new target as a Vector or a mesh
  42231. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42232. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42233. */
  42234. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42235. /** @hidden */
  42236. _getViewMatrix(): Matrix;
  42237. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42238. /**
  42239. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42240. * @param meshes Defines the mesh to zoom on
  42241. * @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)
  42242. */
  42243. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42244. /**
  42245. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42246. * The target will be changed but the radius
  42247. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42248. * @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)
  42249. */
  42250. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42251. min: Vector3;
  42252. max: Vector3;
  42253. distance: number;
  42254. }, doNotUpdateMaxZ?: boolean): void;
  42255. /**
  42256. * @override
  42257. * Override Camera.createRigCamera
  42258. */
  42259. createRigCamera(name: string, cameraIndex: number): Camera;
  42260. /**
  42261. * @hidden
  42262. * @override
  42263. * Override Camera._updateRigCameras
  42264. */
  42265. _updateRigCameras(): void;
  42266. /**
  42267. * Destroy the camera and release the current resources hold by it.
  42268. */
  42269. dispose(): void;
  42270. /**
  42271. * Gets the current object class name.
  42272. * @return the class name
  42273. */
  42274. getClassName(): string;
  42275. }
  42276. }
  42277. declare module BABYLON {
  42278. /**
  42279. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42280. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42281. */
  42282. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42283. /**
  42284. * Gets the name of the behavior.
  42285. */
  42286. get name(): string;
  42287. private _zoomStopsAnimation;
  42288. private _idleRotationSpeed;
  42289. private _idleRotationWaitTime;
  42290. private _idleRotationSpinupTime;
  42291. /**
  42292. * Sets the flag that indicates if user zooming should stop animation.
  42293. */
  42294. set zoomStopsAnimation(flag: boolean);
  42295. /**
  42296. * Gets the flag that indicates if user zooming should stop animation.
  42297. */
  42298. get zoomStopsAnimation(): boolean;
  42299. /**
  42300. * Sets the default speed at which the camera rotates around the model.
  42301. */
  42302. set idleRotationSpeed(speed: number);
  42303. /**
  42304. * Gets the default speed at which the camera rotates around the model.
  42305. */
  42306. get idleRotationSpeed(): number;
  42307. /**
  42308. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42309. */
  42310. set idleRotationWaitTime(time: number);
  42311. /**
  42312. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42313. */
  42314. get idleRotationWaitTime(): number;
  42315. /**
  42316. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42317. */
  42318. set idleRotationSpinupTime(time: number);
  42319. /**
  42320. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42321. */
  42322. get idleRotationSpinupTime(): number;
  42323. /**
  42324. * Gets a value indicating if the camera is currently rotating because of this behavior
  42325. */
  42326. get rotationInProgress(): boolean;
  42327. private _onPrePointerObservableObserver;
  42328. private _onAfterCheckInputsObserver;
  42329. private _attachedCamera;
  42330. private _isPointerDown;
  42331. private _lastFrameTime;
  42332. private _lastInteractionTime;
  42333. private _cameraRotationSpeed;
  42334. /**
  42335. * Initializes the behavior.
  42336. */
  42337. init(): void;
  42338. /**
  42339. * Attaches the behavior to its arc rotate camera.
  42340. * @param camera Defines the camera to attach the behavior to
  42341. */
  42342. attach(camera: ArcRotateCamera): void;
  42343. /**
  42344. * Detaches the behavior from its current arc rotate camera.
  42345. */
  42346. detach(): void;
  42347. /**
  42348. * Returns true if user is scrolling.
  42349. * @return true if user is scrolling.
  42350. */
  42351. private _userIsZooming;
  42352. private _lastFrameRadius;
  42353. private _shouldAnimationStopForInteraction;
  42354. /**
  42355. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42356. */
  42357. private _applyUserInteraction;
  42358. private _userIsMoving;
  42359. }
  42360. }
  42361. declare module BABYLON {
  42362. /**
  42363. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42364. */
  42365. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42366. private ui;
  42367. /**
  42368. * The name of the behavior
  42369. */
  42370. name: string;
  42371. /**
  42372. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42373. */
  42374. distanceAwayFromFace: number;
  42375. /**
  42376. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42377. */
  42378. distanceAwayFromBottomOfFace: number;
  42379. private _faceVectors;
  42380. private _target;
  42381. private _scene;
  42382. private _onRenderObserver;
  42383. private _tmpMatrix;
  42384. private _tmpVector;
  42385. /**
  42386. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42387. * @param ui The transform node that should be attched to the mesh
  42388. */
  42389. constructor(ui: TransformNode);
  42390. /**
  42391. * Initializes the behavior
  42392. */
  42393. init(): void;
  42394. private _closestFace;
  42395. private _zeroVector;
  42396. private _lookAtTmpMatrix;
  42397. private _lookAtToRef;
  42398. /**
  42399. * Attaches the AttachToBoxBehavior to the passed in mesh
  42400. * @param target The mesh that the specified node will be attached to
  42401. */
  42402. attach(target: Mesh): void;
  42403. /**
  42404. * Detaches the behavior from the mesh
  42405. */
  42406. detach(): void;
  42407. }
  42408. }
  42409. declare module BABYLON {
  42410. /**
  42411. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42412. */
  42413. export class FadeInOutBehavior implements Behavior<Mesh> {
  42414. /**
  42415. * Time in milliseconds to delay before fading in (Default: 0)
  42416. */
  42417. delay: number;
  42418. /**
  42419. * Time in milliseconds for the mesh to fade in (Default: 300)
  42420. */
  42421. fadeInTime: number;
  42422. private _millisecondsPerFrame;
  42423. private _hovered;
  42424. private _hoverValue;
  42425. private _ownerNode;
  42426. /**
  42427. * Instatiates the FadeInOutBehavior
  42428. */
  42429. constructor();
  42430. /**
  42431. * The name of the behavior
  42432. */
  42433. get name(): string;
  42434. /**
  42435. * Initializes the behavior
  42436. */
  42437. init(): void;
  42438. /**
  42439. * Attaches the fade behavior on the passed in mesh
  42440. * @param ownerNode The mesh that will be faded in/out once attached
  42441. */
  42442. attach(ownerNode: Mesh): void;
  42443. /**
  42444. * Detaches the behavior from the mesh
  42445. */
  42446. detach(): void;
  42447. /**
  42448. * Triggers the mesh to begin fading in or out
  42449. * @param value if the object should fade in or out (true to fade in)
  42450. */
  42451. fadeIn(value: boolean): void;
  42452. private _update;
  42453. private _setAllVisibility;
  42454. }
  42455. }
  42456. declare module BABYLON {
  42457. /**
  42458. * Class containing a set of static utilities functions for managing Pivots
  42459. * @hidden
  42460. */
  42461. export class PivotTools {
  42462. private static _PivotCached;
  42463. private static _OldPivotPoint;
  42464. private static _PivotTranslation;
  42465. private static _PivotTmpVector;
  42466. /** @hidden */
  42467. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42468. /** @hidden */
  42469. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42470. }
  42471. }
  42472. declare module BABYLON {
  42473. /**
  42474. * Class containing static functions to help procedurally build meshes
  42475. */
  42476. export class PlaneBuilder {
  42477. /**
  42478. * Creates a plane mesh
  42479. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42480. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42481. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42483. * * 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
  42484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42485. * @param name defines the name of the mesh
  42486. * @param options defines the options used to create the mesh
  42487. * @param scene defines the hosting scene
  42488. * @returns the plane mesh
  42489. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42490. */
  42491. static CreatePlane(name: string, options: {
  42492. size?: number;
  42493. width?: number;
  42494. height?: number;
  42495. sideOrientation?: number;
  42496. frontUVs?: Vector4;
  42497. backUVs?: Vector4;
  42498. updatable?: boolean;
  42499. sourcePlane?: Plane;
  42500. }, scene?: Nullable<Scene>): Mesh;
  42501. }
  42502. }
  42503. declare module BABYLON {
  42504. /**
  42505. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42506. */
  42507. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42508. private static _AnyMouseID;
  42509. /**
  42510. * Abstract mesh the behavior is set on
  42511. */
  42512. attachedNode: AbstractMesh;
  42513. private _dragPlane;
  42514. private _scene;
  42515. private _pointerObserver;
  42516. private _beforeRenderObserver;
  42517. private static _planeScene;
  42518. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42519. /**
  42520. * 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)
  42521. */
  42522. maxDragAngle: number;
  42523. /**
  42524. * @hidden
  42525. */
  42526. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42527. /**
  42528. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42529. */
  42530. currentDraggingPointerID: number;
  42531. /**
  42532. * The last position where the pointer hit the drag plane in world space
  42533. */
  42534. lastDragPosition: Vector3;
  42535. /**
  42536. * If the behavior is currently in a dragging state
  42537. */
  42538. dragging: boolean;
  42539. /**
  42540. * 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)
  42541. */
  42542. dragDeltaRatio: number;
  42543. /**
  42544. * If the drag plane orientation should be updated during the dragging (Default: true)
  42545. */
  42546. updateDragPlane: boolean;
  42547. private _debugMode;
  42548. private _moving;
  42549. /**
  42550. * Fires each time the attached mesh is dragged with the pointer
  42551. * * delta between last drag position and current drag position in world space
  42552. * * dragDistance along the drag axis
  42553. * * dragPlaneNormal normal of the current drag plane used during the drag
  42554. * * dragPlanePoint in world space where the drag intersects the drag plane
  42555. */
  42556. onDragObservable: Observable<{
  42557. delta: Vector3;
  42558. dragPlanePoint: Vector3;
  42559. dragPlaneNormal: Vector3;
  42560. dragDistance: number;
  42561. pointerId: number;
  42562. }>;
  42563. /**
  42564. * Fires each time a drag begins (eg. mouse down on mesh)
  42565. */
  42566. onDragStartObservable: Observable<{
  42567. dragPlanePoint: Vector3;
  42568. pointerId: number;
  42569. }>;
  42570. /**
  42571. * Fires each time a drag ends (eg. mouse release after drag)
  42572. */
  42573. onDragEndObservable: Observable<{
  42574. dragPlanePoint: Vector3;
  42575. pointerId: number;
  42576. }>;
  42577. /**
  42578. * If the attached mesh should be moved when dragged
  42579. */
  42580. moveAttached: boolean;
  42581. /**
  42582. * If the drag behavior will react to drag events (Default: true)
  42583. */
  42584. enabled: boolean;
  42585. /**
  42586. * If pointer events should start and release the drag (Default: true)
  42587. */
  42588. startAndReleaseDragOnPointerEvents: boolean;
  42589. /**
  42590. * If camera controls should be detached during the drag
  42591. */
  42592. detachCameraControls: boolean;
  42593. /**
  42594. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42595. */
  42596. useObjectOrientationForDragging: boolean;
  42597. private _options;
  42598. /**
  42599. * Gets the options used by the behavior
  42600. */
  42601. get options(): {
  42602. dragAxis?: Vector3;
  42603. dragPlaneNormal?: Vector3;
  42604. };
  42605. /**
  42606. * Sets the options used by the behavior
  42607. */
  42608. set options(options: {
  42609. dragAxis?: Vector3;
  42610. dragPlaneNormal?: Vector3;
  42611. });
  42612. /**
  42613. * Creates a pointer drag behavior that can be attached to a mesh
  42614. * @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)
  42615. */
  42616. constructor(options?: {
  42617. dragAxis?: Vector3;
  42618. dragPlaneNormal?: Vector3;
  42619. });
  42620. /**
  42621. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42622. */
  42623. validateDrag: (targetPosition: Vector3) => boolean;
  42624. /**
  42625. * The name of the behavior
  42626. */
  42627. get name(): string;
  42628. /**
  42629. * Initializes the behavior
  42630. */
  42631. init(): void;
  42632. private _tmpVector;
  42633. private _alternatePickedPoint;
  42634. private _worldDragAxis;
  42635. private _targetPosition;
  42636. private _attachedElement;
  42637. /**
  42638. * Attaches the drag behavior the passed in mesh
  42639. * @param ownerNode The mesh that will be dragged around once attached
  42640. * @param predicate Predicate to use for pick filtering
  42641. */
  42642. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42643. /**
  42644. * Force relase the drag action by code.
  42645. */
  42646. releaseDrag(): void;
  42647. private _startDragRay;
  42648. private _lastPointerRay;
  42649. /**
  42650. * Simulates the start of a pointer drag event on the behavior
  42651. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42652. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42653. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42654. */
  42655. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42656. private _startDrag;
  42657. private _dragDelta;
  42658. private _moveDrag;
  42659. private _pickWithRayOnDragPlane;
  42660. private _pointA;
  42661. private _pointB;
  42662. private _pointC;
  42663. private _lineA;
  42664. private _lineB;
  42665. private _localAxis;
  42666. private _lookAt;
  42667. private _updateDragPlanePosition;
  42668. /**
  42669. * Detaches the behavior from the mesh
  42670. */
  42671. detach(): void;
  42672. }
  42673. }
  42674. declare module BABYLON {
  42675. /**
  42676. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42677. */
  42678. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42679. private _dragBehaviorA;
  42680. private _dragBehaviorB;
  42681. private _startDistance;
  42682. private _initialScale;
  42683. private _targetScale;
  42684. private _ownerNode;
  42685. private _sceneRenderObserver;
  42686. /**
  42687. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42688. */
  42689. constructor();
  42690. /**
  42691. * The name of the behavior
  42692. */
  42693. get name(): string;
  42694. /**
  42695. * Initializes the behavior
  42696. */
  42697. init(): void;
  42698. private _getCurrentDistance;
  42699. /**
  42700. * Attaches the scale behavior the passed in mesh
  42701. * @param ownerNode The mesh that will be scaled around once attached
  42702. */
  42703. attach(ownerNode: Mesh): void;
  42704. /**
  42705. * Detaches the behavior from the mesh
  42706. */
  42707. detach(): void;
  42708. }
  42709. }
  42710. declare module BABYLON {
  42711. /**
  42712. * 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
  42713. */
  42714. export class SixDofDragBehavior implements Behavior<Mesh> {
  42715. private static _virtualScene;
  42716. private _ownerNode;
  42717. private _sceneRenderObserver;
  42718. private _scene;
  42719. private _targetPosition;
  42720. private _virtualOriginMesh;
  42721. private _virtualDragMesh;
  42722. private _pointerObserver;
  42723. private _moving;
  42724. private _startingOrientation;
  42725. private _attachedElement;
  42726. /**
  42727. * 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)
  42728. */
  42729. private zDragFactor;
  42730. /**
  42731. * If the object should rotate to face the drag origin
  42732. */
  42733. rotateDraggedObject: boolean;
  42734. /**
  42735. * If the behavior is currently in a dragging state
  42736. */
  42737. dragging: boolean;
  42738. /**
  42739. * 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)
  42740. */
  42741. dragDeltaRatio: number;
  42742. /**
  42743. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42744. */
  42745. currentDraggingPointerID: number;
  42746. /**
  42747. * If camera controls should be detached during the drag
  42748. */
  42749. detachCameraControls: boolean;
  42750. /**
  42751. * Fires each time a drag starts
  42752. */
  42753. onDragStartObservable: Observable<{}>;
  42754. /**
  42755. * Fires each time a drag ends (eg. mouse release after drag)
  42756. */
  42757. onDragEndObservable: Observable<{}>;
  42758. /**
  42759. * 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
  42760. */
  42761. constructor();
  42762. /**
  42763. * The name of the behavior
  42764. */
  42765. get name(): string;
  42766. /**
  42767. * Initializes the behavior
  42768. */
  42769. init(): void;
  42770. /**
  42771. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42772. */
  42773. private get _pointerCamera();
  42774. /**
  42775. * Attaches the scale behavior the passed in mesh
  42776. * @param ownerNode The mesh that will be scaled around once attached
  42777. */
  42778. attach(ownerNode: Mesh): void;
  42779. /**
  42780. * Detaches the behavior from the mesh
  42781. */
  42782. detach(): void;
  42783. }
  42784. }
  42785. declare module BABYLON {
  42786. /**
  42787. * Class used to apply inverse kinematics to bones
  42788. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42789. */
  42790. export class BoneIKController {
  42791. private static _tmpVecs;
  42792. private static _tmpQuat;
  42793. private static _tmpMats;
  42794. /**
  42795. * Gets or sets the target mesh
  42796. */
  42797. targetMesh: AbstractMesh;
  42798. /** Gets or sets the mesh used as pole */
  42799. poleTargetMesh: AbstractMesh;
  42800. /**
  42801. * Gets or sets the bone used as pole
  42802. */
  42803. poleTargetBone: Nullable<Bone>;
  42804. /**
  42805. * Gets or sets the target position
  42806. */
  42807. targetPosition: Vector3;
  42808. /**
  42809. * Gets or sets the pole target position
  42810. */
  42811. poleTargetPosition: Vector3;
  42812. /**
  42813. * Gets or sets the pole target local offset
  42814. */
  42815. poleTargetLocalOffset: Vector3;
  42816. /**
  42817. * Gets or sets the pole angle
  42818. */
  42819. poleAngle: number;
  42820. /**
  42821. * Gets or sets the mesh associated with the controller
  42822. */
  42823. mesh: AbstractMesh;
  42824. /**
  42825. * 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)
  42826. */
  42827. slerpAmount: number;
  42828. private _bone1Quat;
  42829. private _bone1Mat;
  42830. private _bone2Ang;
  42831. private _bone1;
  42832. private _bone2;
  42833. private _bone1Length;
  42834. private _bone2Length;
  42835. private _maxAngle;
  42836. private _maxReach;
  42837. private _rightHandedSystem;
  42838. private _bendAxis;
  42839. private _slerping;
  42840. private _adjustRoll;
  42841. /**
  42842. * Gets or sets maximum allowed angle
  42843. */
  42844. get maxAngle(): number;
  42845. set maxAngle(value: number);
  42846. /**
  42847. * Creates a new BoneIKController
  42848. * @param mesh defines the mesh to control
  42849. * @param bone defines the bone to control
  42850. * @param options defines options to set up the controller
  42851. */
  42852. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42853. targetMesh?: AbstractMesh;
  42854. poleTargetMesh?: AbstractMesh;
  42855. poleTargetBone?: Bone;
  42856. poleTargetLocalOffset?: Vector3;
  42857. poleAngle?: number;
  42858. bendAxis?: Vector3;
  42859. maxAngle?: number;
  42860. slerpAmount?: number;
  42861. });
  42862. private _setMaxAngle;
  42863. /**
  42864. * Force the controller to update the bones
  42865. */
  42866. update(): void;
  42867. }
  42868. }
  42869. declare module BABYLON {
  42870. /**
  42871. * Class used to make a bone look toward a point in space
  42872. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42873. */
  42874. export class BoneLookController {
  42875. private static _tmpVecs;
  42876. private static _tmpQuat;
  42877. private static _tmpMats;
  42878. /**
  42879. * The target Vector3 that the bone will look at
  42880. */
  42881. target: Vector3;
  42882. /**
  42883. * The mesh that the bone is attached to
  42884. */
  42885. mesh: AbstractMesh;
  42886. /**
  42887. * The bone that will be looking to the target
  42888. */
  42889. bone: Bone;
  42890. /**
  42891. * The up axis of the coordinate system that is used when the bone is rotated
  42892. */
  42893. upAxis: Vector3;
  42894. /**
  42895. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42896. */
  42897. upAxisSpace: Space;
  42898. /**
  42899. * Used to make an adjustment to the yaw of the bone
  42900. */
  42901. adjustYaw: number;
  42902. /**
  42903. * Used to make an adjustment to the pitch of the bone
  42904. */
  42905. adjustPitch: number;
  42906. /**
  42907. * Used to make an adjustment to the roll of the bone
  42908. */
  42909. adjustRoll: number;
  42910. /**
  42911. * 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)
  42912. */
  42913. slerpAmount: number;
  42914. private _minYaw;
  42915. private _maxYaw;
  42916. private _minPitch;
  42917. private _maxPitch;
  42918. private _minYawSin;
  42919. private _minYawCos;
  42920. private _maxYawSin;
  42921. private _maxYawCos;
  42922. private _midYawConstraint;
  42923. private _minPitchTan;
  42924. private _maxPitchTan;
  42925. private _boneQuat;
  42926. private _slerping;
  42927. private _transformYawPitch;
  42928. private _transformYawPitchInv;
  42929. private _firstFrameSkipped;
  42930. private _yawRange;
  42931. private _fowardAxis;
  42932. /**
  42933. * Gets or sets the minimum yaw angle that the bone can look to
  42934. */
  42935. get minYaw(): number;
  42936. set minYaw(value: number);
  42937. /**
  42938. * Gets or sets the maximum yaw angle that the bone can look to
  42939. */
  42940. get maxYaw(): number;
  42941. set maxYaw(value: number);
  42942. /**
  42943. * Gets or sets the minimum pitch angle that the bone can look to
  42944. */
  42945. get minPitch(): number;
  42946. set minPitch(value: number);
  42947. /**
  42948. * Gets or sets the maximum pitch angle that the bone can look to
  42949. */
  42950. get maxPitch(): number;
  42951. set maxPitch(value: number);
  42952. /**
  42953. * Create a BoneLookController
  42954. * @param mesh the mesh that the bone belongs to
  42955. * @param bone the bone that will be looking to the target
  42956. * @param target the target Vector3 to look at
  42957. * @param options optional settings:
  42958. * * maxYaw: the maximum angle the bone will yaw to
  42959. * * minYaw: the minimum angle the bone will yaw to
  42960. * * maxPitch: the maximum angle the bone will pitch to
  42961. * * minPitch: the minimum angle the bone will yaw to
  42962. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  42963. * * upAxis: the up axis of the coordinate system
  42964. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  42965. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  42966. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  42967. * * adjustYaw: used to make an adjustment to the yaw of the bone
  42968. * * adjustPitch: used to make an adjustment to the pitch of the bone
  42969. * * adjustRoll: used to make an adjustment to the roll of the bone
  42970. **/
  42971. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  42972. maxYaw?: number;
  42973. minYaw?: number;
  42974. maxPitch?: number;
  42975. minPitch?: number;
  42976. slerpAmount?: number;
  42977. upAxis?: Vector3;
  42978. upAxisSpace?: Space;
  42979. yawAxis?: Vector3;
  42980. pitchAxis?: Vector3;
  42981. adjustYaw?: number;
  42982. adjustPitch?: number;
  42983. adjustRoll?: number;
  42984. });
  42985. /**
  42986. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  42987. */
  42988. update(): void;
  42989. private _getAngleDiff;
  42990. private _getAngleBetween;
  42991. private _isAngleBetween;
  42992. }
  42993. }
  42994. declare module BABYLON {
  42995. /**
  42996. * Manage the gamepad inputs to control an arc rotate camera.
  42997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42998. */
  42999. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43000. /**
  43001. * Defines the camera the input is attached to.
  43002. */
  43003. camera: ArcRotateCamera;
  43004. /**
  43005. * Defines the gamepad the input is gathering event from.
  43006. */
  43007. gamepad: Nullable<Gamepad>;
  43008. /**
  43009. * Defines the gamepad rotation sensiblity.
  43010. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43011. */
  43012. gamepadRotationSensibility: number;
  43013. /**
  43014. * Defines the gamepad move sensiblity.
  43015. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43016. */
  43017. gamepadMoveSensibility: number;
  43018. private _yAxisScale;
  43019. /**
  43020. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43021. */
  43022. get invertYAxis(): boolean;
  43023. set invertYAxis(value: boolean);
  43024. private _onGamepadConnectedObserver;
  43025. private _onGamepadDisconnectedObserver;
  43026. /**
  43027. * Attach the input controls to a specific dom element to get the input from.
  43028. * @param element Defines the element the controls should be listened from
  43029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43030. */
  43031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43032. /**
  43033. * Detach the current controls from the specified dom element.
  43034. * @param element Defines the element to stop listening the inputs from
  43035. */
  43036. detachControl(element: Nullable<HTMLElement>): void;
  43037. /**
  43038. * Update the current camera state depending on the inputs that have been used this frame.
  43039. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43040. */
  43041. checkInputs(): void;
  43042. /**
  43043. * Gets the class name of the current intput.
  43044. * @returns the class name
  43045. */
  43046. getClassName(): string;
  43047. /**
  43048. * Get the friendly name associated with the input class.
  43049. * @returns the input friendly name
  43050. */
  43051. getSimpleName(): string;
  43052. }
  43053. }
  43054. declare module BABYLON {
  43055. interface ArcRotateCameraInputsManager {
  43056. /**
  43057. * Add orientation input support to the input manager.
  43058. * @returns the current input manager
  43059. */
  43060. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43061. }
  43062. /**
  43063. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43065. */
  43066. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43067. /**
  43068. * Defines the camera the input is attached to.
  43069. */
  43070. camera: ArcRotateCamera;
  43071. /**
  43072. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43073. */
  43074. alphaCorrection: number;
  43075. /**
  43076. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43077. */
  43078. gammaCorrection: number;
  43079. private _alpha;
  43080. private _gamma;
  43081. private _dirty;
  43082. private _deviceOrientationHandler;
  43083. /**
  43084. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43085. */
  43086. constructor();
  43087. /**
  43088. * Attach the input controls to a specific dom element to get the input from.
  43089. * @param element Defines the element the controls should be listened from
  43090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43091. */
  43092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43093. /** @hidden */
  43094. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43095. /**
  43096. * Update the current camera state depending on the inputs that have been used this frame.
  43097. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43098. */
  43099. checkInputs(): void;
  43100. /**
  43101. * Detach the current controls from the specified dom element.
  43102. * @param element Defines the element to stop listening the inputs from
  43103. */
  43104. detachControl(element: Nullable<HTMLElement>): void;
  43105. /**
  43106. * Gets the class name of the current intput.
  43107. * @returns the class name
  43108. */
  43109. getClassName(): string;
  43110. /**
  43111. * Get the friendly name associated with the input class.
  43112. * @returns the input friendly name
  43113. */
  43114. getSimpleName(): string;
  43115. }
  43116. }
  43117. declare module BABYLON {
  43118. /**
  43119. * Listen to mouse events to control the camera.
  43120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43121. */
  43122. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43123. /**
  43124. * Defines the camera the input is attached to.
  43125. */
  43126. camera: FlyCamera;
  43127. /**
  43128. * Defines if touch is enabled. (Default is true.)
  43129. */
  43130. touchEnabled: boolean;
  43131. /**
  43132. * Defines the buttons associated with the input to handle camera rotation.
  43133. */
  43134. buttons: number[];
  43135. /**
  43136. * Assign buttons for Yaw control.
  43137. */
  43138. buttonsYaw: number[];
  43139. /**
  43140. * Assign buttons for Pitch control.
  43141. */
  43142. buttonsPitch: number[];
  43143. /**
  43144. * Assign buttons for Roll control.
  43145. */
  43146. buttonsRoll: number[];
  43147. /**
  43148. * Detect if any button is being pressed while mouse is moved.
  43149. * -1 = Mouse locked.
  43150. * 0 = Left button.
  43151. * 1 = Middle Button.
  43152. * 2 = Right Button.
  43153. */
  43154. activeButton: number;
  43155. /**
  43156. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43157. * Higher values reduce its sensitivity.
  43158. */
  43159. angularSensibility: number;
  43160. private _mousemoveCallback;
  43161. private _observer;
  43162. private _rollObserver;
  43163. private previousPosition;
  43164. private noPreventDefault;
  43165. private element;
  43166. /**
  43167. * Listen to mouse events to control the camera.
  43168. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43170. */
  43171. constructor(touchEnabled?: boolean);
  43172. /**
  43173. * Attach the mouse control to the HTML DOM element.
  43174. * @param element Defines the element that listens to the input events.
  43175. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43176. */
  43177. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43178. /**
  43179. * Detach the current controls from the specified dom element.
  43180. * @param element Defines the element to stop listening the inputs from
  43181. */
  43182. detachControl(element: Nullable<HTMLElement>): void;
  43183. /**
  43184. * Gets the class name of the current input.
  43185. * @returns the class name.
  43186. */
  43187. getClassName(): string;
  43188. /**
  43189. * Get the friendly name associated with the input class.
  43190. * @returns the input's friendly name.
  43191. */
  43192. getSimpleName(): string;
  43193. private _pointerInput;
  43194. private _onMouseMove;
  43195. /**
  43196. * Rotate camera by mouse offset.
  43197. */
  43198. private rotateCamera;
  43199. }
  43200. }
  43201. declare module BABYLON {
  43202. /**
  43203. * Default Inputs manager for the FlyCamera.
  43204. * It groups all the default supported inputs for ease of use.
  43205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43206. */
  43207. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43208. /**
  43209. * Instantiates a new FlyCameraInputsManager.
  43210. * @param camera Defines the camera the inputs belong to.
  43211. */
  43212. constructor(camera: FlyCamera);
  43213. /**
  43214. * Add keyboard input support to the input manager.
  43215. * @returns the new FlyCameraKeyboardMoveInput().
  43216. */
  43217. addKeyboard(): FlyCameraInputsManager;
  43218. /**
  43219. * Add mouse input support to the input manager.
  43220. * @param touchEnabled Enable touch screen support.
  43221. * @returns the new FlyCameraMouseInput().
  43222. */
  43223. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43224. }
  43225. }
  43226. declare module BABYLON {
  43227. /**
  43228. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43229. * such as in a 3D Space Shooter or a Flight Simulator.
  43230. */
  43231. export class FlyCamera extends TargetCamera {
  43232. /**
  43233. * Define the collision ellipsoid of the camera.
  43234. * This is helpful for simulating a camera body, like a player's body.
  43235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43236. */
  43237. ellipsoid: Vector3;
  43238. /**
  43239. * Define an offset for the position of the ellipsoid around the camera.
  43240. * This can be helpful if the camera is attached away from the player's body center,
  43241. * such as at its head.
  43242. */
  43243. ellipsoidOffset: Vector3;
  43244. /**
  43245. * Enable or disable collisions of the camera with the rest of the scene objects.
  43246. */
  43247. checkCollisions: boolean;
  43248. /**
  43249. * Enable or disable gravity on the camera.
  43250. */
  43251. applyGravity: boolean;
  43252. /**
  43253. * Define the current direction the camera is moving to.
  43254. */
  43255. cameraDirection: Vector3;
  43256. /**
  43257. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43258. * This overrides and empties cameraRotation.
  43259. */
  43260. rotationQuaternion: Quaternion;
  43261. /**
  43262. * Track Roll to maintain the wanted Rolling when looking around.
  43263. */
  43264. _trackRoll: number;
  43265. /**
  43266. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43267. */
  43268. rollCorrect: number;
  43269. /**
  43270. * Mimic a banked turn, Rolling the camera when Yawing.
  43271. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43272. */
  43273. bankedTurn: boolean;
  43274. /**
  43275. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43276. */
  43277. bankedTurnLimit: number;
  43278. /**
  43279. * Value of 0 disables the banked Roll.
  43280. * Value of 1 is equal to the Yaw angle in radians.
  43281. */
  43282. bankedTurnMultiplier: number;
  43283. /**
  43284. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43285. */
  43286. inputs: FlyCameraInputsManager;
  43287. /**
  43288. * Gets the input sensibility for mouse input.
  43289. * Higher values reduce sensitivity.
  43290. */
  43291. get angularSensibility(): number;
  43292. /**
  43293. * Sets the input sensibility for a mouse input.
  43294. * Higher values reduce sensitivity.
  43295. */
  43296. set angularSensibility(value: number);
  43297. /**
  43298. * Get the keys for camera movement forward.
  43299. */
  43300. get keysForward(): number[];
  43301. /**
  43302. * Set the keys for camera movement forward.
  43303. */
  43304. set keysForward(value: number[]);
  43305. /**
  43306. * Get the keys for camera movement backward.
  43307. */
  43308. get keysBackward(): number[];
  43309. set keysBackward(value: number[]);
  43310. /**
  43311. * Get the keys for camera movement up.
  43312. */
  43313. get keysUp(): number[];
  43314. /**
  43315. * Set the keys for camera movement up.
  43316. */
  43317. set keysUp(value: number[]);
  43318. /**
  43319. * Get the keys for camera movement down.
  43320. */
  43321. get keysDown(): number[];
  43322. /**
  43323. * Set the keys for camera movement down.
  43324. */
  43325. set keysDown(value: number[]);
  43326. /**
  43327. * Get the keys for camera movement left.
  43328. */
  43329. get keysLeft(): number[];
  43330. /**
  43331. * Set the keys for camera movement left.
  43332. */
  43333. set keysLeft(value: number[]);
  43334. /**
  43335. * Set the keys for camera movement right.
  43336. */
  43337. get keysRight(): number[];
  43338. /**
  43339. * Set the keys for camera movement right.
  43340. */
  43341. set keysRight(value: number[]);
  43342. /**
  43343. * Event raised when the camera collides with a mesh in the scene.
  43344. */
  43345. onCollide: (collidedMesh: AbstractMesh) => void;
  43346. private _collider;
  43347. private _needMoveForGravity;
  43348. private _oldPosition;
  43349. private _diffPosition;
  43350. private _newPosition;
  43351. /** @hidden */
  43352. _localDirection: Vector3;
  43353. /** @hidden */
  43354. _transformedDirection: Vector3;
  43355. /**
  43356. * Instantiates a FlyCamera.
  43357. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43358. * such as in a 3D Space Shooter or a Flight Simulator.
  43359. * @param name Define the name of the camera in the scene.
  43360. * @param position Define the starting position of the camera in the scene.
  43361. * @param scene Define the scene the camera belongs to.
  43362. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43363. */
  43364. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43365. /**
  43366. * Attach a control to the HTML DOM element.
  43367. * @param element Defines the element that listens to the input events.
  43368. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43369. */
  43370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43371. /**
  43372. * Detach a control from the HTML DOM element.
  43373. * The camera will stop reacting to that input.
  43374. * @param element Defines the element that listens to the input events.
  43375. */
  43376. detachControl(element: HTMLElement): void;
  43377. private _collisionMask;
  43378. /**
  43379. * Get the mask that the camera ignores in collision events.
  43380. */
  43381. get collisionMask(): number;
  43382. /**
  43383. * Set the mask that the camera ignores in collision events.
  43384. */
  43385. set collisionMask(mask: number);
  43386. /** @hidden */
  43387. _collideWithWorld(displacement: Vector3): void;
  43388. /** @hidden */
  43389. private _onCollisionPositionChange;
  43390. /** @hidden */
  43391. _checkInputs(): void;
  43392. /** @hidden */
  43393. _decideIfNeedsToMove(): boolean;
  43394. /** @hidden */
  43395. _updatePosition(): void;
  43396. /**
  43397. * Restore the Roll to its target value at the rate specified.
  43398. * @param rate - Higher means slower restoring.
  43399. * @hidden
  43400. */
  43401. restoreRoll(rate: number): void;
  43402. /**
  43403. * Destroy the camera and release the current resources held by it.
  43404. */
  43405. dispose(): void;
  43406. /**
  43407. * Get the current object class name.
  43408. * @returns the class name.
  43409. */
  43410. getClassName(): string;
  43411. }
  43412. }
  43413. declare module BABYLON {
  43414. /**
  43415. * Listen to keyboard events to control the camera.
  43416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43417. */
  43418. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43419. /**
  43420. * Defines the camera the input is attached to.
  43421. */
  43422. camera: FlyCamera;
  43423. /**
  43424. * The list of keyboard keys used to control the forward move of the camera.
  43425. */
  43426. keysForward: number[];
  43427. /**
  43428. * The list of keyboard keys used to control the backward move of the camera.
  43429. */
  43430. keysBackward: number[];
  43431. /**
  43432. * The list of keyboard keys used to control the forward move of the camera.
  43433. */
  43434. keysUp: number[];
  43435. /**
  43436. * The list of keyboard keys used to control the backward move of the camera.
  43437. */
  43438. keysDown: number[];
  43439. /**
  43440. * The list of keyboard keys used to control the right strafe move of the camera.
  43441. */
  43442. keysRight: number[];
  43443. /**
  43444. * The list of keyboard keys used to control the left strafe move of the camera.
  43445. */
  43446. keysLeft: number[];
  43447. private _keys;
  43448. private _onCanvasBlurObserver;
  43449. private _onKeyboardObserver;
  43450. private _engine;
  43451. private _scene;
  43452. /**
  43453. * Attach the input controls to a specific dom element to get the input from.
  43454. * @param element Defines the element the controls should be listened from
  43455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43456. */
  43457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43458. /**
  43459. * Detach the current controls from the specified dom element.
  43460. * @param element Defines the element to stop listening the inputs from
  43461. */
  43462. detachControl(element: Nullable<HTMLElement>): void;
  43463. /**
  43464. * Gets the class name of the current intput.
  43465. * @returns the class name
  43466. */
  43467. getClassName(): string;
  43468. /** @hidden */
  43469. _onLostFocus(e: FocusEvent): void;
  43470. /**
  43471. * Get the friendly name associated with the input class.
  43472. * @returns the input friendly name
  43473. */
  43474. getSimpleName(): string;
  43475. /**
  43476. * Update the current camera state depending on the inputs that have been used this frame.
  43477. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43478. */
  43479. checkInputs(): void;
  43480. }
  43481. }
  43482. declare module BABYLON {
  43483. /**
  43484. * Manage the mouse wheel inputs to control a follow camera.
  43485. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43486. */
  43487. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43488. /**
  43489. * Defines the camera the input is attached to.
  43490. */
  43491. camera: FollowCamera;
  43492. /**
  43493. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43494. */
  43495. axisControlRadius: boolean;
  43496. /**
  43497. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43498. */
  43499. axisControlHeight: boolean;
  43500. /**
  43501. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43502. */
  43503. axisControlRotation: boolean;
  43504. /**
  43505. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43506. * relation to mouseWheel events.
  43507. */
  43508. wheelPrecision: number;
  43509. /**
  43510. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43511. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43512. */
  43513. wheelDeltaPercentage: number;
  43514. private _wheel;
  43515. private _observer;
  43516. /**
  43517. * Attach the input controls to a specific dom element to get the input from.
  43518. * @param element Defines the element the controls should be listened from
  43519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43520. */
  43521. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43522. /**
  43523. * Detach the current controls from the specified dom element.
  43524. * @param element Defines the element to stop listening the inputs from
  43525. */
  43526. detachControl(element: Nullable<HTMLElement>): void;
  43527. /**
  43528. * Gets the class name of the current intput.
  43529. * @returns the class name
  43530. */
  43531. getClassName(): string;
  43532. /**
  43533. * Get the friendly name associated with the input class.
  43534. * @returns the input friendly name
  43535. */
  43536. getSimpleName(): string;
  43537. }
  43538. }
  43539. declare module BABYLON {
  43540. /**
  43541. * Manage the pointers inputs to control an follow camera.
  43542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43543. */
  43544. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43545. /**
  43546. * Defines the camera the input is attached to.
  43547. */
  43548. camera: FollowCamera;
  43549. /**
  43550. * Gets the class name of the current input.
  43551. * @returns the class name
  43552. */
  43553. getClassName(): string;
  43554. /**
  43555. * Defines the pointer angular sensibility along the X axis or how fast is
  43556. * the camera rotating.
  43557. * A negative number will reverse the axis direction.
  43558. */
  43559. angularSensibilityX: number;
  43560. /**
  43561. * Defines the pointer angular sensibility along the Y axis or how fast is
  43562. * the camera rotating.
  43563. * A negative number will reverse the axis direction.
  43564. */
  43565. angularSensibilityY: number;
  43566. /**
  43567. * Defines the pointer pinch precision or how fast is the camera zooming.
  43568. * A negative number will reverse the axis direction.
  43569. */
  43570. pinchPrecision: number;
  43571. /**
  43572. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43573. * from 0.
  43574. * It defines the percentage of current camera.radius to use as delta when
  43575. * pinch zoom is used.
  43576. */
  43577. pinchDeltaPercentage: number;
  43578. /**
  43579. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43580. */
  43581. axisXControlRadius: boolean;
  43582. /**
  43583. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43584. */
  43585. axisXControlHeight: boolean;
  43586. /**
  43587. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43588. */
  43589. axisXControlRotation: boolean;
  43590. /**
  43591. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43592. */
  43593. axisYControlRadius: boolean;
  43594. /**
  43595. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43596. */
  43597. axisYControlHeight: boolean;
  43598. /**
  43599. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43600. */
  43601. axisYControlRotation: boolean;
  43602. /**
  43603. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43604. */
  43605. axisPinchControlRadius: boolean;
  43606. /**
  43607. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43608. */
  43609. axisPinchControlHeight: boolean;
  43610. /**
  43611. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43612. */
  43613. axisPinchControlRotation: boolean;
  43614. /**
  43615. * Log error messages if basic misconfiguration has occurred.
  43616. */
  43617. warningEnable: boolean;
  43618. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43619. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43620. private _warningCounter;
  43621. private _warning;
  43622. }
  43623. }
  43624. declare module BABYLON {
  43625. /**
  43626. * Default Inputs manager for the FollowCamera.
  43627. * It groups all the default supported inputs for ease of use.
  43628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43629. */
  43630. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43631. /**
  43632. * Instantiates a new FollowCameraInputsManager.
  43633. * @param camera Defines the camera the inputs belong to
  43634. */
  43635. constructor(camera: FollowCamera);
  43636. /**
  43637. * Add keyboard input support to the input manager.
  43638. * @returns the current input manager
  43639. */
  43640. addKeyboard(): FollowCameraInputsManager;
  43641. /**
  43642. * Add mouse wheel input support to the input manager.
  43643. * @returns the current input manager
  43644. */
  43645. addMouseWheel(): FollowCameraInputsManager;
  43646. /**
  43647. * Add pointers input support to the input manager.
  43648. * @returns the current input manager
  43649. */
  43650. addPointers(): FollowCameraInputsManager;
  43651. /**
  43652. * Add orientation input support to the input manager.
  43653. * @returns the current input manager
  43654. */
  43655. addVRDeviceOrientation(): FollowCameraInputsManager;
  43656. }
  43657. }
  43658. declare module BABYLON {
  43659. /**
  43660. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43661. * an arc rotate version arcFollowCamera are available.
  43662. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43663. */
  43664. export class FollowCamera extends TargetCamera {
  43665. /**
  43666. * Distance the follow camera should follow an object at
  43667. */
  43668. radius: number;
  43669. /**
  43670. * Minimum allowed distance of the camera to the axis of rotation
  43671. * (The camera can not get closer).
  43672. * This can help limiting how the Camera is able to move in the scene.
  43673. */
  43674. lowerRadiusLimit: Nullable<number>;
  43675. /**
  43676. * Maximum allowed distance of the camera to the axis of rotation
  43677. * (The camera can not get further).
  43678. * This can help limiting how the Camera is able to move in the scene.
  43679. */
  43680. upperRadiusLimit: Nullable<number>;
  43681. /**
  43682. * Define a rotation offset between the camera and the object it follows
  43683. */
  43684. rotationOffset: number;
  43685. /**
  43686. * Minimum allowed angle to camera position relative to target object.
  43687. * This can help limiting how the Camera is able to move in the scene.
  43688. */
  43689. lowerRotationOffsetLimit: Nullable<number>;
  43690. /**
  43691. * Maximum allowed angle to camera position relative to target object.
  43692. * This can help limiting how the Camera is able to move in the scene.
  43693. */
  43694. upperRotationOffsetLimit: Nullable<number>;
  43695. /**
  43696. * Define a height offset between the camera and the object it follows.
  43697. * It can help following an object from the top (like a car chaing a plane)
  43698. */
  43699. heightOffset: number;
  43700. /**
  43701. * Minimum allowed height of camera position relative to target object.
  43702. * This can help limiting how the Camera is able to move in the scene.
  43703. */
  43704. lowerHeightOffsetLimit: Nullable<number>;
  43705. /**
  43706. * Maximum allowed height of camera position relative to target object.
  43707. * This can help limiting how the Camera is able to move in the scene.
  43708. */
  43709. upperHeightOffsetLimit: Nullable<number>;
  43710. /**
  43711. * Define how fast the camera can accelerate to follow it s target.
  43712. */
  43713. cameraAcceleration: number;
  43714. /**
  43715. * Define the speed limit of the camera following an object.
  43716. */
  43717. maxCameraSpeed: number;
  43718. /**
  43719. * Define the target of the camera.
  43720. */
  43721. lockedTarget: Nullable<AbstractMesh>;
  43722. /**
  43723. * Defines the input associated with the camera.
  43724. */
  43725. inputs: FollowCameraInputsManager;
  43726. /**
  43727. * Instantiates the follow camera.
  43728. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43729. * @param name Define the name of the camera in the scene
  43730. * @param position Define the position of the camera
  43731. * @param scene Define the scene the camera belong to
  43732. * @param lockedTarget Define the target of the camera
  43733. */
  43734. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43735. private _follow;
  43736. /**
  43737. * Attached controls to the current camera.
  43738. * @param element Defines the element the controls should be listened from
  43739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43740. */
  43741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43742. /**
  43743. * Detach the current controls from the camera.
  43744. * The camera will stop reacting to inputs.
  43745. * @param element Defines the element to stop listening the inputs from
  43746. */
  43747. detachControl(element: HTMLElement): void;
  43748. /** @hidden */
  43749. _checkInputs(): void;
  43750. private _checkLimits;
  43751. /**
  43752. * Gets the camera class name.
  43753. * @returns the class name
  43754. */
  43755. getClassName(): string;
  43756. }
  43757. /**
  43758. * Arc Rotate version of the follow camera.
  43759. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43760. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43761. */
  43762. export class ArcFollowCamera extends TargetCamera {
  43763. /** The longitudinal angle of the camera */
  43764. alpha: number;
  43765. /** The latitudinal angle of the camera */
  43766. beta: number;
  43767. /** The radius of the camera from its target */
  43768. radius: number;
  43769. /** Define the camera target (the mesh it should follow) */
  43770. target: Nullable<AbstractMesh>;
  43771. private _cartesianCoordinates;
  43772. /**
  43773. * Instantiates a new ArcFollowCamera
  43774. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  43775. * @param name Define the name of the camera
  43776. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43777. * @param beta Define the rotation angle of the camera around the elevation axis
  43778. * @param radius Define the radius of the camera from its target point
  43779. * @param target Define the target of the camera
  43780. * @param scene Define the scene the camera belongs to
  43781. */
  43782. constructor(name: string,
  43783. /** The longitudinal angle of the camera */
  43784. alpha: number,
  43785. /** The latitudinal angle of the camera */
  43786. beta: number,
  43787. /** The radius of the camera from its target */
  43788. radius: number,
  43789. /** Define the camera target (the mesh it should follow) */
  43790. target: Nullable<AbstractMesh>, scene: Scene);
  43791. private _follow;
  43792. /** @hidden */
  43793. _checkInputs(): void;
  43794. /**
  43795. * Returns the class name of the object.
  43796. * It is mostly used internally for serialization purposes.
  43797. */
  43798. getClassName(): string;
  43799. }
  43800. }
  43801. declare module BABYLON {
  43802. /**
  43803. * Manage the keyboard inputs to control the movement of a follow camera.
  43804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43805. */
  43806. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43807. /**
  43808. * Defines the camera the input is attached to.
  43809. */
  43810. camera: FollowCamera;
  43811. /**
  43812. * Defines the list of key codes associated with the up action (increase heightOffset)
  43813. */
  43814. keysHeightOffsetIncr: number[];
  43815. /**
  43816. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43817. */
  43818. keysHeightOffsetDecr: number[];
  43819. /**
  43820. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43821. */
  43822. keysHeightOffsetModifierAlt: boolean;
  43823. /**
  43824. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43825. */
  43826. keysHeightOffsetModifierCtrl: boolean;
  43827. /**
  43828. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43829. */
  43830. keysHeightOffsetModifierShift: boolean;
  43831. /**
  43832. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43833. */
  43834. keysRotationOffsetIncr: number[];
  43835. /**
  43836. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43837. */
  43838. keysRotationOffsetDecr: number[];
  43839. /**
  43840. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43841. */
  43842. keysRotationOffsetModifierAlt: boolean;
  43843. /**
  43844. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43845. */
  43846. keysRotationOffsetModifierCtrl: boolean;
  43847. /**
  43848. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43849. */
  43850. keysRotationOffsetModifierShift: boolean;
  43851. /**
  43852. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43853. */
  43854. keysRadiusIncr: number[];
  43855. /**
  43856. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43857. */
  43858. keysRadiusDecr: number[];
  43859. /**
  43860. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43861. */
  43862. keysRadiusModifierAlt: boolean;
  43863. /**
  43864. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43865. */
  43866. keysRadiusModifierCtrl: boolean;
  43867. /**
  43868. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43869. */
  43870. keysRadiusModifierShift: boolean;
  43871. /**
  43872. * Defines the rate of change of heightOffset.
  43873. */
  43874. heightSensibility: number;
  43875. /**
  43876. * Defines the rate of change of rotationOffset.
  43877. */
  43878. rotationSensibility: number;
  43879. /**
  43880. * Defines the rate of change of radius.
  43881. */
  43882. radiusSensibility: number;
  43883. private _keys;
  43884. private _ctrlPressed;
  43885. private _altPressed;
  43886. private _shiftPressed;
  43887. private _onCanvasBlurObserver;
  43888. private _onKeyboardObserver;
  43889. private _engine;
  43890. private _scene;
  43891. /**
  43892. * Attach the input controls to a specific dom element to get the input from.
  43893. * @param element Defines the element the controls should be listened from
  43894. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43895. */
  43896. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43897. /**
  43898. * Detach the current controls from the specified dom element.
  43899. * @param element Defines the element to stop listening the inputs from
  43900. */
  43901. detachControl(element: Nullable<HTMLElement>): void;
  43902. /**
  43903. * Update the current camera state depending on the inputs that have been used this frame.
  43904. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43905. */
  43906. checkInputs(): void;
  43907. /**
  43908. * Gets the class name of the current input.
  43909. * @returns the class name
  43910. */
  43911. getClassName(): string;
  43912. /**
  43913. * Get the friendly name associated with the input class.
  43914. * @returns the input friendly name
  43915. */
  43916. getSimpleName(): string;
  43917. /**
  43918. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43919. * allow modification of the heightOffset value.
  43920. */
  43921. private _modifierHeightOffset;
  43922. /**
  43923. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43924. * allow modification of the rotationOffset value.
  43925. */
  43926. private _modifierRotationOffset;
  43927. /**
  43928. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43929. * allow modification of the radius value.
  43930. */
  43931. private _modifierRadius;
  43932. }
  43933. }
  43934. declare module BABYLON {
  43935. interface FreeCameraInputsManager {
  43936. /**
  43937. * @hidden
  43938. */
  43939. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43940. /**
  43941. * Add orientation input support to the input manager.
  43942. * @returns the current input manager
  43943. */
  43944. addDeviceOrientation(): FreeCameraInputsManager;
  43945. }
  43946. /**
  43947. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43948. * Screen rotation is taken into account.
  43949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43950. */
  43951. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43952. private _camera;
  43953. private _screenOrientationAngle;
  43954. private _constantTranform;
  43955. private _screenQuaternion;
  43956. private _alpha;
  43957. private _beta;
  43958. private _gamma;
  43959. /**
  43960. * Can be used to detect if a device orientation sensor is available on a device
  43961. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  43962. * @returns a promise that will resolve on orientation change
  43963. */
  43964. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  43965. /**
  43966. * @hidden
  43967. */
  43968. _onDeviceOrientationChangedObservable: Observable<void>;
  43969. /**
  43970. * Instantiates a new input
  43971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  43972. */
  43973. constructor();
  43974. /**
  43975. * Define the camera controlled by the input.
  43976. */
  43977. get camera(): FreeCamera;
  43978. set camera(camera: FreeCamera);
  43979. /**
  43980. * Attach the input controls to a specific dom element to get the input from.
  43981. * @param element Defines the element the controls should be listened from
  43982. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43983. */
  43984. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43985. private _orientationChanged;
  43986. private _deviceOrientation;
  43987. /**
  43988. * Detach the current controls from the specified dom element.
  43989. * @param element Defines the element to stop listening the inputs from
  43990. */
  43991. detachControl(element: Nullable<HTMLElement>): void;
  43992. /**
  43993. * Update the current camera state depending on the inputs that have been used this frame.
  43994. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43995. */
  43996. checkInputs(): void;
  43997. /**
  43998. * Gets the class name of the current intput.
  43999. * @returns the class name
  44000. */
  44001. getClassName(): string;
  44002. /**
  44003. * Get the friendly name associated with the input class.
  44004. * @returns the input friendly name
  44005. */
  44006. getSimpleName(): string;
  44007. }
  44008. }
  44009. declare module BABYLON {
  44010. /**
  44011. * Manage the gamepad inputs to control a free camera.
  44012. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44013. */
  44014. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44015. /**
  44016. * Define the camera the input is attached to.
  44017. */
  44018. camera: FreeCamera;
  44019. /**
  44020. * Define the Gamepad controlling the input
  44021. */
  44022. gamepad: Nullable<Gamepad>;
  44023. /**
  44024. * Defines the gamepad rotation sensiblity.
  44025. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44026. */
  44027. gamepadAngularSensibility: number;
  44028. /**
  44029. * Defines the gamepad move sensiblity.
  44030. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44031. */
  44032. gamepadMoveSensibility: number;
  44033. private _yAxisScale;
  44034. /**
  44035. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44036. */
  44037. get invertYAxis(): boolean;
  44038. set invertYAxis(value: boolean);
  44039. private _onGamepadConnectedObserver;
  44040. private _onGamepadDisconnectedObserver;
  44041. private _cameraTransform;
  44042. private _deltaTransform;
  44043. private _vector3;
  44044. private _vector2;
  44045. /**
  44046. * Attach the input controls to a specific dom element to get the input from.
  44047. * @param element Defines the element the controls should be listened from
  44048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44049. */
  44050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44051. /**
  44052. * Detach the current controls from the specified dom element.
  44053. * @param element Defines the element to stop listening the inputs from
  44054. */
  44055. detachControl(element: Nullable<HTMLElement>): void;
  44056. /**
  44057. * Update the current camera state depending on the inputs that have been used this frame.
  44058. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44059. */
  44060. checkInputs(): void;
  44061. /**
  44062. * Gets the class name of the current intput.
  44063. * @returns the class name
  44064. */
  44065. getClassName(): string;
  44066. /**
  44067. * Get the friendly name associated with the input class.
  44068. * @returns the input friendly name
  44069. */
  44070. getSimpleName(): string;
  44071. }
  44072. }
  44073. declare module BABYLON {
  44074. /**
  44075. * Defines the potential axis of a Joystick
  44076. */
  44077. export enum JoystickAxis {
  44078. /** X axis */
  44079. X = 0,
  44080. /** Y axis */
  44081. Y = 1,
  44082. /** Z axis */
  44083. Z = 2
  44084. }
  44085. /**
  44086. * Class used to define virtual joystick (used in touch mode)
  44087. */
  44088. export class VirtualJoystick {
  44089. /**
  44090. * Gets or sets a boolean indicating that left and right values must be inverted
  44091. */
  44092. reverseLeftRight: boolean;
  44093. /**
  44094. * Gets or sets a boolean indicating that up and down values must be inverted
  44095. */
  44096. reverseUpDown: boolean;
  44097. /**
  44098. * Gets the offset value for the position (ie. the change of the position value)
  44099. */
  44100. deltaPosition: Vector3;
  44101. /**
  44102. * Gets a boolean indicating if the virtual joystick was pressed
  44103. */
  44104. pressed: boolean;
  44105. /**
  44106. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44107. */
  44108. static Canvas: Nullable<HTMLCanvasElement>;
  44109. private static _globalJoystickIndex;
  44110. private static vjCanvasContext;
  44111. private static vjCanvasWidth;
  44112. private static vjCanvasHeight;
  44113. private static halfWidth;
  44114. private _action;
  44115. private _axisTargetedByLeftAndRight;
  44116. private _axisTargetedByUpAndDown;
  44117. private _joystickSensibility;
  44118. private _inversedSensibility;
  44119. private _joystickPointerID;
  44120. private _joystickColor;
  44121. private _joystickPointerPos;
  44122. private _joystickPreviousPointerPos;
  44123. private _joystickPointerStartPos;
  44124. private _deltaJoystickVector;
  44125. private _leftJoystick;
  44126. private _touches;
  44127. private _onPointerDownHandlerRef;
  44128. private _onPointerMoveHandlerRef;
  44129. private _onPointerUpHandlerRef;
  44130. private _onResize;
  44131. /**
  44132. * Creates a new virtual joystick
  44133. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44134. */
  44135. constructor(leftJoystick?: boolean);
  44136. /**
  44137. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44138. * @param newJoystickSensibility defines the new sensibility
  44139. */
  44140. setJoystickSensibility(newJoystickSensibility: number): void;
  44141. private _onPointerDown;
  44142. private _onPointerMove;
  44143. private _onPointerUp;
  44144. /**
  44145. * Change the color of the virtual joystick
  44146. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44147. */
  44148. setJoystickColor(newColor: string): void;
  44149. /**
  44150. * Defines a callback to call when the joystick is touched
  44151. * @param action defines the callback
  44152. */
  44153. setActionOnTouch(action: () => any): void;
  44154. /**
  44155. * Defines which axis you'd like to control for left & right
  44156. * @param axis defines the axis to use
  44157. */
  44158. setAxisForLeftRight(axis: JoystickAxis): void;
  44159. /**
  44160. * Defines which axis you'd like to control for up & down
  44161. * @param axis defines the axis to use
  44162. */
  44163. setAxisForUpDown(axis: JoystickAxis): void;
  44164. private _drawVirtualJoystick;
  44165. /**
  44166. * Release internal HTML canvas
  44167. */
  44168. releaseCanvas(): void;
  44169. }
  44170. }
  44171. declare module BABYLON {
  44172. interface FreeCameraInputsManager {
  44173. /**
  44174. * Add virtual joystick input support to the input manager.
  44175. * @returns the current input manager
  44176. */
  44177. addVirtualJoystick(): FreeCameraInputsManager;
  44178. }
  44179. /**
  44180. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  44182. */
  44183. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44184. /**
  44185. * Defines the camera the input is attached to.
  44186. */
  44187. camera: FreeCamera;
  44188. private _leftjoystick;
  44189. private _rightjoystick;
  44190. /**
  44191. * Gets the left stick of the virtual joystick.
  44192. * @returns The virtual Joystick
  44193. */
  44194. getLeftJoystick(): VirtualJoystick;
  44195. /**
  44196. * Gets the right stick of the virtual joystick.
  44197. * @returns The virtual Joystick
  44198. */
  44199. getRightJoystick(): VirtualJoystick;
  44200. /**
  44201. * Update the current camera state depending on the inputs that have been used this frame.
  44202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44203. */
  44204. checkInputs(): void;
  44205. /**
  44206. * Attach the input controls to a specific dom element to get the input from.
  44207. * @param element Defines the element the controls should be listened from
  44208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44209. */
  44210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44211. /**
  44212. * Detach the current controls from the specified dom element.
  44213. * @param element Defines the element to stop listening the inputs from
  44214. */
  44215. detachControl(element: Nullable<HTMLElement>): void;
  44216. /**
  44217. * Gets the class name of the current intput.
  44218. * @returns the class name
  44219. */
  44220. getClassName(): string;
  44221. /**
  44222. * Get the friendly name associated with the input class.
  44223. * @returns the input friendly name
  44224. */
  44225. getSimpleName(): string;
  44226. }
  44227. }
  44228. declare module BABYLON {
  44229. /**
  44230. * This represents a FPS type of camera controlled by touch.
  44231. * This is like a universal camera minus the Gamepad controls.
  44232. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44233. */
  44234. export class TouchCamera extends FreeCamera {
  44235. /**
  44236. * Defines the touch sensibility for rotation.
  44237. * The higher the faster.
  44238. */
  44239. get touchAngularSensibility(): number;
  44240. set touchAngularSensibility(value: number);
  44241. /**
  44242. * Defines the touch sensibility for move.
  44243. * The higher the faster.
  44244. */
  44245. get touchMoveSensibility(): number;
  44246. set touchMoveSensibility(value: number);
  44247. /**
  44248. * Instantiates a new touch camera.
  44249. * This represents a FPS type of camera controlled by touch.
  44250. * This is like a universal camera minus the Gamepad controls.
  44251. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44252. * @param name Define the name of the camera in the scene
  44253. * @param position Define the start position of the camera in the scene
  44254. * @param scene Define the scene the camera belongs to
  44255. */
  44256. constructor(name: string, position: Vector3, scene: Scene);
  44257. /**
  44258. * Gets the current object class name.
  44259. * @return the class name
  44260. */
  44261. getClassName(): string;
  44262. /** @hidden */
  44263. _setupInputs(): void;
  44264. }
  44265. }
  44266. declare module BABYLON {
  44267. /**
  44268. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44269. * being tilted forward or back and left or right.
  44270. */
  44271. export class DeviceOrientationCamera extends FreeCamera {
  44272. private _initialQuaternion;
  44273. private _quaternionCache;
  44274. private _tmpDragQuaternion;
  44275. private _disablePointerInputWhenUsingDeviceOrientation;
  44276. /**
  44277. * Creates a new device orientation camera
  44278. * @param name The name of the camera
  44279. * @param position The start position camera
  44280. * @param scene The scene the camera belongs to
  44281. */
  44282. constructor(name: string, position: Vector3, scene: Scene);
  44283. /**
  44284. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44285. */
  44286. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44287. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44288. private _dragFactor;
  44289. /**
  44290. * Enabled turning on the y axis when the orientation sensor is active
  44291. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44292. */
  44293. enableHorizontalDragging(dragFactor?: number): void;
  44294. /**
  44295. * Gets the current instance class name ("DeviceOrientationCamera").
  44296. * This helps avoiding instanceof at run time.
  44297. * @returns the class name
  44298. */
  44299. getClassName(): string;
  44300. /**
  44301. * @hidden
  44302. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44303. */
  44304. _checkInputs(): void;
  44305. /**
  44306. * Reset the camera to its default orientation on the specified axis only.
  44307. * @param axis The axis to reset
  44308. */
  44309. resetToCurrentRotation(axis?: Axis): void;
  44310. }
  44311. }
  44312. declare module BABYLON {
  44313. /**
  44314. * Defines supported buttons for XBox360 compatible gamepads
  44315. */
  44316. export enum Xbox360Button {
  44317. /** A */
  44318. A = 0,
  44319. /** B */
  44320. B = 1,
  44321. /** X */
  44322. X = 2,
  44323. /** Y */
  44324. Y = 3,
  44325. /** Left button */
  44326. LB = 4,
  44327. /** Right button */
  44328. RB = 5,
  44329. /** Back */
  44330. Back = 8,
  44331. /** Start */
  44332. Start = 9,
  44333. /** Left stick */
  44334. LeftStick = 10,
  44335. /** Right stick */
  44336. RightStick = 11
  44337. }
  44338. /** Defines values for XBox360 DPad */
  44339. export enum Xbox360Dpad {
  44340. /** Up */
  44341. Up = 12,
  44342. /** Down */
  44343. Down = 13,
  44344. /** Left */
  44345. Left = 14,
  44346. /** Right */
  44347. Right = 15
  44348. }
  44349. /**
  44350. * Defines a XBox360 gamepad
  44351. */
  44352. export class Xbox360Pad extends Gamepad {
  44353. private _leftTrigger;
  44354. private _rightTrigger;
  44355. private _onlefttriggerchanged;
  44356. private _onrighttriggerchanged;
  44357. private _onbuttondown;
  44358. private _onbuttonup;
  44359. private _ondpaddown;
  44360. private _ondpadup;
  44361. /** Observable raised when a button is pressed */
  44362. onButtonDownObservable: Observable<Xbox360Button>;
  44363. /** Observable raised when a button is released */
  44364. onButtonUpObservable: Observable<Xbox360Button>;
  44365. /** Observable raised when a pad is pressed */
  44366. onPadDownObservable: Observable<Xbox360Dpad>;
  44367. /** Observable raised when a pad is released */
  44368. onPadUpObservable: Observable<Xbox360Dpad>;
  44369. private _buttonA;
  44370. private _buttonB;
  44371. private _buttonX;
  44372. private _buttonY;
  44373. private _buttonBack;
  44374. private _buttonStart;
  44375. private _buttonLB;
  44376. private _buttonRB;
  44377. private _buttonLeftStick;
  44378. private _buttonRightStick;
  44379. private _dPadUp;
  44380. private _dPadDown;
  44381. private _dPadLeft;
  44382. private _dPadRight;
  44383. private _isXboxOnePad;
  44384. /**
  44385. * Creates a new XBox360 gamepad object
  44386. * @param id defines the id of this gamepad
  44387. * @param index defines its index
  44388. * @param gamepad defines the internal HTML gamepad object
  44389. * @param xboxOne defines if it is a XBox One gamepad
  44390. */
  44391. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44392. /**
  44393. * Defines the callback to call when left trigger is pressed
  44394. * @param callback defines the callback to use
  44395. */
  44396. onlefttriggerchanged(callback: (value: number) => void): void;
  44397. /**
  44398. * Defines the callback to call when right trigger is pressed
  44399. * @param callback defines the callback to use
  44400. */
  44401. onrighttriggerchanged(callback: (value: number) => void): void;
  44402. /**
  44403. * Gets the left trigger value
  44404. */
  44405. get leftTrigger(): number;
  44406. /**
  44407. * Sets the left trigger value
  44408. */
  44409. set leftTrigger(newValue: number);
  44410. /**
  44411. * Gets the right trigger value
  44412. */
  44413. get rightTrigger(): number;
  44414. /**
  44415. * Sets the right trigger value
  44416. */
  44417. set rightTrigger(newValue: number);
  44418. /**
  44419. * Defines the callback to call when a button is pressed
  44420. * @param callback defines the callback to use
  44421. */
  44422. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44423. /**
  44424. * Defines the callback to call when a button is released
  44425. * @param callback defines the callback to use
  44426. */
  44427. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44428. /**
  44429. * Defines the callback to call when a pad is pressed
  44430. * @param callback defines the callback to use
  44431. */
  44432. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44433. /**
  44434. * Defines the callback to call when a pad is released
  44435. * @param callback defines the callback to use
  44436. */
  44437. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44438. private _setButtonValue;
  44439. private _setDPadValue;
  44440. /**
  44441. * Gets the value of the `A` button
  44442. */
  44443. get buttonA(): number;
  44444. /**
  44445. * Sets the value of the `A` button
  44446. */
  44447. set buttonA(value: number);
  44448. /**
  44449. * Gets the value of the `B` button
  44450. */
  44451. get buttonB(): number;
  44452. /**
  44453. * Sets the value of the `B` button
  44454. */
  44455. set buttonB(value: number);
  44456. /**
  44457. * Gets the value of the `X` button
  44458. */
  44459. get buttonX(): number;
  44460. /**
  44461. * Sets the value of the `X` button
  44462. */
  44463. set buttonX(value: number);
  44464. /**
  44465. * Gets the value of the `Y` button
  44466. */
  44467. get buttonY(): number;
  44468. /**
  44469. * Sets the value of the `Y` button
  44470. */
  44471. set buttonY(value: number);
  44472. /**
  44473. * Gets the value of the `Start` button
  44474. */
  44475. get buttonStart(): number;
  44476. /**
  44477. * Sets the value of the `Start` button
  44478. */
  44479. set buttonStart(value: number);
  44480. /**
  44481. * Gets the value of the `Back` button
  44482. */
  44483. get buttonBack(): number;
  44484. /**
  44485. * Sets the value of the `Back` button
  44486. */
  44487. set buttonBack(value: number);
  44488. /**
  44489. * Gets the value of the `Left` button
  44490. */
  44491. get buttonLB(): number;
  44492. /**
  44493. * Sets the value of the `Left` button
  44494. */
  44495. set buttonLB(value: number);
  44496. /**
  44497. * Gets the value of the `Right` button
  44498. */
  44499. get buttonRB(): number;
  44500. /**
  44501. * Sets the value of the `Right` button
  44502. */
  44503. set buttonRB(value: number);
  44504. /**
  44505. * Gets the value of the Left joystick
  44506. */
  44507. get buttonLeftStick(): number;
  44508. /**
  44509. * Sets the value of the Left joystick
  44510. */
  44511. set buttonLeftStick(value: number);
  44512. /**
  44513. * Gets the value of the Right joystick
  44514. */
  44515. get buttonRightStick(): number;
  44516. /**
  44517. * Sets the value of the Right joystick
  44518. */
  44519. set buttonRightStick(value: number);
  44520. /**
  44521. * Gets the value of D-pad up
  44522. */
  44523. get dPadUp(): number;
  44524. /**
  44525. * Sets the value of D-pad up
  44526. */
  44527. set dPadUp(value: number);
  44528. /**
  44529. * Gets the value of D-pad down
  44530. */
  44531. get dPadDown(): number;
  44532. /**
  44533. * Sets the value of D-pad down
  44534. */
  44535. set dPadDown(value: number);
  44536. /**
  44537. * Gets the value of D-pad left
  44538. */
  44539. get dPadLeft(): number;
  44540. /**
  44541. * Sets the value of D-pad left
  44542. */
  44543. set dPadLeft(value: number);
  44544. /**
  44545. * Gets the value of D-pad right
  44546. */
  44547. get dPadRight(): number;
  44548. /**
  44549. * Sets the value of D-pad right
  44550. */
  44551. set dPadRight(value: number);
  44552. /**
  44553. * Force the gamepad to synchronize with device values
  44554. */
  44555. update(): void;
  44556. /**
  44557. * Disposes the gamepad
  44558. */
  44559. dispose(): void;
  44560. }
  44561. }
  44562. declare module BABYLON {
  44563. /**
  44564. * Defines supported buttons for DualShock compatible gamepads
  44565. */
  44566. export enum DualShockButton {
  44567. /** Cross */
  44568. Cross = 0,
  44569. /** Circle */
  44570. Circle = 1,
  44571. /** Square */
  44572. Square = 2,
  44573. /** Triangle */
  44574. Triangle = 3,
  44575. /** L1 */
  44576. L1 = 4,
  44577. /** R1 */
  44578. R1 = 5,
  44579. /** Share */
  44580. Share = 8,
  44581. /** Options */
  44582. Options = 9,
  44583. /** Left stick */
  44584. LeftStick = 10,
  44585. /** Right stick */
  44586. RightStick = 11
  44587. }
  44588. /** Defines values for DualShock DPad */
  44589. export enum DualShockDpad {
  44590. /** Up */
  44591. Up = 12,
  44592. /** Down */
  44593. Down = 13,
  44594. /** Left */
  44595. Left = 14,
  44596. /** Right */
  44597. Right = 15
  44598. }
  44599. /**
  44600. * Defines a DualShock gamepad
  44601. */
  44602. export class DualShockPad extends Gamepad {
  44603. private _leftTrigger;
  44604. private _rightTrigger;
  44605. private _onlefttriggerchanged;
  44606. private _onrighttriggerchanged;
  44607. private _onbuttondown;
  44608. private _onbuttonup;
  44609. private _ondpaddown;
  44610. private _ondpadup;
  44611. /** Observable raised when a button is pressed */
  44612. onButtonDownObservable: Observable<DualShockButton>;
  44613. /** Observable raised when a button is released */
  44614. onButtonUpObservable: Observable<DualShockButton>;
  44615. /** Observable raised when a pad is pressed */
  44616. onPadDownObservable: Observable<DualShockDpad>;
  44617. /** Observable raised when a pad is released */
  44618. onPadUpObservable: Observable<DualShockDpad>;
  44619. private _buttonCross;
  44620. private _buttonCircle;
  44621. private _buttonSquare;
  44622. private _buttonTriangle;
  44623. private _buttonShare;
  44624. private _buttonOptions;
  44625. private _buttonL1;
  44626. private _buttonR1;
  44627. private _buttonLeftStick;
  44628. private _buttonRightStick;
  44629. private _dPadUp;
  44630. private _dPadDown;
  44631. private _dPadLeft;
  44632. private _dPadRight;
  44633. /**
  44634. * Creates a new DualShock gamepad object
  44635. * @param id defines the id of this gamepad
  44636. * @param index defines its index
  44637. * @param gamepad defines the internal HTML gamepad object
  44638. */
  44639. constructor(id: string, index: number, gamepad: any);
  44640. /**
  44641. * Defines the callback to call when left trigger is pressed
  44642. * @param callback defines the callback to use
  44643. */
  44644. onlefttriggerchanged(callback: (value: number) => void): void;
  44645. /**
  44646. * Defines the callback to call when right trigger is pressed
  44647. * @param callback defines the callback to use
  44648. */
  44649. onrighttriggerchanged(callback: (value: number) => void): void;
  44650. /**
  44651. * Gets the left trigger value
  44652. */
  44653. get leftTrigger(): number;
  44654. /**
  44655. * Sets the left trigger value
  44656. */
  44657. set leftTrigger(newValue: number);
  44658. /**
  44659. * Gets the right trigger value
  44660. */
  44661. get rightTrigger(): number;
  44662. /**
  44663. * Sets the right trigger value
  44664. */
  44665. set rightTrigger(newValue: number);
  44666. /**
  44667. * Defines the callback to call when a button is pressed
  44668. * @param callback defines the callback to use
  44669. */
  44670. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44671. /**
  44672. * Defines the callback to call when a button is released
  44673. * @param callback defines the callback to use
  44674. */
  44675. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44676. /**
  44677. * Defines the callback to call when a pad is pressed
  44678. * @param callback defines the callback to use
  44679. */
  44680. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44681. /**
  44682. * Defines the callback to call when a pad is released
  44683. * @param callback defines the callback to use
  44684. */
  44685. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44686. private _setButtonValue;
  44687. private _setDPadValue;
  44688. /**
  44689. * Gets the value of the `Cross` button
  44690. */
  44691. get buttonCross(): number;
  44692. /**
  44693. * Sets the value of the `Cross` button
  44694. */
  44695. set buttonCross(value: number);
  44696. /**
  44697. * Gets the value of the `Circle` button
  44698. */
  44699. get buttonCircle(): number;
  44700. /**
  44701. * Sets the value of the `Circle` button
  44702. */
  44703. set buttonCircle(value: number);
  44704. /**
  44705. * Gets the value of the `Square` button
  44706. */
  44707. get buttonSquare(): number;
  44708. /**
  44709. * Sets the value of the `Square` button
  44710. */
  44711. set buttonSquare(value: number);
  44712. /**
  44713. * Gets the value of the `Triangle` button
  44714. */
  44715. get buttonTriangle(): number;
  44716. /**
  44717. * Sets the value of the `Triangle` button
  44718. */
  44719. set buttonTriangle(value: number);
  44720. /**
  44721. * Gets the value of the `Options` button
  44722. */
  44723. get buttonOptions(): number;
  44724. /**
  44725. * Sets the value of the `Options` button
  44726. */
  44727. set buttonOptions(value: number);
  44728. /**
  44729. * Gets the value of the `Share` button
  44730. */
  44731. get buttonShare(): number;
  44732. /**
  44733. * Sets the value of the `Share` button
  44734. */
  44735. set buttonShare(value: number);
  44736. /**
  44737. * Gets the value of the `L1` button
  44738. */
  44739. get buttonL1(): number;
  44740. /**
  44741. * Sets the value of the `L1` button
  44742. */
  44743. set buttonL1(value: number);
  44744. /**
  44745. * Gets the value of the `R1` button
  44746. */
  44747. get buttonR1(): number;
  44748. /**
  44749. * Sets the value of the `R1` button
  44750. */
  44751. set buttonR1(value: number);
  44752. /**
  44753. * Gets the value of the Left joystick
  44754. */
  44755. get buttonLeftStick(): number;
  44756. /**
  44757. * Sets the value of the Left joystick
  44758. */
  44759. set buttonLeftStick(value: number);
  44760. /**
  44761. * Gets the value of the Right joystick
  44762. */
  44763. get buttonRightStick(): number;
  44764. /**
  44765. * Sets the value of the Right joystick
  44766. */
  44767. set buttonRightStick(value: number);
  44768. /**
  44769. * Gets the value of D-pad up
  44770. */
  44771. get dPadUp(): number;
  44772. /**
  44773. * Sets the value of D-pad up
  44774. */
  44775. set dPadUp(value: number);
  44776. /**
  44777. * Gets the value of D-pad down
  44778. */
  44779. get dPadDown(): number;
  44780. /**
  44781. * Sets the value of D-pad down
  44782. */
  44783. set dPadDown(value: number);
  44784. /**
  44785. * Gets the value of D-pad left
  44786. */
  44787. get dPadLeft(): number;
  44788. /**
  44789. * Sets the value of D-pad left
  44790. */
  44791. set dPadLeft(value: number);
  44792. /**
  44793. * Gets the value of D-pad right
  44794. */
  44795. get dPadRight(): number;
  44796. /**
  44797. * Sets the value of D-pad right
  44798. */
  44799. set dPadRight(value: number);
  44800. /**
  44801. * Force the gamepad to synchronize with device values
  44802. */
  44803. update(): void;
  44804. /**
  44805. * Disposes the gamepad
  44806. */
  44807. dispose(): void;
  44808. }
  44809. }
  44810. declare module BABYLON {
  44811. /**
  44812. * Manager for handling gamepads
  44813. */
  44814. export class GamepadManager {
  44815. private _scene?;
  44816. private _babylonGamepads;
  44817. private _oneGamepadConnected;
  44818. /** @hidden */
  44819. _isMonitoring: boolean;
  44820. private _gamepadEventSupported;
  44821. private _gamepadSupport?;
  44822. /**
  44823. * observable to be triggered when the gamepad controller has been connected
  44824. */
  44825. onGamepadConnectedObservable: Observable<Gamepad>;
  44826. /**
  44827. * observable to be triggered when the gamepad controller has been disconnected
  44828. */
  44829. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44830. private _onGamepadConnectedEvent;
  44831. private _onGamepadDisconnectedEvent;
  44832. /**
  44833. * Initializes the gamepad manager
  44834. * @param _scene BabylonJS scene
  44835. */
  44836. constructor(_scene?: Scene | undefined);
  44837. /**
  44838. * The gamepads in the game pad manager
  44839. */
  44840. get gamepads(): Gamepad[];
  44841. /**
  44842. * Get the gamepad controllers based on type
  44843. * @param type The type of gamepad controller
  44844. * @returns Nullable gamepad
  44845. */
  44846. getGamepadByType(type?: number): Nullable<Gamepad>;
  44847. /**
  44848. * Disposes the gamepad manager
  44849. */
  44850. dispose(): void;
  44851. private _addNewGamepad;
  44852. private _startMonitoringGamepads;
  44853. private _stopMonitoringGamepads;
  44854. /** @hidden */
  44855. _checkGamepadsStatus(): void;
  44856. private _updateGamepadObjects;
  44857. }
  44858. }
  44859. declare module BABYLON {
  44860. interface Scene {
  44861. /** @hidden */
  44862. _gamepadManager: Nullable<GamepadManager>;
  44863. /**
  44864. * Gets the gamepad manager associated with the scene
  44865. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  44866. */
  44867. gamepadManager: GamepadManager;
  44868. }
  44869. /**
  44870. * Interface representing a free camera inputs manager
  44871. */
  44872. interface FreeCameraInputsManager {
  44873. /**
  44874. * Adds gamepad input support to the FreeCameraInputsManager.
  44875. * @returns the FreeCameraInputsManager
  44876. */
  44877. addGamepad(): FreeCameraInputsManager;
  44878. }
  44879. /**
  44880. * Interface representing an arc rotate camera inputs manager
  44881. */
  44882. interface ArcRotateCameraInputsManager {
  44883. /**
  44884. * Adds gamepad input support to the ArcRotateCamera InputManager.
  44885. * @returns the camera inputs manager
  44886. */
  44887. addGamepad(): ArcRotateCameraInputsManager;
  44888. }
  44889. /**
  44890. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  44891. */
  44892. export class GamepadSystemSceneComponent implements ISceneComponent {
  44893. /**
  44894. * The component name helpfull to identify the component in the list of scene components.
  44895. */
  44896. readonly name: string;
  44897. /**
  44898. * The scene the component belongs to.
  44899. */
  44900. scene: Scene;
  44901. /**
  44902. * Creates a new instance of the component for the given scene
  44903. * @param scene Defines the scene to register the component in
  44904. */
  44905. constructor(scene: Scene);
  44906. /**
  44907. * Registers the component in a given scene
  44908. */
  44909. register(): void;
  44910. /**
  44911. * Rebuilds the elements related to this component in case of
  44912. * context lost for instance.
  44913. */
  44914. rebuild(): void;
  44915. /**
  44916. * Disposes the component and the associated ressources
  44917. */
  44918. dispose(): void;
  44919. private _beforeCameraUpdate;
  44920. }
  44921. }
  44922. declare module BABYLON {
  44923. /**
  44924. * 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,
  44925. * which still works and will still be found in many Playgrounds.
  44926. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44927. */
  44928. export class UniversalCamera extends TouchCamera {
  44929. /**
  44930. * Defines the gamepad rotation sensiblity.
  44931. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44932. */
  44933. get gamepadAngularSensibility(): number;
  44934. set gamepadAngularSensibility(value: number);
  44935. /**
  44936. * Defines the gamepad move sensiblity.
  44937. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44938. */
  44939. get gamepadMoveSensibility(): number;
  44940. set gamepadMoveSensibility(value: number);
  44941. /**
  44942. * 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,
  44943. * which still works and will still be found in many Playgrounds.
  44944. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44945. * @param name Define the name of the camera in the scene
  44946. * @param position Define the start position of the camera in the scene
  44947. * @param scene Define the scene the camera belongs to
  44948. */
  44949. constructor(name: string, position: Vector3, scene: Scene);
  44950. /**
  44951. * Gets the current object class name.
  44952. * @return the class name
  44953. */
  44954. getClassName(): string;
  44955. }
  44956. }
  44957. declare module BABYLON {
  44958. /**
  44959. * This represents a FPS type of camera. This is only here for back compat purpose.
  44960. * Please use the UniversalCamera instead as both are identical.
  44961. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44962. */
  44963. export class GamepadCamera extends UniversalCamera {
  44964. /**
  44965. * Instantiates a new Gamepad Camera
  44966. * This represents a FPS type of camera. This is only here for back compat purpose.
  44967. * Please use the UniversalCamera instead as both are identical.
  44968. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  44969. * @param name Define the name of the camera in the scene
  44970. * @param position Define the start position of the camera in the scene
  44971. * @param scene Define the scene the camera belongs to
  44972. */
  44973. constructor(name: string, position: Vector3, scene: Scene);
  44974. /**
  44975. * Gets the current object class name.
  44976. * @return the class name
  44977. */
  44978. getClassName(): string;
  44979. }
  44980. }
  44981. declare module BABYLON {
  44982. /** @hidden */
  44983. export var passPixelShader: {
  44984. name: string;
  44985. shader: string;
  44986. };
  44987. }
  44988. declare module BABYLON {
  44989. /** @hidden */
  44990. export var passCubePixelShader: {
  44991. name: string;
  44992. shader: string;
  44993. };
  44994. }
  44995. declare module BABYLON {
  44996. /**
  44997. * PassPostProcess which produces an output the same as it's input
  44998. */
  44999. export class PassPostProcess extends PostProcess {
  45000. /**
  45001. * Creates the PassPostProcess
  45002. * @param name The name of the effect.
  45003. * @param options The required width/height ratio to downsize to before computing the render pass.
  45004. * @param camera The camera to apply the render pass to.
  45005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45006. * @param engine The engine which the post process will be applied. (default: current engine)
  45007. * @param reusable If the post process can be reused on the same frame. (default: false)
  45008. * @param textureType The type of texture to be used when performing the post processing.
  45009. * @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)
  45010. */
  45011. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45012. }
  45013. /**
  45014. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45015. */
  45016. export class PassCubePostProcess extends PostProcess {
  45017. private _face;
  45018. /**
  45019. * Gets or sets the cube face to display.
  45020. * * 0 is +X
  45021. * * 1 is -X
  45022. * * 2 is +Y
  45023. * * 3 is -Y
  45024. * * 4 is +Z
  45025. * * 5 is -Z
  45026. */
  45027. get face(): number;
  45028. set face(value: number);
  45029. /**
  45030. * Creates the PassCubePostProcess
  45031. * @param name The name of the effect.
  45032. * @param options The required width/height ratio to downsize to before computing the render pass.
  45033. * @param camera The camera to apply the render pass to.
  45034. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45035. * @param engine The engine which the post process will be applied. (default: current engine)
  45036. * @param reusable If the post process can be reused on the same frame. (default: false)
  45037. * @param textureType The type of texture to be used when performing the post processing.
  45038. * @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)
  45039. */
  45040. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45041. }
  45042. }
  45043. declare module BABYLON {
  45044. /** @hidden */
  45045. export var anaglyphPixelShader: {
  45046. name: string;
  45047. shader: string;
  45048. };
  45049. }
  45050. declare module BABYLON {
  45051. /**
  45052. * Postprocess used to generate anaglyphic rendering
  45053. */
  45054. export class AnaglyphPostProcess extends PostProcess {
  45055. private _passedProcess;
  45056. /**
  45057. * Creates a new AnaglyphPostProcess
  45058. * @param name defines postprocess name
  45059. * @param options defines creation options or target ratio scale
  45060. * @param rigCameras defines cameras using this postprocess
  45061. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45062. * @param engine defines hosting engine
  45063. * @param reusable defines if the postprocess will be reused multiple times per frame
  45064. */
  45065. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45066. }
  45067. }
  45068. declare module BABYLON {
  45069. /**
  45070. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45071. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45072. */
  45073. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45074. /**
  45075. * Creates a new AnaglyphArcRotateCamera
  45076. * @param name defines camera name
  45077. * @param alpha defines alpha angle (in radians)
  45078. * @param beta defines beta angle (in radians)
  45079. * @param radius defines radius
  45080. * @param target defines camera target
  45081. * @param interaxialDistance defines distance between each color axis
  45082. * @param scene defines the hosting scene
  45083. */
  45084. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45085. /**
  45086. * Gets camera class name
  45087. * @returns AnaglyphArcRotateCamera
  45088. */
  45089. getClassName(): string;
  45090. }
  45091. }
  45092. declare module BABYLON {
  45093. /**
  45094. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45095. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45096. */
  45097. export class AnaglyphFreeCamera extends FreeCamera {
  45098. /**
  45099. * Creates a new AnaglyphFreeCamera
  45100. * @param name defines camera name
  45101. * @param position defines initial position
  45102. * @param interaxialDistance defines distance between each color axis
  45103. * @param scene defines the hosting scene
  45104. */
  45105. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45106. /**
  45107. * Gets camera class name
  45108. * @returns AnaglyphFreeCamera
  45109. */
  45110. getClassName(): string;
  45111. }
  45112. }
  45113. declare module BABYLON {
  45114. /**
  45115. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45116. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45117. */
  45118. export class AnaglyphGamepadCamera extends GamepadCamera {
  45119. /**
  45120. * Creates a new AnaglyphGamepadCamera
  45121. * @param name defines camera name
  45122. * @param position defines initial position
  45123. * @param interaxialDistance defines distance between each color axis
  45124. * @param scene defines the hosting scene
  45125. */
  45126. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45127. /**
  45128. * Gets camera class name
  45129. * @returns AnaglyphGamepadCamera
  45130. */
  45131. getClassName(): string;
  45132. }
  45133. }
  45134. declare module BABYLON {
  45135. /**
  45136. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45137. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45138. */
  45139. export class AnaglyphUniversalCamera extends UniversalCamera {
  45140. /**
  45141. * Creates a new AnaglyphUniversalCamera
  45142. * @param name defines camera name
  45143. * @param position defines initial position
  45144. * @param interaxialDistance defines distance between each color axis
  45145. * @param scene defines the hosting scene
  45146. */
  45147. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45148. /**
  45149. * Gets camera class name
  45150. * @returns AnaglyphUniversalCamera
  45151. */
  45152. getClassName(): string;
  45153. }
  45154. }
  45155. declare module BABYLON {
  45156. /**
  45157. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45158. * @see http://doc.babylonjs.com/features/cameras
  45159. */
  45160. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45161. /**
  45162. * Creates a new StereoscopicArcRotateCamera
  45163. * @param name defines camera name
  45164. * @param alpha defines alpha angle (in radians)
  45165. * @param beta defines beta angle (in radians)
  45166. * @param radius defines radius
  45167. * @param target defines camera target
  45168. * @param interaxialDistance defines distance between each color axis
  45169. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45170. * @param scene defines the hosting scene
  45171. */
  45172. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45173. /**
  45174. * Gets camera class name
  45175. * @returns StereoscopicArcRotateCamera
  45176. */
  45177. getClassName(): string;
  45178. }
  45179. }
  45180. declare module BABYLON {
  45181. /**
  45182. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45183. * @see http://doc.babylonjs.com/features/cameras
  45184. */
  45185. export class StereoscopicFreeCamera extends FreeCamera {
  45186. /**
  45187. * Creates a new StereoscopicFreeCamera
  45188. * @param name defines camera name
  45189. * @param position defines initial position
  45190. * @param interaxialDistance defines distance between each color axis
  45191. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45192. * @param scene defines the hosting scene
  45193. */
  45194. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45195. /**
  45196. * Gets camera class name
  45197. * @returns StereoscopicFreeCamera
  45198. */
  45199. getClassName(): string;
  45200. }
  45201. }
  45202. declare module BABYLON {
  45203. /**
  45204. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45205. * @see http://doc.babylonjs.com/features/cameras
  45206. */
  45207. export class StereoscopicGamepadCamera extends GamepadCamera {
  45208. /**
  45209. * Creates a new StereoscopicGamepadCamera
  45210. * @param name defines camera name
  45211. * @param position defines initial position
  45212. * @param interaxialDistance defines distance between each color axis
  45213. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45214. * @param scene defines the hosting scene
  45215. */
  45216. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45217. /**
  45218. * Gets camera class name
  45219. * @returns StereoscopicGamepadCamera
  45220. */
  45221. getClassName(): string;
  45222. }
  45223. }
  45224. declare module BABYLON {
  45225. /**
  45226. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45227. * @see http://doc.babylonjs.com/features/cameras
  45228. */
  45229. export class StereoscopicUniversalCamera extends UniversalCamera {
  45230. /**
  45231. * Creates a new StereoscopicUniversalCamera
  45232. * @param name defines camera name
  45233. * @param position defines initial position
  45234. * @param interaxialDistance defines distance between each color axis
  45235. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45236. * @param scene defines the hosting scene
  45237. */
  45238. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45239. /**
  45240. * Gets camera class name
  45241. * @returns StereoscopicUniversalCamera
  45242. */
  45243. getClassName(): string;
  45244. }
  45245. }
  45246. declare module BABYLON {
  45247. /**
  45248. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45249. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45250. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45251. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45252. */
  45253. export class VirtualJoysticksCamera extends FreeCamera {
  45254. /**
  45255. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45256. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45257. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45258. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45259. * @param name Define the name of the camera in the scene
  45260. * @param position Define the start position of the camera in the scene
  45261. * @param scene Define the scene the camera belongs to
  45262. */
  45263. constructor(name: string, position: Vector3, scene: Scene);
  45264. /**
  45265. * Gets the current object class name.
  45266. * @return the class name
  45267. */
  45268. getClassName(): string;
  45269. }
  45270. }
  45271. declare module BABYLON {
  45272. /**
  45273. * This represents all the required metrics to create a VR camera.
  45274. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45275. */
  45276. export class VRCameraMetrics {
  45277. /**
  45278. * Define the horizontal resolution off the screen.
  45279. */
  45280. hResolution: number;
  45281. /**
  45282. * Define the vertical resolution off the screen.
  45283. */
  45284. vResolution: number;
  45285. /**
  45286. * Define the horizontal screen size.
  45287. */
  45288. hScreenSize: number;
  45289. /**
  45290. * Define the vertical screen size.
  45291. */
  45292. vScreenSize: number;
  45293. /**
  45294. * Define the vertical screen center position.
  45295. */
  45296. vScreenCenter: number;
  45297. /**
  45298. * Define the distance of the eyes to the screen.
  45299. */
  45300. eyeToScreenDistance: number;
  45301. /**
  45302. * Define the distance between both lenses
  45303. */
  45304. lensSeparationDistance: number;
  45305. /**
  45306. * Define the distance between both viewer's eyes.
  45307. */
  45308. interpupillaryDistance: number;
  45309. /**
  45310. * Define the distortion factor of the VR postprocess.
  45311. * Please, touch with care.
  45312. */
  45313. distortionK: number[];
  45314. /**
  45315. * Define the chromatic aberration correction factors for the VR post process.
  45316. */
  45317. chromaAbCorrection: number[];
  45318. /**
  45319. * Define the scale factor of the post process.
  45320. * The smaller the better but the slower.
  45321. */
  45322. postProcessScaleFactor: number;
  45323. /**
  45324. * Define an offset for the lens center.
  45325. */
  45326. lensCenterOffset: number;
  45327. /**
  45328. * Define if the current vr camera should compensate the distortion of the lense or not.
  45329. */
  45330. compensateDistortion: boolean;
  45331. /**
  45332. * Defines if multiview should be enabled when rendering (Default: false)
  45333. */
  45334. multiviewEnabled: boolean;
  45335. /**
  45336. * Gets the rendering aspect ratio based on the provided resolutions.
  45337. */
  45338. get aspectRatio(): number;
  45339. /**
  45340. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45341. */
  45342. get aspectRatioFov(): number;
  45343. /**
  45344. * @hidden
  45345. */
  45346. get leftHMatrix(): Matrix;
  45347. /**
  45348. * @hidden
  45349. */
  45350. get rightHMatrix(): Matrix;
  45351. /**
  45352. * @hidden
  45353. */
  45354. get leftPreViewMatrix(): Matrix;
  45355. /**
  45356. * @hidden
  45357. */
  45358. get rightPreViewMatrix(): Matrix;
  45359. /**
  45360. * Get the default VRMetrics based on the most generic setup.
  45361. * @returns the default vr metrics
  45362. */
  45363. static GetDefault(): VRCameraMetrics;
  45364. }
  45365. }
  45366. declare module BABYLON {
  45367. /** @hidden */
  45368. export var vrDistortionCorrectionPixelShader: {
  45369. name: string;
  45370. shader: string;
  45371. };
  45372. }
  45373. declare module BABYLON {
  45374. /**
  45375. * VRDistortionCorrectionPostProcess used for mobile VR
  45376. */
  45377. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45378. private _isRightEye;
  45379. private _distortionFactors;
  45380. private _postProcessScaleFactor;
  45381. private _lensCenterOffset;
  45382. private _scaleIn;
  45383. private _scaleFactor;
  45384. private _lensCenter;
  45385. /**
  45386. * Initializes the VRDistortionCorrectionPostProcess
  45387. * @param name The name of the effect.
  45388. * @param camera The camera to apply the render pass to.
  45389. * @param isRightEye If this is for the right eye distortion
  45390. * @param vrMetrics All the required metrics for the VR camera
  45391. */
  45392. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45393. }
  45394. }
  45395. declare module BABYLON {
  45396. /**
  45397. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45398. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45399. */
  45400. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45401. /**
  45402. * Creates a new VRDeviceOrientationArcRotateCamera
  45403. * @param name defines camera name
  45404. * @param alpha defines the camera rotation along the logitudinal axis
  45405. * @param beta defines the camera rotation along the latitudinal axis
  45406. * @param radius defines the camera distance from its target
  45407. * @param target defines the camera target
  45408. * @param scene defines the scene the camera belongs to
  45409. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45410. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45411. */
  45412. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45413. /**
  45414. * Gets camera class name
  45415. * @returns VRDeviceOrientationArcRotateCamera
  45416. */
  45417. getClassName(): string;
  45418. }
  45419. }
  45420. declare module BABYLON {
  45421. /**
  45422. * Camera used to simulate VR rendering (based on FreeCamera)
  45423. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45424. */
  45425. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45426. /**
  45427. * Creates a new VRDeviceOrientationFreeCamera
  45428. * @param name defines camera name
  45429. * @param position defines the start position of the camera
  45430. * @param scene defines the scene the camera belongs to
  45431. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45432. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45433. */
  45434. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45435. /**
  45436. * Gets camera class name
  45437. * @returns VRDeviceOrientationFreeCamera
  45438. */
  45439. getClassName(): string;
  45440. }
  45441. }
  45442. declare module BABYLON {
  45443. /**
  45444. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45445. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45446. */
  45447. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45448. /**
  45449. * Creates a new VRDeviceOrientationGamepadCamera
  45450. * @param name defines camera name
  45451. * @param position defines the start position of the camera
  45452. * @param scene defines the scene the camera belongs to
  45453. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45454. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45455. */
  45456. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45457. /**
  45458. * Gets camera class name
  45459. * @returns VRDeviceOrientationGamepadCamera
  45460. */
  45461. getClassName(): string;
  45462. }
  45463. }
  45464. declare module BABYLON {
  45465. /** @hidden */
  45466. export var imageProcessingPixelShader: {
  45467. name: string;
  45468. shader: string;
  45469. };
  45470. }
  45471. declare module BABYLON {
  45472. /**
  45473. * ImageProcessingPostProcess
  45474. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45475. */
  45476. export class ImageProcessingPostProcess extends PostProcess {
  45477. /**
  45478. * Default configuration related to image processing available in the PBR Material.
  45479. */
  45480. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45481. /**
  45482. * Gets the image processing configuration used either in this material.
  45483. */
  45484. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45485. /**
  45486. * Sets the Default image processing configuration used either in the this material.
  45487. *
  45488. * If sets to null, the scene one is in use.
  45489. */
  45490. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45491. /**
  45492. * Keep track of the image processing observer to allow dispose and replace.
  45493. */
  45494. private _imageProcessingObserver;
  45495. /**
  45496. * Attaches a new image processing configuration to the PBR Material.
  45497. * @param configuration
  45498. */
  45499. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45500. /**
  45501. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45502. */
  45503. get colorCurves(): Nullable<ColorCurves>;
  45504. /**
  45505. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45506. */
  45507. set colorCurves(value: Nullable<ColorCurves>);
  45508. /**
  45509. * Gets wether the color curves effect is enabled.
  45510. */
  45511. get colorCurvesEnabled(): boolean;
  45512. /**
  45513. * Sets wether the color curves effect is enabled.
  45514. */
  45515. set colorCurvesEnabled(value: boolean);
  45516. /**
  45517. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45518. */
  45519. get colorGradingTexture(): Nullable<BaseTexture>;
  45520. /**
  45521. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45522. */
  45523. set colorGradingTexture(value: Nullable<BaseTexture>);
  45524. /**
  45525. * Gets wether the color grading effect is enabled.
  45526. */
  45527. get colorGradingEnabled(): boolean;
  45528. /**
  45529. * Gets wether the color grading effect is enabled.
  45530. */
  45531. set colorGradingEnabled(value: boolean);
  45532. /**
  45533. * Gets exposure used in the effect.
  45534. */
  45535. get exposure(): number;
  45536. /**
  45537. * Sets exposure used in the effect.
  45538. */
  45539. set exposure(value: number);
  45540. /**
  45541. * Gets wether tonemapping is enabled or not.
  45542. */
  45543. get toneMappingEnabled(): boolean;
  45544. /**
  45545. * Sets wether tonemapping is enabled or not
  45546. */
  45547. set toneMappingEnabled(value: boolean);
  45548. /**
  45549. * Gets the type of tone mapping effect.
  45550. */
  45551. get toneMappingType(): number;
  45552. /**
  45553. * Sets the type of tone mapping effect.
  45554. */
  45555. set toneMappingType(value: number);
  45556. /**
  45557. * Gets contrast used in the effect.
  45558. */
  45559. get contrast(): number;
  45560. /**
  45561. * Sets contrast used in the effect.
  45562. */
  45563. set contrast(value: number);
  45564. /**
  45565. * Gets Vignette stretch size.
  45566. */
  45567. get vignetteStretch(): number;
  45568. /**
  45569. * Sets Vignette stretch size.
  45570. */
  45571. set vignetteStretch(value: number);
  45572. /**
  45573. * Gets Vignette centre X Offset.
  45574. */
  45575. get vignetteCentreX(): number;
  45576. /**
  45577. * Sets Vignette centre X Offset.
  45578. */
  45579. set vignetteCentreX(value: number);
  45580. /**
  45581. * Gets Vignette centre Y Offset.
  45582. */
  45583. get vignetteCentreY(): number;
  45584. /**
  45585. * Sets Vignette centre Y Offset.
  45586. */
  45587. set vignetteCentreY(value: number);
  45588. /**
  45589. * Gets Vignette weight or intensity of the vignette effect.
  45590. */
  45591. get vignetteWeight(): number;
  45592. /**
  45593. * Sets Vignette weight or intensity of the vignette effect.
  45594. */
  45595. set vignetteWeight(value: number);
  45596. /**
  45597. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45598. * if vignetteEnabled is set to true.
  45599. */
  45600. get vignetteColor(): Color4;
  45601. /**
  45602. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45603. * if vignetteEnabled is set to true.
  45604. */
  45605. set vignetteColor(value: Color4);
  45606. /**
  45607. * Gets Camera field of view used by the Vignette effect.
  45608. */
  45609. get vignetteCameraFov(): number;
  45610. /**
  45611. * Sets Camera field of view used by the Vignette effect.
  45612. */
  45613. set vignetteCameraFov(value: number);
  45614. /**
  45615. * Gets the vignette blend mode allowing different kind of effect.
  45616. */
  45617. get vignetteBlendMode(): number;
  45618. /**
  45619. * Sets the vignette blend mode allowing different kind of effect.
  45620. */
  45621. set vignetteBlendMode(value: number);
  45622. /**
  45623. * Gets wether the vignette effect is enabled.
  45624. */
  45625. get vignetteEnabled(): boolean;
  45626. /**
  45627. * Sets wether the vignette effect is enabled.
  45628. */
  45629. set vignetteEnabled(value: boolean);
  45630. private _fromLinearSpace;
  45631. /**
  45632. * Gets wether the input of the processing is in Gamma or Linear Space.
  45633. */
  45634. get fromLinearSpace(): boolean;
  45635. /**
  45636. * Sets wether the input of the processing is in Gamma or Linear Space.
  45637. */
  45638. set fromLinearSpace(value: boolean);
  45639. /**
  45640. * Defines cache preventing GC.
  45641. */
  45642. private _defines;
  45643. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45644. /**
  45645. * "ImageProcessingPostProcess"
  45646. * @returns "ImageProcessingPostProcess"
  45647. */
  45648. getClassName(): string;
  45649. protected _updateParameters(): void;
  45650. dispose(camera?: Camera): void;
  45651. }
  45652. }
  45653. declare module BABYLON {
  45654. /**
  45655. * Class containing static functions to help procedurally build meshes
  45656. */
  45657. export class GroundBuilder {
  45658. /**
  45659. * Creates a ground mesh
  45660. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45661. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45663. * @param name defines the name of the mesh
  45664. * @param options defines the options used to create the mesh
  45665. * @param scene defines the hosting scene
  45666. * @returns the ground mesh
  45667. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45668. */
  45669. static CreateGround(name: string, options: {
  45670. width?: number;
  45671. height?: number;
  45672. subdivisions?: number;
  45673. subdivisionsX?: number;
  45674. subdivisionsY?: number;
  45675. updatable?: boolean;
  45676. }, scene: any): Mesh;
  45677. /**
  45678. * Creates a tiled ground mesh
  45679. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45680. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45681. * * 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
  45682. * * 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
  45683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45684. * @param name defines the name of the mesh
  45685. * @param options defines the options used to create the mesh
  45686. * @param scene defines the hosting scene
  45687. * @returns the tiled ground mesh
  45688. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45689. */
  45690. static CreateTiledGround(name: string, options: {
  45691. xmin: number;
  45692. zmin: number;
  45693. xmax: number;
  45694. zmax: number;
  45695. subdivisions?: {
  45696. w: number;
  45697. h: number;
  45698. };
  45699. precision?: {
  45700. w: number;
  45701. h: number;
  45702. };
  45703. updatable?: boolean;
  45704. }, scene?: Nullable<Scene>): Mesh;
  45705. /**
  45706. * Creates a ground mesh from a height map
  45707. * * The parameter `url` sets the URL of the height map image resource.
  45708. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45709. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45710. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45711. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45712. * * 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.
  45713. * * 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).
  45714. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45716. * @param name defines the name of the mesh
  45717. * @param url defines the url to the height map
  45718. * @param options defines the options used to create the mesh
  45719. * @param scene defines the hosting scene
  45720. * @returns the ground mesh
  45721. * @see https://doc.babylonjs.com/babylon101/height_map
  45722. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45723. */
  45724. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45725. width?: number;
  45726. height?: number;
  45727. subdivisions?: number;
  45728. minHeight?: number;
  45729. maxHeight?: number;
  45730. colorFilter?: Color3;
  45731. alphaFilter?: number;
  45732. updatable?: boolean;
  45733. onReady?: (mesh: GroundMesh) => void;
  45734. }, scene?: Nullable<Scene>): GroundMesh;
  45735. }
  45736. }
  45737. declare module BABYLON {
  45738. /**
  45739. * Class containing static functions to help procedurally build meshes
  45740. */
  45741. export class TorusBuilder {
  45742. /**
  45743. * Creates a torus mesh
  45744. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45745. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45746. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45748. * * 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
  45749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45750. * @param name defines the name of the mesh
  45751. * @param options defines the options used to create the mesh
  45752. * @param scene defines the hosting scene
  45753. * @returns the torus mesh
  45754. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45755. */
  45756. static CreateTorus(name: string, options: {
  45757. diameter?: number;
  45758. thickness?: number;
  45759. tessellation?: number;
  45760. updatable?: boolean;
  45761. sideOrientation?: number;
  45762. frontUVs?: Vector4;
  45763. backUVs?: Vector4;
  45764. }, scene: any): Mesh;
  45765. }
  45766. }
  45767. declare module BABYLON {
  45768. /**
  45769. * Class containing static functions to help procedurally build meshes
  45770. */
  45771. export class CylinderBuilder {
  45772. /**
  45773. * Creates a cylinder or a cone mesh
  45774. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  45775. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  45776. * * 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.
  45777. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  45778. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  45779. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  45780. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  45781. * * 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).
  45782. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  45783. * * 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).
  45784. * * 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
  45785. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  45786. * * 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
  45787. * * 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.
  45788. * * If `enclose` is false, a ring surface is one element.
  45789. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  45790. * * 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
  45791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45792. * * 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
  45793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45794. * @param name defines the name of the mesh
  45795. * @param options defines the options used to create the mesh
  45796. * @param scene defines the hosting scene
  45797. * @returns the cylinder mesh
  45798. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  45799. */
  45800. static CreateCylinder(name: string, options: {
  45801. height?: number;
  45802. diameterTop?: number;
  45803. diameterBottom?: number;
  45804. diameter?: number;
  45805. tessellation?: number;
  45806. subdivisions?: number;
  45807. arc?: number;
  45808. faceColors?: Color4[];
  45809. faceUV?: Vector4[];
  45810. updatable?: boolean;
  45811. hasRings?: boolean;
  45812. enclose?: boolean;
  45813. cap?: number;
  45814. sideOrientation?: number;
  45815. frontUVs?: Vector4;
  45816. backUVs?: Vector4;
  45817. }, scene: any): Mesh;
  45818. }
  45819. }
  45820. declare module BABYLON {
  45821. /**
  45822. * States of the webXR experience
  45823. */
  45824. export enum WebXRState {
  45825. /**
  45826. * Transitioning to being in XR mode
  45827. */
  45828. ENTERING_XR = 0,
  45829. /**
  45830. * Transitioning to non XR mode
  45831. */
  45832. EXITING_XR = 1,
  45833. /**
  45834. * In XR mode and presenting
  45835. */
  45836. IN_XR = 2,
  45837. /**
  45838. * Not entered XR mode
  45839. */
  45840. NOT_IN_XR = 3
  45841. }
  45842. /**
  45843. * Abstraction of the XR render target
  45844. */
  45845. export interface WebXRRenderTarget extends IDisposable {
  45846. /**
  45847. * xrpresent context of the canvas which can be used to display/mirror xr content
  45848. */
  45849. canvasContext: WebGLRenderingContext;
  45850. /**
  45851. * xr layer for the canvas
  45852. */
  45853. xrLayer: Nullable<XRWebGLLayer>;
  45854. /**
  45855. * Initializes the xr layer for the session
  45856. * @param xrSession xr session
  45857. * @returns a promise that will resolve once the XR Layer has been created
  45858. */
  45859. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45860. }
  45861. }
  45862. declare module BABYLON {
  45863. /**
  45864. * COnfiguration object for WebXR output canvas
  45865. */
  45866. export class WebXRManagedOutputCanvasOptions {
  45867. /**
  45868. * An optional canvas in case you wish to create it yourself and provide it here.
  45869. * If not provided, a new canvas will be created
  45870. */
  45871. canvasElement?: HTMLCanvasElement;
  45872. /**
  45873. * Options for this XR Layer output
  45874. */
  45875. canvasOptions?: XRWebGLLayerOptions;
  45876. /**
  45877. * CSS styling for a newly created canvas (if not provided)
  45878. */
  45879. newCanvasCssStyle?: string;
  45880. /**
  45881. * Get the default values of the configuration object
  45882. * @returns default values of this configuration object
  45883. */
  45884. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  45885. }
  45886. /**
  45887. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  45888. */
  45889. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  45890. private _options;
  45891. private _canvas;
  45892. private _engine;
  45893. /**
  45894. * Rendering context of the canvas which can be used to display/mirror xr content
  45895. */
  45896. canvasContext: WebGLRenderingContext;
  45897. /**
  45898. * xr layer for the canvas
  45899. */
  45900. xrLayer: Nullable<XRWebGLLayer>;
  45901. /**
  45902. * Initializes the canvas to be added/removed upon entering/exiting xr
  45903. * @param _xrSessionManager The XR Session manager
  45904. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  45905. */
  45906. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  45907. /**
  45908. * Disposes of the object
  45909. */
  45910. dispose(): void;
  45911. /**
  45912. * Initializes the xr layer for the session
  45913. * @param xrSession xr session
  45914. * @returns a promise that will resolve once the XR Layer has been created
  45915. */
  45916. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  45917. private _addCanvas;
  45918. private _removeCanvas;
  45919. private _setManagedOutputCanvas;
  45920. }
  45921. }
  45922. declare module BABYLON {
  45923. /**
  45924. * Manages an XRSession to work with Babylon's engine
  45925. * @see https://doc.babylonjs.com/how_to/webxr
  45926. */
  45927. export class WebXRSessionManager implements IDisposable {
  45928. /** The scene which the session should be created for */
  45929. scene: Scene;
  45930. private _referenceSpace;
  45931. private _rttProvider;
  45932. private _sessionEnded;
  45933. private _xrNavigator;
  45934. private baseLayer;
  45935. /**
  45936. * The base reference space from which the session started. good if you want to reset your
  45937. * reference space
  45938. */
  45939. baseReferenceSpace: XRReferenceSpace;
  45940. /**
  45941. * Current XR frame
  45942. */
  45943. currentFrame: Nullable<XRFrame>;
  45944. /** WebXR timestamp updated every frame */
  45945. currentTimestamp: number;
  45946. /**
  45947. * Used just in case of a failure to initialize an immersive session.
  45948. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  45949. */
  45950. defaultHeightCompensation: number;
  45951. /**
  45952. * Fires every time a new xrFrame arrives which can be used to update the camera
  45953. */
  45954. onXRFrameObservable: Observable<XRFrame>;
  45955. /**
  45956. * Fires when the reference space changed
  45957. */
  45958. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  45959. /**
  45960. * Fires when the xr session is ended either by the device or manually done
  45961. */
  45962. onXRSessionEnded: Observable<any>;
  45963. /**
  45964. * Fires when the xr session is ended either by the device or manually done
  45965. */
  45966. onXRSessionInit: Observable<XRSession>;
  45967. /**
  45968. * Underlying xr session
  45969. */
  45970. session: XRSession;
  45971. /**
  45972. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  45973. * or get the offset the player is currently at.
  45974. */
  45975. viewerReferenceSpace: XRReferenceSpace;
  45976. /**
  45977. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  45978. * @param scene The scene which the session should be created for
  45979. */
  45980. constructor(
  45981. /** The scene which the session should be created for */
  45982. scene: Scene);
  45983. /**
  45984. * The current reference space used in this session. This reference space can constantly change!
  45985. * It is mainly used to offset the camera's position.
  45986. */
  45987. get referenceSpace(): XRReferenceSpace;
  45988. /**
  45989. * Set a new reference space and triggers the observable
  45990. */
  45991. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  45992. /**
  45993. * Disposes of the session manager
  45994. */
  45995. dispose(): void;
  45996. /**
  45997. * Stops the xrSession and restores the render loop
  45998. * @returns Promise which resolves after it exits XR
  45999. */
  46000. exitXRAsync(): Promise<void>;
  46001. /**
  46002. * Gets the correct render target texture to be rendered this frame for this eye
  46003. * @param eye the eye for which to get the render target
  46004. * @returns the render target for the specified eye
  46005. */
  46006. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46007. /**
  46008. * Creates a WebXRRenderTarget object for the XR session
  46009. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46010. * @param options optional options to provide when creating a new render target
  46011. * @returns a WebXR render target to which the session can render
  46012. */
  46013. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46014. /**
  46015. * Initializes the manager
  46016. * After initialization enterXR can be called to start an XR session
  46017. * @returns Promise which resolves after it is initialized
  46018. */
  46019. initializeAsync(): Promise<void>;
  46020. /**
  46021. * Initializes an xr session
  46022. * @param xrSessionMode mode to initialize
  46023. * @param xrSessionInit defines optional and required values to pass to the session builder
  46024. * @returns a promise which will resolve once the session has been initialized
  46025. */
  46026. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46027. /**
  46028. * Checks if a session would be supported for the creation options specified
  46029. * @param sessionMode session mode to check if supported eg. immersive-vr
  46030. * @returns A Promise that resolves to true if supported and false if not
  46031. */
  46032. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46033. /**
  46034. * Resets the reference space to the one started the session
  46035. */
  46036. resetReferenceSpace(): void;
  46037. /**
  46038. * Starts rendering to the xr layer
  46039. */
  46040. runXRRenderLoop(): void;
  46041. /**
  46042. * Sets the reference space on the xr session
  46043. * @param referenceSpaceType space to set
  46044. * @returns a promise that will resolve once the reference space has been set
  46045. */
  46046. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46047. /**
  46048. * Updates the render state of the session
  46049. * @param state state to set
  46050. * @returns a promise that resolves once the render state has been updated
  46051. */
  46052. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46053. /**
  46054. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46055. * @param sessionMode defines the session to test
  46056. * @returns a promise with boolean as final value
  46057. */
  46058. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46059. private _createRenderTargetTexture;
  46060. }
  46061. }
  46062. declare module BABYLON {
  46063. /**
  46064. * WebXR Camera which holds the views for the xrSession
  46065. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46066. */
  46067. export class WebXRCamera extends FreeCamera {
  46068. private _xrSessionManager;
  46069. private _firstFrame;
  46070. private _referenceQuaternion;
  46071. private _referencedPosition;
  46072. private _xrInvPositionCache;
  46073. private _xrInvQuaternionCache;
  46074. /**
  46075. * Should position compensation execute on first frame.
  46076. * This is used when copying the position from a native (non XR) camera
  46077. */
  46078. compensateOnFirstFrame: boolean;
  46079. /**
  46080. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46081. * @param name the name of the camera
  46082. * @param scene the scene to add the camera to
  46083. * @param _xrSessionManager a constructed xr session manager
  46084. */
  46085. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46086. /**
  46087. * Return the user's height, unrelated to the current ground.
  46088. * This will be the y position of this camera, when ground level is 0.
  46089. */
  46090. get realWorldHeight(): number;
  46091. /** @hidden */
  46092. _updateForDualEyeDebugging(): void;
  46093. /**
  46094. * Sets this camera's transformation based on a non-vr camera
  46095. * @param otherCamera the non-vr camera to copy the transformation from
  46096. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46097. */
  46098. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46099. /**
  46100. * Gets the current instance class name ("WebXRCamera").
  46101. * @returns the class name
  46102. */
  46103. getClassName(): string;
  46104. /**
  46105. * Overriding the _getViewMatrix function, as it is computed by WebXR
  46106. */
  46107. _getViewMatrix(): Matrix;
  46108. private _updateFromXRSession;
  46109. private _updateNumberOfRigCameras;
  46110. private _updateReferenceSpace;
  46111. private _updateReferenceSpaceOffset;
  46112. }
  46113. }
  46114. declare module BABYLON {
  46115. /**
  46116. * Defining the interface required for a (webxr) feature
  46117. */
  46118. export interface IWebXRFeature extends IDisposable {
  46119. /**
  46120. * Is this feature attached
  46121. */
  46122. attached: boolean;
  46123. /**
  46124. * Should auto-attach be disabled?
  46125. */
  46126. disableAutoAttach: boolean;
  46127. /**
  46128. * Attach the feature to the session
  46129. * Will usually be called by the features manager
  46130. *
  46131. * @param force should attachment be forced (even when already attached)
  46132. * @returns true if successful.
  46133. */
  46134. attach(force?: boolean): boolean;
  46135. /**
  46136. * Detach the feature from the session
  46137. * Will usually be called by the features manager
  46138. *
  46139. * @returns true if successful.
  46140. */
  46141. detach(): boolean;
  46142. }
  46143. /**
  46144. * A list of the currently available features without referencing them
  46145. */
  46146. export class WebXRFeatureName {
  46147. /**
  46148. * The name of the anchor system feature
  46149. */
  46150. static ANCHOR_SYSTEM: string;
  46151. /**
  46152. * The name of the background remover feature
  46153. */
  46154. static BACKGROUND_REMOVER: string;
  46155. /**
  46156. * The name of the hit test feature
  46157. */
  46158. static HIT_TEST: string;
  46159. /**
  46160. * physics impostors for xr controllers feature
  46161. */
  46162. static PHYSICS_CONTROLLERS: string;
  46163. /**
  46164. * The name of the plane detection feature
  46165. */
  46166. static PLANE_DETECTION: string;
  46167. /**
  46168. * The name of the pointer selection feature
  46169. */
  46170. static POINTER_SELECTION: string;
  46171. /**
  46172. * The name of the teleportation feature
  46173. */
  46174. static TELEPORTATION: string;
  46175. }
  46176. /**
  46177. * Defining the constructor of a feature. Used to register the modules.
  46178. */
  46179. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46180. /**
  46181. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46182. * It is mainly used in AR sessions.
  46183. *
  46184. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46185. */
  46186. export class WebXRFeaturesManager implements IDisposable {
  46187. private _xrSessionManager;
  46188. private static readonly _AvailableFeatures;
  46189. private _features;
  46190. /**
  46191. * constructs a new features manages.
  46192. *
  46193. * @param _xrSessionManager an instance of WebXRSessionManager
  46194. */
  46195. constructor(_xrSessionManager: WebXRSessionManager);
  46196. /**
  46197. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46198. * Mainly used internally.
  46199. *
  46200. * @param featureName the name of the feature to register
  46201. * @param constructorFunction the function used to construct the module
  46202. * @param version the (babylon) version of the module
  46203. * @param stable is that a stable version of this module
  46204. */
  46205. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46206. /**
  46207. * Returns a constructor of a specific feature.
  46208. *
  46209. * @param featureName the name of the feature to construct
  46210. * @param version the version of the feature to load
  46211. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46212. * @param options optional options provided to the module.
  46213. * @returns a function that, when called, will return a new instance of this feature
  46214. */
  46215. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46216. /**
  46217. * Can be used to return the list of features currently registered
  46218. *
  46219. * @returns an Array of available features
  46220. */
  46221. static GetAvailableFeatures(): string[];
  46222. /**
  46223. * Gets the versions available for a specific feature
  46224. * @param featureName the name of the feature
  46225. * @returns an array with the available versions
  46226. */
  46227. static GetAvailableVersions(featureName: string): string[];
  46228. /**
  46229. * Return the latest unstable 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 GetLatestVersionOfFeature(featureName: string): number;
  46234. /**
  46235. * Return the latest stable version of this feature
  46236. * @param featureName the name of the feature to search
  46237. * @returns the version number. if not found will return -1
  46238. */
  46239. static GetStableVersionOfFeature(featureName: string): number;
  46240. /**
  46241. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46242. * Can be used during a session to start a feature
  46243. * @param featureName the name of feature to attach
  46244. */
  46245. attachFeature(featureName: string): void;
  46246. /**
  46247. * Can be used inside a session or when the session ends to detach a specific feature
  46248. * @param featureName the name of the feature to detach
  46249. */
  46250. detachFeature(featureName: string): void;
  46251. /**
  46252. * Used to disable an already-enabled feature
  46253. * The feature will be disposed and will be recreated once enabled.
  46254. * @param featureName the feature to disable
  46255. * @returns true if disable was successful
  46256. */
  46257. disableFeature(featureName: string | {
  46258. Name: string;
  46259. }): boolean;
  46260. /**
  46261. * dispose this features manager
  46262. */
  46263. dispose(): void;
  46264. /**
  46265. * 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.
  46266. * 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.
  46267. *
  46268. * @param featureName the name of the feature to load or the class of the feature
  46269. * @param version optional version to load. if not provided the latest version will be enabled
  46270. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46271. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46272. * @returns a new constructed feature or throws an error if feature not found.
  46273. */
  46274. enableFeature(featureName: string | {
  46275. Name: string;
  46276. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46277. /**
  46278. * get the implementation of an enabled feature.
  46279. * @param featureName the name of the feature to load
  46280. * @returns the feature class, if found
  46281. */
  46282. getEnabledFeature(featureName: string): IWebXRFeature;
  46283. /**
  46284. * Get the list of enabled features
  46285. * @returns an array of enabled features
  46286. */
  46287. getEnabledFeatures(): string[];
  46288. }
  46289. }
  46290. declare module BABYLON {
  46291. /**
  46292. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46293. * @see https://doc.babylonjs.com/how_to/webxr
  46294. */
  46295. export class WebXRExperienceHelper implements IDisposable {
  46296. private scene;
  46297. private _nonVRCamera;
  46298. private _originalSceneAutoClear;
  46299. private _supported;
  46300. /**
  46301. * Camera used to render xr content
  46302. */
  46303. camera: WebXRCamera;
  46304. /** A features manager for this xr session */
  46305. featuresManager: WebXRFeaturesManager;
  46306. /**
  46307. * Observers registered here will be triggered after the camera's initial transformation is set
  46308. * This can be used to set a different ground level or an extra rotation.
  46309. *
  46310. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46311. * to the position set after this observable is done executing.
  46312. */
  46313. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46314. /**
  46315. * Fires when the state of the experience helper has changed
  46316. */
  46317. onStateChangedObservable: Observable<WebXRState>;
  46318. /** Session manager used to keep track of xr session */
  46319. sessionManager: WebXRSessionManager;
  46320. /**
  46321. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46322. */
  46323. state: WebXRState;
  46324. /**
  46325. * Creates a WebXRExperienceHelper
  46326. * @param scene The scene the helper should be created in
  46327. */
  46328. private constructor();
  46329. /**
  46330. * Creates the experience helper
  46331. * @param scene the scene to attach the experience helper to
  46332. * @returns a promise for the experience helper
  46333. */
  46334. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46335. /**
  46336. * Disposes of the experience helper
  46337. */
  46338. dispose(): void;
  46339. /**
  46340. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46341. * @param sessionMode options for the XR session
  46342. * @param referenceSpaceType frame of reference of the XR session
  46343. * @param renderTarget the output canvas that will be used to enter XR mode
  46344. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46345. * @returns promise that resolves after xr mode has entered
  46346. */
  46347. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46348. /**
  46349. * Exits XR mode and returns the scene to its original state
  46350. * @returns promise that resolves after xr mode has exited
  46351. */
  46352. exitXRAsync(): Promise<void>;
  46353. private _nonXRToXRCamera;
  46354. private _setState;
  46355. }
  46356. }
  46357. declare module BABYLON {
  46358. /**
  46359. * X-Y values for axes in WebXR
  46360. */
  46361. export interface IWebXRMotionControllerAxesValue {
  46362. /**
  46363. * The value of the x axis
  46364. */
  46365. x: number;
  46366. /**
  46367. * The value of the y-axis
  46368. */
  46369. y: number;
  46370. }
  46371. /**
  46372. * changed / previous values for the values of this component
  46373. */
  46374. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46375. /**
  46376. * current (this frame) value
  46377. */
  46378. current: T;
  46379. /**
  46380. * previous (last change) value
  46381. */
  46382. previous: T;
  46383. }
  46384. /**
  46385. * Represents changes in the component between current frame and last values recorded
  46386. */
  46387. export interface IWebXRMotionControllerComponentChanges {
  46388. /**
  46389. * will be populated with previous and current values if axes changed
  46390. */
  46391. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46392. /**
  46393. * will be populated with previous and current values if pressed changed
  46394. */
  46395. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46396. /**
  46397. * will be populated with previous and current values if touched changed
  46398. */
  46399. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46400. /**
  46401. * will be populated with previous and current values if value changed
  46402. */
  46403. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46404. }
  46405. /**
  46406. * This class represents a single component (for example button or thumbstick) of a motion controller
  46407. */
  46408. export class WebXRControllerComponent implements IDisposable {
  46409. /**
  46410. * the id of this component
  46411. */
  46412. id: string;
  46413. /**
  46414. * the type of the component
  46415. */
  46416. type: MotionControllerComponentType;
  46417. private _buttonIndex;
  46418. private _axesIndices;
  46419. private _axes;
  46420. private _changes;
  46421. private _currentValue;
  46422. private _hasChanges;
  46423. private _pressed;
  46424. private _touched;
  46425. /**
  46426. * button component type
  46427. */
  46428. static BUTTON_TYPE: MotionControllerComponentType;
  46429. /**
  46430. * squeeze component type
  46431. */
  46432. static SQUEEZE_TYPE: MotionControllerComponentType;
  46433. /**
  46434. * Thumbstick component type
  46435. */
  46436. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46437. /**
  46438. * Touchpad component type
  46439. */
  46440. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46441. /**
  46442. * trigger component type
  46443. */
  46444. static TRIGGER_TYPE: MotionControllerComponentType;
  46445. /**
  46446. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46447. * the axes data changes
  46448. */
  46449. onAxisValueChangedObservable: Observable<{
  46450. x: number;
  46451. y: number;
  46452. }>;
  46453. /**
  46454. * Observers registered here will be triggered when the state of a button changes
  46455. * State change is either pressed / touched / value
  46456. */
  46457. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46458. /**
  46459. * Creates a new component for a motion controller.
  46460. * It is created by the motion controller itself
  46461. *
  46462. * @param id the id of this component
  46463. * @param type the type of the component
  46464. * @param _buttonIndex index in the buttons array of the gamepad
  46465. * @param _axesIndices indices of the values in the axes array of the gamepad
  46466. */
  46467. constructor(
  46468. /**
  46469. * the id of this component
  46470. */
  46471. id: string,
  46472. /**
  46473. * the type of the component
  46474. */
  46475. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46476. /**
  46477. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46478. */
  46479. get axes(): IWebXRMotionControllerAxesValue;
  46480. /**
  46481. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46482. */
  46483. get changes(): IWebXRMotionControllerComponentChanges;
  46484. /**
  46485. * Return whether or not the component changed the last frame
  46486. */
  46487. get hasChanges(): boolean;
  46488. /**
  46489. * is the button currently pressed
  46490. */
  46491. get pressed(): boolean;
  46492. /**
  46493. * is the button currently touched
  46494. */
  46495. get touched(): boolean;
  46496. /**
  46497. * Get the current value of this component
  46498. */
  46499. get value(): number;
  46500. /**
  46501. * Dispose this component
  46502. */
  46503. dispose(): void;
  46504. /**
  46505. * Are there axes correlating to this component
  46506. * @return true is axes data is available
  46507. */
  46508. isAxes(): boolean;
  46509. /**
  46510. * Is this component a button (hence - pressable)
  46511. * @returns true if can be pressed
  46512. */
  46513. isButton(): boolean;
  46514. /**
  46515. * update this component using the gamepad object it is in. Called on every frame
  46516. * @param nativeController the native gamepad controller object
  46517. */
  46518. update(nativeController: IMinimalMotionControllerObject): void;
  46519. }
  46520. }
  46521. declare module BABYLON {
  46522. /**
  46523. * Class used to represent data loading progression
  46524. */
  46525. export class SceneLoaderProgressEvent {
  46526. /** defines if data length to load can be evaluated */
  46527. readonly lengthComputable: boolean;
  46528. /** defines the loaded data length */
  46529. readonly loaded: number;
  46530. /** defines the data length to load */
  46531. readonly total: number;
  46532. /**
  46533. * Create a new progress event
  46534. * @param lengthComputable defines if data length to load can be evaluated
  46535. * @param loaded defines the loaded data length
  46536. * @param total defines the data length to load
  46537. */
  46538. constructor(
  46539. /** defines if data length to load can be evaluated */
  46540. lengthComputable: boolean,
  46541. /** defines the loaded data length */
  46542. loaded: number,
  46543. /** defines the data length to load */
  46544. total: number);
  46545. /**
  46546. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  46547. * @param event defines the source event
  46548. * @returns a new SceneLoaderProgressEvent
  46549. */
  46550. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  46551. }
  46552. /**
  46553. * Interface used by SceneLoader plugins to define supported file extensions
  46554. */
  46555. export interface ISceneLoaderPluginExtensions {
  46556. /**
  46557. * Defines the list of supported extensions
  46558. */
  46559. [extension: string]: {
  46560. isBinary: boolean;
  46561. };
  46562. }
  46563. /**
  46564. * Interface used by SceneLoader plugin factory
  46565. */
  46566. export interface ISceneLoaderPluginFactory {
  46567. /**
  46568. * Defines the name of the factory
  46569. */
  46570. name: string;
  46571. /**
  46572. * Function called to create a new plugin
  46573. * @return the new plugin
  46574. */
  46575. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46576. /**
  46577. * The callback that returns true if the data can be directly loaded.
  46578. * @param data string containing the file data
  46579. * @returns if the data can be loaded directly
  46580. */
  46581. canDirectLoad?(data: string): boolean;
  46582. }
  46583. /**
  46584. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46585. */
  46586. export interface ISceneLoaderPluginBase {
  46587. /**
  46588. * The friendly name of this plugin.
  46589. */
  46590. name: string;
  46591. /**
  46592. * The file extensions supported by this plugin.
  46593. */
  46594. extensions: string | ISceneLoaderPluginExtensions;
  46595. /**
  46596. * The callback called when loading from a url.
  46597. * @param scene scene loading this url
  46598. * @param url url to load
  46599. * @param onSuccess callback called when the file successfully loads
  46600. * @param onProgress callback called while file is loading (if the server supports this mode)
  46601. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46602. * @param onError callback called when the file fails to load
  46603. * @returns a file request object
  46604. */
  46605. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46606. /**
  46607. * The callback called when loading from a file object.
  46608. * @param scene scene loading this file
  46609. * @param file defines the file to load
  46610. * @param onSuccess defines the callback to call when data is loaded
  46611. * @param onProgress defines the callback to call during loading process
  46612. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46613. * @param onError defines the callback to call when an error occurs
  46614. * @returns a file request object
  46615. */
  46616. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46617. /**
  46618. * The callback that returns true if the data can be directly loaded.
  46619. * @param data string containing the file data
  46620. * @returns if the data can be loaded directly
  46621. */
  46622. canDirectLoad?(data: string): boolean;
  46623. /**
  46624. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46625. * @param scene scene loading this data
  46626. * @param data string containing the data
  46627. * @returns data to pass to the plugin
  46628. */
  46629. directLoad?(scene: Scene, data: string): any;
  46630. /**
  46631. * The callback that allows custom handling of the root url based on the response url.
  46632. * @param rootUrl the original root url
  46633. * @param responseURL the response url if available
  46634. * @returns the new root url
  46635. */
  46636. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46637. }
  46638. /**
  46639. * Interface used to define a SceneLoader plugin
  46640. */
  46641. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46642. /**
  46643. * Import meshes into a scene.
  46644. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46645. * @param scene The scene to import into
  46646. * @param data The data to import
  46647. * @param rootUrl The root url for scene and resources
  46648. * @param meshes The meshes array to import into
  46649. * @param particleSystems The particle systems array to import into
  46650. * @param skeletons The skeletons array to import into
  46651. * @param onError The callback when import fails
  46652. * @returns True if successful or false otherwise
  46653. */
  46654. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46655. /**
  46656. * Load into a scene.
  46657. * @param scene The scene to load into
  46658. * @param data The data to import
  46659. * @param rootUrl The root url for scene and resources
  46660. * @param onError The callback when import fails
  46661. * @returns True if successful or false otherwise
  46662. */
  46663. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46664. /**
  46665. * Load into an asset container.
  46666. * @param scene The scene to load into
  46667. * @param data The data to import
  46668. * @param rootUrl The root url for scene and resources
  46669. * @param onError The callback when import fails
  46670. * @returns The loaded asset container
  46671. */
  46672. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46673. }
  46674. /**
  46675. * Interface used to define an async SceneLoader plugin
  46676. */
  46677. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46678. /**
  46679. * Import meshes into a scene.
  46680. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46681. * @param scene The scene to import into
  46682. * @param data The data to import
  46683. * @param rootUrl The root url for scene and resources
  46684. * @param onProgress The callback when the load progresses
  46685. * @param fileName Defines the name of the file to load
  46686. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46687. */
  46688. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46689. meshes: AbstractMesh[];
  46690. particleSystems: IParticleSystem[];
  46691. skeletons: Skeleton[];
  46692. animationGroups: AnimationGroup[];
  46693. }>;
  46694. /**
  46695. * Load into a scene.
  46696. * @param scene The scene to load into
  46697. * @param data The data to import
  46698. * @param rootUrl The root url for scene and resources
  46699. * @param onProgress The callback when the load progresses
  46700. * @param fileName Defines the name of the file to load
  46701. * @returns Nothing
  46702. */
  46703. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46704. /**
  46705. * Load into an asset container.
  46706. * @param scene The scene to load into
  46707. * @param data The data to import
  46708. * @param rootUrl The root url for scene and resources
  46709. * @param onProgress The callback when the load progresses
  46710. * @param fileName Defines the name of the file to load
  46711. * @returns The loaded asset container
  46712. */
  46713. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46714. }
  46715. /**
  46716. * Mode that determines how to handle old animation groups before loading new ones.
  46717. */
  46718. export enum SceneLoaderAnimationGroupLoadingMode {
  46719. /**
  46720. * Reset all old animations to initial state then dispose them.
  46721. */
  46722. Clean = 0,
  46723. /**
  46724. * Stop all old animations.
  46725. */
  46726. Stop = 1,
  46727. /**
  46728. * Restart old animations from first frame.
  46729. */
  46730. Sync = 2,
  46731. /**
  46732. * Old animations remains untouched.
  46733. */
  46734. NoSync = 3
  46735. }
  46736. /**
  46737. * Class used to load scene from various file formats using registered plugins
  46738. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  46739. */
  46740. export class SceneLoader {
  46741. /**
  46742. * No logging while loading
  46743. */
  46744. static readonly NO_LOGGING: number;
  46745. /**
  46746. * Minimal logging while loading
  46747. */
  46748. static readonly MINIMAL_LOGGING: number;
  46749. /**
  46750. * Summary logging while loading
  46751. */
  46752. static readonly SUMMARY_LOGGING: number;
  46753. /**
  46754. * Detailled logging while loading
  46755. */
  46756. static readonly DETAILED_LOGGING: number;
  46757. /**
  46758. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46759. */
  46760. static get ForceFullSceneLoadingForIncremental(): boolean;
  46761. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46762. /**
  46763. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46764. */
  46765. static get ShowLoadingScreen(): boolean;
  46766. static set ShowLoadingScreen(value: boolean);
  46767. /**
  46768. * Defines the current logging level (while loading the scene)
  46769. * @ignorenaming
  46770. */
  46771. static get loggingLevel(): number;
  46772. static set loggingLevel(value: number);
  46773. /**
  46774. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  46775. */
  46776. static get CleanBoneMatrixWeights(): boolean;
  46777. static set CleanBoneMatrixWeights(value: boolean);
  46778. /**
  46779. * Event raised when a plugin is used to load a scene
  46780. */
  46781. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  46782. private static _registeredPlugins;
  46783. private static _getDefaultPlugin;
  46784. private static _getPluginForExtension;
  46785. private static _getPluginForDirectLoad;
  46786. private static _getPluginForFilename;
  46787. private static _getDirectLoad;
  46788. private static _loadData;
  46789. private static _getFileInfo;
  46790. /**
  46791. * Gets a plugin that can load the given extension
  46792. * @param extension defines the extension to load
  46793. * @returns a plugin or null if none works
  46794. */
  46795. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  46796. /**
  46797. * Gets a boolean indicating that the given extension can be loaded
  46798. * @param extension defines the extension to load
  46799. * @returns true if the extension is supported
  46800. */
  46801. static IsPluginForExtensionAvailable(extension: string): boolean;
  46802. /**
  46803. * Adds a new plugin to the list of registered plugins
  46804. * @param plugin defines the plugin to add
  46805. */
  46806. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  46807. /**
  46808. * Import meshes into a scene
  46809. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46810. * @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)
  46811. * @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)
  46812. * @param scene the instance of BABYLON.Scene to append to
  46813. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  46814. * @param onProgress a callback with a progress event for each file being loaded
  46815. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46816. * @param pluginExtension the extension used to determine the plugin
  46817. * @returns The loaded plugin
  46818. */
  46819. 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>;
  46820. /**
  46821. * Import meshes into a scene
  46822. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46823. * @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)
  46824. * @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)
  46825. * @param scene the instance of BABYLON.Scene to append to
  46826. * @param onProgress a callback with a progress event for each file being loaded
  46827. * @param pluginExtension the extension used to determine the plugin
  46828. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  46829. */
  46830. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  46831. meshes: AbstractMesh[];
  46832. particleSystems: IParticleSystem[];
  46833. skeletons: Skeleton[];
  46834. animationGroups: AnimationGroup[];
  46835. }>;
  46836. /**
  46837. * Load a scene
  46838. * @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)
  46839. * @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)
  46840. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46841. * @param onSuccess a callback with the scene when import succeeds
  46842. * @param onProgress a callback with a progress event for each file being loaded
  46843. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46844. * @param pluginExtension the extension used to determine the plugin
  46845. * @returns The loaded plugin
  46846. */
  46847. 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>;
  46848. /**
  46849. * Load a scene
  46850. * @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)
  46851. * @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)
  46852. * @param engine is the instance of BABYLON.Engine to use to create the scene
  46853. * @param onProgress a callback with a progress event for each file being loaded
  46854. * @param pluginExtension the extension used to determine the plugin
  46855. * @returns The loaded scene
  46856. */
  46857. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46858. /**
  46859. * Append a scene
  46860. * @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)
  46861. * @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)
  46862. * @param scene is the instance of BABYLON.Scene to append to
  46863. * @param onSuccess a callback with the scene when import succeeds
  46864. * @param onProgress a callback with a progress event for each file being loaded
  46865. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46866. * @param pluginExtension the extension used to determine the plugin
  46867. * @returns The loaded plugin
  46868. */
  46869. 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>;
  46870. /**
  46871. * Append a scene
  46872. * @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)
  46873. * @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)
  46874. * @param scene is the instance of BABYLON.Scene to append to
  46875. * @param onProgress a callback with a progress event for each file being loaded
  46876. * @param pluginExtension the extension used to determine the plugin
  46877. * @returns The given scene
  46878. */
  46879. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  46880. /**
  46881. * Load a scene into an asset container
  46882. * @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)
  46883. * @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)
  46884. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46885. * @param onSuccess a callback with the scene when import succeeds
  46886. * @param onProgress a callback with a progress event for each file being loaded
  46887. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46888. * @param pluginExtension the extension used to determine the plugin
  46889. * @returns The loaded plugin
  46890. */
  46891. 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>;
  46892. /**
  46893. * Load a scene into an asset container
  46894. * @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)
  46895. * @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)
  46896. * @param scene is the instance of Scene to append to
  46897. * @param onProgress a callback with a progress event for each file being loaded
  46898. * @param pluginExtension the extension used to determine the plugin
  46899. * @returns The loaded asset container
  46900. */
  46901. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  46902. /**
  46903. * Import animations from a file into a scene
  46904. * @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)
  46905. * @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)
  46906. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46907. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46908. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46909. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46910. * @param onSuccess a callback with the scene when import succeeds
  46911. * @param onProgress a callback with a progress event for each file being loaded
  46912. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46913. */
  46914. 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;
  46915. /**
  46916. * Import animations from a file into a scene
  46917. * @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)
  46918. * @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)
  46919. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46920. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  46921. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  46922. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  46923. * @param onSuccess a callback with the scene when import succeeds
  46924. * @param onProgress a callback with a progress event for each file being loaded
  46925. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  46926. * @returns the updated scene with imported animations
  46927. */
  46928. 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>;
  46929. }
  46930. }
  46931. declare module BABYLON {
  46932. /**
  46933. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  46934. */
  46935. export type MotionControllerHandedness = "none" | "left" | "right";
  46936. /**
  46937. * The type of components available in motion controllers.
  46938. * This is not the name of the component.
  46939. */
  46940. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  46941. /**
  46942. * The state of a controller component
  46943. */
  46944. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  46945. /**
  46946. * The schema of motion controller layout.
  46947. * No object will be initialized using this interface
  46948. * This is used just to define the profile.
  46949. */
  46950. export interface IMotionControllerLayout {
  46951. /**
  46952. * Path to load the assets. Usually relative to the base path
  46953. */
  46954. assetPath: string;
  46955. /**
  46956. * Available components (unsorted)
  46957. */
  46958. components: {
  46959. /**
  46960. * A map of component Ids
  46961. */
  46962. [componentId: string]: {
  46963. /**
  46964. * The type of input the component outputs
  46965. */
  46966. type: MotionControllerComponentType;
  46967. /**
  46968. * The indices of this component in the gamepad object
  46969. */
  46970. gamepadIndices: {
  46971. /**
  46972. * Index of button
  46973. */
  46974. button?: number;
  46975. /**
  46976. * If available, index of x-axis
  46977. */
  46978. xAxis?: number;
  46979. /**
  46980. * If available, index of y-axis
  46981. */
  46982. yAxis?: number;
  46983. };
  46984. /**
  46985. * The mesh's root node name
  46986. */
  46987. rootNodeName: string;
  46988. /**
  46989. * Animation definitions for this model
  46990. */
  46991. visualResponses: {
  46992. [stateKey: string]: {
  46993. /**
  46994. * What property will be animated
  46995. */
  46996. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  46997. /**
  46998. * What states influence this visual response
  46999. */
  47000. states: MotionControllerComponentStateType[];
  47001. /**
  47002. * Type of animation - movement or visibility
  47003. */
  47004. valueNodeProperty: "transform" | "visibility";
  47005. /**
  47006. * Base node name to move. Its position will be calculated according to the min and max nodes
  47007. */
  47008. valueNodeName?: string;
  47009. /**
  47010. * Minimum movement node
  47011. */
  47012. minNodeName?: string;
  47013. /**
  47014. * Max movement node
  47015. */
  47016. maxNodeName?: string;
  47017. };
  47018. };
  47019. /**
  47020. * If touch enabled, what is the name of node to display user feedback
  47021. */
  47022. touchPointNodeName?: string;
  47023. };
  47024. };
  47025. /**
  47026. * Is it xr standard mapping or not
  47027. */
  47028. gamepadMapping: "" | "xr-standard";
  47029. /**
  47030. * Base root node of this entire model
  47031. */
  47032. rootNodeName: string;
  47033. /**
  47034. * Defines the main button component id
  47035. */
  47036. selectComponentId: string;
  47037. }
  47038. /**
  47039. * A definition for the layout map in the input profile
  47040. */
  47041. export interface IMotionControllerLayoutMap {
  47042. /**
  47043. * Layouts with handedness type as a key
  47044. */
  47045. [handedness: string]: IMotionControllerLayout;
  47046. }
  47047. /**
  47048. * The XR Input profile schema
  47049. * Profiles can be found here:
  47050. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47051. */
  47052. export interface IMotionControllerProfile {
  47053. /**
  47054. * fallback profiles for this profileId
  47055. */
  47056. fallbackProfileIds: string[];
  47057. /**
  47058. * The layout map, with handedness as key
  47059. */
  47060. layouts: IMotionControllerLayoutMap;
  47061. /**
  47062. * The id of this profile
  47063. * correlates to the profile(s) in the xrInput.profiles array
  47064. */
  47065. profileId: string;
  47066. }
  47067. /**
  47068. * A helper-interface for the 3 meshes needed for controller button animation
  47069. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47070. */
  47071. export interface IMotionControllerButtonMeshMap {
  47072. /**
  47073. * the mesh that defines the pressed value mesh position.
  47074. * This is used to find the max-position of this button
  47075. */
  47076. pressedMesh: AbstractMesh;
  47077. /**
  47078. * the mesh that defines the unpressed value mesh position.
  47079. * This is used to find the min (or initial) position of this button
  47080. */
  47081. unpressedMesh: AbstractMesh;
  47082. /**
  47083. * The mesh that will be changed when value changes
  47084. */
  47085. valueMesh: AbstractMesh;
  47086. }
  47087. /**
  47088. * A helper-interface for the 3 meshes needed for controller axis animation.
  47089. * This will be expanded when touchpad animations are fully supported
  47090. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47091. */
  47092. export interface IMotionControllerMeshMap {
  47093. /**
  47094. * the mesh that defines the maximum value mesh position.
  47095. */
  47096. maxMesh?: AbstractMesh;
  47097. /**
  47098. * the mesh that defines the minimum value mesh position.
  47099. */
  47100. minMesh?: AbstractMesh;
  47101. /**
  47102. * The mesh that will be changed when axis value changes
  47103. */
  47104. valueMesh: AbstractMesh;
  47105. }
  47106. /**
  47107. * The elements needed for change-detection of the gamepad objects in motion controllers
  47108. */
  47109. export interface IMinimalMotionControllerObject {
  47110. /**
  47111. * Available axes of this controller
  47112. */
  47113. axes: number[];
  47114. /**
  47115. * An array of available buttons
  47116. */
  47117. buttons: Array<{
  47118. /**
  47119. * Value of the button/trigger
  47120. */
  47121. value: number;
  47122. /**
  47123. * If the button/trigger is currently touched
  47124. */
  47125. touched: boolean;
  47126. /**
  47127. * If the button/trigger is currently pressed
  47128. */
  47129. pressed: boolean;
  47130. }>;
  47131. /**
  47132. * EXPERIMENTAL haptic support.
  47133. */
  47134. hapticActuators?: Array<{
  47135. pulse: (value: number, duration: number) => Promise<boolean>;
  47136. }>;
  47137. }
  47138. /**
  47139. * An Abstract Motion controller
  47140. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47141. * Each component has an observable to check for changes in value and state
  47142. */
  47143. export abstract class WebXRAbstractMotionController implements IDisposable {
  47144. protected scene: Scene;
  47145. protected layout: IMotionControllerLayout;
  47146. /**
  47147. * The gamepad object correlating to this controller
  47148. */
  47149. gamepadObject: IMinimalMotionControllerObject;
  47150. /**
  47151. * handedness (left/right/none) of this controller
  47152. */
  47153. handedness: MotionControllerHandedness;
  47154. private _initComponent;
  47155. private _modelReady;
  47156. /**
  47157. * A map of components (WebXRControllerComponent) in this motion controller
  47158. * Components have a ComponentType and can also have both button and axis definitions
  47159. */
  47160. readonly components: {
  47161. [id: string]: WebXRControllerComponent;
  47162. };
  47163. /**
  47164. * Disable the model's animation. Can be set at any time.
  47165. */
  47166. disableAnimation: boolean;
  47167. /**
  47168. * Observers registered here will be triggered when the model of this controller is done loading
  47169. */
  47170. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47171. /**
  47172. * The profile id of this motion controller
  47173. */
  47174. abstract profileId: string;
  47175. /**
  47176. * The root mesh of the model. It is null if the model was not yet initialized
  47177. */
  47178. rootMesh: Nullable<AbstractMesh>;
  47179. /**
  47180. * constructs a new abstract motion controller
  47181. * @param scene the scene to which the model of the controller will be added
  47182. * @param layout The profile layout to load
  47183. * @param gamepadObject The gamepad object correlating to this controller
  47184. * @param handedness handedness (left/right/none) of this controller
  47185. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47186. */
  47187. constructor(scene: Scene, layout: IMotionControllerLayout,
  47188. /**
  47189. * The gamepad object correlating to this controller
  47190. */
  47191. gamepadObject: IMinimalMotionControllerObject,
  47192. /**
  47193. * handedness (left/right/none) of this controller
  47194. */
  47195. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47196. /**
  47197. * Dispose this controller, the model mesh and all its components
  47198. */
  47199. dispose(): void;
  47200. /**
  47201. * Returns all components of specific type
  47202. * @param type the type to search for
  47203. * @return an array of components with this type
  47204. */
  47205. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47206. /**
  47207. * get a component based an its component id as defined in layout.components
  47208. * @param id the id of the component
  47209. * @returns the component correlates to the id or undefined if not found
  47210. */
  47211. getComponent(id: string): WebXRControllerComponent;
  47212. /**
  47213. * Get the list of components available in this motion controller
  47214. * @returns an array of strings correlating to available components
  47215. */
  47216. getComponentIds(): string[];
  47217. /**
  47218. * Get the first component of specific type
  47219. * @param type type of component to find
  47220. * @return a controller component or null if not found
  47221. */
  47222. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47223. /**
  47224. * Get the main (Select) component of this controller as defined in the layout
  47225. * @returns the main component of this controller
  47226. */
  47227. getMainComponent(): WebXRControllerComponent;
  47228. /**
  47229. * Loads the model correlating to this controller
  47230. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47231. * @returns A promise fulfilled with the result of the model loading
  47232. */
  47233. loadModel(): Promise<boolean>;
  47234. /**
  47235. * Update this model using the current XRFrame
  47236. * @param xrFrame the current xr frame to use and update the model
  47237. */
  47238. updateFromXRFrame(xrFrame: XRFrame): void;
  47239. /**
  47240. * Backwards compatibility due to a deeply-integrated typo
  47241. */
  47242. get handness(): XREye;
  47243. /**
  47244. * Pulse (vibrate) this controller
  47245. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47246. * Consecutive calls to this function will cancel the last pulse call
  47247. *
  47248. * @param value the strength of the pulse in 0.0...1.0 range
  47249. * @param duration Duration of the pulse in milliseconds
  47250. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47251. * @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
  47252. */
  47253. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47254. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47255. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47256. /**
  47257. * Moves the axis on the controller mesh based on its current state
  47258. * @param axis the index of the axis
  47259. * @param axisValue the value of the axis which determines the meshes new position
  47260. * @hidden
  47261. */
  47262. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47263. /**
  47264. * Update the model itself with the current frame data
  47265. * @param xrFrame the frame to use for updating the model mesh
  47266. */
  47267. protected updateModel(xrFrame: XRFrame): void;
  47268. /**
  47269. * Get the filename and path for this controller's model
  47270. * @returns a map of filename and path
  47271. */
  47272. protected abstract _getFilenameAndPath(): {
  47273. filename: string;
  47274. path: string;
  47275. };
  47276. /**
  47277. * This function is called before the mesh is loaded. It checks for loading constraints.
  47278. * For example, this function can check if the GLB loader is available
  47279. * If this function returns false, the generic controller will be loaded instead
  47280. * @returns Is the client ready to load the mesh
  47281. */
  47282. protected abstract _getModelLoadingConstraints(): boolean;
  47283. /**
  47284. * This function will be called after the model was successfully loaded and can be used
  47285. * for mesh transformations before it is available for the user
  47286. * @param meshes the loaded meshes
  47287. */
  47288. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47289. /**
  47290. * Set the root mesh for this controller. Important for the WebXR controller class
  47291. * @param meshes the loaded meshes
  47292. */
  47293. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47294. /**
  47295. * A function executed each frame that updates the mesh (if needed)
  47296. * @param xrFrame the current xrFrame
  47297. */
  47298. protected abstract _updateModel(xrFrame: XRFrame): void;
  47299. private _getGenericFilenameAndPath;
  47300. private _getGenericParentMesh;
  47301. }
  47302. }
  47303. declare module BABYLON {
  47304. /**
  47305. * A generic trigger-only motion controller for WebXR
  47306. */
  47307. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47308. /**
  47309. * Static version of the profile id of this controller
  47310. */
  47311. static ProfileId: string;
  47312. profileId: string;
  47313. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47314. protected _getFilenameAndPath(): {
  47315. filename: string;
  47316. path: string;
  47317. };
  47318. protected _getModelLoadingConstraints(): boolean;
  47319. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47320. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47321. protected _updateModel(): void;
  47322. }
  47323. }
  47324. declare module BABYLON {
  47325. /**
  47326. * Class containing static functions to help procedurally build meshes
  47327. */
  47328. export class SphereBuilder {
  47329. /**
  47330. * Creates a sphere mesh
  47331. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47332. * * 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`)
  47333. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47334. * * 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
  47335. * * 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)
  47336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47337. * * 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
  47338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47339. * @param name defines the name of the mesh
  47340. * @param options defines the options used to create the mesh
  47341. * @param scene defines the hosting scene
  47342. * @returns the sphere mesh
  47343. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47344. */
  47345. static CreateSphere(name: string, options: {
  47346. segments?: number;
  47347. diameter?: number;
  47348. diameterX?: number;
  47349. diameterY?: number;
  47350. diameterZ?: number;
  47351. arc?: number;
  47352. slice?: number;
  47353. sideOrientation?: number;
  47354. frontUVs?: Vector4;
  47355. backUVs?: Vector4;
  47356. updatable?: boolean;
  47357. }, scene?: Nullable<Scene>): Mesh;
  47358. }
  47359. }
  47360. declare module BABYLON {
  47361. /**
  47362. * A profiled motion controller has its profile loaded from an online repository.
  47363. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47364. */
  47365. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47366. private _repositoryUrl;
  47367. private _buttonMeshMapping;
  47368. private _touchDots;
  47369. /**
  47370. * The profile ID of this controller. Will be populated when the controller initializes.
  47371. */
  47372. profileId: string;
  47373. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47374. dispose(): void;
  47375. protected _getFilenameAndPath(): {
  47376. filename: string;
  47377. path: string;
  47378. };
  47379. protected _getModelLoadingConstraints(): boolean;
  47380. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47381. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47382. protected _updateModel(_xrFrame: XRFrame): void;
  47383. }
  47384. }
  47385. declare module BABYLON {
  47386. /**
  47387. * A construction function type to create a new controller based on an xrInput object
  47388. */
  47389. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47390. /**
  47391. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47392. *
  47393. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47394. * it should be replaced with auto-loaded controllers.
  47395. *
  47396. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47397. */
  47398. export class WebXRMotionControllerManager {
  47399. private static _AvailableControllers;
  47400. private static _Fallbacks;
  47401. private static _ProfileLoadingPromises;
  47402. private static _ProfilesList;
  47403. /**
  47404. * The base URL of the online controller repository. Can be changed at any time.
  47405. */
  47406. static BaseRepositoryUrl: string;
  47407. /**
  47408. * Which repository gets priority - local or online
  47409. */
  47410. static PrioritizeOnlineRepository: boolean;
  47411. /**
  47412. * Use the online repository, or use only locally-defined controllers
  47413. */
  47414. static UseOnlineRepository: boolean;
  47415. /**
  47416. * Clear the cache used for profile loading and reload when requested again
  47417. */
  47418. static ClearProfilesCache(): void;
  47419. /**
  47420. * Register the default fallbacks.
  47421. * This function is called automatically when this file is imported.
  47422. */
  47423. static DefaultFallbacks(): void;
  47424. /**
  47425. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47426. * @param profileId the profile to which a fallback needs to be found
  47427. * @return an array with corresponding fallback profiles
  47428. */
  47429. static FindFallbackWithProfileId(profileId: string): string[];
  47430. /**
  47431. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47432. * The order of search:
  47433. *
  47434. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47435. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47436. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47437. * 4) return the generic trigger controller if none were found
  47438. *
  47439. * @param xrInput the xrInput to which a new controller is initialized
  47440. * @param scene the scene to which the model will be added
  47441. * @param forceProfile force a certain profile for this controller
  47442. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47443. */
  47444. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47445. /**
  47446. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47447. *
  47448. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47449. *
  47450. * @param type the profile type to register
  47451. * @param constructFunction the function to be called when loading this profile
  47452. */
  47453. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47454. /**
  47455. * Register a fallback to a specific profile.
  47456. * @param profileId the profileId that will receive the fallbacks
  47457. * @param fallbacks A list of fallback profiles
  47458. */
  47459. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47460. /**
  47461. * Will update the list of profiles available in the repository
  47462. * @return a promise that resolves to a map of profiles available online
  47463. */
  47464. static UpdateProfilesList(): Promise<{
  47465. [profile: string]: string;
  47466. }>;
  47467. private static _LoadProfileFromRepository;
  47468. private static _LoadProfilesFromAvailableControllers;
  47469. }
  47470. }
  47471. declare module BABYLON {
  47472. /**
  47473. * Configuration options for the WebXR controller creation
  47474. */
  47475. export interface IWebXRControllerOptions {
  47476. /**
  47477. * Should the controller mesh be animated when a user interacts with it
  47478. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47479. */
  47480. disableMotionControllerAnimation?: boolean;
  47481. /**
  47482. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47483. */
  47484. doNotLoadControllerMesh?: boolean;
  47485. /**
  47486. * Force a specific controller type for this controller.
  47487. * This can be used when creating your own profile or when testing different controllers
  47488. */
  47489. forceControllerProfile?: string;
  47490. /**
  47491. * Defines a rendering group ID for meshes that will be loaded.
  47492. * This is for the default controllers only.
  47493. */
  47494. renderingGroupId?: number;
  47495. }
  47496. /**
  47497. * Represents an XR controller
  47498. */
  47499. export class WebXRInputSource {
  47500. private _scene;
  47501. /** The underlying input source for the controller */
  47502. inputSource: XRInputSource;
  47503. private _options;
  47504. private _tmpVector;
  47505. private _uniqueId;
  47506. /**
  47507. * 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
  47508. */
  47509. grip?: AbstractMesh;
  47510. /**
  47511. * If available, this is the gamepad object related to this controller.
  47512. * Using this object it is possible to get click events and trackpad changes of the
  47513. * webxr controller that is currently being used.
  47514. */
  47515. motionController?: WebXRAbstractMotionController;
  47516. /**
  47517. * Event that fires when the controller is removed/disposed.
  47518. * The object provided as event data is this controller, after associated assets were disposed.
  47519. * uniqueId is still available.
  47520. */
  47521. onDisposeObservable: Observable<WebXRInputSource>;
  47522. /**
  47523. * Will be triggered when the mesh associated with the motion controller is done loading.
  47524. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47525. * A shortened version of controller -> motion controller -> on mesh loaded.
  47526. */
  47527. onMeshLoadedObservable: Observable<AbstractMesh>;
  47528. /**
  47529. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47530. */
  47531. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47532. /**
  47533. * Pointer which can be used to select objects or attach a visible laser to
  47534. */
  47535. pointer: AbstractMesh;
  47536. /**
  47537. * Creates the controller
  47538. * @see https://doc.babylonjs.com/how_to/webxr
  47539. * @param _scene the scene which the controller should be associated to
  47540. * @param inputSource the underlying input source for the controller
  47541. * @param _options options for this controller creation
  47542. */
  47543. constructor(_scene: Scene,
  47544. /** The underlying input source for the controller */
  47545. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47546. /**
  47547. * Get this controllers unique id
  47548. */
  47549. get uniqueId(): string;
  47550. /**
  47551. * Disposes of the object
  47552. */
  47553. dispose(): void;
  47554. /**
  47555. * Gets a world space ray coming from the pointer or grip
  47556. * @param result the resulting ray
  47557. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47558. */
  47559. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47560. /**
  47561. * Updates the controller pose based on the given XRFrame
  47562. * @param xrFrame xr frame to update the pose with
  47563. * @param referenceSpace reference space to use
  47564. */
  47565. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47566. }
  47567. }
  47568. declare module BABYLON {
  47569. /**
  47570. * The schema for initialization options of the XR Input class
  47571. */
  47572. export interface IWebXRInputOptions {
  47573. /**
  47574. * If set to true no model will be automatically loaded
  47575. */
  47576. doNotLoadControllerMeshes?: boolean;
  47577. /**
  47578. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47579. * If not found, the xr input profile data will be used.
  47580. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47581. */
  47582. forceInputProfile?: string;
  47583. /**
  47584. * Do not send a request to the controller repository to load the profile.
  47585. *
  47586. * Instead, use the controllers available in babylon itself.
  47587. */
  47588. disableOnlineControllerRepository?: boolean;
  47589. /**
  47590. * A custom URL for the controllers repository
  47591. */
  47592. customControllersRepositoryURL?: string;
  47593. /**
  47594. * Should the controller model's components not move according to the user input
  47595. */
  47596. disableControllerAnimation?: boolean;
  47597. /**
  47598. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47599. */
  47600. controllerOptions?: IWebXRControllerOptions;
  47601. }
  47602. /**
  47603. * XR input used to track XR inputs such as controllers/rays
  47604. */
  47605. export class WebXRInput implements IDisposable {
  47606. /**
  47607. * the xr session manager for this session
  47608. */
  47609. xrSessionManager: WebXRSessionManager;
  47610. /**
  47611. * the WebXR camera for this session. Mainly used for teleportation
  47612. */
  47613. xrCamera: WebXRCamera;
  47614. private readonly options;
  47615. /**
  47616. * XR controllers being tracked
  47617. */
  47618. controllers: Array<WebXRInputSource>;
  47619. private _frameObserver;
  47620. private _sessionEndedObserver;
  47621. private _sessionInitObserver;
  47622. /**
  47623. * Event when a controller has been connected/added
  47624. */
  47625. onControllerAddedObservable: Observable<WebXRInputSource>;
  47626. /**
  47627. * Event when a controller has been removed/disconnected
  47628. */
  47629. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47630. /**
  47631. * Initializes the WebXRInput
  47632. * @param xrSessionManager the xr session manager for this session
  47633. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47634. * @param options = initialization options for this xr input
  47635. */
  47636. constructor(
  47637. /**
  47638. * the xr session manager for this session
  47639. */
  47640. xrSessionManager: WebXRSessionManager,
  47641. /**
  47642. * the WebXR camera for this session. Mainly used for teleportation
  47643. */
  47644. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47645. private _onInputSourcesChange;
  47646. private _addAndRemoveControllers;
  47647. /**
  47648. * Disposes of the object
  47649. */
  47650. dispose(): void;
  47651. }
  47652. }
  47653. declare module BABYLON {
  47654. /**
  47655. * This is the base class for all WebXR features.
  47656. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47657. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47658. */
  47659. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47660. protected _xrSessionManager: WebXRSessionManager;
  47661. private _attached;
  47662. private _removeOnDetach;
  47663. /**
  47664. * Should auto-attach be disabled?
  47665. */
  47666. disableAutoAttach: boolean;
  47667. /**
  47668. * Construct a new (abstract) WebXR feature
  47669. * @param _xrSessionManager the xr session manager for this feature
  47670. */
  47671. constructor(_xrSessionManager: WebXRSessionManager);
  47672. /**
  47673. * Is this feature attached
  47674. */
  47675. get attached(): boolean;
  47676. /**
  47677. * attach this feature
  47678. *
  47679. * @param force should attachment be forced (even when already attached)
  47680. * @returns true if successful, false is failed or already attached
  47681. */
  47682. attach(force?: boolean): boolean;
  47683. /**
  47684. * detach this feature.
  47685. *
  47686. * @returns true if successful, false if failed or already detached
  47687. */
  47688. detach(): boolean;
  47689. /**
  47690. * Dispose this feature and all of the resources attached
  47691. */
  47692. dispose(): void;
  47693. /**
  47694. * This is used to register callbacks that will automatically be removed when detach is called.
  47695. * @param observable the observable to which the observer will be attached
  47696. * @param callback the callback to register
  47697. */
  47698. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47699. /**
  47700. * Code in this function will be executed on each xrFrame received from the browser.
  47701. * This function will not execute after the feature is detached.
  47702. * @param _xrFrame the current frame
  47703. */
  47704. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47705. }
  47706. }
  47707. declare module BABYLON {
  47708. /**
  47709. * Renders a layer on top of an existing scene
  47710. */
  47711. export class UtilityLayerRenderer implements IDisposable {
  47712. /** the original scene that will be rendered on top of */
  47713. originalScene: Scene;
  47714. private _pointerCaptures;
  47715. private _lastPointerEvents;
  47716. private static _DefaultUtilityLayer;
  47717. private static _DefaultKeepDepthUtilityLayer;
  47718. private _sharedGizmoLight;
  47719. private _renderCamera;
  47720. /**
  47721. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47722. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47723. * @returns the camera that is used when rendering the utility layer
  47724. */
  47725. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47726. /**
  47727. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47728. * @param cam the camera that should be used when rendering the utility layer
  47729. */
  47730. setRenderCamera(cam: Nullable<Camera>): void;
  47731. /**
  47732. * @hidden
  47733. * Light which used by gizmos to get light shading
  47734. */
  47735. _getSharedGizmoLight(): HemisphericLight;
  47736. /**
  47737. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47738. */
  47739. pickUtilitySceneFirst: boolean;
  47740. /**
  47741. * 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)
  47742. */
  47743. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47744. /**
  47745. * 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)
  47746. */
  47747. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47748. /**
  47749. * The scene that is rendered on top of the original scene
  47750. */
  47751. utilityLayerScene: Scene;
  47752. /**
  47753. * If the utility layer should automatically be rendered on top of existing scene
  47754. */
  47755. shouldRender: boolean;
  47756. /**
  47757. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47758. */
  47759. onlyCheckPointerDownEvents: boolean;
  47760. /**
  47761. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47762. */
  47763. processAllEvents: boolean;
  47764. /**
  47765. * Observable raised when the pointer move from the utility layer scene to the main scene
  47766. */
  47767. onPointerOutObservable: Observable<number>;
  47768. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47769. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47770. private _afterRenderObserver;
  47771. private _sceneDisposeObserver;
  47772. private _originalPointerObserver;
  47773. /**
  47774. * Instantiates a UtilityLayerRenderer
  47775. * @param originalScene the original scene that will be rendered on top of
  47776. * @param handleEvents boolean indicating if the utility layer should handle events
  47777. */
  47778. constructor(
  47779. /** the original scene that will be rendered on top of */
  47780. originalScene: Scene, handleEvents?: boolean);
  47781. private _notifyObservers;
  47782. /**
  47783. * Renders the utility layers scene on top of the original scene
  47784. */
  47785. render(): void;
  47786. /**
  47787. * Disposes of the renderer
  47788. */
  47789. dispose(): void;
  47790. private _updateCamera;
  47791. }
  47792. }
  47793. declare module BABYLON {
  47794. /**
  47795. * Options interface for the pointer selection module
  47796. */
  47797. export interface IWebXRControllerPointerSelectionOptions {
  47798. /**
  47799. * if provided, this scene will be used to render meshes.
  47800. */
  47801. customUtilityLayerScene?: Scene;
  47802. /**
  47803. * 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)
  47804. * If not disabled, the last picked point will be used to execute a pointer up event
  47805. * If disabled, pointer up event will be triggered right after the pointer down event.
  47806. * Used in screen and gaze target ray mode only
  47807. */
  47808. disablePointerUpOnTouchOut: boolean;
  47809. /**
  47810. * For gaze mode (time to select instead of press)
  47811. */
  47812. forceGazeMode: boolean;
  47813. /**
  47814. * 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
  47815. * to start a new countdown to the pointer down event.
  47816. * Defaults to 1.
  47817. */
  47818. gazeModePointerMovedFactor?: number;
  47819. /**
  47820. * Different button type to use instead of the main component
  47821. */
  47822. overrideButtonId?: string;
  47823. /**
  47824. * use this rendering group id for the meshes (optional)
  47825. */
  47826. renderingGroupId?: number;
  47827. /**
  47828. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  47829. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  47830. * 3000 means 3 seconds between pointing at something and selecting it
  47831. */
  47832. timeToSelect?: number;
  47833. /**
  47834. * Should meshes created here be added to a utility layer or the main scene
  47835. */
  47836. useUtilityLayer?: boolean;
  47837. /**
  47838. * the xr input to use with this pointer selection
  47839. */
  47840. xrInput: WebXRInput;
  47841. }
  47842. /**
  47843. * A module that will enable pointer selection for motion controllers of XR Input Sources
  47844. */
  47845. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  47846. private readonly _options;
  47847. private static _idCounter;
  47848. private _attachController;
  47849. private _controllers;
  47850. private _scene;
  47851. private _tmpVectorForPickCompare;
  47852. /**
  47853. * The module's name
  47854. */
  47855. static readonly Name: string;
  47856. /**
  47857. * The (Babylon) version of this module.
  47858. * This is an integer representing the implementation version.
  47859. * This number does not correspond to the WebXR specs version
  47860. */
  47861. static readonly Version: number;
  47862. /**
  47863. * Disable lighting on the laser pointer (so it will always be visible)
  47864. */
  47865. disablePointerLighting: boolean;
  47866. /**
  47867. * Disable lighting on the selection mesh (so it will always be visible)
  47868. */
  47869. disableSelectionMeshLighting: boolean;
  47870. /**
  47871. * Should the laser pointer be displayed
  47872. */
  47873. displayLaserPointer: boolean;
  47874. /**
  47875. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  47876. */
  47877. displaySelectionMesh: boolean;
  47878. /**
  47879. * This color will be set to the laser pointer when selection is triggered
  47880. */
  47881. laserPointerPickedColor: Color3;
  47882. /**
  47883. * Default color of the laser pointer
  47884. */
  47885. laserPointerDefaultColor: Color3;
  47886. /**
  47887. * default color of the selection ring
  47888. */
  47889. selectionMeshDefaultColor: Color3;
  47890. /**
  47891. * This color will be applied to the selection ring when selection is triggered
  47892. */
  47893. selectionMeshPickedColor: Color3;
  47894. /**
  47895. * Optional filter to be used for ray selection. This predicate shares behavior with
  47896. * scene.pointerMovePredicate which takes priority if it is also assigned.
  47897. */
  47898. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47899. /**
  47900. * constructs a new background remover module
  47901. * @param _xrSessionManager the session manager for this module
  47902. * @param _options read-only options to be used in this module
  47903. */
  47904. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  47905. /**
  47906. * attach this feature
  47907. * Will usually be called by the features manager
  47908. *
  47909. * @returns true if successful.
  47910. */
  47911. attach(): boolean;
  47912. /**
  47913. * detach this feature.
  47914. * Will usually be called by the features manager
  47915. *
  47916. * @returns true if successful.
  47917. */
  47918. detach(): boolean;
  47919. /**
  47920. * Will get the mesh under a specific pointer.
  47921. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  47922. * @param controllerId the controllerId to check
  47923. * @returns The mesh under pointer or null if no mesh is under the pointer
  47924. */
  47925. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  47926. /**
  47927. * Get the xr controller that correlates to the pointer id in the pointer event
  47928. *
  47929. * @param id the pointer id to search for
  47930. * @returns the controller that correlates to this id or null if not found
  47931. */
  47932. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  47933. protected _onXRFrame(_xrFrame: XRFrame): void;
  47934. private _attachGazeMode;
  47935. private _attachScreenRayMode;
  47936. private _attachTrackedPointerRayMode;
  47937. private _convertNormalToDirectionOfRay;
  47938. private _detachController;
  47939. private _generateNewMeshPair;
  47940. private _pickingMoved;
  47941. private _updatePointerDistance;
  47942. /** @hidden */
  47943. get lasterPointerDefaultColor(): Color3;
  47944. }
  47945. }
  47946. declare module BABYLON {
  47947. /**
  47948. * Button which can be used to enter a different mode of XR
  47949. */
  47950. export class WebXREnterExitUIButton {
  47951. /** button element */
  47952. element: HTMLElement;
  47953. /** XR initialization options for the button */
  47954. sessionMode: XRSessionMode;
  47955. /** Reference space type */
  47956. referenceSpaceType: XRReferenceSpaceType;
  47957. /**
  47958. * Creates a WebXREnterExitUIButton
  47959. * @param element button element
  47960. * @param sessionMode XR initialization session mode
  47961. * @param referenceSpaceType the type of reference space to be used
  47962. */
  47963. constructor(
  47964. /** button element */
  47965. element: HTMLElement,
  47966. /** XR initialization options for the button */
  47967. sessionMode: XRSessionMode,
  47968. /** Reference space type */
  47969. referenceSpaceType: XRReferenceSpaceType);
  47970. /**
  47971. * Extendable function which can be used to update the button's visuals when the state changes
  47972. * @param activeButton the current active button in the UI
  47973. */
  47974. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  47975. }
  47976. /**
  47977. * Options to create the webXR UI
  47978. */
  47979. export class WebXREnterExitUIOptions {
  47980. /**
  47981. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  47982. */
  47983. customButtons?: Array<WebXREnterExitUIButton>;
  47984. /**
  47985. * A reference space type to use when creating the default button.
  47986. * Default is local-floor
  47987. */
  47988. referenceSpaceType?: XRReferenceSpaceType;
  47989. /**
  47990. * Context to enter xr with
  47991. */
  47992. renderTarget?: Nullable<WebXRRenderTarget>;
  47993. /**
  47994. * A session mode to use when creating the default button.
  47995. * Default is immersive-vr
  47996. */
  47997. sessionMode?: XRSessionMode;
  47998. /**
  47999. * A list of optional features to init the session with
  48000. */
  48001. optionalFeatures?: string[];
  48002. }
  48003. /**
  48004. * UI to allow the user to enter/exit XR mode
  48005. */
  48006. export class WebXREnterExitUI implements IDisposable {
  48007. private scene;
  48008. /** version of the options passed to this UI */
  48009. options: WebXREnterExitUIOptions;
  48010. private _activeButton;
  48011. private _buttons;
  48012. private _overlay;
  48013. /**
  48014. * Fired every time the active button is changed.
  48015. *
  48016. * When xr is entered via a button that launches xr that button will be the callback parameter
  48017. *
  48018. * When exiting xr the callback parameter will be null)
  48019. */
  48020. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48021. /**
  48022. *
  48023. * @param scene babylon scene object to use
  48024. * @param options (read-only) version of the options passed to this UI
  48025. */
  48026. private constructor();
  48027. /**
  48028. * Creates UI to allow the user to enter/exit XR mode
  48029. * @param scene the scene to add the ui to
  48030. * @param helper the xr experience helper to enter/exit xr with
  48031. * @param options options to configure the UI
  48032. * @returns the created ui
  48033. */
  48034. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48035. /**
  48036. * Disposes of the XR UI component
  48037. */
  48038. dispose(): void;
  48039. private _updateButtons;
  48040. }
  48041. }
  48042. declare module BABYLON {
  48043. /**
  48044. * Class containing static functions to help procedurally build meshes
  48045. */
  48046. export class LinesBuilder {
  48047. /**
  48048. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48049. * * 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
  48050. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48051. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48052. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48053. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48054. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48055. * * 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
  48056. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48059. * @param name defines the name of the new line system
  48060. * @param options defines the options used to create the line system
  48061. * @param scene defines the hosting scene
  48062. * @returns a new line system mesh
  48063. */
  48064. static CreateLineSystem(name: string, options: {
  48065. lines: Vector3[][];
  48066. updatable?: boolean;
  48067. instance?: Nullable<LinesMesh>;
  48068. colors?: Nullable<Color4[][]>;
  48069. useVertexAlpha?: boolean;
  48070. }, scene: Nullable<Scene>): LinesMesh;
  48071. /**
  48072. * Creates a line mesh
  48073. * 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
  48074. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48075. * * The parameter `points` is an array successive Vector3
  48076. * * 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
  48077. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48078. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48079. * * When updating an instance, remember that only point positions can change, not the number of points
  48080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48082. * @param name defines the name of the new line system
  48083. * @param options defines the options used to create the line system
  48084. * @param scene defines the hosting scene
  48085. * @returns a new line mesh
  48086. */
  48087. static CreateLines(name: string, options: {
  48088. points: Vector3[];
  48089. updatable?: boolean;
  48090. instance?: Nullable<LinesMesh>;
  48091. colors?: Color4[];
  48092. useVertexAlpha?: boolean;
  48093. }, scene?: Nullable<Scene>): LinesMesh;
  48094. /**
  48095. * Creates a dashed line mesh
  48096. * * 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
  48097. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48098. * * The parameter `points` is an array successive Vector3
  48099. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48100. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48101. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48102. * * 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
  48103. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48104. * * When updating an instance, remember that only point positions can change, not the number of points
  48105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48106. * @param name defines the name of the mesh
  48107. * @param options defines the options used to create the mesh
  48108. * @param scene defines the hosting scene
  48109. * @returns the dashed line mesh
  48110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48111. */
  48112. static CreateDashedLines(name: string, options: {
  48113. points: Vector3[];
  48114. dashSize?: number;
  48115. gapSize?: number;
  48116. dashNb?: number;
  48117. updatable?: boolean;
  48118. instance?: LinesMesh;
  48119. useVertexAlpha?: boolean;
  48120. }, scene?: Nullable<Scene>): LinesMesh;
  48121. }
  48122. }
  48123. declare module BABYLON {
  48124. /**
  48125. * Construction options for a timer
  48126. */
  48127. export interface ITimerOptions<T> {
  48128. /**
  48129. * Time-to-end
  48130. */
  48131. timeout: number;
  48132. /**
  48133. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48134. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48135. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48136. */
  48137. contextObservable: Observable<T>;
  48138. /**
  48139. * Optional parameters when adding an observer to the observable
  48140. */
  48141. observableParameters?: {
  48142. mask?: number;
  48143. insertFirst?: boolean;
  48144. scope?: any;
  48145. };
  48146. /**
  48147. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48148. */
  48149. breakCondition?: (data?: ITimerData<T>) => boolean;
  48150. /**
  48151. * Will be triggered when the time condition has met
  48152. */
  48153. onEnded?: (data: ITimerData<any>) => void;
  48154. /**
  48155. * Will be triggered when the break condition has met (prematurely ended)
  48156. */
  48157. onAborted?: (data: ITimerData<any>) => void;
  48158. /**
  48159. * Optional function to execute on each tick (or count)
  48160. */
  48161. onTick?: (data: ITimerData<any>) => void;
  48162. }
  48163. /**
  48164. * An interface defining the data sent by the timer
  48165. */
  48166. export interface ITimerData<T> {
  48167. /**
  48168. * When did it start
  48169. */
  48170. startTime: number;
  48171. /**
  48172. * Time now
  48173. */
  48174. currentTime: number;
  48175. /**
  48176. * Time passed since started
  48177. */
  48178. deltaTime: number;
  48179. /**
  48180. * How much is completed, in [0.0...1.0].
  48181. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48182. */
  48183. completeRate: number;
  48184. /**
  48185. * What the registered observable sent in the last count
  48186. */
  48187. payload: T;
  48188. }
  48189. /**
  48190. * The current state of the timer
  48191. */
  48192. export enum TimerState {
  48193. /**
  48194. * Timer initialized, not yet started
  48195. */
  48196. INIT = 0,
  48197. /**
  48198. * Timer started and counting
  48199. */
  48200. STARTED = 1,
  48201. /**
  48202. * Timer ended (whether aborted or time reached)
  48203. */
  48204. ENDED = 2
  48205. }
  48206. /**
  48207. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48208. *
  48209. * @param options options with which to initialize this timer
  48210. */
  48211. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48212. /**
  48213. * An advanced implementation of a timer class
  48214. */
  48215. export class AdvancedTimer<T = any> implements IDisposable {
  48216. /**
  48217. * Will notify each time the timer calculates the remaining time
  48218. */
  48219. onEachCountObservable: Observable<ITimerData<T>>;
  48220. /**
  48221. * Will trigger when the timer was aborted due to the break condition
  48222. */
  48223. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48224. /**
  48225. * Will trigger when the timer ended successfully
  48226. */
  48227. onTimerEndedObservable: Observable<ITimerData<T>>;
  48228. /**
  48229. * Will trigger when the timer state has changed
  48230. */
  48231. onStateChangedObservable: Observable<TimerState>;
  48232. private _observer;
  48233. private _contextObservable;
  48234. private _observableParameters;
  48235. private _startTime;
  48236. private _timer;
  48237. private _state;
  48238. private _breakCondition;
  48239. private _timeToEnd;
  48240. private _breakOnNextTick;
  48241. /**
  48242. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48243. * @param options construction options for this advanced timer
  48244. */
  48245. constructor(options: ITimerOptions<T>);
  48246. /**
  48247. * set a breaking condition for this timer. Default is to never break during count
  48248. * @param predicate the new break condition. Returns true to break, false otherwise
  48249. */
  48250. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48251. /**
  48252. * Reset ALL associated observables in this advanced timer
  48253. */
  48254. clearObservables(): void;
  48255. /**
  48256. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48257. *
  48258. * @param timeToEnd how much time to measure until timer ended
  48259. */
  48260. start(timeToEnd?: number): void;
  48261. /**
  48262. * Will force a stop on the next tick.
  48263. */
  48264. stop(): void;
  48265. /**
  48266. * Dispose this timer, clearing all resources
  48267. */
  48268. dispose(): void;
  48269. private _setState;
  48270. private _tick;
  48271. private _stop;
  48272. }
  48273. }
  48274. declare module BABYLON {
  48275. /**
  48276. * The options container for the teleportation module
  48277. */
  48278. export interface IWebXRTeleportationOptions {
  48279. /**
  48280. * if provided, this scene will be used to render meshes.
  48281. */
  48282. customUtilityLayerScene?: Scene;
  48283. /**
  48284. * Values to configure the default target mesh
  48285. */
  48286. defaultTargetMeshOptions?: {
  48287. /**
  48288. * Fill color of the teleportation area
  48289. */
  48290. teleportationFillColor?: string;
  48291. /**
  48292. * Border color for the teleportation area
  48293. */
  48294. teleportationBorderColor?: string;
  48295. /**
  48296. * Disable the mesh's animation sequence
  48297. */
  48298. disableAnimation?: boolean;
  48299. /**
  48300. * Disable lighting on the material or the ring and arrow
  48301. */
  48302. disableLighting?: boolean;
  48303. /**
  48304. * Override the default material of the torus and arrow
  48305. */
  48306. torusArrowMaterial?: Material;
  48307. };
  48308. /**
  48309. * A list of meshes to use as floor meshes.
  48310. * Meshes can be added and removed after initializing the feature using the
  48311. * addFloorMesh and removeFloorMesh functions
  48312. * If empty, rotation will still work
  48313. */
  48314. floorMeshes?: AbstractMesh[];
  48315. /**
  48316. * use this rendering group id for the meshes (optional)
  48317. */
  48318. renderingGroupId?: number;
  48319. /**
  48320. * Should teleportation move only to snap points
  48321. */
  48322. snapPointsOnly?: boolean;
  48323. /**
  48324. * An array of points to which the teleportation will snap to.
  48325. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48326. */
  48327. snapPositions?: Vector3[];
  48328. /**
  48329. * How close should the teleportation ray be in order to snap to position.
  48330. * Default to 0.8 units (meters)
  48331. */
  48332. snapToPositionRadius?: number;
  48333. /**
  48334. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48335. * If you want to support rotation, make sure your mesh has a direction indicator.
  48336. *
  48337. * When left untouched, the default mesh will be initialized.
  48338. */
  48339. teleportationTargetMesh?: AbstractMesh;
  48340. /**
  48341. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48342. */
  48343. timeToTeleport?: number;
  48344. /**
  48345. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48346. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48347. */
  48348. useMainComponentOnly?: boolean;
  48349. /**
  48350. * Should meshes created here be added to a utility layer or the main scene
  48351. */
  48352. useUtilityLayer?: boolean;
  48353. /**
  48354. * Babylon XR Input class for controller
  48355. */
  48356. xrInput: WebXRInput;
  48357. }
  48358. /**
  48359. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48360. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48361. * the input of the attached controllers.
  48362. */
  48363. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48364. private _options;
  48365. private _controllers;
  48366. private _currentTeleportationControllerId;
  48367. private _floorMeshes;
  48368. private _quadraticBezierCurve;
  48369. private _selectionFeature;
  48370. private _snapToPositions;
  48371. private _snappedToPoint;
  48372. private _teleportationRingMaterial?;
  48373. private _tmpRay;
  48374. private _tmpVector;
  48375. /**
  48376. * The module's name
  48377. */
  48378. static readonly Name: string;
  48379. /**
  48380. * The (Babylon) version of this module.
  48381. * This is an integer representing the implementation version.
  48382. * This number does not correspond to the webxr specs version
  48383. */
  48384. static readonly Version: number;
  48385. /**
  48386. * Is movement backwards enabled
  48387. */
  48388. backwardsMovementEnabled: boolean;
  48389. /**
  48390. * Distance to travel when moving backwards
  48391. */
  48392. backwardsTeleportationDistance: number;
  48393. /**
  48394. * The distance from the user to the inspection point in the direction of the controller
  48395. * A higher number will allow the user to move further
  48396. * defaults to 5 (meters, in xr units)
  48397. */
  48398. parabolicCheckRadius: number;
  48399. /**
  48400. * Should the module support parabolic ray on top of direct ray
  48401. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48402. * Very helpful when moving between floors / different heights
  48403. */
  48404. parabolicRayEnabled: boolean;
  48405. /**
  48406. * How much rotation should be applied when rotating right and left
  48407. */
  48408. rotationAngle: number;
  48409. /**
  48410. * Is rotation enabled when moving forward?
  48411. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48412. */
  48413. rotationEnabled: boolean;
  48414. /**
  48415. * constructs a new anchor system
  48416. * @param _xrSessionManager an instance of WebXRSessionManager
  48417. * @param _options configuration object for this feature
  48418. */
  48419. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48420. /**
  48421. * Get the snapPointsOnly flag
  48422. */
  48423. get snapPointsOnly(): boolean;
  48424. /**
  48425. * Sets the snapPointsOnly flag
  48426. * @param snapToPoints should teleportation be exclusively to snap points
  48427. */
  48428. set snapPointsOnly(snapToPoints: boolean);
  48429. /**
  48430. * Add a new mesh to the floor meshes array
  48431. * @param mesh the mesh to use as floor mesh
  48432. */
  48433. addFloorMesh(mesh: AbstractMesh): void;
  48434. /**
  48435. * Add a new snap-to point to fix teleportation to this position
  48436. * @param newSnapPoint The new Snap-To point
  48437. */
  48438. addSnapPoint(newSnapPoint: Vector3): void;
  48439. attach(): boolean;
  48440. detach(): boolean;
  48441. dispose(): void;
  48442. /**
  48443. * Remove a mesh from the floor meshes array
  48444. * @param mesh the mesh to remove
  48445. */
  48446. removeFloorMesh(mesh: AbstractMesh): void;
  48447. /**
  48448. * Remove a mesh from the floor meshes array using its name
  48449. * @param name the mesh name to remove
  48450. */
  48451. removeFloorMeshByName(name: string): void;
  48452. /**
  48453. * 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
  48454. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48455. * @returns was the point found and removed or not
  48456. */
  48457. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48458. /**
  48459. * This function sets a selection feature that will be disabled when
  48460. * the forward ray is shown and will be reattached when hidden.
  48461. * This is used to remove the selection rays when moving.
  48462. * @param selectionFeature the feature to disable when forward movement is enabled
  48463. */
  48464. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48465. protected _onXRFrame(_xrFrame: XRFrame): void;
  48466. private _attachController;
  48467. private _createDefaultTargetMesh;
  48468. private _detachController;
  48469. private _findClosestSnapPointWithRadius;
  48470. private _setTargetMeshPosition;
  48471. private _setTargetMeshVisibility;
  48472. private _showParabolicPath;
  48473. private _teleportForward;
  48474. }
  48475. }
  48476. declare module BABYLON {
  48477. /**
  48478. * Options for the default xr helper
  48479. */
  48480. export class WebXRDefaultExperienceOptions {
  48481. /**
  48482. * Enable or disable default UI to enter XR
  48483. */
  48484. disableDefaultUI?: boolean;
  48485. /**
  48486. * Should teleportation not initialize. defaults to false.
  48487. */
  48488. disableTeleportation?: boolean;
  48489. /**
  48490. * Floor meshes that will be used for teleport
  48491. */
  48492. floorMeshes?: Array<AbstractMesh>;
  48493. /**
  48494. * If set to true, the first frame will not be used to reset position
  48495. * The first frame is mainly used when copying transformation from the old camera
  48496. * Mainly used in AR
  48497. */
  48498. ignoreNativeCameraTransformation?: boolean;
  48499. /**
  48500. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48501. */
  48502. inputOptions?: IWebXRInputOptions;
  48503. /**
  48504. * optional configuration for the output canvas
  48505. */
  48506. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48507. /**
  48508. * optional UI options. This can be used among other to change session mode and reference space type
  48509. */
  48510. uiOptions?: WebXREnterExitUIOptions;
  48511. /**
  48512. * When loading teleportation and pointer select, use stable versions instead of latest.
  48513. */
  48514. useStablePlugins?: boolean;
  48515. /**
  48516. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48517. */
  48518. renderingGroupId?: number;
  48519. /**
  48520. * A list of optional features to init the session with
  48521. * If set to true, all features we support will be added
  48522. */
  48523. optionalFeatures?: boolean | string[];
  48524. }
  48525. /**
  48526. * Default experience which provides a similar setup to the previous webVRExperience
  48527. */
  48528. export class WebXRDefaultExperience {
  48529. /**
  48530. * Base experience
  48531. */
  48532. baseExperience: WebXRExperienceHelper;
  48533. /**
  48534. * Enables ui for entering/exiting xr
  48535. */
  48536. enterExitUI: WebXREnterExitUI;
  48537. /**
  48538. * Input experience extension
  48539. */
  48540. input: WebXRInput;
  48541. /**
  48542. * Enables laser pointer and selection
  48543. */
  48544. pointerSelection: WebXRControllerPointerSelection;
  48545. /**
  48546. * Default target xr should render to
  48547. */
  48548. renderTarget: WebXRRenderTarget;
  48549. /**
  48550. * Enables teleportation
  48551. */
  48552. teleportation: WebXRMotionControllerTeleportation;
  48553. private constructor();
  48554. /**
  48555. * Creates the default xr experience
  48556. * @param scene scene
  48557. * @param options options for basic configuration
  48558. * @returns resulting WebXRDefaultExperience
  48559. */
  48560. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48561. /**
  48562. * DIsposes of the experience helper
  48563. */
  48564. dispose(): void;
  48565. }
  48566. }
  48567. declare module BABYLON {
  48568. /**
  48569. * Options to modify the vr teleportation behavior.
  48570. */
  48571. export interface VRTeleportationOptions {
  48572. /**
  48573. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48574. */
  48575. floorMeshName?: string;
  48576. /**
  48577. * A list of meshes to be used as the teleportation floor. (default: empty)
  48578. */
  48579. floorMeshes?: Mesh[];
  48580. /**
  48581. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48582. */
  48583. teleportationMode?: number;
  48584. /**
  48585. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48586. */
  48587. teleportationTime?: number;
  48588. /**
  48589. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48590. */
  48591. teleportationSpeed?: number;
  48592. /**
  48593. * The easing function used in the animation or null for Linear. (default CircleEase)
  48594. */
  48595. easingFunction?: EasingFunction;
  48596. }
  48597. /**
  48598. * Options to modify the vr experience helper's behavior.
  48599. */
  48600. export interface VRExperienceHelperOptions extends WebVROptions {
  48601. /**
  48602. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48603. */
  48604. createDeviceOrientationCamera?: boolean;
  48605. /**
  48606. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48607. */
  48608. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48609. /**
  48610. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48611. */
  48612. laserToggle?: boolean;
  48613. /**
  48614. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48615. */
  48616. floorMeshes?: Mesh[];
  48617. /**
  48618. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48619. */
  48620. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48621. /**
  48622. * Defines if WebXR should be used instead of WebVR (if available)
  48623. */
  48624. useXR?: boolean;
  48625. }
  48626. /**
  48627. * Event containing information after VR has been entered
  48628. */
  48629. export class OnAfterEnteringVRObservableEvent {
  48630. /**
  48631. * If entering vr was successful
  48632. */
  48633. success: boolean;
  48634. }
  48635. /**
  48636. * Helps to quickly add VR support to an existing scene.
  48637. * See http://doc.babylonjs.com/how_to/webvr_helper
  48638. */
  48639. export class VRExperienceHelper {
  48640. /** Options to modify the vr experience helper's behavior. */
  48641. webVROptions: VRExperienceHelperOptions;
  48642. private _scene;
  48643. private _position;
  48644. private _btnVR;
  48645. private _btnVRDisplayed;
  48646. private _webVRsupported;
  48647. private _webVRready;
  48648. private _webVRrequesting;
  48649. private _webVRpresenting;
  48650. private _hasEnteredVR;
  48651. private _fullscreenVRpresenting;
  48652. private _inputElement;
  48653. private _webVRCamera;
  48654. private _vrDeviceOrientationCamera;
  48655. private _deviceOrientationCamera;
  48656. private _existingCamera;
  48657. private _onKeyDown;
  48658. private _onVrDisplayPresentChange;
  48659. private _onVRDisplayChanged;
  48660. private _onVRRequestPresentStart;
  48661. private _onVRRequestPresentComplete;
  48662. /**
  48663. * 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)
  48664. */
  48665. enableGazeEvenWhenNoPointerLock: boolean;
  48666. /**
  48667. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48668. */
  48669. exitVROnDoubleTap: boolean;
  48670. /**
  48671. * Observable raised right before entering VR.
  48672. */
  48673. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48674. /**
  48675. * Observable raised when entering VR has completed.
  48676. */
  48677. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48678. /**
  48679. * Observable raised when exiting VR.
  48680. */
  48681. onExitingVRObservable: Observable<VRExperienceHelper>;
  48682. /**
  48683. * Observable raised when controller mesh is loaded.
  48684. */
  48685. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48686. /** Return this.onEnteringVRObservable
  48687. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48688. */
  48689. get onEnteringVR(): Observable<VRExperienceHelper>;
  48690. /** Return this.onExitingVRObservable
  48691. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48692. */
  48693. get onExitingVR(): Observable<VRExperienceHelper>;
  48694. /** Return this.onControllerMeshLoadedObservable
  48695. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48696. */
  48697. get onControllerMeshLoaded(): Observable<WebVRController>;
  48698. private _rayLength;
  48699. private _useCustomVRButton;
  48700. private _teleportationRequested;
  48701. private _teleportActive;
  48702. private _floorMeshName;
  48703. private _floorMeshesCollection;
  48704. private _teleportationMode;
  48705. private _teleportationTime;
  48706. private _teleportationSpeed;
  48707. private _teleportationEasing;
  48708. private _rotationAllowed;
  48709. private _teleportBackwardsVector;
  48710. private _teleportationTarget;
  48711. private _isDefaultTeleportationTarget;
  48712. private _postProcessMove;
  48713. private _teleportationFillColor;
  48714. private _teleportationBorderColor;
  48715. private _rotationAngle;
  48716. private _haloCenter;
  48717. private _cameraGazer;
  48718. private _padSensibilityUp;
  48719. private _padSensibilityDown;
  48720. private _leftController;
  48721. private _rightController;
  48722. private _gazeColor;
  48723. private _laserColor;
  48724. private _pickedLaserColor;
  48725. private _pickedGazeColor;
  48726. /**
  48727. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48728. */
  48729. onNewMeshSelected: Observable<AbstractMesh>;
  48730. /**
  48731. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48732. * This observable will provide the mesh and the controller used to select the mesh
  48733. */
  48734. onMeshSelectedWithController: Observable<{
  48735. mesh: AbstractMesh;
  48736. controller: WebVRController;
  48737. }>;
  48738. /**
  48739. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48740. */
  48741. onNewMeshPicked: Observable<PickingInfo>;
  48742. private _circleEase;
  48743. /**
  48744. * Observable raised before camera teleportation
  48745. */
  48746. onBeforeCameraTeleport: Observable<Vector3>;
  48747. /**
  48748. * Observable raised after camera teleportation
  48749. */
  48750. onAfterCameraTeleport: Observable<Vector3>;
  48751. /**
  48752. * Observable raised when current selected mesh gets unselected
  48753. */
  48754. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48755. private _raySelectionPredicate;
  48756. /**
  48757. * To be optionaly changed by user to define custom ray selection
  48758. */
  48759. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48760. /**
  48761. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48762. */
  48763. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48764. /**
  48765. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48766. */
  48767. teleportationEnabled: boolean;
  48768. private _defaultHeight;
  48769. private _teleportationInitialized;
  48770. private _interactionsEnabled;
  48771. private _interactionsRequested;
  48772. private _displayGaze;
  48773. private _displayLaserPointer;
  48774. /**
  48775. * The mesh used to display where the user is going to teleport.
  48776. */
  48777. get teleportationTarget(): Mesh;
  48778. /**
  48779. * Sets the mesh to be used to display where the user is going to teleport.
  48780. */
  48781. set teleportationTarget(value: Mesh);
  48782. /**
  48783. * 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
  48784. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  48785. * See http://doc.babylonjs.com/resources/baking_transformations
  48786. */
  48787. get gazeTrackerMesh(): Mesh;
  48788. set gazeTrackerMesh(value: Mesh);
  48789. /**
  48790. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  48791. */
  48792. updateGazeTrackerScale: boolean;
  48793. /**
  48794. * If the gaze trackers color should be updated when selecting meshes
  48795. */
  48796. updateGazeTrackerColor: boolean;
  48797. /**
  48798. * If the controller laser color should be updated when selecting meshes
  48799. */
  48800. updateControllerLaserColor: boolean;
  48801. /**
  48802. * The gaze tracking mesh corresponding to the left controller
  48803. */
  48804. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  48805. /**
  48806. * The gaze tracking mesh corresponding to the right controller
  48807. */
  48808. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  48809. /**
  48810. * If the ray of the gaze should be displayed.
  48811. */
  48812. get displayGaze(): boolean;
  48813. /**
  48814. * Sets if the ray of the gaze should be displayed.
  48815. */
  48816. set displayGaze(value: boolean);
  48817. /**
  48818. * If the ray of the LaserPointer should be displayed.
  48819. */
  48820. get displayLaserPointer(): boolean;
  48821. /**
  48822. * Sets if the ray of the LaserPointer should be displayed.
  48823. */
  48824. set displayLaserPointer(value: boolean);
  48825. /**
  48826. * The deviceOrientationCamera used as the camera when not in VR.
  48827. */
  48828. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  48829. /**
  48830. * Based on the current WebVR support, returns the current VR camera used.
  48831. */
  48832. get currentVRCamera(): Nullable<Camera>;
  48833. /**
  48834. * The webVRCamera which is used when in VR.
  48835. */
  48836. get webVRCamera(): WebVRFreeCamera;
  48837. /**
  48838. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  48839. */
  48840. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  48841. /**
  48842. * The html button that is used to trigger entering into VR.
  48843. */
  48844. get vrButton(): Nullable<HTMLButtonElement>;
  48845. private get _teleportationRequestInitiated();
  48846. /**
  48847. * Defines whether or not Pointer lock should be requested when switching to
  48848. * full screen.
  48849. */
  48850. requestPointerLockOnFullScreen: boolean;
  48851. /**
  48852. * If asking to force XR, this will be populated with the default xr experience
  48853. */
  48854. xr: WebXRDefaultExperience;
  48855. /**
  48856. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  48857. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  48858. */
  48859. xrTestDone: boolean;
  48860. /**
  48861. * Instantiates a VRExperienceHelper.
  48862. * Helps to quickly add VR support to an existing scene.
  48863. * @param scene The scene the VRExperienceHelper belongs to.
  48864. * @param webVROptions Options to modify the vr experience helper's behavior.
  48865. */
  48866. constructor(scene: Scene,
  48867. /** Options to modify the vr experience helper's behavior. */
  48868. webVROptions?: VRExperienceHelperOptions);
  48869. private completeVRInit;
  48870. private _onDefaultMeshLoaded;
  48871. private _onResize;
  48872. private _onFullscreenChange;
  48873. /**
  48874. * Gets a value indicating if we are currently in VR mode.
  48875. */
  48876. get isInVRMode(): boolean;
  48877. private onVrDisplayPresentChange;
  48878. private onVRDisplayChanged;
  48879. private moveButtonToBottomRight;
  48880. private displayVRButton;
  48881. private updateButtonVisibility;
  48882. private _cachedAngularSensibility;
  48883. /**
  48884. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  48885. * Otherwise, will use the fullscreen API.
  48886. */
  48887. enterVR(): void;
  48888. /**
  48889. * Attempt to exit VR, or fullscreen.
  48890. */
  48891. exitVR(): void;
  48892. /**
  48893. * The position of the vr experience helper.
  48894. */
  48895. get position(): Vector3;
  48896. /**
  48897. * Sets the position of the vr experience helper.
  48898. */
  48899. set position(value: Vector3);
  48900. /**
  48901. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  48902. */
  48903. enableInteractions(): void;
  48904. private get _noControllerIsActive();
  48905. private beforeRender;
  48906. private _isTeleportationFloor;
  48907. /**
  48908. * Adds a floor mesh to be used for teleportation.
  48909. * @param floorMesh the mesh to be used for teleportation.
  48910. */
  48911. addFloorMesh(floorMesh: Mesh): void;
  48912. /**
  48913. * Removes a floor mesh from being used for teleportation.
  48914. * @param floorMesh the mesh to be removed.
  48915. */
  48916. removeFloorMesh(floorMesh: Mesh): void;
  48917. /**
  48918. * Enables interactions and teleportation using the VR controllers and gaze.
  48919. * @param vrTeleportationOptions options to modify teleportation behavior.
  48920. */
  48921. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  48922. private _onNewGamepadConnected;
  48923. private _tryEnableInteractionOnController;
  48924. private _onNewGamepadDisconnected;
  48925. private _enableInteractionOnController;
  48926. private _checkTeleportWithRay;
  48927. private _checkRotate;
  48928. private _checkTeleportBackwards;
  48929. private _enableTeleportationOnController;
  48930. private _createTeleportationCircles;
  48931. private _displayTeleportationTarget;
  48932. private _hideTeleportationTarget;
  48933. private _rotateCamera;
  48934. private _moveTeleportationSelectorTo;
  48935. private _workingVector;
  48936. private _workingQuaternion;
  48937. private _workingMatrix;
  48938. /**
  48939. * Time Constant Teleportation Mode
  48940. */
  48941. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  48942. /**
  48943. * Speed Constant Teleportation Mode
  48944. */
  48945. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  48946. /**
  48947. * Teleports the users feet to the desired location
  48948. * @param location The location where the user's feet should be placed
  48949. */
  48950. teleportCamera(location: Vector3): void;
  48951. private _convertNormalToDirectionOfRay;
  48952. private _castRayAndSelectObject;
  48953. private _notifySelectedMeshUnselected;
  48954. /**
  48955. * Permanently set new colors for the laser pointer
  48956. * @param color the new laser color
  48957. * @param pickedColor the new laser color when picked mesh detected
  48958. */
  48959. setLaserColor(color: Color3, pickedColor?: Color3): void;
  48960. /**
  48961. * Set lighting enabled / disabled on the laser pointer of both controllers
  48962. * @param enabled should the lighting be enabled on the laser pointer
  48963. */
  48964. setLaserLightingState(enabled?: boolean): void;
  48965. /**
  48966. * Permanently set new colors for the gaze pointer
  48967. * @param color the new gaze color
  48968. * @param pickedColor the new gaze color when picked mesh detected
  48969. */
  48970. setGazeColor(color: Color3, pickedColor?: Color3): void;
  48971. /**
  48972. * Sets the color of the laser ray from the vr controllers.
  48973. * @param color new color for the ray.
  48974. */
  48975. changeLaserColor(color: Color3): void;
  48976. /**
  48977. * Sets the color of the ray from the vr headsets gaze.
  48978. * @param color new color for the ray.
  48979. */
  48980. changeGazeColor(color: Color3): void;
  48981. /**
  48982. * Exits VR and disposes of the vr experience helper
  48983. */
  48984. dispose(): void;
  48985. /**
  48986. * Gets the name of the VRExperienceHelper class
  48987. * @returns "VRExperienceHelper"
  48988. */
  48989. getClassName(): string;
  48990. }
  48991. }
  48992. declare module BABYLON {
  48993. /**
  48994. * Contains an array of blocks representing the octree
  48995. */
  48996. export interface IOctreeContainer<T> {
  48997. /**
  48998. * Blocks within the octree
  48999. */
  49000. blocks: Array<OctreeBlock<T>>;
  49001. }
  49002. /**
  49003. * Class used to store a cell in an octree
  49004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49005. */
  49006. export class OctreeBlock<T> {
  49007. /**
  49008. * Gets the content of the current block
  49009. */
  49010. entries: T[];
  49011. /**
  49012. * Gets the list of block children
  49013. */
  49014. blocks: Array<OctreeBlock<T>>;
  49015. private _depth;
  49016. private _maxDepth;
  49017. private _capacity;
  49018. private _minPoint;
  49019. private _maxPoint;
  49020. private _boundingVectors;
  49021. private _creationFunc;
  49022. /**
  49023. * Creates a new block
  49024. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49025. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49026. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49027. * @param depth defines the current depth of this block in the octree
  49028. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49029. * @param creationFunc defines a callback to call when an element is added to the block
  49030. */
  49031. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49032. /**
  49033. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49034. */
  49035. get capacity(): number;
  49036. /**
  49037. * Gets the minimum vector (in world space) of the block's bounding box
  49038. */
  49039. get minPoint(): Vector3;
  49040. /**
  49041. * Gets the maximum vector (in world space) of the block's bounding box
  49042. */
  49043. get maxPoint(): Vector3;
  49044. /**
  49045. * Add a new element to this block
  49046. * @param entry defines the element to add
  49047. */
  49048. addEntry(entry: T): void;
  49049. /**
  49050. * Remove an element from this block
  49051. * @param entry defines the element to remove
  49052. */
  49053. removeEntry(entry: T): void;
  49054. /**
  49055. * Add an array of elements to this block
  49056. * @param entries defines the array of elements to add
  49057. */
  49058. addEntries(entries: T[]): void;
  49059. /**
  49060. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49061. * @param frustumPlanes defines the frustum planes to test
  49062. * @param selection defines the array to store current content if selection is positive
  49063. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49064. */
  49065. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49066. /**
  49067. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49068. * @param sphereCenter defines the bounding sphere center
  49069. * @param sphereRadius defines the bounding sphere radius
  49070. * @param selection defines the array to store current content if selection is positive
  49071. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49072. */
  49073. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49074. /**
  49075. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49076. * @param ray defines the ray to test with
  49077. * @param selection defines the array to store current content if selection is positive
  49078. */
  49079. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49080. /**
  49081. * Subdivide the content into child blocks (this block will then be empty)
  49082. */
  49083. createInnerBlocks(): void;
  49084. /**
  49085. * @hidden
  49086. */
  49087. 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;
  49088. }
  49089. }
  49090. declare module BABYLON {
  49091. /**
  49092. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49093. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49094. */
  49095. export class Octree<T> {
  49096. /** 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.) */
  49097. maxDepth: number;
  49098. /**
  49099. * Blocks within the octree containing objects
  49100. */
  49101. blocks: Array<OctreeBlock<T>>;
  49102. /**
  49103. * Content stored in the octree
  49104. */
  49105. dynamicContent: T[];
  49106. private _maxBlockCapacity;
  49107. private _selectionContent;
  49108. private _creationFunc;
  49109. /**
  49110. * Creates a octree
  49111. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49112. * @param creationFunc function to be used to instatiate the octree
  49113. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49114. * @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.)
  49115. */
  49116. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49117. /** 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.) */
  49118. maxDepth?: number);
  49119. /**
  49120. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49121. * @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);
  49122. * @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);
  49123. * @param entries meshes to be added to the octree blocks
  49124. */
  49125. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49126. /**
  49127. * Adds a mesh to the octree
  49128. * @param entry Mesh to add to the octree
  49129. */
  49130. addMesh(entry: T): void;
  49131. /**
  49132. * Remove an element from the octree
  49133. * @param entry defines the element to remove
  49134. */
  49135. removeMesh(entry: T): void;
  49136. /**
  49137. * Selects an array of meshes within the frustum
  49138. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49139. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49140. * @returns array of meshes within the frustum
  49141. */
  49142. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49143. /**
  49144. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49145. * @param sphereCenter defines the bounding sphere center
  49146. * @param sphereRadius defines the bounding sphere radius
  49147. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49148. * @returns an array of objects that intersect the sphere
  49149. */
  49150. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49151. /**
  49152. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49153. * @param ray defines the ray to test with
  49154. * @returns array of intersected objects
  49155. */
  49156. intersectsRay(ray: Ray): SmartArray<T>;
  49157. /**
  49158. * Adds a mesh into the octree block if it intersects the block
  49159. */
  49160. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49161. /**
  49162. * Adds a submesh into the octree block if it intersects the block
  49163. */
  49164. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49165. }
  49166. }
  49167. declare module BABYLON {
  49168. interface Scene {
  49169. /**
  49170. * @hidden
  49171. * Backing Filed
  49172. */
  49173. _selectionOctree: Octree<AbstractMesh>;
  49174. /**
  49175. * Gets the octree used to boost mesh selection (picking)
  49176. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49177. */
  49178. selectionOctree: Octree<AbstractMesh>;
  49179. /**
  49180. * Creates or updates the octree used to boost selection (picking)
  49181. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49182. * @param maxCapacity defines the maximum capacity per leaf
  49183. * @param maxDepth defines the maximum depth of the octree
  49184. * @returns an octree of AbstractMesh
  49185. */
  49186. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49187. }
  49188. interface AbstractMesh {
  49189. /**
  49190. * @hidden
  49191. * Backing Field
  49192. */
  49193. _submeshesOctree: Octree<SubMesh>;
  49194. /**
  49195. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49196. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49197. * @param maxCapacity defines the maximum size of each block (64 by default)
  49198. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49199. * @returns the new octree
  49200. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49201. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49202. */
  49203. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49204. }
  49205. /**
  49206. * Defines the octree scene component responsible to manage any octrees
  49207. * in a given scene.
  49208. */
  49209. export class OctreeSceneComponent {
  49210. /**
  49211. * The component name help to identify the component in the list of scene components.
  49212. */
  49213. readonly name: string;
  49214. /**
  49215. * The scene the component belongs to.
  49216. */
  49217. scene: Scene;
  49218. /**
  49219. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49220. */
  49221. readonly checksIsEnabled: boolean;
  49222. /**
  49223. * Creates a new instance of the component for the given scene
  49224. * @param scene Defines the scene to register the component in
  49225. */
  49226. constructor(scene: Scene);
  49227. /**
  49228. * Registers the component in a given scene
  49229. */
  49230. register(): void;
  49231. /**
  49232. * Return the list of active meshes
  49233. * @returns the list of active meshes
  49234. */
  49235. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49236. /**
  49237. * Return the list of active sub meshes
  49238. * @param mesh The mesh to get the candidates sub meshes from
  49239. * @returns the list of active sub meshes
  49240. */
  49241. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49242. private _tempRay;
  49243. /**
  49244. * Return the list of sub meshes intersecting with a given local ray
  49245. * @param mesh defines the mesh to find the submesh for
  49246. * @param localRay defines the ray in local space
  49247. * @returns the list of intersecting sub meshes
  49248. */
  49249. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49250. /**
  49251. * Return the list of sub meshes colliding with a collider
  49252. * @param mesh defines the mesh to find the submesh for
  49253. * @param collider defines the collider to evaluate the collision against
  49254. * @returns the list of colliding sub meshes
  49255. */
  49256. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49257. /**
  49258. * Rebuilds the elements related to this component in case of
  49259. * context lost for instance.
  49260. */
  49261. rebuild(): void;
  49262. /**
  49263. * Disposes the component and the associated ressources.
  49264. */
  49265. dispose(): void;
  49266. }
  49267. }
  49268. declare module BABYLON {
  49269. /**
  49270. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49271. */
  49272. export class Gizmo implements IDisposable {
  49273. /** The utility layer the gizmo will be added to */
  49274. gizmoLayer: UtilityLayerRenderer;
  49275. /**
  49276. * The root mesh of the gizmo
  49277. */
  49278. _rootMesh: Mesh;
  49279. private _attachedMesh;
  49280. /**
  49281. * Ratio for the scale of the gizmo (Default: 1)
  49282. */
  49283. scaleRatio: number;
  49284. /**
  49285. * If a custom mesh has been set (Default: false)
  49286. */
  49287. protected _customMeshSet: boolean;
  49288. /**
  49289. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49290. * * When set, interactions will be enabled
  49291. */
  49292. get attachedMesh(): Nullable<AbstractMesh>;
  49293. set attachedMesh(value: Nullable<AbstractMesh>);
  49294. /**
  49295. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49296. * @param mesh The mesh to replace the default mesh of the gizmo
  49297. */
  49298. setCustomMesh(mesh: Mesh): void;
  49299. /**
  49300. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49301. */
  49302. updateGizmoRotationToMatchAttachedMesh: boolean;
  49303. /**
  49304. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49305. */
  49306. updateGizmoPositionToMatchAttachedMesh: boolean;
  49307. /**
  49308. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49309. */
  49310. updateScale: boolean;
  49311. protected _interactionsEnabled: boolean;
  49312. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49313. private _beforeRenderObserver;
  49314. private _tempVector;
  49315. /**
  49316. * Creates a gizmo
  49317. * @param gizmoLayer The utility layer the gizmo will be added to
  49318. */
  49319. constructor(
  49320. /** The utility layer the gizmo will be added to */
  49321. gizmoLayer?: UtilityLayerRenderer);
  49322. /**
  49323. * Updates the gizmo to match the attached mesh's position/rotation
  49324. */
  49325. protected _update(): void;
  49326. /**
  49327. * Disposes of the gizmo
  49328. */
  49329. dispose(): void;
  49330. }
  49331. }
  49332. declare module BABYLON {
  49333. /**
  49334. * Single plane drag gizmo
  49335. */
  49336. export class PlaneDragGizmo extends Gizmo {
  49337. /**
  49338. * Drag behavior responsible for the gizmos dragging interactions
  49339. */
  49340. dragBehavior: PointerDragBehavior;
  49341. private _pointerObserver;
  49342. /**
  49343. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49344. */
  49345. snapDistance: number;
  49346. /**
  49347. * Event that fires each time the gizmo snaps to a new location.
  49348. * * snapDistance is the the change in distance
  49349. */
  49350. onSnapObservable: Observable<{
  49351. snapDistance: number;
  49352. }>;
  49353. private _plane;
  49354. private _coloredMaterial;
  49355. private _hoverMaterial;
  49356. private _isEnabled;
  49357. private _parent;
  49358. /** @hidden */
  49359. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49360. /** @hidden */
  49361. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49362. /**
  49363. * Creates a PlaneDragGizmo
  49364. * @param gizmoLayer The utility layer the gizmo will be added to
  49365. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49366. * @param color The color of the gizmo
  49367. */
  49368. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49369. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49370. /**
  49371. * If the gizmo is enabled
  49372. */
  49373. set isEnabled(value: boolean);
  49374. get isEnabled(): boolean;
  49375. /**
  49376. * Disposes of the gizmo
  49377. */
  49378. dispose(): void;
  49379. }
  49380. }
  49381. declare module BABYLON {
  49382. /**
  49383. * Gizmo that enables dragging a mesh along 3 axis
  49384. */
  49385. export class PositionGizmo extends Gizmo {
  49386. /**
  49387. * Internal gizmo used for interactions on the x axis
  49388. */
  49389. xGizmo: AxisDragGizmo;
  49390. /**
  49391. * Internal gizmo used for interactions on the y axis
  49392. */
  49393. yGizmo: AxisDragGizmo;
  49394. /**
  49395. * Internal gizmo used for interactions on the z axis
  49396. */
  49397. zGizmo: AxisDragGizmo;
  49398. /**
  49399. * Internal gizmo used for interactions on the yz plane
  49400. */
  49401. xPlaneGizmo: PlaneDragGizmo;
  49402. /**
  49403. * Internal gizmo used for interactions on the xz plane
  49404. */
  49405. yPlaneGizmo: PlaneDragGizmo;
  49406. /**
  49407. * Internal gizmo used for interactions on the xy plane
  49408. */
  49409. zPlaneGizmo: PlaneDragGizmo;
  49410. /**
  49411. * private variables
  49412. */
  49413. private _meshAttached;
  49414. private _updateGizmoRotationToMatchAttachedMesh;
  49415. private _snapDistance;
  49416. private _scaleRatio;
  49417. /** Fires an event when any of it's sub gizmos are dragged */
  49418. onDragStartObservable: Observable<unknown>;
  49419. /** Fires an event when any of it's sub gizmos are released from dragging */
  49420. onDragEndObservable: Observable<unknown>;
  49421. /**
  49422. * If set to true, planar drag is enabled
  49423. */
  49424. private _planarGizmoEnabled;
  49425. get attachedMesh(): Nullable<AbstractMesh>;
  49426. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49427. /**
  49428. * Creates a PositionGizmo
  49429. * @param gizmoLayer The utility layer the gizmo will be added to
  49430. */
  49431. constructor(gizmoLayer?: UtilityLayerRenderer);
  49432. /**
  49433. * If the planar drag gizmo is enabled
  49434. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49435. */
  49436. set planarGizmoEnabled(value: boolean);
  49437. get planarGizmoEnabled(): boolean;
  49438. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49439. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49440. /**
  49441. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49442. */
  49443. set snapDistance(value: number);
  49444. get snapDistance(): number;
  49445. /**
  49446. * Ratio for the scale of the gizmo (Default: 1)
  49447. */
  49448. set scaleRatio(value: number);
  49449. get scaleRatio(): number;
  49450. /**
  49451. * Disposes of the gizmo
  49452. */
  49453. dispose(): void;
  49454. /**
  49455. * CustomMeshes are not supported by this gizmo
  49456. * @param mesh The mesh to replace the default mesh of the gizmo
  49457. */
  49458. setCustomMesh(mesh: Mesh): void;
  49459. }
  49460. }
  49461. declare module BABYLON {
  49462. /**
  49463. * Single axis drag gizmo
  49464. */
  49465. export class AxisDragGizmo extends Gizmo {
  49466. /**
  49467. * Drag behavior responsible for the gizmos dragging interactions
  49468. */
  49469. dragBehavior: PointerDragBehavior;
  49470. private _pointerObserver;
  49471. /**
  49472. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49473. */
  49474. snapDistance: number;
  49475. /**
  49476. * Event that fires each time the gizmo snaps to a new location.
  49477. * * snapDistance is the the change in distance
  49478. */
  49479. onSnapObservable: Observable<{
  49480. snapDistance: number;
  49481. }>;
  49482. private _isEnabled;
  49483. private _parent;
  49484. private _arrow;
  49485. private _coloredMaterial;
  49486. private _hoverMaterial;
  49487. /** @hidden */
  49488. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49489. /** @hidden */
  49490. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49491. /**
  49492. * Creates an AxisDragGizmo
  49493. * @param gizmoLayer The utility layer the gizmo will be added to
  49494. * @param dragAxis The axis which the gizmo will be able to drag on
  49495. * @param color The color of the gizmo
  49496. */
  49497. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49498. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49499. /**
  49500. * If the gizmo is enabled
  49501. */
  49502. set isEnabled(value: boolean);
  49503. get isEnabled(): boolean;
  49504. /**
  49505. * Disposes of the gizmo
  49506. */
  49507. dispose(): void;
  49508. }
  49509. }
  49510. declare module BABYLON.Debug {
  49511. /**
  49512. * The Axes viewer will show 3 axes in a specific point in space
  49513. */
  49514. export class AxesViewer {
  49515. private _xAxis;
  49516. private _yAxis;
  49517. private _zAxis;
  49518. private _scaleLinesFactor;
  49519. private _instanced;
  49520. /**
  49521. * Gets the hosting scene
  49522. */
  49523. scene: Scene;
  49524. /**
  49525. * Gets or sets a number used to scale line length
  49526. */
  49527. scaleLines: number;
  49528. /** Gets the node hierarchy used to render x-axis */
  49529. get xAxis(): TransformNode;
  49530. /** Gets the node hierarchy used to render y-axis */
  49531. get yAxis(): TransformNode;
  49532. /** Gets the node hierarchy used to render z-axis */
  49533. get zAxis(): TransformNode;
  49534. /**
  49535. * Creates a new AxesViewer
  49536. * @param scene defines the hosting scene
  49537. * @param scaleLines defines a number used to scale line length (1 by default)
  49538. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49539. * @param xAxis defines the node hierarchy used to render the x-axis
  49540. * @param yAxis defines the node hierarchy used to render the y-axis
  49541. * @param zAxis defines the node hierarchy used to render the z-axis
  49542. */
  49543. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49544. /**
  49545. * Force the viewer to update
  49546. * @param position defines the position of the viewer
  49547. * @param xaxis defines the x axis of the viewer
  49548. * @param yaxis defines the y axis of the viewer
  49549. * @param zaxis defines the z axis of the viewer
  49550. */
  49551. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49552. /**
  49553. * Creates an instance of this axes viewer.
  49554. * @returns a new axes viewer with instanced meshes
  49555. */
  49556. createInstance(): AxesViewer;
  49557. /** Releases resources */
  49558. dispose(): void;
  49559. private static _SetRenderingGroupId;
  49560. }
  49561. }
  49562. declare module BABYLON.Debug {
  49563. /**
  49564. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49565. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49566. */
  49567. export class BoneAxesViewer extends AxesViewer {
  49568. /**
  49569. * Gets or sets the target mesh where to display the axes viewer
  49570. */
  49571. mesh: Nullable<Mesh>;
  49572. /**
  49573. * Gets or sets the target bone where to display the axes viewer
  49574. */
  49575. bone: Nullable<Bone>;
  49576. /** Gets current position */
  49577. pos: Vector3;
  49578. /** Gets direction of X axis */
  49579. xaxis: Vector3;
  49580. /** Gets direction of Y axis */
  49581. yaxis: Vector3;
  49582. /** Gets direction of Z axis */
  49583. zaxis: Vector3;
  49584. /**
  49585. * Creates a new BoneAxesViewer
  49586. * @param scene defines the hosting scene
  49587. * @param bone defines the target bone
  49588. * @param mesh defines the target mesh
  49589. * @param scaleLines defines a scaling factor for line length (1 by default)
  49590. */
  49591. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49592. /**
  49593. * Force the viewer to update
  49594. */
  49595. update(): void;
  49596. /** Releases resources */
  49597. dispose(): void;
  49598. }
  49599. }
  49600. declare module BABYLON {
  49601. /**
  49602. * Interface used to define scene explorer extensibility option
  49603. */
  49604. export interface IExplorerExtensibilityOption {
  49605. /**
  49606. * Define the option label
  49607. */
  49608. label: string;
  49609. /**
  49610. * Defines the action to execute on click
  49611. */
  49612. action: (entity: any) => void;
  49613. }
  49614. /**
  49615. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49616. */
  49617. export interface IExplorerExtensibilityGroup {
  49618. /**
  49619. * Defines a predicate to test if a given type mut be extended
  49620. */
  49621. predicate: (entity: any) => boolean;
  49622. /**
  49623. * Gets the list of options added to a type
  49624. */
  49625. entries: IExplorerExtensibilityOption[];
  49626. }
  49627. /**
  49628. * Interface used to define the options to use to create the Inspector
  49629. */
  49630. export interface IInspectorOptions {
  49631. /**
  49632. * Display in overlay mode (default: false)
  49633. */
  49634. overlay?: boolean;
  49635. /**
  49636. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49637. */
  49638. globalRoot?: HTMLElement;
  49639. /**
  49640. * Display the Scene explorer
  49641. */
  49642. showExplorer?: boolean;
  49643. /**
  49644. * Display the property inspector
  49645. */
  49646. showInspector?: boolean;
  49647. /**
  49648. * Display in embed mode (both panes on the right)
  49649. */
  49650. embedMode?: boolean;
  49651. /**
  49652. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49653. */
  49654. handleResize?: boolean;
  49655. /**
  49656. * Allow the panes to popup (default: true)
  49657. */
  49658. enablePopup?: boolean;
  49659. /**
  49660. * Allow the panes to be closed by users (default: true)
  49661. */
  49662. enableClose?: boolean;
  49663. /**
  49664. * Optional list of extensibility entries
  49665. */
  49666. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49667. /**
  49668. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49669. */
  49670. inspectorURL?: string;
  49671. /**
  49672. * Optional initial tab (default to DebugLayerTab.Properties)
  49673. */
  49674. initialTab?: DebugLayerTab;
  49675. }
  49676. interface Scene {
  49677. /**
  49678. * @hidden
  49679. * Backing field
  49680. */
  49681. _debugLayer: DebugLayer;
  49682. /**
  49683. * Gets the debug layer (aka Inspector) associated with the scene
  49684. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49685. */
  49686. debugLayer: DebugLayer;
  49687. }
  49688. /**
  49689. * Enum of inspector action tab
  49690. */
  49691. export enum DebugLayerTab {
  49692. /**
  49693. * Properties tag (default)
  49694. */
  49695. Properties = 0,
  49696. /**
  49697. * Debug tab
  49698. */
  49699. Debug = 1,
  49700. /**
  49701. * Statistics tab
  49702. */
  49703. Statistics = 2,
  49704. /**
  49705. * Tools tab
  49706. */
  49707. Tools = 3,
  49708. /**
  49709. * Settings tab
  49710. */
  49711. Settings = 4
  49712. }
  49713. /**
  49714. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49715. * what is happening in your scene
  49716. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49717. */
  49718. export class DebugLayer {
  49719. /**
  49720. * Define the url to get the inspector script from.
  49721. * By default it uses the babylonjs CDN.
  49722. * @ignoreNaming
  49723. */
  49724. static InspectorURL: string;
  49725. private _scene;
  49726. private BJSINSPECTOR;
  49727. private _onPropertyChangedObservable?;
  49728. /**
  49729. * Observable triggered when a property is changed through the inspector.
  49730. */
  49731. get onPropertyChangedObservable(): any;
  49732. /**
  49733. * Instantiates a new debug layer.
  49734. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49735. * what is happening in your scene
  49736. * @see http://doc.babylonjs.com/features/playground_debuglayer
  49737. * @param scene Defines the scene to inspect
  49738. */
  49739. constructor(scene: Scene);
  49740. /** Creates the inspector window. */
  49741. private _createInspector;
  49742. /**
  49743. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49744. * @param entity defines the entity to select
  49745. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49746. */
  49747. select(entity: any, lineContainerTitles?: string | string[]): void;
  49748. /** Get the inspector from bundle or global */
  49749. private _getGlobalInspector;
  49750. /**
  49751. * Get if the inspector is visible or not.
  49752. * @returns true if visible otherwise, false
  49753. */
  49754. isVisible(): boolean;
  49755. /**
  49756. * Hide the inspector and close its window.
  49757. */
  49758. hide(): void;
  49759. /**
  49760. * Update the scene in the inspector
  49761. */
  49762. setAsActiveScene(): void;
  49763. /**
  49764. * Launch the debugLayer.
  49765. * @param config Define the configuration of the inspector
  49766. * @return a promise fulfilled when the debug layer is visible
  49767. */
  49768. show(config?: IInspectorOptions): Promise<DebugLayer>;
  49769. }
  49770. }
  49771. declare module BABYLON {
  49772. /**
  49773. * Class containing static functions to help procedurally build meshes
  49774. */
  49775. export class BoxBuilder {
  49776. /**
  49777. * Creates a box mesh
  49778. * * The parameter `size` sets the size (float) of each box side (default 1)
  49779. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49780. * * 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)
  49781. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49783. * * 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
  49784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49785. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49786. * @param name defines the name of the mesh
  49787. * @param options defines the options used to create the mesh
  49788. * @param scene defines the hosting scene
  49789. * @returns the box mesh
  49790. */
  49791. static CreateBox(name: string, options: {
  49792. size?: number;
  49793. width?: number;
  49794. height?: number;
  49795. depth?: number;
  49796. faceUV?: Vector4[];
  49797. faceColors?: Color4[];
  49798. sideOrientation?: number;
  49799. frontUVs?: Vector4;
  49800. backUVs?: Vector4;
  49801. wrap?: boolean;
  49802. topBaseAt?: number;
  49803. bottomBaseAt?: number;
  49804. updatable?: boolean;
  49805. }, scene?: Nullable<Scene>): Mesh;
  49806. }
  49807. }
  49808. declare module BABYLON.Debug {
  49809. /**
  49810. * Used to show the physics impostor around the specific mesh
  49811. */
  49812. export class PhysicsViewer {
  49813. /** @hidden */
  49814. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  49815. /** @hidden */
  49816. protected _meshes: Array<Nullable<AbstractMesh>>;
  49817. /** @hidden */
  49818. protected _scene: Nullable<Scene>;
  49819. /** @hidden */
  49820. protected _numMeshes: number;
  49821. /** @hidden */
  49822. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  49823. private _renderFunction;
  49824. private _utilityLayer;
  49825. private _debugBoxMesh;
  49826. private _debugSphereMesh;
  49827. private _debugCylinderMesh;
  49828. private _debugMaterial;
  49829. private _debugMeshMeshes;
  49830. /**
  49831. * Creates a new PhysicsViewer
  49832. * @param scene defines the hosting scene
  49833. */
  49834. constructor(scene: Scene);
  49835. /** @hidden */
  49836. protected _updateDebugMeshes(): void;
  49837. /**
  49838. * Renders a specified physic impostor
  49839. * @param impostor defines the impostor to render
  49840. * @param targetMesh defines the mesh represented by the impostor
  49841. * @returns the new debug mesh used to render the impostor
  49842. */
  49843. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  49844. /**
  49845. * Hides a specified physic impostor
  49846. * @param impostor defines the impostor to hide
  49847. */
  49848. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  49849. private _getDebugMaterial;
  49850. private _getDebugBoxMesh;
  49851. private _getDebugSphereMesh;
  49852. private _getDebugCylinderMesh;
  49853. private _getDebugMeshMesh;
  49854. private _getDebugMesh;
  49855. /** Releases all resources */
  49856. dispose(): void;
  49857. }
  49858. }
  49859. declare module BABYLON {
  49860. /**
  49861. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49862. * in order to better appreciate the issue one might have.
  49863. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49864. */
  49865. export class RayHelper {
  49866. /**
  49867. * Defines the ray we are currently tryin to visualize.
  49868. */
  49869. ray: Nullable<Ray>;
  49870. private _renderPoints;
  49871. private _renderLine;
  49872. private _renderFunction;
  49873. private _scene;
  49874. private _updateToMeshFunction;
  49875. private _attachedToMesh;
  49876. private _meshSpaceDirection;
  49877. private _meshSpaceOrigin;
  49878. /**
  49879. * Helper function to create a colored helper in a scene in one line.
  49880. * @param ray Defines the ray we are currently tryin to visualize
  49881. * @param scene Defines the scene the ray is used in
  49882. * @param color Defines the color we want to see the ray in
  49883. * @returns The newly created ray helper.
  49884. */
  49885. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  49886. /**
  49887. * Instantiate a new ray helper.
  49888. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  49889. * in order to better appreciate the issue one might have.
  49890. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  49891. * @param ray Defines the ray we are currently tryin to visualize
  49892. */
  49893. constructor(ray: Ray);
  49894. /**
  49895. * Shows the ray we are willing to debug.
  49896. * @param scene Defines the scene the ray needs to be rendered in
  49897. * @param color Defines the color the ray needs to be rendered in
  49898. */
  49899. show(scene: Scene, color?: Color3): void;
  49900. /**
  49901. * Hides the ray we are debugging.
  49902. */
  49903. hide(): void;
  49904. private _render;
  49905. /**
  49906. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  49907. * @param mesh Defines the mesh we want the helper attached to
  49908. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  49909. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  49910. * @param length Defines the length of the ray
  49911. */
  49912. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  49913. /**
  49914. * Detach the ray helper from the mesh it has previously been attached to.
  49915. */
  49916. detachFromMesh(): void;
  49917. private _updateToMesh;
  49918. /**
  49919. * Dispose the helper and release its associated resources.
  49920. */
  49921. dispose(): void;
  49922. }
  49923. }
  49924. declare module BABYLON.Debug {
  49925. /**
  49926. * Class used to render a debug view of a given skeleton
  49927. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  49928. */
  49929. export class SkeletonViewer {
  49930. /** defines the skeleton to render */
  49931. skeleton: Skeleton;
  49932. /** defines the mesh attached to the skeleton */
  49933. mesh: AbstractMesh;
  49934. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49935. autoUpdateBonesMatrices: boolean;
  49936. /** defines the rendering group id to use with the viewer */
  49937. renderingGroupId: number;
  49938. /** Gets or sets the color used to render the skeleton */
  49939. color: Color3;
  49940. private _scene;
  49941. private _debugLines;
  49942. private _debugMesh;
  49943. private _isEnabled;
  49944. private _renderFunction;
  49945. private _utilityLayer;
  49946. /**
  49947. * Returns the mesh used to render the bones
  49948. */
  49949. get debugMesh(): Nullable<LinesMesh>;
  49950. /**
  49951. * Creates a new SkeletonViewer
  49952. * @param skeleton defines the skeleton to render
  49953. * @param mesh defines the mesh attached to the skeleton
  49954. * @param scene defines the hosting scene
  49955. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  49956. * @param renderingGroupId defines the rendering group id to use with the viewer
  49957. */
  49958. constructor(
  49959. /** defines the skeleton to render */
  49960. skeleton: Skeleton,
  49961. /** defines the mesh attached to the skeleton */
  49962. mesh: AbstractMesh, scene: Scene,
  49963. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  49964. autoUpdateBonesMatrices?: boolean,
  49965. /** defines the rendering group id to use with the viewer */
  49966. renderingGroupId?: number);
  49967. /** Gets or sets a boolean indicating if the viewer is enabled */
  49968. set isEnabled(value: boolean);
  49969. get isEnabled(): boolean;
  49970. private _getBonePosition;
  49971. private _getLinesForBonesWithLength;
  49972. private _getLinesForBonesNoLength;
  49973. /** Update the viewer to sync with current skeleton state */
  49974. update(): void;
  49975. /** Release associated resources */
  49976. dispose(): void;
  49977. }
  49978. }
  49979. declare module BABYLON {
  49980. /**
  49981. * Enum for Device Types
  49982. */
  49983. export enum DeviceType {
  49984. /** Generic */
  49985. Generic = 0,
  49986. /** Keyboard */
  49987. Keyboard = 1,
  49988. /** Mouse */
  49989. Mouse = 2,
  49990. /** Touch Pointers */
  49991. Touch = 3,
  49992. /** PS4 Dual Shock */
  49993. DualShock = 4,
  49994. /** Xbox */
  49995. Xbox = 5,
  49996. /** Switch Controller */
  49997. Switch = 6
  49998. }
  49999. /**
  50000. * Enum for All Pointers (Touch/Mouse)
  50001. */
  50002. export enum PointerInput {
  50003. /** Horizontal Axis */
  50004. Horizontal = 0,
  50005. /** Vertical Axis */
  50006. Vertical = 1,
  50007. /** Left Click or Touch */
  50008. LeftClick = 2,
  50009. /** Middle Click */
  50010. MiddleClick = 3,
  50011. /** Right Click */
  50012. RightClick = 4,
  50013. /** Browser Back */
  50014. BrowserBack = 5,
  50015. /** Browser Forward */
  50016. BrowserForward = 6
  50017. }
  50018. /**
  50019. * Enum for Dual Shock Gamepad
  50020. */
  50021. export enum DualShockInput {
  50022. /** Cross */
  50023. Cross = 0,
  50024. /** Circle */
  50025. Circle = 1,
  50026. /** Square */
  50027. Square = 2,
  50028. /** Triangle */
  50029. Triangle = 3,
  50030. /** L1 */
  50031. L1 = 4,
  50032. /** R1 */
  50033. R1 = 5,
  50034. /** L2 */
  50035. L2 = 6,
  50036. /** R2 */
  50037. R2 = 7,
  50038. /** Share */
  50039. Share = 8,
  50040. /** Options */
  50041. Options = 9,
  50042. /** L3 */
  50043. L3 = 10,
  50044. /** R3 */
  50045. R3 = 11,
  50046. /** DPadUp */
  50047. DPadUp = 12,
  50048. /** DPadDown */
  50049. DPadDown = 13,
  50050. /** DPadLeft */
  50051. DPadLeft = 14,
  50052. /** DRight */
  50053. DPadRight = 15,
  50054. /** Home */
  50055. Home = 16,
  50056. /** TouchPad */
  50057. TouchPad = 17,
  50058. /** LStickXAxis */
  50059. LStickXAxis = 18,
  50060. /** LStickYAxis */
  50061. LStickYAxis = 19,
  50062. /** RStickXAxis */
  50063. RStickXAxis = 20,
  50064. /** RStickYAxis */
  50065. RStickYAxis = 21
  50066. }
  50067. /**
  50068. * Enum for Xbox Gamepad
  50069. */
  50070. export enum XboxInput {
  50071. /** A */
  50072. A = 0,
  50073. /** B */
  50074. B = 1,
  50075. /** X */
  50076. X = 2,
  50077. /** Y */
  50078. Y = 3,
  50079. /** LB */
  50080. LB = 4,
  50081. /** RB */
  50082. RB = 5,
  50083. /** LT */
  50084. LT = 6,
  50085. /** RT */
  50086. RT = 7,
  50087. /** Back */
  50088. Back = 8,
  50089. /** Start */
  50090. Start = 9,
  50091. /** LS */
  50092. LS = 10,
  50093. /** RS */
  50094. RS = 11,
  50095. /** DPadUp */
  50096. DPadUp = 12,
  50097. /** DPadDown */
  50098. DPadDown = 13,
  50099. /** DPadLeft */
  50100. DPadLeft = 14,
  50101. /** DRight */
  50102. DPadRight = 15,
  50103. /** Home */
  50104. Home = 16,
  50105. /** LStickXAxis */
  50106. LStickXAxis = 17,
  50107. /** LStickYAxis */
  50108. LStickYAxis = 18,
  50109. /** RStickXAxis */
  50110. RStickXAxis = 19,
  50111. /** RStickYAxis */
  50112. RStickYAxis = 20
  50113. }
  50114. /**
  50115. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50116. */
  50117. export enum SwitchInput {
  50118. /** B */
  50119. B = 0,
  50120. /** A */
  50121. A = 1,
  50122. /** Y */
  50123. Y = 2,
  50124. /** X */
  50125. X = 3,
  50126. /** L */
  50127. L = 4,
  50128. /** R */
  50129. R = 5,
  50130. /** ZL */
  50131. ZL = 6,
  50132. /** ZR */
  50133. ZR = 7,
  50134. /** Minus */
  50135. Minus = 8,
  50136. /** Plus */
  50137. Plus = 9,
  50138. /** LS */
  50139. LS = 10,
  50140. /** RS */
  50141. RS = 11,
  50142. /** DPadUp */
  50143. DPadUp = 12,
  50144. /** DPadDown */
  50145. DPadDown = 13,
  50146. /** DPadLeft */
  50147. DPadLeft = 14,
  50148. /** DRight */
  50149. DPadRight = 15,
  50150. /** Home */
  50151. Home = 16,
  50152. /** Capture */
  50153. Capture = 17,
  50154. /** LStickXAxis */
  50155. LStickXAxis = 18,
  50156. /** LStickYAxis */
  50157. LStickYAxis = 19,
  50158. /** RStickXAxis */
  50159. RStickXAxis = 20,
  50160. /** RStickYAxis */
  50161. RStickYAxis = 21
  50162. }
  50163. }
  50164. declare module BABYLON {
  50165. /**
  50166. * This class will take all inputs from Keyboard, Pointer, and
  50167. * any Gamepads and provide a polling system that all devices
  50168. * will use. This class assumes that there will only be one
  50169. * pointer device and one keyboard.
  50170. */
  50171. export class DeviceInputSystem implements IDisposable {
  50172. /**
  50173. * Callback to be triggered when a device is connected
  50174. */
  50175. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50176. /**
  50177. * Callback to be triggered when a device is disconnected
  50178. */
  50179. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50180. /**
  50181. * Callback to be triggered when event driven input is updated
  50182. */
  50183. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50184. private _inputs;
  50185. private _gamepads;
  50186. private _keyboardActive;
  50187. private _pointerActive;
  50188. private _elementToAttachTo;
  50189. private _keyboardDownEvent;
  50190. private _keyboardUpEvent;
  50191. private _pointerMoveEvent;
  50192. private _pointerDownEvent;
  50193. private _pointerUpEvent;
  50194. private _gamepadConnectedEvent;
  50195. private _gamepadDisconnectedEvent;
  50196. private static _MAX_KEYCODES;
  50197. private static _MAX_POINTER_INPUTS;
  50198. private constructor();
  50199. /**
  50200. * Creates a new DeviceInputSystem instance
  50201. * @param engine Engine to pull input element from
  50202. * @returns The new instance
  50203. */
  50204. static Create(engine: Engine): DeviceInputSystem;
  50205. /**
  50206. * Checks for current device input value, given an id and input index
  50207. * @param deviceName Id of connected device
  50208. * @param inputIndex Index of device input
  50209. * @returns Current value of input
  50210. */
  50211. /**
  50212. * Checks for current device input value, given an id and input index
  50213. * @param deviceType Enum specifiying device type
  50214. * @param deviceSlot "Slot" or index that device is referenced in
  50215. * @param inputIndex Id of input to be checked
  50216. * @returns Current value of input
  50217. */
  50218. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50219. /**
  50220. * Dispose of all the eventlisteners
  50221. */
  50222. dispose(): void;
  50223. /**
  50224. * Add device and inputs to device array
  50225. * @param deviceType Enum specifiying device type
  50226. * @param deviceSlot "Slot" or index that device is referenced in
  50227. * @param numberOfInputs Number of input entries to create for given device
  50228. */
  50229. private _registerDevice;
  50230. /**
  50231. * Given a specific device name, remove that device from the device map
  50232. * @param deviceType Enum specifiying device type
  50233. * @param deviceSlot "Slot" or index that device is referenced in
  50234. */
  50235. private _unregisterDevice;
  50236. /**
  50237. * Handle all actions that come from keyboard interaction
  50238. */
  50239. private _handleKeyActions;
  50240. /**
  50241. * Handle all actions that come from pointer interaction
  50242. */
  50243. private _handlePointerActions;
  50244. /**
  50245. * Handle all actions that come from gamepad interaction
  50246. */
  50247. private _handleGamepadActions;
  50248. /**
  50249. * Update all non-event based devices with each frame
  50250. * @param deviceType Enum specifiying device type
  50251. * @param deviceSlot "Slot" or index that device is referenced in
  50252. * @param inputIndex Id of input to be checked
  50253. */
  50254. private _updateDevice;
  50255. /**
  50256. * Gets DeviceType from the device name
  50257. * @param deviceName Name of Device from DeviceInputSystem
  50258. * @returns DeviceType enum value
  50259. */
  50260. private _getGamepadDeviceType;
  50261. }
  50262. }
  50263. declare module BABYLON {
  50264. /**
  50265. * Type to handle enforcement of inputs
  50266. */
  50267. 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;
  50268. }
  50269. declare module BABYLON {
  50270. /**
  50271. * Class that handles all input for a specific device
  50272. */
  50273. export class DeviceSource<T extends DeviceType> {
  50274. /** Type of device */
  50275. readonly deviceType: DeviceType;
  50276. /** "Slot" or index that device is referenced in */
  50277. readonly deviceSlot: number;
  50278. /**
  50279. * Observable to handle device input changes per device
  50280. */
  50281. readonly onInputChangedObservable: Observable<{
  50282. inputIndex: DeviceInput<T>;
  50283. previousState: Nullable<number>;
  50284. currentState: Nullable<number>;
  50285. }>;
  50286. private readonly _deviceInputSystem;
  50287. /**
  50288. * Default Constructor
  50289. * @param deviceInputSystem Reference to DeviceInputSystem
  50290. * @param deviceType Type of device
  50291. * @param deviceSlot "Slot" or index that device is referenced in
  50292. */
  50293. constructor(deviceInputSystem: DeviceInputSystem,
  50294. /** Type of device */
  50295. deviceType: DeviceType,
  50296. /** "Slot" or index that device is referenced in */
  50297. deviceSlot?: number);
  50298. /**
  50299. * Get input for specific input
  50300. * @param inputIndex index of specific input on device
  50301. * @returns Input value from DeviceInputSystem
  50302. */
  50303. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50304. }
  50305. /**
  50306. * Class to keep track of devices
  50307. */
  50308. export class DeviceSourceManager implements IDisposable {
  50309. /**
  50310. * Observable to be triggered when before a device is connected
  50311. */
  50312. readonly onBeforeDeviceConnectedObservable: Observable<{
  50313. deviceType: DeviceType;
  50314. deviceSlot: number;
  50315. }>;
  50316. /**
  50317. * Observable to be triggered when before a device is disconnected
  50318. */
  50319. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50320. deviceType: DeviceType;
  50321. deviceSlot: number;
  50322. }>;
  50323. /**
  50324. * Observable to be triggered when after a device is connected
  50325. */
  50326. readonly onAfterDeviceConnectedObservable: Observable<{
  50327. deviceType: DeviceType;
  50328. deviceSlot: number;
  50329. }>;
  50330. /**
  50331. * Observable to be triggered when after a device is disconnected
  50332. */
  50333. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50334. deviceType: DeviceType;
  50335. deviceSlot: number;
  50336. }>;
  50337. private readonly _devices;
  50338. private readonly _firstDevice;
  50339. private readonly _deviceInputSystem;
  50340. /**
  50341. * Default Constructor
  50342. * @param engine engine to pull input element from
  50343. */
  50344. constructor(engine: Engine);
  50345. /**
  50346. * Gets a DeviceSource, given a type and slot
  50347. * @param deviceType Enum specifying device type
  50348. * @param deviceSlot "Slot" or index that device is referenced in
  50349. * @returns DeviceSource object
  50350. */
  50351. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50352. /**
  50353. * Gets an array of DeviceSource objects for a given device type
  50354. * @param deviceType Enum specifying device type
  50355. * @returns Array of DeviceSource objects
  50356. */
  50357. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50358. /**
  50359. * Dispose of DeviceInputSystem and other parts
  50360. */
  50361. dispose(): void;
  50362. /**
  50363. * Function to add 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 _addDevice;
  50368. /**
  50369. * Function to remove device name to device list
  50370. * @param deviceType Enum specifying device type
  50371. * @param deviceSlot "Slot" or index that device is referenced in
  50372. */
  50373. private _removeDevice;
  50374. /**
  50375. * Updates array storing first connected device of each type
  50376. * @param type Type of Device
  50377. */
  50378. private _updateFirstDevices;
  50379. }
  50380. }
  50381. declare module BABYLON {
  50382. /**
  50383. * Options to create the null engine
  50384. */
  50385. export class NullEngineOptions {
  50386. /**
  50387. * Render width (Default: 512)
  50388. */
  50389. renderWidth: number;
  50390. /**
  50391. * Render height (Default: 256)
  50392. */
  50393. renderHeight: number;
  50394. /**
  50395. * Texture size (Default: 512)
  50396. */
  50397. textureSize: number;
  50398. /**
  50399. * If delta time between frames should be constant
  50400. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50401. */
  50402. deterministicLockstep: boolean;
  50403. /**
  50404. * Maximum about of steps between frames (Default: 4)
  50405. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50406. */
  50407. lockstepMaxSteps: number;
  50408. }
  50409. /**
  50410. * The null engine class provides support for headless version of babylon.js.
  50411. * This can be used in server side scenario or for testing purposes
  50412. */
  50413. export class NullEngine extends Engine {
  50414. private _options;
  50415. /**
  50416. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50417. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50418. * @returns true if engine is in deterministic lock step mode
  50419. */
  50420. isDeterministicLockStep(): boolean;
  50421. /**
  50422. * Gets the max steps when engine is running in deterministic lock step
  50423. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50424. * @returns the max steps
  50425. */
  50426. getLockstepMaxSteps(): number;
  50427. /**
  50428. * Gets the current hardware scaling level.
  50429. * By default the hardware scaling level is computed from the window device ratio.
  50430. * 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.
  50431. * @returns a number indicating the current hardware scaling level
  50432. */
  50433. getHardwareScalingLevel(): number;
  50434. constructor(options?: NullEngineOptions);
  50435. /**
  50436. * Creates a vertex buffer
  50437. * @param vertices the data for the vertex buffer
  50438. * @returns the new WebGL static buffer
  50439. */
  50440. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50441. /**
  50442. * Creates a new index buffer
  50443. * @param indices defines the content of the index buffer
  50444. * @param updatable defines if the index buffer must be updatable
  50445. * @returns a new webGL buffer
  50446. */
  50447. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50448. /**
  50449. * Clear the current render buffer or the current render target (if any is set up)
  50450. * @param color defines the color to use
  50451. * @param backBuffer defines if the back buffer must be cleared
  50452. * @param depth defines if the depth buffer must be cleared
  50453. * @param stencil defines if the stencil buffer must be cleared
  50454. */
  50455. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50456. /**
  50457. * Gets the current render width
  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 width
  50460. */
  50461. getRenderWidth(useScreen?: boolean): number;
  50462. /**
  50463. * Gets the current render height
  50464. * @param useScreen defines if screen size must be used (or the current render target if any)
  50465. * @returns a number defining the current render height
  50466. */
  50467. getRenderHeight(useScreen?: boolean): number;
  50468. /**
  50469. * Set the WebGL's viewport
  50470. * @param viewport defines the viewport element to be used
  50471. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50472. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50473. */
  50474. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50475. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50476. /**
  50477. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50478. * @param pipelineContext defines the pipeline context to use
  50479. * @param uniformsNames defines the list of uniform names
  50480. * @returns an array of webGL uniform locations
  50481. */
  50482. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50483. /**
  50484. * Gets the lsit of active attributes for a given webGL program
  50485. * @param pipelineContext defines the pipeline context to use
  50486. * @param attributesNames defines the list of attribute names to get
  50487. * @returns an array of indices indicating the offset of each attribute
  50488. */
  50489. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50490. /**
  50491. * Binds an effect to the webGL context
  50492. * @param effect defines the effect to bind
  50493. */
  50494. bindSamplers(effect: Effect): void;
  50495. /**
  50496. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50497. * @param effect defines the effect to activate
  50498. */
  50499. enableEffect(effect: Effect): void;
  50500. /**
  50501. * Set various states to the webGL context
  50502. * @param culling defines backface culling state
  50503. * @param zOffset defines the value to apply to zOffset (0 by default)
  50504. * @param force defines if states must be applied even if cache is up to date
  50505. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50506. */
  50507. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50508. /**
  50509. * Set the value of an uniform to an array of int32
  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. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50514. /**
  50515. * Set the value of an uniform to an array of int32 (stored as vec2)
  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. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50520. /**
  50521. * Set the value of an uniform to an array of int32 (stored as vec3)
  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. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50526. /**
  50527. * Set the value of an uniform to an array of int32 (stored as vec4)
  50528. * @param uniform defines the webGL uniform location where to store the value
  50529. * @param array defines the array of int32 to store
  50530. */
  50531. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50532. /**
  50533. * Set the value of an uniform to an array of float32
  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. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50538. /**
  50539. * Set the value of an uniform to an array of float32 (stored as vec2)
  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. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50544. /**
  50545. * Set the value of an uniform to an array of float32 (stored as vec3)
  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. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50550. /**
  50551. * Set the value of an uniform to an array of float32 (stored as vec4)
  50552. * @param uniform defines the webGL uniform location where to store the value
  50553. * @param array defines the array of float32 to store
  50554. */
  50555. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50556. /**
  50557. * Set the value of an uniform to an array of number
  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. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50562. /**
  50563. * Set the value of an uniform to an array of number (stored as vec2)
  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. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50568. /**
  50569. * Set the value of an uniform to an array of number (stored as vec3)
  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. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50574. /**
  50575. * Set the value of an uniform to an array of number (stored as vec4)
  50576. * @param uniform defines the webGL uniform location where to store the value
  50577. * @param array defines the array of number to store
  50578. */
  50579. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50580. /**
  50581. * Set the value of an uniform to an array of float32 (stored as matrices)
  50582. * @param uniform defines the webGL uniform location where to store the value
  50583. * @param matrices defines the array of float32 to store
  50584. */
  50585. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50586. /**
  50587. * Set the value of an uniform to a matrix (3x3)
  50588. * @param uniform defines the webGL uniform location where to store the value
  50589. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50590. */
  50591. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50592. /**
  50593. * Set the value of an uniform to a matrix (2x2)
  50594. * @param uniform defines the webGL uniform location where to store the value
  50595. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50596. */
  50597. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50598. /**
  50599. * Set the value of an uniform to a number (float)
  50600. * @param uniform defines the webGL uniform location where to store the value
  50601. * @param value defines the float number to store
  50602. */
  50603. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50604. /**
  50605. * Set the value of an uniform to a vec2
  50606. * @param uniform defines the webGL uniform location where to store the value
  50607. * @param x defines the 1st component of the value
  50608. * @param y defines the 2nd component of the value
  50609. */
  50610. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50611. /**
  50612. * Set the value of an uniform to a vec3
  50613. * @param uniform defines the webGL uniform location where to store the value
  50614. * @param x defines the 1st component of the value
  50615. * @param y defines the 2nd component of the value
  50616. * @param z defines the 3rd component of the value
  50617. */
  50618. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50619. /**
  50620. * Set the value of an uniform to a boolean
  50621. * @param uniform defines the webGL uniform location where to store the value
  50622. * @param bool defines the boolean to store
  50623. */
  50624. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50625. /**
  50626. * Set the value of an uniform to a vec4
  50627. * @param uniform defines the webGL uniform location where to store the value
  50628. * @param x defines the 1st component of the value
  50629. * @param y defines the 2nd component of the value
  50630. * @param z defines the 3rd component of the value
  50631. * @param w defines the 4th component of the value
  50632. */
  50633. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50634. /**
  50635. * Sets the current alpha mode
  50636. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50637. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50638. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50639. */
  50640. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50641. /**
  50642. * Bind webGl buffers directly to the webGL context
  50643. * @param vertexBuffers defines the vertex buffer to bind
  50644. * @param indexBuffer defines the index buffer to bind
  50645. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50646. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50647. * @param effect defines the effect associated with the vertex buffer
  50648. */
  50649. bindBuffers(vertexBuffers: {
  50650. [key: string]: VertexBuffer;
  50651. }, indexBuffer: DataBuffer, effect: Effect): void;
  50652. /**
  50653. * Force the entire cache to be cleared
  50654. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50655. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50656. */
  50657. wipeCaches(bruteForce?: boolean): void;
  50658. /**
  50659. * Send a draw order
  50660. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50661. * @param indexStart defines the starting index
  50662. * @param indexCount defines the number of index to draw
  50663. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50664. */
  50665. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50666. /**
  50667. * Draw a list of indexed primitives
  50668. * @param fillMode defines the primitive to use
  50669. * @param indexStart defines the starting index
  50670. * @param indexCount defines the number of index to draw
  50671. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50672. */
  50673. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50674. /**
  50675. * Draw a list of unindexed primitives
  50676. * @param fillMode defines the primitive to use
  50677. * @param verticesStart defines the index of first vertex to draw
  50678. * @param verticesCount defines the count of vertices to draw
  50679. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50680. */
  50681. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50682. /** @hidden */
  50683. _createTexture(): WebGLTexture;
  50684. /** @hidden */
  50685. _releaseTexture(texture: InternalTexture): void;
  50686. /**
  50687. * Usually called from Texture.ts.
  50688. * Passed information to create a WebGLTexture
  50689. * @param urlArg defines a value which contains one of the following:
  50690. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50691. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50692. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50693. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50694. * @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)
  50695. * @param scene needed for loading to the correct scene
  50696. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50697. * @param onLoad optional callback to be called upon successful completion
  50698. * @param onError optional callback to be called upon failure
  50699. * @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
  50700. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50701. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50702. * @param forcedExtension defines the extension to use to pick the right loader
  50703. * @param mimeType defines an optional mime type
  50704. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50705. */
  50706. 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;
  50707. /**
  50708. * Creates a new render target texture
  50709. * @param size defines the size of the texture
  50710. * @param options defines the options used to create the texture
  50711. * @returns a new render target texture stored in an InternalTexture
  50712. */
  50713. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50714. /**
  50715. * Update the sampling mode of a given texture
  50716. * @param samplingMode defines the required sampling mode
  50717. * @param texture defines the texture to update
  50718. */
  50719. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50720. /**
  50721. * Binds the frame buffer to the specified texture.
  50722. * @param texture The texture to render to or null for the default canvas
  50723. * @param faceIndex The face of the texture to render to in case of cube texture
  50724. * @param requiredWidth The width of the target to render to
  50725. * @param requiredHeight The height of the target to render to
  50726. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50727. * @param lodLevel defines le lod level to bind to the frame buffer
  50728. */
  50729. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50730. /**
  50731. * Unbind the current render target texture from the webGL context
  50732. * @param texture defines the render target texture to unbind
  50733. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50734. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50735. */
  50736. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50737. /**
  50738. * Creates a dynamic vertex buffer
  50739. * @param vertices the data for the dynamic vertex buffer
  50740. * @returns the new WebGL dynamic buffer
  50741. */
  50742. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50743. /**
  50744. * Update the content of a dynamic texture
  50745. * @param texture defines the texture to update
  50746. * @param canvas defines the canvas containing the source
  50747. * @param invertY defines if data must be stored with Y axis inverted
  50748. * @param premulAlpha defines if alpha is stored as premultiplied
  50749. * @param format defines the format of the data
  50750. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50751. */
  50752. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50753. /**
  50754. * Gets a boolean indicating if all created effects are ready
  50755. * @returns true if all effects are ready
  50756. */
  50757. areAllEffectsReady(): boolean;
  50758. /**
  50759. * @hidden
  50760. * Get the current error code of the webGL context
  50761. * @returns the error code
  50762. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50763. */
  50764. getError(): number;
  50765. /** @hidden */
  50766. _getUnpackAlignement(): number;
  50767. /** @hidden */
  50768. _unpackFlipY(value: boolean): void;
  50769. /**
  50770. * Update a dynamic index buffer
  50771. * @param indexBuffer defines the target index buffer
  50772. * @param indices defines the data to update
  50773. * @param offset defines the offset in the target index buffer where update should start
  50774. */
  50775. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  50776. /**
  50777. * Updates a dynamic vertex buffer.
  50778. * @param vertexBuffer the vertex buffer to update
  50779. * @param vertices the data used to update the vertex buffer
  50780. * @param byteOffset the byte offset of the data (optional)
  50781. * @param byteLength the byte length of the data (optional)
  50782. */
  50783. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  50784. /** @hidden */
  50785. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  50786. /** @hidden */
  50787. _bindTexture(channel: number, texture: InternalTexture): void;
  50788. protected _deleteBuffer(buffer: WebGLBuffer): void;
  50789. /**
  50790. * 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
  50791. */
  50792. releaseEffects(): void;
  50793. displayLoadingUI(): void;
  50794. hideLoadingUI(): void;
  50795. /** @hidden */
  50796. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50797. /** @hidden */
  50798. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50799. /** @hidden */
  50800. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50801. /** @hidden */
  50802. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50803. }
  50804. }
  50805. declare module BABYLON {
  50806. /**
  50807. * @hidden
  50808. **/
  50809. export class _TimeToken {
  50810. _startTimeQuery: Nullable<WebGLQuery>;
  50811. _endTimeQuery: Nullable<WebGLQuery>;
  50812. _timeElapsedQuery: Nullable<WebGLQuery>;
  50813. _timeElapsedQueryEnded: boolean;
  50814. }
  50815. }
  50816. declare module BABYLON {
  50817. /** @hidden */
  50818. export class _OcclusionDataStorage {
  50819. /** @hidden */
  50820. occlusionInternalRetryCounter: number;
  50821. /** @hidden */
  50822. isOcclusionQueryInProgress: boolean;
  50823. /** @hidden */
  50824. isOccluded: boolean;
  50825. /** @hidden */
  50826. occlusionRetryCount: number;
  50827. /** @hidden */
  50828. occlusionType: number;
  50829. /** @hidden */
  50830. occlusionQueryAlgorithmType: number;
  50831. }
  50832. interface Engine {
  50833. /**
  50834. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  50835. * @return the new query
  50836. */
  50837. createQuery(): WebGLQuery;
  50838. /**
  50839. * Delete and release a webGL query
  50840. * @param query defines the query to delete
  50841. * @return the current engine
  50842. */
  50843. deleteQuery(query: WebGLQuery): Engine;
  50844. /**
  50845. * Check if a given query has resolved and got its value
  50846. * @param query defines the query to check
  50847. * @returns true if the query got its value
  50848. */
  50849. isQueryResultAvailable(query: WebGLQuery): boolean;
  50850. /**
  50851. * Gets the value of a given query
  50852. * @param query defines the query to check
  50853. * @returns the value of the query
  50854. */
  50855. getQueryResult(query: WebGLQuery): number;
  50856. /**
  50857. * Initiates an occlusion query
  50858. * @param algorithmType defines the algorithm to use
  50859. * @param query defines the query to use
  50860. * @returns the current engine
  50861. * @see http://doc.babylonjs.com/features/occlusionquery
  50862. */
  50863. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  50864. /**
  50865. * Ends an occlusion query
  50866. * @see http://doc.babylonjs.com/features/occlusionquery
  50867. * @param algorithmType defines the algorithm to use
  50868. * @returns the current engine
  50869. */
  50870. endOcclusionQuery(algorithmType: number): Engine;
  50871. /**
  50872. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  50873. * Please note that only one query can be issued at a time
  50874. * @returns a time token used to track the time span
  50875. */
  50876. startTimeQuery(): Nullable<_TimeToken>;
  50877. /**
  50878. * Ends a time query
  50879. * @param token defines the token used to measure the time span
  50880. * @returns the time spent (in ns)
  50881. */
  50882. endTimeQuery(token: _TimeToken): int;
  50883. /** @hidden */
  50884. _currentNonTimestampToken: Nullable<_TimeToken>;
  50885. /** @hidden */
  50886. _createTimeQuery(): WebGLQuery;
  50887. /** @hidden */
  50888. _deleteTimeQuery(query: WebGLQuery): void;
  50889. /** @hidden */
  50890. _getGlAlgorithmType(algorithmType: number): number;
  50891. /** @hidden */
  50892. _getTimeQueryResult(query: WebGLQuery): any;
  50893. /** @hidden */
  50894. _getTimeQueryAvailability(query: WebGLQuery): any;
  50895. }
  50896. interface AbstractMesh {
  50897. /**
  50898. * Backing filed
  50899. * @hidden
  50900. */
  50901. __occlusionDataStorage: _OcclusionDataStorage;
  50902. /**
  50903. * Access property
  50904. * @hidden
  50905. */
  50906. _occlusionDataStorage: _OcclusionDataStorage;
  50907. /**
  50908. * 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.
  50909. * The default value is -1 which means don't break the query and wait till the result
  50910. * @see http://doc.babylonjs.com/features/occlusionquery
  50911. */
  50912. occlusionRetryCount: number;
  50913. /**
  50914. * 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:
  50915. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  50916. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  50917. * * 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.
  50918. * @see http://doc.babylonjs.com/features/occlusionquery
  50919. */
  50920. occlusionType: number;
  50921. /**
  50922. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  50923. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  50924. * * 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.
  50925. * @see http://doc.babylonjs.com/features/occlusionquery
  50926. */
  50927. occlusionQueryAlgorithmType: number;
  50928. /**
  50929. * 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
  50930. * @see http://doc.babylonjs.com/features/occlusionquery
  50931. */
  50932. isOccluded: boolean;
  50933. /**
  50934. * Flag to check the progress status of the query
  50935. * @see http://doc.babylonjs.com/features/occlusionquery
  50936. */
  50937. isOcclusionQueryInProgress: boolean;
  50938. }
  50939. }
  50940. declare module BABYLON {
  50941. /** @hidden */
  50942. export var _forceTransformFeedbackToBundle: boolean;
  50943. interface Engine {
  50944. /**
  50945. * Creates a webGL transform feedback object
  50946. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  50947. * @returns the webGL transform feedback object
  50948. */
  50949. createTransformFeedback(): WebGLTransformFeedback;
  50950. /**
  50951. * Delete a webGL transform feedback object
  50952. * @param value defines the webGL transform feedback object to delete
  50953. */
  50954. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  50955. /**
  50956. * Bind a webGL transform feedback object to the webgl context
  50957. * @param value defines the webGL transform feedback object to bind
  50958. */
  50959. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  50960. /**
  50961. * Begins a transform feedback operation
  50962. * @param usePoints defines if points or triangles must be used
  50963. */
  50964. beginTransformFeedback(usePoints: boolean): void;
  50965. /**
  50966. * Ends a transform feedback operation
  50967. */
  50968. endTransformFeedback(): void;
  50969. /**
  50970. * Specify the varyings to use with transform feedback
  50971. * @param program defines the associated webGL program
  50972. * @param value defines the list of strings representing the varying names
  50973. */
  50974. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  50975. /**
  50976. * Bind a webGL buffer for a transform feedback operation
  50977. * @param value defines the webGL buffer to bind
  50978. */
  50979. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  50980. }
  50981. }
  50982. declare module BABYLON {
  50983. /**
  50984. * Creation options of the multi render target texture.
  50985. */
  50986. export interface IMultiRenderTargetOptions {
  50987. /**
  50988. * Define if the texture needs to create mip maps after render.
  50989. */
  50990. generateMipMaps?: boolean;
  50991. /**
  50992. * Define the types of all the draw buffers we want to create
  50993. */
  50994. types?: number[];
  50995. /**
  50996. * Define the sampling modes of all the draw buffers we want to create
  50997. */
  50998. samplingModes?: number[];
  50999. /**
  51000. * Define if a depth buffer is required
  51001. */
  51002. generateDepthBuffer?: boolean;
  51003. /**
  51004. * Define if a stencil buffer is required
  51005. */
  51006. generateStencilBuffer?: boolean;
  51007. /**
  51008. * Define if a depth texture is required instead of a depth buffer
  51009. */
  51010. generateDepthTexture?: boolean;
  51011. /**
  51012. * Define the number of desired draw buffers
  51013. */
  51014. textureCount?: number;
  51015. /**
  51016. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51017. */
  51018. doNotChangeAspectRatio?: boolean;
  51019. /**
  51020. * Define the default type of the buffers we are creating
  51021. */
  51022. defaultType?: number;
  51023. }
  51024. /**
  51025. * A multi render target, like a render target provides the ability to render to a texture.
  51026. * Unlike the render target, it can render to several draw buffers in one draw.
  51027. * This is specially interesting in deferred rendering or for any effects requiring more than
  51028. * just one color from a single pass.
  51029. */
  51030. export class MultiRenderTarget extends RenderTargetTexture {
  51031. private _internalTextures;
  51032. private _textures;
  51033. private _multiRenderTargetOptions;
  51034. /**
  51035. * Get if draw buffers are currently supported by the used hardware and browser.
  51036. */
  51037. get isSupported(): boolean;
  51038. /**
  51039. * Get the list of textures generated by the multi render target.
  51040. */
  51041. get textures(): Texture[];
  51042. /**
  51043. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51044. */
  51045. get depthTexture(): Texture;
  51046. /**
  51047. * Set the wrapping mode on U of all the textures we are rendering to.
  51048. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51049. */
  51050. set wrapU(wrap: number);
  51051. /**
  51052. * Set the wrapping mode on V of all the textures we are rendering to.
  51053. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51054. */
  51055. set wrapV(wrap: number);
  51056. /**
  51057. * Instantiate a new multi render target texture.
  51058. * A multi render target, like a render target provides the ability to render to a texture.
  51059. * Unlike the render target, it can render to several draw buffers in one draw.
  51060. * This is specially interesting in deferred rendering or for any effects requiring more than
  51061. * just one color from a single pass.
  51062. * @param name Define the name of the texture
  51063. * @param size Define the size of the buffers to render to
  51064. * @param count Define the number of target we are rendering into
  51065. * @param scene Define the scene the texture belongs to
  51066. * @param options Define the options used to create the multi render target
  51067. */
  51068. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51069. /** @hidden */
  51070. _rebuild(): void;
  51071. private _createInternalTextures;
  51072. private _createTextures;
  51073. /**
  51074. * Define the number of samples used if MSAA is enabled.
  51075. */
  51076. get samples(): number;
  51077. set samples(value: number);
  51078. /**
  51079. * Resize all the textures in the multi render target.
  51080. * Be carrefull as it will recreate all the data in the new texture.
  51081. * @param size Define the new size
  51082. */
  51083. resize(size: any): void;
  51084. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51085. /**
  51086. * Dispose the render targets and their associated resources
  51087. */
  51088. dispose(): void;
  51089. /**
  51090. * Release all the underlying texture used as draw buffers.
  51091. */
  51092. releaseInternalTextures(): void;
  51093. }
  51094. }
  51095. declare module BABYLON {
  51096. interface ThinEngine {
  51097. /**
  51098. * Unbind a list of render target textures from the webGL context
  51099. * This is used only when drawBuffer extension or webGL2 are active
  51100. * @param textures defines the render target textures to unbind
  51101. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51102. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51103. */
  51104. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51105. /**
  51106. * Create a multi render target texture
  51107. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  51108. * @param size defines the size of the texture
  51109. * @param options defines the creation options
  51110. * @returns the cube texture as an InternalTexture
  51111. */
  51112. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51113. /**
  51114. * Update the sample count for a given multiple render target texture
  51115. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51116. * @param textures defines the textures to update
  51117. * @param samples defines the sample count to set
  51118. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51119. */
  51120. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51121. }
  51122. }
  51123. declare module BABYLON {
  51124. /**
  51125. * Class used to define an additional view for the engine
  51126. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51127. */
  51128. export class EngineView {
  51129. /** Defines the canvas where to render the view */
  51130. target: HTMLCanvasElement;
  51131. /** Defines an optional camera used to render the view (will use active camera else) */
  51132. camera?: Camera;
  51133. }
  51134. interface Engine {
  51135. /**
  51136. * Gets or sets the HTML element to use for attaching events
  51137. */
  51138. inputElement: Nullable<HTMLElement>;
  51139. /**
  51140. * Gets the current engine view
  51141. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51142. */
  51143. activeView: Nullable<EngineView>;
  51144. /** Gets or sets the list of views */
  51145. views: EngineView[];
  51146. /**
  51147. * Register a new child canvas
  51148. * @param canvas defines the canvas to register
  51149. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51150. * @returns the associated view
  51151. */
  51152. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51153. /**
  51154. * Remove a registered child canvas
  51155. * @param canvas defines the canvas to remove
  51156. * @returns the current engine
  51157. */
  51158. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51159. }
  51160. }
  51161. declare module BABYLON {
  51162. interface Engine {
  51163. /** @hidden */
  51164. _excludedCompressedTextures: string[];
  51165. /** @hidden */
  51166. _textureFormatInUse: string;
  51167. /**
  51168. * Gets the list of texture formats supported
  51169. */
  51170. readonly texturesSupported: Array<string>;
  51171. /**
  51172. * Gets the texture format in use
  51173. */
  51174. readonly textureFormatInUse: Nullable<string>;
  51175. /**
  51176. * Set the compressed texture extensions or file names to skip.
  51177. *
  51178. * @param skippedFiles defines the list of those texture files you want to skip
  51179. * Example: [".dds", ".env", "myfile.png"]
  51180. */
  51181. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51182. /**
  51183. * Set the compressed texture format to use, based on the formats you have, and the formats
  51184. * supported by the hardware / browser.
  51185. *
  51186. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51187. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51188. * to API arguments needed to compressed textures. This puts the burden on the container
  51189. * generator to house the arcane code for determining these for current & future formats.
  51190. *
  51191. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51192. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51193. *
  51194. * Note: The result of this call is not taken into account when a texture is base64.
  51195. *
  51196. * @param formatsAvailable defines the list of those format families you have created
  51197. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51198. *
  51199. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51200. * @returns The extension selected.
  51201. */
  51202. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51203. }
  51204. }
  51205. declare module BABYLON {
  51206. /**
  51207. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51208. */
  51209. export interface CubeMapInfo {
  51210. /**
  51211. * The pixel array for the front face.
  51212. * This is stored in format, left to right, up to down format.
  51213. */
  51214. front: Nullable<ArrayBufferView>;
  51215. /**
  51216. * The pixel array for the back face.
  51217. * This is stored in format, left to right, up to down format.
  51218. */
  51219. back: Nullable<ArrayBufferView>;
  51220. /**
  51221. * The pixel array for the left face.
  51222. * This is stored in format, left to right, up to down format.
  51223. */
  51224. left: Nullable<ArrayBufferView>;
  51225. /**
  51226. * The pixel array for the right face.
  51227. * This is stored in format, left to right, up to down format.
  51228. */
  51229. right: Nullable<ArrayBufferView>;
  51230. /**
  51231. * The pixel array for the up face.
  51232. * This is stored in format, left to right, up to down format.
  51233. */
  51234. up: Nullable<ArrayBufferView>;
  51235. /**
  51236. * The pixel array for the down face.
  51237. * This is stored in format, left to right, up to down format.
  51238. */
  51239. down: Nullable<ArrayBufferView>;
  51240. /**
  51241. * The size of the cubemap stored.
  51242. *
  51243. * Each faces will be size * size pixels.
  51244. */
  51245. size: number;
  51246. /**
  51247. * The format of the texture.
  51248. *
  51249. * RGBA, RGB.
  51250. */
  51251. format: number;
  51252. /**
  51253. * The type of the texture data.
  51254. *
  51255. * UNSIGNED_INT, FLOAT.
  51256. */
  51257. type: number;
  51258. /**
  51259. * Specifies whether the texture is in gamma space.
  51260. */
  51261. gammaSpace: boolean;
  51262. }
  51263. /**
  51264. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51265. */
  51266. export class PanoramaToCubeMapTools {
  51267. private static FACE_LEFT;
  51268. private static FACE_RIGHT;
  51269. private static FACE_FRONT;
  51270. private static FACE_BACK;
  51271. private static FACE_DOWN;
  51272. private static FACE_UP;
  51273. /**
  51274. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51275. *
  51276. * @param float32Array The source data.
  51277. * @param inputWidth The width of the input panorama.
  51278. * @param inputHeight The height of the input panorama.
  51279. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51280. * @return The cubemap data
  51281. */
  51282. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51283. private static CreateCubemapTexture;
  51284. private static CalcProjectionSpherical;
  51285. }
  51286. }
  51287. declare module BABYLON {
  51288. /**
  51289. * Helper class dealing with the extraction of spherical polynomial dataArray
  51290. * from a cube map.
  51291. */
  51292. export class CubeMapToSphericalPolynomialTools {
  51293. private static FileFaces;
  51294. /**
  51295. * Converts a texture to the according Spherical Polynomial data.
  51296. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51297. *
  51298. * @param texture The texture to extract the information from.
  51299. * @return The Spherical Polynomial data.
  51300. */
  51301. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51302. /**
  51303. * Converts a cubemap to the according Spherical Polynomial data.
  51304. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51305. *
  51306. * @param cubeInfo The Cube map to extract the information from.
  51307. * @return The Spherical Polynomial data.
  51308. */
  51309. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51310. }
  51311. }
  51312. declare module BABYLON {
  51313. interface BaseTexture {
  51314. /**
  51315. * Get the polynomial representation of the texture data.
  51316. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51317. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51318. */
  51319. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51320. }
  51321. }
  51322. declare module BABYLON {
  51323. /** @hidden */
  51324. export var rgbdEncodePixelShader: {
  51325. name: string;
  51326. shader: string;
  51327. };
  51328. }
  51329. declare module BABYLON {
  51330. /** @hidden */
  51331. export var rgbdDecodePixelShader: {
  51332. name: string;
  51333. shader: string;
  51334. };
  51335. }
  51336. declare module BABYLON {
  51337. /**
  51338. * Raw texture data and descriptor sufficient for WebGL texture upload
  51339. */
  51340. export interface EnvironmentTextureInfo {
  51341. /**
  51342. * Version of the environment map
  51343. */
  51344. version: number;
  51345. /**
  51346. * Width of image
  51347. */
  51348. width: number;
  51349. /**
  51350. * Irradiance information stored in the file.
  51351. */
  51352. irradiance: any;
  51353. /**
  51354. * Specular information stored in the file.
  51355. */
  51356. specular: any;
  51357. }
  51358. /**
  51359. * Defines One Image in the file. It requires only the position in the file
  51360. * as well as the length.
  51361. */
  51362. interface BufferImageData {
  51363. /**
  51364. * Length of the image data.
  51365. */
  51366. length: number;
  51367. /**
  51368. * Position of the data from the null terminator delimiting the end of the JSON.
  51369. */
  51370. position: number;
  51371. }
  51372. /**
  51373. * Defines the specular data enclosed in the file.
  51374. * This corresponds to the version 1 of the data.
  51375. */
  51376. export interface EnvironmentTextureSpecularInfoV1 {
  51377. /**
  51378. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51379. */
  51380. specularDataPosition?: number;
  51381. /**
  51382. * This contains all the images data needed to reconstruct the cubemap.
  51383. */
  51384. mipmaps: Array<BufferImageData>;
  51385. /**
  51386. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51387. */
  51388. lodGenerationScale: number;
  51389. }
  51390. /**
  51391. * Sets of helpers addressing the serialization and deserialization of environment texture
  51392. * stored in a BabylonJS env file.
  51393. * Those files are usually stored as .env files.
  51394. */
  51395. export class EnvironmentTextureTools {
  51396. /**
  51397. * Magic number identifying the env file.
  51398. */
  51399. private static _MagicBytes;
  51400. /**
  51401. * Gets the environment info from an env file.
  51402. * @param data The array buffer containing the .env bytes.
  51403. * @returns the environment file info (the json header) if successfully parsed.
  51404. */
  51405. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51406. /**
  51407. * Creates an environment texture from a loaded cube texture.
  51408. * @param texture defines the cube texture to convert in env file
  51409. * @return a promise containing the environment data if succesfull.
  51410. */
  51411. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51412. /**
  51413. * Creates a JSON representation of the spherical data.
  51414. * @param texture defines the texture containing the polynomials
  51415. * @return the JSON representation of the spherical info
  51416. */
  51417. private static _CreateEnvTextureIrradiance;
  51418. /**
  51419. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51420. * @param data the image data
  51421. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51422. * @return the views described by info providing access to the underlying buffer
  51423. */
  51424. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51425. /**
  51426. * Uploads the texture info contained in the env file to the GPU.
  51427. * @param texture defines the internal texture to upload to
  51428. * @param data defines the data to load
  51429. * @param info defines the texture info retrieved through the GetEnvInfo method
  51430. * @returns a promise
  51431. */
  51432. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51433. private static _OnImageReadyAsync;
  51434. /**
  51435. * Uploads the levels of image data to the GPU.
  51436. * @param texture defines the internal texture to upload to
  51437. * @param imageData defines the array buffer views of image data [mipmap][face]
  51438. * @returns a promise
  51439. */
  51440. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51441. /**
  51442. * Uploads spherical polynomials information to the texture.
  51443. * @param texture defines the texture we are trying to upload the information to
  51444. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51445. */
  51446. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51447. /** @hidden */
  51448. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51449. }
  51450. }
  51451. declare module BABYLON {
  51452. /** @hidden */
  51453. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  51454. private _genericAttributeLocation;
  51455. private _varyingLocationCount;
  51456. private _varyingLocationMap;
  51457. private _replacements;
  51458. private _textureCount;
  51459. private _uniforms;
  51460. lineProcessor(line: string): string;
  51461. attributeProcessor(attribute: string): string;
  51462. varyingProcessor(varying: string, isFragment: boolean): string;
  51463. uniformProcessor(uniform: string): string;
  51464. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  51465. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  51466. }
  51467. }
  51468. declare module BABYLON {
  51469. /**
  51470. * Class used to inline functions in shader code
  51471. */
  51472. export class ShaderCodeInliner {
  51473. private static readonly _RegexpFindFunctionNameAndType;
  51474. private _sourceCode;
  51475. private _functionDescr;
  51476. private _numMaxIterations;
  51477. /** Gets or sets the token used to mark the functions to inline */
  51478. inlineToken: string;
  51479. /** Gets or sets the debug mode */
  51480. debug: boolean;
  51481. /** Gets the code after the inlining process */
  51482. get code(): string;
  51483. /**
  51484. * Initializes the inliner
  51485. * @param sourceCode shader code source to inline
  51486. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51487. */
  51488. constructor(sourceCode: string, numMaxIterations?: number);
  51489. /**
  51490. * Start the processing of the shader code
  51491. */
  51492. processCode(): void;
  51493. private _collectFunctions;
  51494. private _processInlining;
  51495. private _extractBetweenMarkers;
  51496. private _skipWhitespaces;
  51497. private _removeComments;
  51498. private _replaceFunctionCallsByCode;
  51499. private _findBackward;
  51500. private _escapeRegExp;
  51501. private _replaceNames;
  51502. }
  51503. }
  51504. declare module BABYLON {
  51505. /**
  51506. * Container for accessors for natively-stored mesh data buffers.
  51507. */
  51508. class NativeDataBuffer extends DataBuffer {
  51509. /**
  51510. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51511. */
  51512. nativeIndexBuffer?: any;
  51513. /**
  51514. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51515. */
  51516. nativeVertexBuffer?: any;
  51517. }
  51518. /** @hidden */
  51519. class NativeTexture extends InternalTexture {
  51520. getInternalTexture(): InternalTexture;
  51521. getViewCount(): number;
  51522. }
  51523. /** @hidden */
  51524. export class NativeEngine extends Engine {
  51525. private readonly _native;
  51526. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51527. private readonly INVALID_HANDLE;
  51528. getHardwareScalingLevel(): number;
  51529. constructor();
  51530. dispose(): void;
  51531. /**
  51532. * Can be used to override the current requestAnimationFrame requester.
  51533. * @hidden
  51534. */
  51535. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51536. /**
  51537. * Override default engine behavior.
  51538. * @param color
  51539. * @param backBuffer
  51540. * @param depth
  51541. * @param stencil
  51542. */
  51543. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51544. /**
  51545. * Gets host document
  51546. * @returns the host document object
  51547. */
  51548. getHostDocument(): Nullable<Document>;
  51549. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51550. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51551. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51552. recordVertexArrayObject(vertexBuffers: {
  51553. [key: string]: VertexBuffer;
  51554. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51555. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51556. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51557. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51558. /**
  51559. * Draw a list of indexed primitives
  51560. * @param fillMode defines the primitive to use
  51561. * @param indexStart defines the starting index
  51562. * @param indexCount defines the number of index to draw
  51563. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51564. */
  51565. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51566. /**
  51567. * Draw a list of unindexed primitives
  51568. * @param fillMode defines the primitive to use
  51569. * @param verticesStart defines the index of first vertex to draw
  51570. * @param verticesCount defines the count of vertices to draw
  51571. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51572. */
  51573. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51574. createPipelineContext(): IPipelineContext;
  51575. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51576. /** @hidden */
  51577. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51578. /** @hidden */
  51579. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51580. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51581. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51582. protected _setProgram(program: WebGLProgram): void;
  51583. _releaseEffect(effect: Effect): void;
  51584. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51585. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51586. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51587. bindSamplers(effect: Effect): void;
  51588. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51589. getRenderWidth(useScreen?: boolean): number;
  51590. getRenderHeight(useScreen?: boolean): number;
  51591. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51592. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51593. /**
  51594. * Set the z offset to apply to current rendering
  51595. * @param value defines the offset to apply
  51596. */
  51597. setZOffset(value: number): void;
  51598. /**
  51599. * Gets the current value of the zOffset
  51600. * @returns the current zOffset state
  51601. */
  51602. getZOffset(): number;
  51603. /**
  51604. * Enable or disable depth buffering
  51605. * @param enable defines the state to set
  51606. */
  51607. setDepthBuffer(enable: boolean): void;
  51608. /**
  51609. * Gets a boolean indicating if depth writing is enabled
  51610. * @returns the current depth writing state
  51611. */
  51612. getDepthWrite(): boolean;
  51613. /**
  51614. * Enable or disable depth writing
  51615. * @param enable defines the state to set
  51616. */
  51617. setDepthWrite(enable: boolean): void;
  51618. /**
  51619. * Enable or disable color writing
  51620. * @param enable defines the state to set
  51621. */
  51622. setColorWrite(enable: boolean): void;
  51623. /**
  51624. * Gets a boolean indicating if color writing is enabled
  51625. * @returns the current color writing state
  51626. */
  51627. getColorWrite(): boolean;
  51628. /**
  51629. * Sets alpha constants used by some alpha blending modes
  51630. * @param r defines the red component
  51631. * @param g defines the green component
  51632. * @param b defines the blue component
  51633. * @param a defines the alpha component
  51634. */
  51635. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51636. /**
  51637. * Sets the current alpha mode
  51638. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51639. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51640. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51641. */
  51642. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51643. /**
  51644. * Gets the current alpha mode
  51645. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51646. * @returns the current alpha mode
  51647. */
  51648. getAlphaMode(): number;
  51649. setInt(uniform: WebGLUniformLocation, int: number): void;
  51650. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51651. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51652. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51653. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51654. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51655. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51656. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51657. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51658. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51659. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51660. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51661. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51662. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51663. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51664. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51665. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51666. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51667. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51668. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51669. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51670. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51671. wipeCaches(bruteForce?: boolean): void;
  51672. _createTexture(): WebGLTexture;
  51673. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51674. /**
  51675. * Usually called from Texture.ts.
  51676. * Passed information to create a WebGLTexture
  51677. * @param url defines a value which contains one of the following:
  51678. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51679. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51680. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51681. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51682. * @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)
  51683. * @param scene needed for loading to the correct scene
  51684. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51685. * @param onLoad optional callback to be called upon successful completion
  51686. * @param onError optional callback to be called upon failure
  51687. * @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
  51688. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51689. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51690. * @param forcedExtension defines the extension to use to pick the right loader
  51691. * @param mimeType defines an optional mime type
  51692. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51693. */
  51694. 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;
  51695. /**
  51696. * Creates a cube texture
  51697. * @param rootUrl defines the url where the files to load is located
  51698. * @param scene defines the current scene
  51699. * @param files defines the list of files to load (1 per face)
  51700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51701. * @param onLoad defines an optional callback raised when the texture is loaded
  51702. * @param onError defines an optional callback raised if there is an issue to load the texture
  51703. * @param format defines the format of the data
  51704. * @param forcedExtension defines the extension to use to pick the right loader
  51705. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51706. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51707. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51708. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51709. * @returns the cube texture as an InternalTexture
  51710. */
  51711. 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;
  51712. private _getSamplingFilter;
  51713. private static _GetNativeTextureFormat;
  51714. createRenderTargetTexture(size: number | {
  51715. width: number;
  51716. height: number;
  51717. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51718. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51719. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51720. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51721. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51722. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51723. /**
  51724. * Updates a dynamic vertex buffer.
  51725. * @param vertexBuffer the vertex buffer to update
  51726. * @param data the data used to update the vertex buffer
  51727. * @param byteOffset the byte offset of the data (optional)
  51728. * @param byteLength the byte length of the data (optional)
  51729. */
  51730. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51731. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51732. private _updateAnisotropicLevel;
  51733. private _getAddressMode;
  51734. /** @hidden */
  51735. _bindTexture(channel: number, texture: InternalTexture): void;
  51736. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51737. releaseEffects(): void;
  51738. /** @hidden */
  51739. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51740. /** @hidden */
  51741. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51742. /** @hidden */
  51743. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51744. /** @hidden */
  51745. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51746. }
  51747. }
  51748. declare module BABYLON {
  51749. /**
  51750. * Gather the list of clipboard event types as constants.
  51751. */
  51752. export class ClipboardEventTypes {
  51753. /**
  51754. * The clipboard event is fired when a copy command is active (pressed).
  51755. */
  51756. static readonly COPY: number;
  51757. /**
  51758. * The clipboard event is fired when a cut command is active (pressed).
  51759. */
  51760. static readonly CUT: number;
  51761. /**
  51762. * The clipboard event is fired when a paste command is active (pressed).
  51763. */
  51764. static readonly PASTE: number;
  51765. }
  51766. /**
  51767. * This class is used to store clipboard related info for the onClipboardObservable event.
  51768. */
  51769. export class ClipboardInfo {
  51770. /**
  51771. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51772. */
  51773. type: number;
  51774. /**
  51775. * Defines the related dom event
  51776. */
  51777. event: ClipboardEvent;
  51778. /**
  51779. *Creates an instance of ClipboardInfo.
  51780. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  51781. * @param event Defines the related dom event
  51782. */
  51783. constructor(
  51784. /**
  51785. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51786. */
  51787. type: number,
  51788. /**
  51789. * Defines the related dom event
  51790. */
  51791. event: ClipboardEvent);
  51792. /**
  51793. * Get the clipboard event's type from the keycode.
  51794. * @param keyCode Defines the keyCode for the current keyboard event.
  51795. * @return {number}
  51796. */
  51797. static GetTypeFromCharacter(keyCode: number): number;
  51798. }
  51799. }
  51800. declare module BABYLON {
  51801. /**
  51802. * Google Daydream controller
  51803. */
  51804. export class DaydreamController extends WebVRController {
  51805. /**
  51806. * Base Url for the controller model.
  51807. */
  51808. static MODEL_BASE_URL: string;
  51809. /**
  51810. * File name for the controller model.
  51811. */
  51812. static MODEL_FILENAME: string;
  51813. /**
  51814. * Gamepad Id prefix used to identify Daydream Controller.
  51815. */
  51816. static readonly GAMEPAD_ID_PREFIX: string;
  51817. /**
  51818. * Creates a new DaydreamController from a gamepad
  51819. * @param vrGamepad the gamepad that the controller should be created from
  51820. */
  51821. constructor(vrGamepad: any);
  51822. /**
  51823. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51824. * @param scene scene in which to add meshes
  51825. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51826. */
  51827. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51828. /**
  51829. * Called once for each button that changed state since the last frame
  51830. * @param buttonIdx Which button index changed
  51831. * @param state New state of the button
  51832. * @param changes Which properties on the state changed since last frame
  51833. */
  51834. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51835. }
  51836. }
  51837. declare module BABYLON {
  51838. /**
  51839. * Gear VR Controller
  51840. */
  51841. export class GearVRController extends WebVRController {
  51842. /**
  51843. * Base Url for the controller model.
  51844. */
  51845. static MODEL_BASE_URL: string;
  51846. /**
  51847. * File name for the controller model.
  51848. */
  51849. static MODEL_FILENAME: string;
  51850. /**
  51851. * Gamepad Id prefix used to identify this controller.
  51852. */
  51853. static readonly GAMEPAD_ID_PREFIX: string;
  51854. private readonly _buttonIndexToObservableNameMap;
  51855. /**
  51856. * Creates a new GearVRController from a gamepad
  51857. * @param vrGamepad the gamepad that the controller should be created from
  51858. */
  51859. constructor(vrGamepad: any);
  51860. /**
  51861. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51862. * @param scene scene in which to add meshes
  51863. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51864. */
  51865. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51866. /**
  51867. * Called once for each button that changed state since the last frame
  51868. * @param buttonIdx Which button index changed
  51869. * @param state New state of the button
  51870. * @param changes Which properties on the state changed since last frame
  51871. */
  51872. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51873. }
  51874. }
  51875. declare module BABYLON {
  51876. /**
  51877. * Generic Controller
  51878. */
  51879. export class GenericController extends WebVRController {
  51880. /**
  51881. * Base Url for the controller model.
  51882. */
  51883. static readonly MODEL_BASE_URL: string;
  51884. /**
  51885. * File name for the controller model.
  51886. */
  51887. static readonly MODEL_FILENAME: string;
  51888. /**
  51889. * Creates a new GenericController from a gamepad
  51890. * @param vrGamepad the gamepad that the controller should be created from
  51891. */
  51892. constructor(vrGamepad: any);
  51893. /**
  51894. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51895. * @param scene scene in which to add meshes
  51896. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51897. */
  51898. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51899. /**
  51900. * Called once for each button that changed state since the last frame
  51901. * @param buttonIdx Which button index changed
  51902. * @param state New state of the button
  51903. * @param changes Which properties on the state changed since last frame
  51904. */
  51905. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51906. }
  51907. }
  51908. declare module BABYLON {
  51909. /**
  51910. * Oculus Touch Controller
  51911. */
  51912. export class OculusTouchController extends WebVRController {
  51913. /**
  51914. * Base Url for the controller model.
  51915. */
  51916. static MODEL_BASE_URL: string;
  51917. /**
  51918. * File name for the left controller model.
  51919. */
  51920. static MODEL_LEFT_FILENAME: string;
  51921. /**
  51922. * File name for the right controller model.
  51923. */
  51924. static MODEL_RIGHT_FILENAME: string;
  51925. /**
  51926. * Base Url for the Quest controller model.
  51927. */
  51928. static QUEST_MODEL_BASE_URL: string;
  51929. /**
  51930. * @hidden
  51931. * If the controllers are running on a device that needs the updated Quest controller models
  51932. */
  51933. static _IsQuest: boolean;
  51934. /**
  51935. * Fired when the secondary trigger on this controller is modified
  51936. */
  51937. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  51938. /**
  51939. * Fired when the thumb rest on this controller is modified
  51940. */
  51941. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  51942. /**
  51943. * Creates a new OculusTouchController from a gamepad
  51944. * @param vrGamepad the gamepad that the controller should be created from
  51945. */
  51946. constructor(vrGamepad: any);
  51947. /**
  51948. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  51949. * @param scene scene in which to add meshes
  51950. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  51951. */
  51952. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  51953. /**
  51954. * Fired when the A button on this controller is modified
  51955. */
  51956. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51957. /**
  51958. * Fired when the B button on this controller is modified
  51959. */
  51960. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51961. /**
  51962. * Fired when the X button on this controller is modified
  51963. */
  51964. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51965. /**
  51966. * Fired when the Y button on this controller is modified
  51967. */
  51968. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  51969. /**
  51970. * Called once for each button that changed state since the last frame
  51971. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  51972. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  51973. * 2) secondary trigger (same)
  51974. * 3) A (right) X (left), touch, pressed = value
  51975. * 4) B / Y
  51976. * 5) thumb rest
  51977. * @param buttonIdx Which button index changed
  51978. * @param state New state of the button
  51979. * @param changes Which properties on the state changed since last frame
  51980. */
  51981. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  51982. }
  51983. }
  51984. declare module BABYLON {
  51985. /**
  51986. * Vive Controller
  51987. */
  51988. export class ViveController extends WebVRController {
  51989. /**
  51990. * Base Url for the controller model.
  51991. */
  51992. static MODEL_BASE_URL: string;
  51993. /**
  51994. * File name for the controller model.
  51995. */
  51996. static MODEL_FILENAME: string;
  51997. /**
  51998. * Creates a new ViveController from a gamepad
  51999. * @param vrGamepad the gamepad that the controller should be created from
  52000. */
  52001. constructor(vrGamepad: any);
  52002. /**
  52003. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52004. * @param scene scene in which to add meshes
  52005. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52006. */
  52007. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52008. /**
  52009. * Fired when the left button on this controller is modified
  52010. */
  52011. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52012. /**
  52013. * Fired when the right button on this controller is modified
  52014. */
  52015. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52016. /**
  52017. * Fired when the menu button on this controller is modified
  52018. */
  52019. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52020. /**
  52021. * Called once for each button that changed state since the last frame
  52022. * Vive mapping:
  52023. * 0: touchpad
  52024. * 1: trigger
  52025. * 2: left AND right buttons
  52026. * 3: menu button
  52027. * @param buttonIdx Which button index changed
  52028. * @param state New state of the button
  52029. * @param changes Which properties on the state changed since last frame
  52030. */
  52031. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52032. }
  52033. }
  52034. declare module BABYLON {
  52035. /**
  52036. * Defines the WindowsMotionController object that the state of the windows motion controller
  52037. */
  52038. export class WindowsMotionController extends WebVRController {
  52039. /**
  52040. * The base url used to load the left and right controller models
  52041. */
  52042. static MODEL_BASE_URL: string;
  52043. /**
  52044. * The name of the left controller model file
  52045. */
  52046. static MODEL_LEFT_FILENAME: string;
  52047. /**
  52048. * The name of the right controller model file
  52049. */
  52050. static MODEL_RIGHT_FILENAME: string;
  52051. /**
  52052. * The controller name prefix for this controller type
  52053. */
  52054. static readonly GAMEPAD_ID_PREFIX: string;
  52055. /**
  52056. * The controller id pattern for this controller type
  52057. */
  52058. private static readonly GAMEPAD_ID_PATTERN;
  52059. private _loadedMeshInfo;
  52060. protected readonly _mapping: {
  52061. buttons: string[];
  52062. buttonMeshNames: {
  52063. trigger: string;
  52064. menu: string;
  52065. grip: string;
  52066. thumbstick: string;
  52067. trackpad: string;
  52068. };
  52069. buttonObservableNames: {
  52070. trigger: string;
  52071. menu: string;
  52072. grip: string;
  52073. thumbstick: string;
  52074. trackpad: string;
  52075. };
  52076. axisMeshNames: string[];
  52077. pointingPoseMeshName: string;
  52078. };
  52079. /**
  52080. * Fired when the trackpad on this controller is clicked
  52081. */
  52082. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52083. /**
  52084. * Fired when the trackpad on this controller is modified
  52085. */
  52086. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52087. /**
  52088. * The current x and y values of this controller's trackpad
  52089. */
  52090. trackpad: StickValues;
  52091. /**
  52092. * Creates a new WindowsMotionController from a gamepad
  52093. * @param vrGamepad the gamepad that the controller should be created from
  52094. */
  52095. constructor(vrGamepad: any);
  52096. /**
  52097. * Fired when the trigger on this controller is modified
  52098. */
  52099. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52100. /**
  52101. * Fired when the menu button on this controller is modified
  52102. */
  52103. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52104. /**
  52105. * Fired when the grip button on this controller is modified
  52106. */
  52107. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52108. /**
  52109. * Fired when the thumbstick button on this controller is modified
  52110. */
  52111. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52112. /**
  52113. * Fired when the touchpad button on this controller is modified
  52114. */
  52115. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52116. /**
  52117. * Fired when the touchpad values on this controller are modified
  52118. */
  52119. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52120. protected _updateTrackpad(): void;
  52121. /**
  52122. * Called once per frame by the engine.
  52123. */
  52124. update(): void;
  52125. /**
  52126. * Called once for each button that changed state since the last frame
  52127. * @param buttonIdx Which button index changed
  52128. * @param state New state of the button
  52129. * @param changes Which properties on the state changed since last frame
  52130. */
  52131. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52132. /**
  52133. * Moves the buttons on the controller mesh based on their current state
  52134. * @param buttonName the name of the button to move
  52135. * @param buttonValue the value of the button which determines the buttons new position
  52136. */
  52137. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52138. /**
  52139. * Moves the axis on the controller mesh based on its current state
  52140. * @param axis the index of the axis
  52141. * @param axisValue the value of the axis which determines the meshes new position
  52142. * @hidden
  52143. */
  52144. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52145. /**
  52146. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52147. * @param scene scene in which to add meshes
  52148. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52149. */
  52150. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52151. /**
  52152. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52153. * can be transformed by button presses and axes values, based on this._mapping.
  52154. *
  52155. * @param scene scene in which the meshes exist
  52156. * @param meshes list of meshes that make up the controller model to process
  52157. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52158. */
  52159. private processModel;
  52160. private createMeshInfo;
  52161. /**
  52162. * Gets the ray of the controller in the direction the controller is pointing
  52163. * @param length the length the resulting ray should be
  52164. * @returns a ray in the direction the controller is pointing
  52165. */
  52166. getForwardRay(length?: number): Ray;
  52167. /**
  52168. * Disposes of the controller
  52169. */
  52170. dispose(): void;
  52171. }
  52172. /**
  52173. * This class represents a new windows motion controller in XR.
  52174. */
  52175. export class XRWindowsMotionController extends WindowsMotionController {
  52176. /**
  52177. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52178. */
  52179. protected readonly _mapping: {
  52180. buttons: string[];
  52181. buttonMeshNames: {
  52182. trigger: string;
  52183. menu: string;
  52184. grip: string;
  52185. thumbstick: string;
  52186. trackpad: string;
  52187. };
  52188. buttonObservableNames: {
  52189. trigger: string;
  52190. menu: string;
  52191. grip: string;
  52192. thumbstick: string;
  52193. trackpad: string;
  52194. };
  52195. axisMeshNames: string[];
  52196. pointingPoseMeshName: string;
  52197. };
  52198. /**
  52199. * Construct a new XR-Based windows motion controller
  52200. *
  52201. * @param gamepadInfo the gamepad object from the browser
  52202. */
  52203. constructor(gamepadInfo: any);
  52204. /**
  52205. * holds the thumbstick values (X,Y)
  52206. */
  52207. thumbstickValues: StickValues;
  52208. /**
  52209. * Fired when the thumbstick on this controller is clicked
  52210. */
  52211. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52212. /**
  52213. * Fired when the thumbstick on this controller is modified
  52214. */
  52215. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52216. /**
  52217. * Fired when the touchpad button on this controller is modified
  52218. */
  52219. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52220. /**
  52221. * Fired when the touchpad values on this controller are modified
  52222. */
  52223. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52224. /**
  52225. * Fired when the thumbstick button on this controller is modified
  52226. * here to prevent breaking changes
  52227. */
  52228. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52229. /**
  52230. * updating the thumbstick(!) and not the trackpad.
  52231. * This is named this way due to the difference between WebVR and XR and to avoid
  52232. * changing the parent class.
  52233. */
  52234. protected _updateTrackpad(): void;
  52235. /**
  52236. * Disposes the class with joy
  52237. */
  52238. dispose(): void;
  52239. }
  52240. }
  52241. declare module BABYLON {
  52242. /**
  52243. * Class containing static functions to help procedurally build meshes
  52244. */
  52245. export class PolyhedronBuilder {
  52246. /**
  52247. * Creates a polyhedron mesh
  52248. * * 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
  52249. * * The parameter `size` (positive float, default 1) sets the polygon size
  52250. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52251. * * 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`
  52252. * * 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
  52253. * * 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)`)
  52254. * * 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
  52255. * * 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
  52256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52257. * * 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
  52258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52259. * @param name defines the name of the mesh
  52260. * @param options defines the options used to create the mesh
  52261. * @param scene defines the hosting scene
  52262. * @returns the polyhedron mesh
  52263. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52264. */
  52265. static CreatePolyhedron(name: string, options: {
  52266. type?: number;
  52267. size?: number;
  52268. sizeX?: number;
  52269. sizeY?: number;
  52270. sizeZ?: number;
  52271. custom?: any;
  52272. faceUV?: Vector4[];
  52273. faceColors?: Color4[];
  52274. flat?: boolean;
  52275. updatable?: boolean;
  52276. sideOrientation?: number;
  52277. frontUVs?: Vector4;
  52278. backUVs?: Vector4;
  52279. }, scene?: Nullable<Scene>): Mesh;
  52280. }
  52281. }
  52282. declare module BABYLON {
  52283. /**
  52284. * Gizmo that enables scaling a mesh along 3 axis
  52285. */
  52286. export class ScaleGizmo extends Gizmo {
  52287. /**
  52288. * Internal gizmo used for interactions on the x axis
  52289. */
  52290. xGizmo: AxisScaleGizmo;
  52291. /**
  52292. * Internal gizmo used for interactions on the y axis
  52293. */
  52294. yGizmo: AxisScaleGizmo;
  52295. /**
  52296. * Internal gizmo used for interactions on the z axis
  52297. */
  52298. zGizmo: AxisScaleGizmo;
  52299. /**
  52300. * Internal gizmo used to scale all axis equally
  52301. */
  52302. uniformScaleGizmo: AxisScaleGizmo;
  52303. private _meshAttached;
  52304. private _updateGizmoRotationToMatchAttachedMesh;
  52305. private _snapDistance;
  52306. private _scaleRatio;
  52307. private _uniformScalingMesh;
  52308. private _octahedron;
  52309. private _sensitivity;
  52310. /** Fires an event when any of it's sub gizmos are dragged */
  52311. onDragStartObservable: Observable<unknown>;
  52312. /** Fires an event when any of it's sub gizmos are released from dragging */
  52313. onDragEndObservable: Observable<unknown>;
  52314. get attachedMesh(): Nullable<AbstractMesh>;
  52315. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52316. /**
  52317. * Creates a ScaleGizmo
  52318. * @param gizmoLayer The utility layer the gizmo will be added to
  52319. */
  52320. constructor(gizmoLayer?: UtilityLayerRenderer);
  52321. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52322. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52323. /**
  52324. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52325. */
  52326. set snapDistance(value: number);
  52327. get snapDistance(): number;
  52328. /**
  52329. * Ratio for the scale of the gizmo (Default: 1)
  52330. */
  52331. set scaleRatio(value: number);
  52332. get scaleRatio(): number;
  52333. /**
  52334. * Sensitivity factor for dragging (Default: 1)
  52335. */
  52336. set sensitivity(value: number);
  52337. get sensitivity(): number;
  52338. /**
  52339. * Disposes of the gizmo
  52340. */
  52341. dispose(): void;
  52342. }
  52343. }
  52344. declare module BABYLON {
  52345. /**
  52346. * Single axis scale gizmo
  52347. */
  52348. export class AxisScaleGizmo extends Gizmo {
  52349. /**
  52350. * Drag behavior responsible for the gizmos dragging interactions
  52351. */
  52352. dragBehavior: PointerDragBehavior;
  52353. private _pointerObserver;
  52354. /**
  52355. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52356. */
  52357. snapDistance: number;
  52358. /**
  52359. * Event that fires each time the gizmo snaps to a new location.
  52360. * * snapDistance is the the change in distance
  52361. */
  52362. onSnapObservable: Observable<{
  52363. snapDistance: number;
  52364. }>;
  52365. /**
  52366. * If the scaling operation should be done on all axis (default: false)
  52367. */
  52368. uniformScaling: boolean;
  52369. /**
  52370. * Custom sensitivity value for the drag strength
  52371. */
  52372. sensitivity: number;
  52373. private _isEnabled;
  52374. private _parent;
  52375. private _arrow;
  52376. private _coloredMaterial;
  52377. private _hoverMaterial;
  52378. /**
  52379. * Creates an AxisScaleGizmo
  52380. * @param gizmoLayer The utility layer the gizmo will be added to
  52381. * @param dragAxis The axis which the gizmo will be able to scale on
  52382. * @param color The color of the gizmo
  52383. */
  52384. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52385. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52386. /**
  52387. * If the gizmo is enabled
  52388. */
  52389. set isEnabled(value: boolean);
  52390. get isEnabled(): boolean;
  52391. /**
  52392. * Disposes of the gizmo
  52393. */
  52394. dispose(): void;
  52395. /**
  52396. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52397. * @param mesh The mesh to replace the default mesh of the gizmo
  52398. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52399. */
  52400. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52401. }
  52402. }
  52403. declare module BABYLON {
  52404. /**
  52405. * Bounding box gizmo
  52406. */
  52407. export class BoundingBoxGizmo extends Gizmo {
  52408. private _lineBoundingBox;
  52409. private _rotateSpheresParent;
  52410. private _scaleBoxesParent;
  52411. private _boundingDimensions;
  52412. private _renderObserver;
  52413. private _pointerObserver;
  52414. private _scaleDragSpeed;
  52415. private _tmpQuaternion;
  52416. private _tmpVector;
  52417. private _tmpRotationMatrix;
  52418. /**
  52419. * 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)
  52420. */
  52421. ignoreChildren: boolean;
  52422. /**
  52423. * 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)
  52424. */
  52425. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52426. /**
  52427. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52428. */
  52429. rotationSphereSize: number;
  52430. /**
  52431. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52432. */
  52433. scaleBoxSize: number;
  52434. /**
  52435. * 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)
  52436. */
  52437. fixedDragMeshScreenSize: boolean;
  52438. /**
  52439. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52440. */
  52441. fixedDragMeshScreenSizeDistanceFactor: number;
  52442. /**
  52443. * Fired when a rotation sphere or scale box is dragged
  52444. */
  52445. onDragStartObservable: Observable<{}>;
  52446. /**
  52447. * Fired when a scale box is dragged
  52448. */
  52449. onScaleBoxDragObservable: Observable<{}>;
  52450. /**
  52451. * Fired when a scale box drag is ended
  52452. */
  52453. onScaleBoxDragEndObservable: Observable<{}>;
  52454. /**
  52455. * Fired when a rotation sphere is dragged
  52456. */
  52457. onRotationSphereDragObservable: Observable<{}>;
  52458. /**
  52459. * Fired when a rotation sphere drag is ended
  52460. */
  52461. onRotationSphereDragEndObservable: Observable<{}>;
  52462. /**
  52463. * 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)
  52464. */
  52465. scalePivot: Nullable<Vector3>;
  52466. /**
  52467. * Mesh used as a pivot to rotate the attached mesh
  52468. */
  52469. private _anchorMesh;
  52470. private _existingMeshScale;
  52471. private _dragMesh;
  52472. private pointerDragBehavior;
  52473. private coloredMaterial;
  52474. private hoverColoredMaterial;
  52475. /**
  52476. * Sets the color of the bounding box gizmo
  52477. * @param color the color to set
  52478. */
  52479. setColor(color: Color3): void;
  52480. /**
  52481. * Creates an BoundingBoxGizmo
  52482. * @param gizmoLayer The utility layer the gizmo will be added to
  52483. * @param color The color of the gizmo
  52484. */
  52485. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52486. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52487. private _selectNode;
  52488. /**
  52489. * Updates the bounding box information for the Gizmo
  52490. */
  52491. updateBoundingBox(): void;
  52492. private _updateRotationSpheres;
  52493. private _updateScaleBoxes;
  52494. /**
  52495. * Enables rotation on the specified axis and disables rotation on the others
  52496. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52497. */
  52498. setEnabledRotationAxis(axis: string): void;
  52499. /**
  52500. * Enables/disables scaling
  52501. * @param enable if scaling should be enabled
  52502. * @param homogeneousScaling defines if scaling should only be homogeneous
  52503. */
  52504. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52505. private _updateDummy;
  52506. /**
  52507. * Enables a pointer drag behavior on the bounding box of the gizmo
  52508. */
  52509. enableDragBehavior(): void;
  52510. /**
  52511. * Disposes of the gizmo
  52512. */
  52513. dispose(): void;
  52514. /**
  52515. * 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)
  52516. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52517. * @returns the bounding box mesh with the passed in mesh as a child
  52518. */
  52519. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52520. /**
  52521. * CustomMeshes are not supported by this gizmo
  52522. * @param mesh The mesh to replace the default mesh of the gizmo
  52523. */
  52524. setCustomMesh(mesh: Mesh): void;
  52525. }
  52526. }
  52527. declare module BABYLON {
  52528. /**
  52529. * Single plane rotation gizmo
  52530. */
  52531. export class PlaneRotationGizmo extends Gizmo {
  52532. /**
  52533. * Drag behavior responsible for the gizmos dragging interactions
  52534. */
  52535. dragBehavior: PointerDragBehavior;
  52536. private _pointerObserver;
  52537. /**
  52538. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52539. */
  52540. snapDistance: number;
  52541. /**
  52542. * Event that fires each time the gizmo snaps to a new location.
  52543. * * snapDistance is the the change in distance
  52544. */
  52545. onSnapObservable: Observable<{
  52546. snapDistance: number;
  52547. }>;
  52548. private _isEnabled;
  52549. private _parent;
  52550. /**
  52551. * Creates a PlaneRotationGizmo
  52552. * @param gizmoLayer The utility layer the gizmo will be added to
  52553. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52554. * @param color The color of the gizmo
  52555. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52556. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52557. */
  52558. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52559. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52560. /**
  52561. * If the gizmo is enabled
  52562. */
  52563. set isEnabled(value: boolean);
  52564. get isEnabled(): boolean;
  52565. /**
  52566. * Disposes of the gizmo
  52567. */
  52568. dispose(): void;
  52569. }
  52570. }
  52571. declare module BABYLON {
  52572. /**
  52573. * Gizmo that enables rotating a mesh along 3 axis
  52574. */
  52575. export class RotationGizmo extends Gizmo {
  52576. /**
  52577. * Internal gizmo used for interactions on the x axis
  52578. */
  52579. xGizmo: PlaneRotationGizmo;
  52580. /**
  52581. * Internal gizmo used for interactions on the y axis
  52582. */
  52583. yGizmo: PlaneRotationGizmo;
  52584. /**
  52585. * Internal gizmo used for interactions on the z axis
  52586. */
  52587. zGizmo: PlaneRotationGizmo;
  52588. /** Fires an event when any of it's sub gizmos are dragged */
  52589. onDragStartObservable: Observable<unknown>;
  52590. /** Fires an event when any of it's sub gizmos are released from dragging */
  52591. onDragEndObservable: Observable<unknown>;
  52592. private _meshAttached;
  52593. get attachedMesh(): Nullable<AbstractMesh>;
  52594. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52595. /**
  52596. * Creates a RotationGizmo
  52597. * @param gizmoLayer The utility layer the gizmo will be added to
  52598. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52599. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52600. */
  52601. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52602. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52603. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52604. /**
  52605. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52606. */
  52607. set snapDistance(value: number);
  52608. get snapDistance(): number;
  52609. /**
  52610. * Ratio for the scale of the gizmo (Default: 1)
  52611. */
  52612. set scaleRatio(value: number);
  52613. get scaleRatio(): number;
  52614. /**
  52615. * Disposes of the gizmo
  52616. */
  52617. dispose(): void;
  52618. /**
  52619. * CustomMeshes are not supported by this gizmo
  52620. * @param mesh The mesh to replace the default mesh of the gizmo
  52621. */
  52622. setCustomMesh(mesh: Mesh): void;
  52623. }
  52624. }
  52625. declare module BABYLON {
  52626. /**
  52627. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52628. */
  52629. export class GizmoManager implements IDisposable {
  52630. private scene;
  52631. /**
  52632. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52633. */
  52634. gizmos: {
  52635. positionGizmo: Nullable<PositionGizmo>;
  52636. rotationGizmo: Nullable<RotationGizmo>;
  52637. scaleGizmo: Nullable<ScaleGizmo>;
  52638. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52639. };
  52640. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52641. clearGizmoOnEmptyPointerEvent: boolean;
  52642. /** Fires an event when the manager is attached to a mesh */
  52643. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52644. private _gizmosEnabled;
  52645. private _pointerObserver;
  52646. private _attachedMesh;
  52647. private _boundingBoxColor;
  52648. private _defaultUtilityLayer;
  52649. private _defaultKeepDepthUtilityLayer;
  52650. /**
  52651. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52652. */
  52653. boundingBoxDragBehavior: SixDofDragBehavior;
  52654. /**
  52655. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52656. */
  52657. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52658. /**
  52659. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52660. */
  52661. usePointerToAttachGizmos: boolean;
  52662. /**
  52663. * Utility layer that the bounding box gizmo belongs to
  52664. */
  52665. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52666. /**
  52667. * Utility layer that all gizmos besides bounding box belong to
  52668. */
  52669. get utilityLayer(): UtilityLayerRenderer;
  52670. /**
  52671. * Instatiates a gizmo manager
  52672. * @param scene the scene to overlay the gizmos on top of
  52673. */
  52674. constructor(scene: Scene);
  52675. /**
  52676. * Attaches a set of gizmos to the specified mesh
  52677. * @param mesh The mesh the gizmo's should be attached to
  52678. */
  52679. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52680. /**
  52681. * If the position gizmo is enabled
  52682. */
  52683. set positionGizmoEnabled(value: boolean);
  52684. get positionGizmoEnabled(): boolean;
  52685. /**
  52686. * If the rotation gizmo is enabled
  52687. */
  52688. set rotationGizmoEnabled(value: boolean);
  52689. get rotationGizmoEnabled(): boolean;
  52690. /**
  52691. * If the scale gizmo is enabled
  52692. */
  52693. set scaleGizmoEnabled(value: boolean);
  52694. get scaleGizmoEnabled(): boolean;
  52695. /**
  52696. * If the boundingBox gizmo is enabled
  52697. */
  52698. set boundingBoxGizmoEnabled(value: boolean);
  52699. get boundingBoxGizmoEnabled(): boolean;
  52700. /**
  52701. * Disposes of the gizmo manager
  52702. */
  52703. dispose(): void;
  52704. }
  52705. }
  52706. declare module BABYLON {
  52707. /**
  52708. * A directional light is defined by a direction (what a surprise!).
  52709. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52710. * 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.
  52711. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52712. */
  52713. export class DirectionalLight extends ShadowLight {
  52714. private _shadowFrustumSize;
  52715. /**
  52716. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52717. */
  52718. get shadowFrustumSize(): number;
  52719. /**
  52720. * Specifies a fix frustum size for the shadow generation.
  52721. */
  52722. set shadowFrustumSize(value: number);
  52723. private _shadowOrthoScale;
  52724. /**
  52725. * Gets 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. get shadowOrthoScale(): number;
  52730. /**
  52731. * Sets the shadow projection scale against the optimal computed one.
  52732. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52733. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52734. */
  52735. set shadowOrthoScale(value: number);
  52736. /**
  52737. * Automatically compute the projection matrix to best fit (including all the casters)
  52738. * on each frame.
  52739. */
  52740. autoUpdateExtends: boolean;
  52741. /**
  52742. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52743. * on each frame. autoUpdateExtends must be set to true for this to work
  52744. */
  52745. autoCalcShadowZBounds: boolean;
  52746. private _orthoLeft;
  52747. private _orthoRight;
  52748. private _orthoTop;
  52749. private _orthoBottom;
  52750. /**
  52751. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52752. * The directional light is emitted from everywhere in the given direction.
  52753. * It can cast shadows.
  52754. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52755. * @param name The friendly name of the light
  52756. * @param direction The direction of the light
  52757. * @param scene The scene the light belongs to
  52758. */
  52759. constructor(name: string, direction: Vector3, scene: Scene);
  52760. /**
  52761. * Returns the string "DirectionalLight".
  52762. * @return The class name
  52763. */
  52764. getClassName(): string;
  52765. /**
  52766. * Returns the integer 1.
  52767. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52768. */
  52769. getTypeID(): number;
  52770. /**
  52771. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52772. * Returns the DirectionalLight Shadow projection matrix.
  52773. */
  52774. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52775. /**
  52776. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  52777. * Returns the DirectionalLight Shadow projection matrix.
  52778. */
  52779. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  52780. /**
  52781. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  52782. * Returns the DirectionalLight Shadow projection matrix.
  52783. */
  52784. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52785. protected _buildUniformLayout(): void;
  52786. /**
  52787. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  52788. * @param effect The effect to update
  52789. * @param lightIndex The index of the light in the effect to update
  52790. * @returns The directional light
  52791. */
  52792. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  52793. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  52794. /**
  52795. * Gets the minZ used for shadow according to both the scene and the light.
  52796. *
  52797. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52798. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52799. * @param activeCamera The camera we are returning the min for
  52800. * @returns the depth min z
  52801. */
  52802. getDepthMinZ(activeCamera: Camera): number;
  52803. /**
  52804. * Gets the maxZ used for shadow according to both the scene and the light.
  52805. *
  52806. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  52807. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  52808. * @param activeCamera The camera we are returning the max for
  52809. * @returns the depth max z
  52810. */
  52811. getDepthMaxZ(activeCamera: Camera): number;
  52812. /**
  52813. * Prepares the list of defines specific to the light type.
  52814. * @param defines the list of defines
  52815. * @param lightIndex defines the index of the light for the effect
  52816. */
  52817. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52818. }
  52819. }
  52820. declare module BABYLON {
  52821. /**
  52822. * Class containing static functions to help procedurally build meshes
  52823. */
  52824. export class HemisphereBuilder {
  52825. /**
  52826. * Creates a hemisphere mesh
  52827. * @param name defines the name of the mesh
  52828. * @param options defines the options used to create the mesh
  52829. * @param scene defines the hosting scene
  52830. * @returns the hemisphere mesh
  52831. */
  52832. static CreateHemisphere(name: string, options: {
  52833. segments?: number;
  52834. diameter?: number;
  52835. sideOrientation?: number;
  52836. }, scene: any): Mesh;
  52837. }
  52838. }
  52839. declare module BABYLON {
  52840. /**
  52841. * A spot light is defined by a position, a direction, an angle, and an exponent.
  52842. * These values define a cone of light starting from the position, emitting toward the direction.
  52843. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  52844. * and the exponent defines the speed of the decay of the light with distance (reach).
  52845. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52846. */
  52847. export class SpotLight extends ShadowLight {
  52848. private _angle;
  52849. private _innerAngle;
  52850. private _cosHalfAngle;
  52851. private _lightAngleScale;
  52852. private _lightAngleOffset;
  52853. /**
  52854. * Gets the cone angle of the spot light in Radians.
  52855. */
  52856. get angle(): number;
  52857. /**
  52858. * Sets the cone angle of the spot light in Radians.
  52859. */
  52860. set angle(value: 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. get innerAngle(): number;
  52867. /**
  52868. * Only used in gltf falloff mode, this defines the angle where
  52869. * the directional falloff will start before cutting at angle which could be seen
  52870. * as outer angle.
  52871. */
  52872. set innerAngle(value: number);
  52873. private _shadowAngleScale;
  52874. /**
  52875. * Allows scaling the angle of the light for shadow generation only.
  52876. */
  52877. get shadowAngleScale(): number;
  52878. /**
  52879. * Allows scaling the angle of the light for shadow generation only.
  52880. */
  52881. set shadowAngleScale(value: number);
  52882. /**
  52883. * The light decay speed with the distance from the emission spot.
  52884. */
  52885. exponent: number;
  52886. private _projectionTextureMatrix;
  52887. /**
  52888. * Allows reading the projecton texture
  52889. */
  52890. get projectionTextureMatrix(): Matrix;
  52891. protected _projectionTextureLightNear: number;
  52892. /**
  52893. * Gets the near clip of the Spotlight for texture projection.
  52894. */
  52895. get projectionTextureLightNear(): number;
  52896. /**
  52897. * Sets the near clip of the Spotlight for texture projection.
  52898. */
  52899. set projectionTextureLightNear(value: number);
  52900. protected _projectionTextureLightFar: number;
  52901. /**
  52902. * Gets the far clip of the Spotlight for texture projection.
  52903. */
  52904. get projectionTextureLightFar(): number;
  52905. /**
  52906. * Sets the far clip of the Spotlight for texture projection.
  52907. */
  52908. set projectionTextureLightFar(value: number);
  52909. protected _projectionTextureUpDirection: Vector3;
  52910. /**
  52911. * Gets the Up vector of the Spotlight for texture projection.
  52912. */
  52913. get projectionTextureUpDirection(): Vector3;
  52914. /**
  52915. * Sets the Up vector of the Spotlight for texture projection.
  52916. */
  52917. set projectionTextureUpDirection(value: Vector3);
  52918. private _projectionTexture;
  52919. /**
  52920. * Gets the projection texture of the light.
  52921. */
  52922. get projectionTexture(): Nullable<BaseTexture>;
  52923. /**
  52924. * Sets the projection texture of the light.
  52925. */
  52926. set projectionTexture(value: Nullable<BaseTexture>);
  52927. private _projectionTextureViewLightDirty;
  52928. private _projectionTextureProjectionLightDirty;
  52929. private _projectionTextureDirty;
  52930. private _projectionTextureViewTargetVector;
  52931. private _projectionTextureViewLightMatrix;
  52932. private _projectionTextureProjectionLightMatrix;
  52933. private _projectionTextureScalingMatrix;
  52934. /**
  52935. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  52936. * It can cast shadows.
  52937. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52938. * @param name The light friendly name
  52939. * @param position The position of the spot light in the scene
  52940. * @param direction The direction of the light in the scene
  52941. * @param angle The cone angle of the light in Radians
  52942. * @param exponent The light decay speed with the distance from the emission spot
  52943. * @param scene The scene the lights belongs to
  52944. */
  52945. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  52946. /**
  52947. * Returns the string "SpotLight".
  52948. * @returns the class name
  52949. */
  52950. getClassName(): string;
  52951. /**
  52952. * Returns the integer 2.
  52953. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52954. */
  52955. getTypeID(): number;
  52956. /**
  52957. * Overrides the direction setter to recompute the projection texture view light Matrix.
  52958. */
  52959. protected _setDirection(value: Vector3): void;
  52960. /**
  52961. * Overrides the position setter to recompute the projection texture view light Matrix.
  52962. */
  52963. protected _setPosition(value: Vector3): void;
  52964. /**
  52965. * 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.
  52966. * Returns the SpotLight.
  52967. */
  52968. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52969. protected _computeProjectionTextureViewLightMatrix(): void;
  52970. protected _computeProjectionTextureProjectionLightMatrix(): void;
  52971. /**
  52972. * Main function for light texture projection matrix computing.
  52973. */
  52974. protected _computeProjectionTextureMatrix(): void;
  52975. protected _buildUniformLayout(): void;
  52976. private _computeAngleValues;
  52977. /**
  52978. * Sets the passed Effect "effect" with the Light textures.
  52979. * @param effect The effect to update
  52980. * @param lightIndex The index of the light in the effect to update
  52981. * @returns The light
  52982. */
  52983. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  52984. /**
  52985. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  52986. * @param effect The effect to update
  52987. * @param lightIndex The index of the light in the effect to update
  52988. * @returns The spot light
  52989. */
  52990. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  52991. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52992. /**
  52993. * Disposes the light and the associated resources.
  52994. */
  52995. dispose(): void;
  52996. /**
  52997. * Prepares the list of defines specific to the light type.
  52998. * @param defines the list of defines
  52999. * @param lightIndex defines the index of the light for the effect
  53000. */
  53001. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53002. }
  53003. }
  53004. declare module BABYLON {
  53005. /**
  53006. * Gizmo that enables viewing a light
  53007. */
  53008. export class LightGizmo extends Gizmo {
  53009. private _lightMesh;
  53010. private _material;
  53011. private _cachedPosition;
  53012. private _cachedForward;
  53013. private _attachedMeshParent;
  53014. /**
  53015. * Creates a LightGizmo
  53016. * @param gizmoLayer The utility layer the gizmo will be added to
  53017. */
  53018. constructor(gizmoLayer?: UtilityLayerRenderer);
  53019. private _light;
  53020. /**
  53021. * The light that the gizmo is attached to
  53022. */
  53023. set light(light: Nullable<Light>);
  53024. get light(): Nullable<Light>;
  53025. /**
  53026. * Gets the material used to render the light gizmo
  53027. */
  53028. get material(): StandardMaterial;
  53029. /**
  53030. * @hidden
  53031. * Updates the gizmo to match the attached mesh's position/rotation
  53032. */
  53033. protected _update(): void;
  53034. private static _Scale;
  53035. /**
  53036. * Creates the lines for a light mesh
  53037. */
  53038. private static _CreateLightLines;
  53039. /**
  53040. * Disposes of the light gizmo
  53041. */
  53042. dispose(): void;
  53043. private static _CreateHemisphericLightMesh;
  53044. private static _CreatePointLightMesh;
  53045. private static _CreateSpotLightMesh;
  53046. private static _CreateDirectionalLightMesh;
  53047. }
  53048. }
  53049. declare module BABYLON {
  53050. /** @hidden */
  53051. export var backgroundFragmentDeclaration: {
  53052. name: string;
  53053. shader: string;
  53054. };
  53055. }
  53056. declare module BABYLON {
  53057. /** @hidden */
  53058. export var backgroundUboDeclaration: {
  53059. name: string;
  53060. shader: string;
  53061. };
  53062. }
  53063. declare module BABYLON {
  53064. /** @hidden */
  53065. export var backgroundPixelShader: {
  53066. name: string;
  53067. shader: string;
  53068. };
  53069. }
  53070. declare module BABYLON {
  53071. /** @hidden */
  53072. export var backgroundVertexDeclaration: {
  53073. name: string;
  53074. shader: string;
  53075. };
  53076. }
  53077. declare module BABYLON {
  53078. /** @hidden */
  53079. export var backgroundVertexShader: {
  53080. name: string;
  53081. shader: string;
  53082. };
  53083. }
  53084. declare module BABYLON {
  53085. /**
  53086. * Background material used to create an efficient environement around your scene.
  53087. */
  53088. export class BackgroundMaterial extends PushMaterial {
  53089. /**
  53090. * Standard reflectance value at parallel view angle.
  53091. */
  53092. static StandardReflectance0: number;
  53093. /**
  53094. * Standard reflectance value at grazing angle.
  53095. */
  53096. static StandardReflectance90: number;
  53097. protected _primaryColor: Color3;
  53098. /**
  53099. * Key light Color (multiply against the environement texture)
  53100. */
  53101. primaryColor: Color3;
  53102. protected __perceptualColor: Nullable<Color3>;
  53103. /**
  53104. * Experimental Internal Use Only.
  53105. *
  53106. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53107. * This acts as a helper to set the primary color to a more "human friendly" value.
  53108. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53109. * output color as close as possible from the chosen value.
  53110. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53111. * part of lighting setup.)
  53112. */
  53113. get _perceptualColor(): Nullable<Color3>;
  53114. set _perceptualColor(value: Nullable<Color3>);
  53115. protected _primaryColorShadowLevel: float;
  53116. /**
  53117. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53118. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53119. */
  53120. get primaryColorShadowLevel(): float;
  53121. set primaryColorShadowLevel(value: float);
  53122. protected _primaryColorHighlightLevel: float;
  53123. /**
  53124. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53125. * The primary color is used at the level chosen to define what the white area would look.
  53126. */
  53127. get primaryColorHighlightLevel(): float;
  53128. set primaryColorHighlightLevel(value: float);
  53129. protected _reflectionTexture: Nullable<BaseTexture>;
  53130. /**
  53131. * Reflection Texture used in the material.
  53132. * Should be author in a specific way for the best result (refer to the documentation).
  53133. */
  53134. reflectionTexture: Nullable<BaseTexture>;
  53135. protected _reflectionBlur: float;
  53136. /**
  53137. * Reflection Texture level of blur.
  53138. *
  53139. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53140. * texture twice.
  53141. */
  53142. reflectionBlur: float;
  53143. protected _diffuseTexture: Nullable<BaseTexture>;
  53144. /**
  53145. * Diffuse Texture used in the material.
  53146. * Should be author in a specific way for the best result (refer to the documentation).
  53147. */
  53148. diffuseTexture: Nullable<BaseTexture>;
  53149. protected _shadowLights: Nullable<IShadowLight[]>;
  53150. /**
  53151. * Specify the list of lights casting shadow on the material.
  53152. * All scene shadow lights will be included if null.
  53153. */
  53154. shadowLights: Nullable<IShadowLight[]>;
  53155. protected _shadowLevel: float;
  53156. /**
  53157. * Helps adjusting the shadow to a softer level if required.
  53158. * 0 means black shadows and 1 means no shadows.
  53159. */
  53160. shadowLevel: float;
  53161. protected _sceneCenter: Vector3;
  53162. /**
  53163. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53164. * It is usually zero but might be interesting to modify according to your setup.
  53165. */
  53166. sceneCenter: Vector3;
  53167. protected _opacityFresnel: boolean;
  53168. /**
  53169. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53170. * This helps ensuring a nice transition when the camera goes under the ground.
  53171. */
  53172. opacityFresnel: boolean;
  53173. protected _reflectionFresnel: boolean;
  53174. /**
  53175. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53176. * This helps adding a mirror texture on the ground.
  53177. */
  53178. reflectionFresnel: boolean;
  53179. protected _reflectionFalloffDistance: number;
  53180. /**
  53181. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53182. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53183. */
  53184. reflectionFalloffDistance: number;
  53185. protected _reflectionAmount: number;
  53186. /**
  53187. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53188. */
  53189. reflectionAmount: number;
  53190. protected _reflectionReflectance0: number;
  53191. /**
  53192. * This specifies the weight of the reflection at grazing angle.
  53193. */
  53194. reflectionReflectance0: number;
  53195. protected _reflectionReflectance90: number;
  53196. /**
  53197. * This specifies the weight of the reflection at a perpendicular point of view.
  53198. */
  53199. reflectionReflectance90: number;
  53200. /**
  53201. * Sets the reflection reflectance fresnel values according to the default standard
  53202. * empirically know to work well :-)
  53203. */
  53204. set reflectionStandardFresnelWeight(value: number);
  53205. protected _useRGBColor: boolean;
  53206. /**
  53207. * Helps to directly use the maps channels instead of their level.
  53208. */
  53209. useRGBColor: boolean;
  53210. protected _enableNoise: boolean;
  53211. /**
  53212. * This helps reducing the banding effect that could occur on the background.
  53213. */
  53214. enableNoise: boolean;
  53215. /**
  53216. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53217. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53218. * Recommended to be keep at 1.0 except for special cases.
  53219. */
  53220. get fovMultiplier(): number;
  53221. set fovMultiplier(value: number);
  53222. private _fovMultiplier;
  53223. /**
  53224. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53225. */
  53226. useEquirectangularFOV: boolean;
  53227. private _maxSimultaneousLights;
  53228. /**
  53229. * Number of Simultaneous lights allowed on the material.
  53230. */
  53231. maxSimultaneousLights: int;
  53232. /**
  53233. * Default configuration related to image processing available in the Background Material.
  53234. */
  53235. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53236. /**
  53237. * Keep track of the image processing observer to allow dispose and replace.
  53238. */
  53239. private _imageProcessingObserver;
  53240. /**
  53241. * Attaches a new image processing configuration to the PBR Material.
  53242. * @param configuration (if null the scene configuration will be use)
  53243. */
  53244. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53245. /**
  53246. * Gets the image processing configuration used either in this material.
  53247. */
  53248. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53249. /**
  53250. * Sets the Default image processing configuration used either in the this material.
  53251. *
  53252. * If sets to null, the scene one is in use.
  53253. */
  53254. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53255. /**
  53256. * Gets wether the color curves effect is enabled.
  53257. */
  53258. get cameraColorCurvesEnabled(): boolean;
  53259. /**
  53260. * Sets wether the color curves effect is enabled.
  53261. */
  53262. set cameraColorCurvesEnabled(value: boolean);
  53263. /**
  53264. * Gets wether the color grading effect is enabled.
  53265. */
  53266. get cameraColorGradingEnabled(): boolean;
  53267. /**
  53268. * Gets wether the color grading effect is enabled.
  53269. */
  53270. set cameraColorGradingEnabled(value: boolean);
  53271. /**
  53272. * Gets wether tonemapping is enabled or not.
  53273. */
  53274. get cameraToneMappingEnabled(): boolean;
  53275. /**
  53276. * Sets wether tonemapping is enabled or not
  53277. */
  53278. set cameraToneMappingEnabled(value: boolean);
  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. get cameraExposure(): float;
  53285. /**
  53286. * The camera exposure used on this material.
  53287. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53288. * This corresponds to a photographic exposure.
  53289. */
  53290. set cameraExposure(value: float);
  53291. /**
  53292. * Gets The camera contrast used on this material.
  53293. */
  53294. get cameraContrast(): float;
  53295. /**
  53296. * Sets The camera contrast used on this material.
  53297. */
  53298. set cameraContrast(value: float);
  53299. /**
  53300. * Gets the Color Grading 2D Lookup Texture.
  53301. */
  53302. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53303. /**
  53304. * Sets the Color Grading 2D Lookup Texture.
  53305. */
  53306. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53307. /**
  53308. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53309. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53310. * 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;
  53311. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53312. */
  53313. get cameraColorCurves(): Nullable<ColorCurves>;
  53314. /**
  53315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53317. * 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;
  53318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53319. */
  53320. set cameraColorCurves(value: Nullable<ColorCurves>);
  53321. /**
  53322. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53323. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53324. */
  53325. switchToBGR: boolean;
  53326. private _renderTargets;
  53327. private _reflectionControls;
  53328. private _white;
  53329. private _primaryShadowColor;
  53330. private _primaryHighlightColor;
  53331. /**
  53332. * Instantiates a Background Material in the given scene
  53333. * @param name The friendly name of the material
  53334. * @param scene The scene to add the material to
  53335. */
  53336. constructor(name: string, scene: Scene);
  53337. /**
  53338. * Gets a boolean indicating that current material needs to register RTT
  53339. */
  53340. get hasRenderTargetTextures(): boolean;
  53341. /**
  53342. * The entire material has been created in order to prevent overdraw.
  53343. * @returns false
  53344. */
  53345. needAlphaTesting(): boolean;
  53346. /**
  53347. * The entire material has been created in order to prevent overdraw.
  53348. * @returns true if blending is enable
  53349. */
  53350. needAlphaBlending(): boolean;
  53351. /**
  53352. * Checks wether the material is ready to be rendered for a given mesh.
  53353. * @param mesh The mesh to render
  53354. * @param subMesh The submesh to check against
  53355. * @param useInstances Specify wether or not the material is used with instances
  53356. * @returns true if all the dependencies are ready (Textures, Effects...)
  53357. */
  53358. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53359. /**
  53360. * Compute the primary color according to the chosen perceptual color.
  53361. */
  53362. private _computePrimaryColorFromPerceptualColor;
  53363. /**
  53364. * Compute the highlights and shadow colors according to their chosen levels.
  53365. */
  53366. private _computePrimaryColors;
  53367. /**
  53368. * Build the uniform buffer used in the material.
  53369. */
  53370. buildUniformLayout(): void;
  53371. /**
  53372. * Unbind the material.
  53373. */
  53374. unbind(): void;
  53375. /**
  53376. * Bind only the world matrix to the material.
  53377. * @param world The world matrix to bind.
  53378. */
  53379. bindOnlyWorldMatrix(world: Matrix): void;
  53380. /**
  53381. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53382. * @param world The world matrix to bind.
  53383. * @param subMesh The submesh to bind for.
  53384. */
  53385. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53386. /**
  53387. * Checks to see if a texture is used in the material.
  53388. * @param texture - Base texture to use.
  53389. * @returns - Boolean specifying if a texture is used in the material.
  53390. */
  53391. hasTexture(texture: BaseTexture): boolean;
  53392. /**
  53393. * Dispose the material.
  53394. * @param forceDisposeEffect Force disposal of the associated effect.
  53395. * @param forceDisposeTextures Force disposal of the associated textures.
  53396. */
  53397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53398. /**
  53399. * Clones the material.
  53400. * @param name The cloned name.
  53401. * @returns The cloned material.
  53402. */
  53403. clone(name: string): BackgroundMaterial;
  53404. /**
  53405. * Serializes the current material to its JSON representation.
  53406. * @returns The JSON representation.
  53407. */
  53408. serialize(): any;
  53409. /**
  53410. * Gets the class name of the material
  53411. * @returns "BackgroundMaterial"
  53412. */
  53413. getClassName(): string;
  53414. /**
  53415. * Parse a JSON input to create back a background material.
  53416. * @param source The JSON data to parse
  53417. * @param scene The scene to create the parsed material in
  53418. * @param rootUrl The root url of the assets the material depends upon
  53419. * @returns the instantiated BackgroundMaterial.
  53420. */
  53421. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53422. }
  53423. }
  53424. declare module BABYLON {
  53425. /**
  53426. * Represents the different options available during the creation of
  53427. * a Environment helper.
  53428. *
  53429. * This can control the default ground, skybox and image processing setup of your scene.
  53430. */
  53431. export interface IEnvironmentHelperOptions {
  53432. /**
  53433. * Specifies whether or not to create a ground.
  53434. * True by default.
  53435. */
  53436. createGround: boolean;
  53437. /**
  53438. * Specifies the ground size.
  53439. * 15 by default.
  53440. */
  53441. groundSize: number;
  53442. /**
  53443. * The texture used on the ground for the main color.
  53444. * Comes from the BabylonJS CDN by default.
  53445. *
  53446. * Remarks: Can be either a texture or a url.
  53447. */
  53448. groundTexture: string | BaseTexture;
  53449. /**
  53450. * The color mixed in the ground texture by default.
  53451. * BabylonJS clearColor by default.
  53452. */
  53453. groundColor: Color3;
  53454. /**
  53455. * Specifies the ground opacity.
  53456. * 1 by default.
  53457. */
  53458. groundOpacity: number;
  53459. /**
  53460. * Enables the ground to receive shadows.
  53461. * True by default.
  53462. */
  53463. enableGroundShadow: boolean;
  53464. /**
  53465. * Helps preventing the shadow to be fully black on the ground.
  53466. * 0.5 by default.
  53467. */
  53468. groundShadowLevel: number;
  53469. /**
  53470. * Creates a mirror texture attach to the ground.
  53471. * false by default.
  53472. */
  53473. enableGroundMirror: boolean;
  53474. /**
  53475. * Specifies the ground mirror size ratio.
  53476. * 0.3 by default as the default kernel is 64.
  53477. */
  53478. groundMirrorSizeRatio: number;
  53479. /**
  53480. * Specifies the ground mirror blur kernel size.
  53481. * 64 by default.
  53482. */
  53483. groundMirrorBlurKernel: number;
  53484. /**
  53485. * Specifies the ground mirror visibility amount.
  53486. * 1 by default
  53487. */
  53488. groundMirrorAmount: number;
  53489. /**
  53490. * Specifies the ground mirror reflectance weight.
  53491. * This uses the standard weight of the background material to setup the fresnel effect
  53492. * of the mirror.
  53493. * 1 by default.
  53494. */
  53495. groundMirrorFresnelWeight: number;
  53496. /**
  53497. * Specifies the ground mirror Falloff distance.
  53498. * This can helps reducing the size of the reflection.
  53499. * 0 by Default.
  53500. */
  53501. groundMirrorFallOffDistance: number;
  53502. /**
  53503. * Specifies the ground mirror texture type.
  53504. * Unsigned Int by Default.
  53505. */
  53506. groundMirrorTextureType: number;
  53507. /**
  53508. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53509. * the shown objects.
  53510. */
  53511. groundYBias: number;
  53512. /**
  53513. * Specifies whether or not to create a skybox.
  53514. * True by default.
  53515. */
  53516. createSkybox: boolean;
  53517. /**
  53518. * Specifies the skybox size.
  53519. * 20 by default.
  53520. */
  53521. skyboxSize: number;
  53522. /**
  53523. * The texture used on the skybox for the main color.
  53524. * Comes from the BabylonJS CDN by default.
  53525. *
  53526. * Remarks: Can be either a texture or a url.
  53527. */
  53528. skyboxTexture: string | BaseTexture;
  53529. /**
  53530. * The color mixed in the skybox texture by default.
  53531. * BabylonJS clearColor by default.
  53532. */
  53533. skyboxColor: Color3;
  53534. /**
  53535. * The background rotation around the Y axis of the scene.
  53536. * This helps aligning the key lights of your scene with the background.
  53537. * 0 by default.
  53538. */
  53539. backgroundYRotation: number;
  53540. /**
  53541. * Compute automatically the size of the elements to best fit with the scene.
  53542. */
  53543. sizeAuto: boolean;
  53544. /**
  53545. * Default position of the rootMesh if autoSize is not true.
  53546. */
  53547. rootPosition: Vector3;
  53548. /**
  53549. * Sets up the image processing in the scene.
  53550. * true by default.
  53551. */
  53552. setupImageProcessing: boolean;
  53553. /**
  53554. * The texture used as your environment texture in the scene.
  53555. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53556. *
  53557. * Remarks: Can be either a texture or a url.
  53558. */
  53559. environmentTexture: string | BaseTexture;
  53560. /**
  53561. * The value of the exposure to apply to the scene.
  53562. * 0.6 by default if setupImageProcessing is true.
  53563. */
  53564. cameraExposure: number;
  53565. /**
  53566. * The value of the contrast to apply to the scene.
  53567. * 1.6 by default if setupImageProcessing is true.
  53568. */
  53569. cameraContrast: number;
  53570. /**
  53571. * Specifies whether or not tonemapping should be enabled in the scene.
  53572. * true by default if setupImageProcessing is true.
  53573. */
  53574. toneMappingEnabled: boolean;
  53575. }
  53576. /**
  53577. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53578. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53579. * It also helps with the default setup of your imageProcessing configuration.
  53580. */
  53581. export class EnvironmentHelper {
  53582. /**
  53583. * Default ground texture URL.
  53584. */
  53585. private static _groundTextureCDNUrl;
  53586. /**
  53587. * Default skybox texture URL.
  53588. */
  53589. private static _skyboxTextureCDNUrl;
  53590. /**
  53591. * Default environment texture URL.
  53592. */
  53593. private static _environmentTextureCDNUrl;
  53594. /**
  53595. * Creates the default options for the helper.
  53596. */
  53597. private static _getDefaultOptions;
  53598. private _rootMesh;
  53599. /**
  53600. * Gets the root mesh created by the helper.
  53601. */
  53602. get rootMesh(): Mesh;
  53603. private _skybox;
  53604. /**
  53605. * Gets the skybox created by the helper.
  53606. */
  53607. get skybox(): Nullable<Mesh>;
  53608. private _skyboxTexture;
  53609. /**
  53610. * Gets the skybox texture created by the helper.
  53611. */
  53612. get skyboxTexture(): Nullable<BaseTexture>;
  53613. private _skyboxMaterial;
  53614. /**
  53615. * Gets the skybox material created by the helper.
  53616. */
  53617. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53618. private _ground;
  53619. /**
  53620. * Gets the ground mesh created by the helper.
  53621. */
  53622. get ground(): Nullable<Mesh>;
  53623. private _groundTexture;
  53624. /**
  53625. * Gets the ground texture created by the helper.
  53626. */
  53627. get groundTexture(): Nullable<BaseTexture>;
  53628. private _groundMirror;
  53629. /**
  53630. * Gets the ground mirror created by the helper.
  53631. */
  53632. get groundMirror(): Nullable<MirrorTexture>;
  53633. /**
  53634. * Gets the ground mirror render list to helps pushing the meshes
  53635. * you wish in the ground reflection.
  53636. */
  53637. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53638. private _groundMaterial;
  53639. /**
  53640. * Gets the ground material created by the helper.
  53641. */
  53642. get groundMaterial(): Nullable<BackgroundMaterial>;
  53643. /**
  53644. * Stores the creation options.
  53645. */
  53646. private readonly _scene;
  53647. private _options;
  53648. /**
  53649. * This observable will be notified with any error during the creation of the environment,
  53650. * mainly texture creation errors.
  53651. */
  53652. onErrorObservable: Observable<{
  53653. message?: string;
  53654. exception?: any;
  53655. }>;
  53656. /**
  53657. * constructor
  53658. * @param options Defines the options we want to customize the helper
  53659. * @param scene The scene to add the material to
  53660. */
  53661. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53662. /**
  53663. * Updates the background according to the new options
  53664. * @param options
  53665. */
  53666. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53667. /**
  53668. * Sets the primary color of all the available elements.
  53669. * @param color the main color to affect to the ground and the background
  53670. */
  53671. setMainColor(color: Color3): void;
  53672. /**
  53673. * Setup the image processing according to the specified options.
  53674. */
  53675. private _setupImageProcessing;
  53676. /**
  53677. * Setup the environment texture according to the specified options.
  53678. */
  53679. private _setupEnvironmentTexture;
  53680. /**
  53681. * Setup the background according to the specified options.
  53682. */
  53683. private _setupBackground;
  53684. /**
  53685. * Get the scene sizes according to the setup.
  53686. */
  53687. private _getSceneSize;
  53688. /**
  53689. * Setup the ground according to the specified options.
  53690. */
  53691. private _setupGround;
  53692. /**
  53693. * Setup the ground material according to the specified options.
  53694. */
  53695. private _setupGroundMaterial;
  53696. /**
  53697. * Setup the ground diffuse texture according to the specified options.
  53698. */
  53699. private _setupGroundDiffuseTexture;
  53700. /**
  53701. * Setup the ground mirror texture according to the specified options.
  53702. */
  53703. private _setupGroundMirrorTexture;
  53704. /**
  53705. * Setup the ground to receive the mirror texture.
  53706. */
  53707. private _setupMirrorInGroundMaterial;
  53708. /**
  53709. * Setup the skybox according to the specified options.
  53710. */
  53711. private _setupSkybox;
  53712. /**
  53713. * Setup the skybox material according to the specified options.
  53714. */
  53715. private _setupSkyboxMaterial;
  53716. /**
  53717. * Setup the skybox reflection texture according to the specified options.
  53718. */
  53719. private _setupSkyboxReflectionTexture;
  53720. private _errorHandler;
  53721. /**
  53722. * Dispose all the elements created by the Helper.
  53723. */
  53724. dispose(): void;
  53725. }
  53726. }
  53727. declare module BABYLON {
  53728. /**
  53729. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53730. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53731. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53732. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53733. */
  53734. export class PhotoDome extends TransformNode {
  53735. /**
  53736. * Define the image as a Monoscopic panoramic 360 image.
  53737. */
  53738. static readonly MODE_MONOSCOPIC: number;
  53739. /**
  53740. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53741. */
  53742. static readonly MODE_TOPBOTTOM: number;
  53743. /**
  53744. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53745. */
  53746. static readonly MODE_SIDEBYSIDE: number;
  53747. private _useDirectMapping;
  53748. /**
  53749. * The texture being displayed on the sphere
  53750. */
  53751. protected _photoTexture: Texture;
  53752. /**
  53753. * Gets or sets the texture being displayed on the sphere
  53754. */
  53755. get photoTexture(): Texture;
  53756. set photoTexture(value: Texture);
  53757. /**
  53758. * Observable raised when an error occured while loading the 360 image
  53759. */
  53760. onLoadErrorObservable: Observable<string>;
  53761. /**
  53762. * The skybox material
  53763. */
  53764. protected _material: BackgroundMaterial;
  53765. /**
  53766. * The surface used for the skybox
  53767. */
  53768. protected _mesh: Mesh;
  53769. /**
  53770. * Gets the mesh used for the skybox.
  53771. */
  53772. get mesh(): Mesh;
  53773. /**
  53774. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53775. * Also see the options.resolution property.
  53776. */
  53777. get fovMultiplier(): number;
  53778. set fovMultiplier(value: number);
  53779. private _imageMode;
  53780. /**
  53781. * Gets or set the current video mode for the video. It can be:
  53782. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  53783. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53784. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53785. */
  53786. get imageMode(): number;
  53787. set imageMode(value: number);
  53788. /**
  53789. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  53790. * @param name Element's name, child elements will append suffixes for their own names.
  53791. * @param urlsOfPhoto defines the url of the photo to display
  53792. * @param options defines an object containing optional or exposed sub element properties
  53793. * @param onError defines a callback called when an error occured while loading the texture
  53794. */
  53795. constructor(name: string, urlOfPhoto: string, options: {
  53796. resolution?: number;
  53797. size?: number;
  53798. useDirectMapping?: boolean;
  53799. faceForward?: boolean;
  53800. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  53801. private _onBeforeCameraRenderObserver;
  53802. private _changeImageMode;
  53803. /**
  53804. * Releases resources associated with this node.
  53805. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53806. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53807. */
  53808. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53809. }
  53810. }
  53811. declare module BABYLON {
  53812. /**
  53813. * Class used to host RGBD texture specific utilities
  53814. */
  53815. export class RGBDTextureTools {
  53816. /**
  53817. * Expand the RGBD Texture from RGBD to Half Float if possible.
  53818. * @param texture the texture to expand.
  53819. */
  53820. static ExpandRGBDTexture(texture: Texture): void;
  53821. }
  53822. }
  53823. declare module BABYLON {
  53824. /**
  53825. * Class used to host texture specific utilities
  53826. */
  53827. export class BRDFTextureTools {
  53828. /**
  53829. * Prevents texture cache collision
  53830. */
  53831. private static _instanceNumber;
  53832. /**
  53833. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  53834. * @param scene defines the hosting scene
  53835. * @returns the environment BRDF texture
  53836. */
  53837. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  53838. private static _environmentBRDFBase64Texture;
  53839. }
  53840. }
  53841. declare module BABYLON {
  53842. /**
  53843. * @hidden
  53844. */
  53845. export interface IMaterialClearCoatDefines {
  53846. CLEARCOAT: boolean;
  53847. CLEARCOAT_DEFAULTIOR: boolean;
  53848. CLEARCOAT_TEXTURE: boolean;
  53849. CLEARCOAT_TEXTUREDIRECTUV: number;
  53850. CLEARCOAT_BUMP: boolean;
  53851. CLEARCOAT_BUMPDIRECTUV: number;
  53852. CLEARCOAT_TINT: boolean;
  53853. CLEARCOAT_TINT_TEXTURE: boolean;
  53854. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53855. /** @hidden */
  53856. _areTexturesDirty: boolean;
  53857. }
  53858. /**
  53859. * Define the code related to the clear coat parameters of the pbr material.
  53860. */
  53861. export class PBRClearCoatConfiguration {
  53862. /**
  53863. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53864. * The default fits with a polyurethane material.
  53865. */
  53866. private static readonly _DefaultIndexOfRefraction;
  53867. private _isEnabled;
  53868. /**
  53869. * Defines if the clear coat is enabled in the material.
  53870. */
  53871. isEnabled: boolean;
  53872. /**
  53873. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53874. */
  53875. intensity: number;
  53876. /**
  53877. * Defines the clear coat layer roughness.
  53878. */
  53879. roughness: number;
  53880. private _indexOfRefraction;
  53881. /**
  53882. * Defines the index of refraction of the clear coat.
  53883. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53884. * The default fits with a polyurethane material.
  53885. * Changing the default value is more performance intensive.
  53886. */
  53887. indexOfRefraction: number;
  53888. private _texture;
  53889. /**
  53890. * Stores the clear coat values in a texture.
  53891. */
  53892. texture: Nullable<BaseTexture>;
  53893. private _bumpTexture;
  53894. /**
  53895. * Define the clear coat specific bump texture.
  53896. */
  53897. bumpTexture: Nullable<BaseTexture>;
  53898. private _isTintEnabled;
  53899. /**
  53900. * Defines if the clear coat tint is enabled in the material.
  53901. */
  53902. isTintEnabled: boolean;
  53903. /**
  53904. * Defines the clear coat tint of the material.
  53905. * This is only use if tint is enabled
  53906. */
  53907. tintColor: Color3;
  53908. /**
  53909. * Defines the distance at which the tint color should be found in the
  53910. * clear coat media.
  53911. * This is only use if tint is enabled
  53912. */
  53913. tintColorAtDistance: number;
  53914. /**
  53915. * Defines the clear coat layer thickness.
  53916. * This is only use if tint is enabled
  53917. */
  53918. tintThickness: number;
  53919. private _tintTexture;
  53920. /**
  53921. * Stores the clear tint values in a texture.
  53922. * rgb is tint
  53923. * a is a thickness factor
  53924. */
  53925. tintTexture: Nullable<BaseTexture>;
  53926. /** @hidden */
  53927. private _internalMarkAllSubMeshesAsTexturesDirty;
  53928. /** @hidden */
  53929. _markAllSubMeshesAsTexturesDirty(): void;
  53930. /**
  53931. * Instantiate a new istance of clear coat configuration.
  53932. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53933. */
  53934. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53935. /**
  53936. * Gets wehter the submesh is ready to be used or not.
  53937. * @param defines the list of "defines" to update.
  53938. * @param scene defines the scene the material belongs to.
  53939. * @param engine defines the engine the material belongs to.
  53940. * @param disableBumpMap defines wether the material disables bump or not.
  53941. * @returns - boolean indicating that the submesh is ready or not.
  53942. */
  53943. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  53944. /**
  53945. * Checks to see if a texture is used in the material.
  53946. * @param defines the list of "defines" to update.
  53947. * @param scene defines the scene to the material belongs to.
  53948. */
  53949. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  53950. /**
  53951. * Binds the material data.
  53952. * @param uniformBuffer defines the Uniform buffer to fill in.
  53953. * @param scene defines the scene the material belongs to.
  53954. * @param engine defines the engine the material belongs to.
  53955. * @param disableBumpMap defines wether the material disables bump or not.
  53956. * @param isFrozen defines wether the material is frozen or not.
  53957. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53958. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53959. */
  53960. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  53961. /**
  53962. * Checks to see if a texture is used in the material.
  53963. * @param texture - Base texture to use.
  53964. * @returns - Boolean specifying if a texture is used in the material.
  53965. */
  53966. hasTexture(texture: BaseTexture): boolean;
  53967. /**
  53968. * Returns an array of the actively used textures.
  53969. * @param activeTextures Array of BaseTextures
  53970. */
  53971. getActiveTextures(activeTextures: BaseTexture[]): void;
  53972. /**
  53973. * Returns the animatable textures.
  53974. * @param animatables Array of animatable textures.
  53975. */
  53976. getAnimatables(animatables: IAnimatable[]): void;
  53977. /**
  53978. * Disposes the resources of the material.
  53979. * @param forceDisposeTextures - Forces the disposal of all textures.
  53980. */
  53981. dispose(forceDisposeTextures?: boolean): void;
  53982. /**
  53983. * Get the current class name of the texture useful for serialization or dynamic coding.
  53984. * @returns "PBRClearCoatConfiguration"
  53985. */
  53986. getClassName(): string;
  53987. /**
  53988. * Add fallbacks to the effect fallbacks list.
  53989. * @param defines defines the Base texture to use.
  53990. * @param fallbacks defines the current fallback list.
  53991. * @param currentRank defines the current fallback rank.
  53992. * @returns the new fallback rank.
  53993. */
  53994. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53995. /**
  53996. * Add the required uniforms to the current list.
  53997. * @param uniforms defines the current uniform list.
  53998. */
  53999. static AddUniforms(uniforms: string[]): void;
  54000. /**
  54001. * Add the required samplers to the current list.
  54002. * @param samplers defines the current sampler list.
  54003. */
  54004. static AddSamplers(samplers: string[]): void;
  54005. /**
  54006. * Add the required uniforms to the current buffer.
  54007. * @param uniformBuffer defines the current uniform buffer.
  54008. */
  54009. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54010. /**
  54011. * Makes a duplicate of the current configuration into another one.
  54012. * @param clearCoatConfiguration define the config where to copy the info
  54013. */
  54014. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54015. /**
  54016. * Serializes this clear coat configuration.
  54017. * @returns - An object with the serialized config.
  54018. */
  54019. serialize(): any;
  54020. /**
  54021. * Parses a anisotropy Configuration from a serialized object.
  54022. * @param source - Serialized object.
  54023. * @param scene Defines the scene we are parsing for
  54024. * @param rootUrl Defines the rootUrl to load from
  54025. */
  54026. parse(source: any, scene: Scene, rootUrl: string): void;
  54027. }
  54028. }
  54029. declare module BABYLON {
  54030. /**
  54031. * @hidden
  54032. */
  54033. export interface IMaterialAnisotropicDefines {
  54034. ANISOTROPIC: boolean;
  54035. ANISOTROPIC_TEXTURE: boolean;
  54036. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54037. MAINUV1: boolean;
  54038. _areTexturesDirty: boolean;
  54039. _needUVs: boolean;
  54040. }
  54041. /**
  54042. * Define the code related to the anisotropic parameters of the pbr material.
  54043. */
  54044. export class PBRAnisotropicConfiguration {
  54045. private _isEnabled;
  54046. /**
  54047. * Defines if the anisotropy is enabled in the material.
  54048. */
  54049. isEnabled: boolean;
  54050. /**
  54051. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54052. */
  54053. intensity: number;
  54054. /**
  54055. * Defines if the effect is along the tangents, bitangents or in between.
  54056. * By default, the effect is "strectching" the highlights along the tangents.
  54057. */
  54058. direction: Vector2;
  54059. private _texture;
  54060. /**
  54061. * Stores the anisotropy values in a texture.
  54062. * rg is direction (like normal from -1 to 1)
  54063. * b is a intensity
  54064. */
  54065. texture: Nullable<BaseTexture>;
  54066. /** @hidden */
  54067. private _internalMarkAllSubMeshesAsTexturesDirty;
  54068. /** @hidden */
  54069. _markAllSubMeshesAsTexturesDirty(): void;
  54070. /**
  54071. * Instantiate a new istance of anisotropy configuration.
  54072. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54073. */
  54074. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54075. /**
  54076. * Specifies that the submesh is ready to be used.
  54077. * @param defines the list of "defines" to update.
  54078. * @param scene defines the scene the material belongs to.
  54079. * @returns - boolean indicating that the submesh is ready or not.
  54080. */
  54081. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54082. /**
  54083. * Checks to see if a texture is used in the material.
  54084. * @param defines the list of "defines" to update.
  54085. * @param mesh the mesh we are preparing the defines for.
  54086. * @param scene defines the scene the material belongs to.
  54087. */
  54088. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54089. /**
  54090. * Binds the material data.
  54091. * @param uniformBuffer defines the Uniform buffer to fill in.
  54092. * @param scene defines the scene the material belongs to.
  54093. * @param isFrozen defines wether the material is frozen or not.
  54094. */
  54095. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54096. /**
  54097. * Checks to see if a texture is used in the material.
  54098. * @param texture - Base texture to use.
  54099. * @returns - Boolean specifying if a texture is used in the material.
  54100. */
  54101. hasTexture(texture: BaseTexture): boolean;
  54102. /**
  54103. * Returns an array of the actively used textures.
  54104. * @param activeTextures Array of BaseTextures
  54105. */
  54106. getActiveTextures(activeTextures: BaseTexture[]): void;
  54107. /**
  54108. * Returns the animatable textures.
  54109. * @param animatables Array of animatable textures.
  54110. */
  54111. getAnimatables(animatables: IAnimatable[]): void;
  54112. /**
  54113. * Disposes the resources of the material.
  54114. * @param forceDisposeTextures - Forces the disposal of all textures.
  54115. */
  54116. dispose(forceDisposeTextures?: boolean): void;
  54117. /**
  54118. * Get the current class name of the texture useful for serialization or dynamic coding.
  54119. * @returns "PBRAnisotropicConfiguration"
  54120. */
  54121. getClassName(): string;
  54122. /**
  54123. * Add fallbacks to the effect fallbacks list.
  54124. * @param defines defines the Base texture to use.
  54125. * @param fallbacks defines the current fallback list.
  54126. * @param currentRank defines the current fallback rank.
  54127. * @returns the new fallback rank.
  54128. */
  54129. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54130. /**
  54131. * Add the required uniforms to the current list.
  54132. * @param uniforms defines the current uniform list.
  54133. */
  54134. static AddUniforms(uniforms: string[]): void;
  54135. /**
  54136. * Add the required uniforms to the current buffer.
  54137. * @param uniformBuffer defines the current uniform buffer.
  54138. */
  54139. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54140. /**
  54141. * Add the required samplers to the current list.
  54142. * @param samplers defines the current sampler list.
  54143. */
  54144. static AddSamplers(samplers: string[]): void;
  54145. /**
  54146. * Makes a duplicate of the current configuration into another one.
  54147. * @param anisotropicConfiguration define the config where to copy the info
  54148. */
  54149. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54150. /**
  54151. * Serializes this anisotropy configuration.
  54152. * @returns - An object with the serialized config.
  54153. */
  54154. serialize(): any;
  54155. /**
  54156. * Parses a anisotropy Configuration from a serialized object.
  54157. * @param source - Serialized object.
  54158. * @param scene Defines the scene we are parsing for
  54159. * @param rootUrl Defines the rootUrl to load from
  54160. */
  54161. parse(source: any, scene: Scene, rootUrl: string): void;
  54162. }
  54163. }
  54164. declare module BABYLON {
  54165. /**
  54166. * @hidden
  54167. */
  54168. export interface IMaterialBRDFDefines {
  54169. BRDF_V_HEIGHT_CORRELATED: boolean;
  54170. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54171. SPHERICAL_HARMONICS: boolean;
  54172. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54173. /** @hidden */
  54174. _areMiscDirty: boolean;
  54175. }
  54176. /**
  54177. * Define the code related to the BRDF parameters of the pbr material.
  54178. */
  54179. export class PBRBRDFConfiguration {
  54180. /**
  54181. * Default value used for the energy conservation.
  54182. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54183. */
  54184. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54185. /**
  54186. * Default value used for the Smith Visibility Height Correlated mode.
  54187. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54188. */
  54189. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54190. /**
  54191. * Default value used for the IBL diffuse part.
  54192. * This can help switching back to the polynomials mode globally which is a tiny bit
  54193. * less GPU intensive at the drawback of a lower quality.
  54194. */
  54195. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54196. /**
  54197. * Default value used for activating energy conservation for the specular workflow.
  54198. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54199. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54200. */
  54201. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54202. private _useEnergyConservation;
  54203. /**
  54204. * Defines if the material uses energy conservation.
  54205. */
  54206. useEnergyConservation: boolean;
  54207. private _useSmithVisibilityHeightCorrelated;
  54208. /**
  54209. * LEGACY Mode set to false
  54210. * Defines if the material uses height smith correlated visibility term.
  54211. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54212. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54213. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54214. * Not relying on height correlated will also disable energy conservation.
  54215. */
  54216. useSmithVisibilityHeightCorrelated: boolean;
  54217. private _useSphericalHarmonics;
  54218. /**
  54219. * LEGACY Mode set to false
  54220. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54221. * diffuse part of the IBL.
  54222. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54223. * to the ground truth.
  54224. */
  54225. useSphericalHarmonics: boolean;
  54226. private _useSpecularGlossinessInputEnergyConservation;
  54227. /**
  54228. * Defines if the material uses energy conservation, when the specular workflow is active.
  54229. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54230. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54231. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54232. */
  54233. useSpecularGlossinessInputEnergyConservation: boolean;
  54234. /** @hidden */
  54235. private _internalMarkAllSubMeshesAsMiscDirty;
  54236. /** @hidden */
  54237. _markAllSubMeshesAsMiscDirty(): void;
  54238. /**
  54239. * Instantiate a new istance of clear coat configuration.
  54240. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54241. */
  54242. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54243. /**
  54244. * Checks to see if a texture is used in the material.
  54245. * @param defines the list of "defines" to update.
  54246. */
  54247. prepareDefines(defines: IMaterialBRDFDefines): void;
  54248. /**
  54249. * Get the current class name of the texture useful for serialization or dynamic coding.
  54250. * @returns "PBRClearCoatConfiguration"
  54251. */
  54252. getClassName(): string;
  54253. /**
  54254. * Makes a duplicate of the current configuration into another one.
  54255. * @param brdfConfiguration define the config where to copy the info
  54256. */
  54257. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54258. /**
  54259. * Serializes this BRDF configuration.
  54260. * @returns - An object with the serialized config.
  54261. */
  54262. serialize(): any;
  54263. /**
  54264. * Parses a anisotropy Configuration from a serialized object.
  54265. * @param source - Serialized object.
  54266. * @param scene Defines the scene we are parsing for
  54267. * @param rootUrl Defines the rootUrl to load from
  54268. */
  54269. parse(source: any, scene: Scene, rootUrl: string): void;
  54270. }
  54271. }
  54272. declare module BABYLON {
  54273. /**
  54274. * @hidden
  54275. */
  54276. export interface IMaterialSheenDefines {
  54277. SHEEN: boolean;
  54278. SHEEN_TEXTURE: boolean;
  54279. SHEEN_TEXTUREDIRECTUV: number;
  54280. SHEEN_LINKWITHALBEDO: boolean;
  54281. SHEEN_ROUGHNESS: boolean;
  54282. SHEEN_ALBEDOSCALING: boolean;
  54283. /** @hidden */
  54284. _areTexturesDirty: boolean;
  54285. }
  54286. /**
  54287. * Define the code related to the Sheen parameters of the pbr material.
  54288. */
  54289. export class PBRSheenConfiguration {
  54290. private _isEnabled;
  54291. /**
  54292. * Defines if the material uses sheen.
  54293. */
  54294. isEnabled: boolean;
  54295. private _linkSheenWithAlbedo;
  54296. /**
  54297. * Defines if the sheen is linked to the sheen color.
  54298. */
  54299. linkSheenWithAlbedo: boolean;
  54300. /**
  54301. * Defines the sheen intensity.
  54302. */
  54303. intensity: number;
  54304. /**
  54305. * Defines the sheen color.
  54306. */
  54307. color: Color3;
  54308. private _texture;
  54309. /**
  54310. * Stores the sheen tint values in a texture.
  54311. * rgb is tint
  54312. * a is a intensity
  54313. */
  54314. texture: Nullable<BaseTexture>;
  54315. private _roughness;
  54316. /**
  54317. * Defines the sheen roughness.
  54318. * It is not taken into account if linkSheenWithAlbedo is true.
  54319. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54320. */
  54321. roughness: Nullable<number>;
  54322. private _albedoScaling;
  54323. /**
  54324. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54325. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54326. * making it easier to setup and tweak the effect
  54327. */
  54328. albedoScaling: boolean;
  54329. /** @hidden */
  54330. private _internalMarkAllSubMeshesAsTexturesDirty;
  54331. /** @hidden */
  54332. _markAllSubMeshesAsTexturesDirty(): void;
  54333. /**
  54334. * Instantiate a new istance of clear coat configuration.
  54335. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54336. */
  54337. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54338. /**
  54339. * Specifies that the submesh is ready to be used.
  54340. * @param defines the list of "defines" to update.
  54341. * @param scene defines the scene the material belongs to.
  54342. * @returns - boolean indicating that the submesh is ready or not.
  54343. */
  54344. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54345. /**
  54346. * Checks to see if a texture is used in the material.
  54347. * @param defines the list of "defines" to update.
  54348. * @param scene defines the scene the material belongs to.
  54349. */
  54350. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54351. /**
  54352. * Binds the material data.
  54353. * @param uniformBuffer defines the Uniform buffer to fill in.
  54354. * @param scene defines the scene the material belongs to.
  54355. * @param isFrozen defines wether the material is frozen or not.
  54356. */
  54357. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54358. /**
  54359. * Checks to see if a texture is used in the material.
  54360. * @param texture - Base texture to use.
  54361. * @returns - Boolean specifying if a texture is used in the material.
  54362. */
  54363. hasTexture(texture: BaseTexture): boolean;
  54364. /**
  54365. * Returns an array of the actively used textures.
  54366. * @param activeTextures Array of BaseTextures
  54367. */
  54368. getActiveTextures(activeTextures: BaseTexture[]): void;
  54369. /**
  54370. * Returns the animatable textures.
  54371. * @param animatables Array of animatable textures.
  54372. */
  54373. getAnimatables(animatables: IAnimatable[]): void;
  54374. /**
  54375. * Disposes the resources of the material.
  54376. * @param forceDisposeTextures - Forces the disposal of all textures.
  54377. */
  54378. dispose(forceDisposeTextures?: boolean): void;
  54379. /**
  54380. * Get the current class name of the texture useful for serialization or dynamic coding.
  54381. * @returns "PBRSheenConfiguration"
  54382. */
  54383. getClassName(): string;
  54384. /**
  54385. * Add fallbacks to the effect fallbacks list.
  54386. * @param defines defines the Base texture to use.
  54387. * @param fallbacks defines the current fallback list.
  54388. * @param currentRank defines the current fallback rank.
  54389. * @returns the new fallback rank.
  54390. */
  54391. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54392. /**
  54393. * Add the required uniforms to the current list.
  54394. * @param uniforms defines the current uniform list.
  54395. */
  54396. static AddUniforms(uniforms: string[]): void;
  54397. /**
  54398. * Add the required uniforms to the current buffer.
  54399. * @param uniformBuffer defines the current uniform buffer.
  54400. */
  54401. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54402. /**
  54403. * Add the required samplers to the current list.
  54404. * @param samplers defines the current sampler list.
  54405. */
  54406. static AddSamplers(samplers: string[]): void;
  54407. /**
  54408. * Makes a duplicate of the current configuration into another one.
  54409. * @param sheenConfiguration define the config where to copy the info
  54410. */
  54411. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54412. /**
  54413. * Serializes this BRDF configuration.
  54414. * @returns - An object with the serialized config.
  54415. */
  54416. serialize(): any;
  54417. /**
  54418. * Parses a anisotropy Configuration from a serialized object.
  54419. * @param source - Serialized object.
  54420. * @param scene Defines the scene we are parsing for
  54421. * @param rootUrl Defines the rootUrl to load from
  54422. */
  54423. parse(source: any, scene: Scene, rootUrl: string): void;
  54424. }
  54425. }
  54426. declare module BABYLON {
  54427. /**
  54428. * @hidden
  54429. */
  54430. export interface IMaterialSubSurfaceDefines {
  54431. SUBSURFACE: boolean;
  54432. SS_REFRACTION: boolean;
  54433. SS_TRANSLUCENCY: boolean;
  54434. SS_SCATTERING: boolean;
  54435. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54436. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54437. SS_REFRACTIONMAP_3D: boolean;
  54438. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54439. SS_LODINREFRACTIONALPHA: boolean;
  54440. SS_GAMMAREFRACTION: boolean;
  54441. SS_RGBDREFRACTION: boolean;
  54442. SS_LINEARSPECULARREFRACTION: boolean;
  54443. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54444. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54445. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54446. /** @hidden */
  54447. _areTexturesDirty: boolean;
  54448. }
  54449. /**
  54450. * Define the code related to the sub surface parameters of the pbr material.
  54451. */
  54452. export class PBRSubSurfaceConfiguration {
  54453. private _isRefractionEnabled;
  54454. /**
  54455. * Defines if the refraction is enabled in the material.
  54456. */
  54457. isRefractionEnabled: boolean;
  54458. private _isTranslucencyEnabled;
  54459. /**
  54460. * Defines if the translucency is enabled in the material.
  54461. */
  54462. isTranslucencyEnabled: boolean;
  54463. private _isScatteringEnabled;
  54464. /**
  54465. * Defines the refraction intensity of the material.
  54466. * The refraction when enabled replaces the Diffuse part of the material.
  54467. * The intensity helps transitionning between diffuse and refraction.
  54468. */
  54469. refractionIntensity: number;
  54470. /**
  54471. * Defines the translucency intensity of the material.
  54472. * When translucency has been enabled, this defines how much of the "translucency"
  54473. * is addded to the diffuse part of the material.
  54474. */
  54475. translucencyIntensity: number;
  54476. /**
  54477. * Defines the scattering intensity of the material.
  54478. * When scattering has been enabled, this defines how much of the "scattered light"
  54479. * is addded to the diffuse part of the material.
  54480. */
  54481. scatteringIntensity: number;
  54482. /**
  54483. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54484. */
  54485. useAlbedoToTintRefraction: boolean;
  54486. private _thicknessTexture;
  54487. /**
  54488. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54489. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54490. * 0 would mean minimumThickness
  54491. * 1 would mean maximumThickness
  54492. * The other channels might be use as a mask to vary the different effects intensity.
  54493. */
  54494. thicknessTexture: Nullable<BaseTexture>;
  54495. private _refractionTexture;
  54496. /**
  54497. * Defines the texture to use for refraction.
  54498. */
  54499. refractionTexture: Nullable<BaseTexture>;
  54500. private _indexOfRefraction;
  54501. /**
  54502. * Index of refraction of the material base layer.
  54503. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54504. *
  54505. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54506. *
  54507. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54508. */
  54509. indexOfRefraction: number;
  54510. private _volumeIndexOfRefraction;
  54511. /**
  54512. * Index of refraction of the material's volume.
  54513. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54514. *
  54515. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54516. * the volume will use the same IOR as the surface.
  54517. */
  54518. get volumeIndexOfRefraction(): number;
  54519. set volumeIndexOfRefraction(value: number);
  54520. private _invertRefractionY;
  54521. /**
  54522. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54523. */
  54524. invertRefractionY: boolean;
  54525. private _linkRefractionWithTransparency;
  54526. /**
  54527. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54528. * Materials half opaque for instance using refraction could benefit from this control.
  54529. */
  54530. linkRefractionWithTransparency: boolean;
  54531. /**
  54532. * Defines the minimum thickness stored in the thickness map.
  54533. * If no thickness map is defined, this value will be used to simulate thickness.
  54534. */
  54535. minimumThickness: number;
  54536. /**
  54537. * Defines the maximum thickness stored in the thickness map.
  54538. */
  54539. maximumThickness: number;
  54540. /**
  54541. * Defines the volume tint of the material.
  54542. * This is used for both translucency and scattering.
  54543. */
  54544. tintColor: Color3;
  54545. /**
  54546. * Defines the distance at which the tint color should be found in the media.
  54547. * This is used for refraction only.
  54548. */
  54549. tintColorAtDistance: number;
  54550. /**
  54551. * Defines how far each channel transmit through the media.
  54552. * It is defined as a color to simplify it selection.
  54553. */
  54554. diffusionDistance: Color3;
  54555. private _useMaskFromThicknessTexture;
  54556. /**
  54557. * Stores the intensity of the different subsurface effects in the thickness texture.
  54558. * * the green channel is the translucency intensity.
  54559. * * the blue channel is the scattering intensity.
  54560. * * the alpha channel is the refraction intensity.
  54561. */
  54562. useMaskFromThicknessTexture: boolean;
  54563. /** @hidden */
  54564. private _internalMarkAllSubMeshesAsTexturesDirty;
  54565. /** @hidden */
  54566. _markAllSubMeshesAsTexturesDirty(): void;
  54567. /**
  54568. * Instantiate a new istance of sub surface configuration.
  54569. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54570. */
  54571. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54572. /**
  54573. * Gets wehter the submesh is ready to be used or not.
  54574. * @param defines the list of "defines" to update.
  54575. * @param scene defines the scene the material belongs to.
  54576. * @returns - boolean indicating that the submesh is ready or not.
  54577. */
  54578. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54579. /**
  54580. * Checks to see if a texture is used in the material.
  54581. * @param defines the list of "defines" to update.
  54582. * @param scene defines the scene to the material belongs to.
  54583. */
  54584. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54585. /**
  54586. * Binds the material data.
  54587. * @param uniformBuffer defines the Uniform buffer to fill in.
  54588. * @param scene defines the scene the material belongs to.
  54589. * @param engine defines the engine the material belongs to.
  54590. * @param isFrozen defines whether the material is frozen or not.
  54591. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54592. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54593. */
  54594. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54595. /**
  54596. * Unbinds the material from the mesh.
  54597. * @param activeEffect defines the effect that should be unbound from.
  54598. * @returns true if unbound, otherwise false
  54599. */
  54600. unbind(activeEffect: Effect): boolean;
  54601. /**
  54602. * Returns the texture used for refraction or null if none is used.
  54603. * @param scene defines the scene the material belongs to.
  54604. * @returns - Refraction texture if present. If no refraction texture and refraction
  54605. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54606. */
  54607. private _getRefractionTexture;
  54608. /**
  54609. * Returns true if alpha blending should be disabled.
  54610. */
  54611. get disableAlphaBlending(): boolean;
  54612. /**
  54613. * Fills the list of render target textures.
  54614. * @param renderTargets the list of render targets to update
  54615. */
  54616. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54617. /**
  54618. * Checks to see if a texture is used in the material.
  54619. * @param texture - Base texture to use.
  54620. * @returns - Boolean specifying if a texture is used in the material.
  54621. */
  54622. hasTexture(texture: BaseTexture): boolean;
  54623. /**
  54624. * Gets a boolean indicating that current material needs to register RTT
  54625. * @returns true if this uses a render target otherwise false.
  54626. */
  54627. hasRenderTargetTextures(): boolean;
  54628. /**
  54629. * Returns an array of the actively used textures.
  54630. * @param activeTextures Array of BaseTextures
  54631. */
  54632. getActiveTextures(activeTextures: BaseTexture[]): void;
  54633. /**
  54634. * Returns the animatable textures.
  54635. * @param animatables Array of animatable textures.
  54636. */
  54637. getAnimatables(animatables: IAnimatable[]): void;
  54638. /**
  54639. * Disposes the resources of the material.
  54640. * @param forceDisposeTextures - Forces the disposal of all textures.
  54641. */
  54642. dispose(forceDisposeTextures?: boolean): void;
  54643. /**
  54644. * Get the current class name of the texture useful for serialization or dynamic coding.
  54645. * @returns "PBRSubSurfaceConfiguration"
  54646. */
  54647. getClassName(): string;
  54648. /**
  54649. * Add fallbacks to the effect fallbacks list.
  54650. * @param defines defines the Base texture to use.
  54651. * @param fallbacks defines the current fallback list.
  54652. * @param currentRank defines the current fallback rank.
  54653. * @returns the new fallback rank.
  54654. */
  54655. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54656. /**
  54657. * Add the required uniforms to the current list.
  54658. * @param uniforms defines the current uniform list.
  54659. */
  54660. static AddUniforms(uniforms: string[]): void;
  54661. /**
  54662. * Add the required samplers to the current list.
  54663. * @param samplers defines the current sampler list.
  54664. */
  54665. static AddSamplers(samplers: string[]): void;
  54666. /**
  54667. * Add the required uniforms to the current buffer.
  54668. * @param uniformBuffer defines the current uniform buffer.
  54669. */
  54670. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54671. /**
  54672. * Makes a duplicate of the current configuration into another one.
  54673. * @param configuration define the config where to copy the info
  54674. */
  54675. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54676. /**
  54677. * Serializes this Sub Surface configuration.
  54678. * @returns - An object with the serialized config.
  54679. */
  54680. serialize(): any;
  54681. /**
  54682. * Parses a anisotropy Configuration from a serialized object.
  54683. * @param source - Serialized object.
  54684. * @param scene Defines the scene we are parsing for
  54685. * @param rootUrl Defines the rootUrl to load from
  54686. */
  54687. parse(source: any, scene: Scene, rootUrl: string): void;
  54688. }
  54689. }
  54690. declare module BABYLON {
  54691. /** @hidden */
  54692. export var pbrFragmentDeclaration: {
  54693. name: string;
  54694. shader: string;
  54695. };
  54696. }
  54697. declare module BABYLON {
  54698. /** @hidden */
  54699. export var pbrUboDeclaration: {
  54700. name: string;
  54701. shader: string;
  54702. };
  54703. }
  54704. declare module BABYLON {
  54705. /** @hidden */
  54706. export var pbrFragmentExtraDeclaration: {
  54707. name: string;
  54708. shader: string;
  54709. };
  54710. }
  54711. declare module BABYLON {
  54712. /** @hidden */
  54713. export var pbrFragmentSamplersDeclaration: {
  54714. name: string;
  54715. shader: string;
  54716. };
  54717. }
  54718. declare module BABYLON {
  54719. /** @hidden */
  54720. export var importanceSampling: {
  54721. name: string;
  54722. shader: string;
  54723. };
  54724. }
  54725. declare module BABYLON {
  54726. /** @hidden */
  54727. export var pbrHelperFunctions: {
  54728. name: string;
  54729. shader: string;
  54730. };
  54731. }
  54732. declare module BABYLON {
  54733. /** @hidden */
  54734. export var harmonicsFunctions: {
  54735. name: string;
  54736. shader: string;
  54737. };
  54738. }
  54739. declare module BABYLON {
  54740. /** @hidden */
  54741. export var pbrDirectLightingSetupFunctions: {
  54742. name: string;
  54743. shader: string;
  54744. };
  54745. }
  54746. declare module BABYLON {
  54747. /** @hidden */
  54748. export var pbrDirectLightingFalloffFunctions: {
  54749. name: string;
  54750. shader: string;
  54751. };
  54752. }
  54753. declare module BABYLON {
  54754. /** @hidden */
  54755. export var pbrBRDFFunctions: {
  54756. name: string;
  54757. shader: string;
  54758. };
  54759. }
  54760. declare module BABYLON {
  54761. /** @hidden */
  54762. export var hdrFilteringFunctions: {
  54763. name: string;
  54764. shader: string;
  54765. };
  54766. }
  54767. declare module BABYLON {
  54768. /** @hidden */
  54769. export var pbrDirectLightingFunctions: {
  54770. name: string;
  54771. shader: string;
  54772. };
  54773. }
  54774. declare module BABYLON {
  54775. /** @hidden */
  54776. export var pbrIBLFunctions: {
  54777. name: string;
  54778. shader: string;
  54779. };
  54780. }
  54781. declare module BABYLON {
  54782. /** @hidden */
  54783. export var pbrBlockAlbedoOpacity: {
  54784. name: string;
  54785. shader: string;
  54786. };
  54787. }
  54788. declare module BABYLON {
  54789. /** @hidden */
  54790. export var pbrBlockReflectivity: {
  54791. name: string;
  54792. shader: string;
  54793. };
  54794. }
  54795. declare module BABYLON {
  54796. /** @hidden */
  54797. export var pbrBlockAmbientOcclusion: {
  54798. name: string;
  54799. shader: string;
  54800. };
  54801. }
  54802. declare module BABYLON {
  54803. /** @hidden */
  54804. export var pbrBlockAlphaFresnel: {
  54805. name: string;
  54806. shader: string;
  54807. };
  54808. }
  54809. declare module BABYLON {
  54810. /** @hidden */
  54811. export var pbrBlockAnisotropic: {
  54812. name: string;
  54813. shader: string;
  54814. };
  54815. }
  54816. declare module BABYLON {
  54817. /** @hidden */
  54818. export var pbrBlockReflection: {
  54819. name: string;
  54820. shader: string;
  54821. };
  54822. }
  54823. declare module BABYLON {
  54824. /** @hidden */
  54825. export var pbrBlockSheen: {
  54826. name: string;
  54827. shader: string;
  54828. };
  54829. }
  54830. declare module BABYLON {
  54831. /** @hidden */
  54832. export var pbrBlockClearcoat: {
  54833. name: string;
  54834. shader: string;
  54835. };
  54836. }
  54837. declare module BABYLON {
  54838. /** @hidden */
  54839. export var pbrBlockSubSurface: {
  54840. name: string;
  54841. shader: string;
  54842. };
  54843. }
  54844. declare module BABYLON {
  54845. /** @hidden */
  54846. export var pbrBlockNormalGeometric: {
  54847. name: string;
  54848. shader: string;
  54849. };
  54850. }
  54851. declare module BABYLON {
  54852. /** @hidden */
  54853. export var pbrBlockNormalFinal: {
  54854. name: string;
  54855. shader: string;
  54856. };
  54857. }
  54858. declare module BABYLON {
  54859. /** @hidden */
  54860. export var pbrBlockGeometryInfo: {
  54861. name: string;
  54862. shader: string;
  54863. };
  54864. }
  54865. declare module BABYLON {
  54866. /** @hidden */
  54867. export var pbrBlockReflectance0: {
  54868. name: string;
  54869. shader: string;
  54870. };
  54871. }
  54872. declare module BABYLON {
  54873. /** @hidden */
  54874. export var pbrBlockReflectance: {
  54875. name: string;
  54876. shader: string;
  54877. };
  54878. }
  54879. declare module BABYLON {
  54880. /** @hidden */
  54881. export var pbrBlockDirectLighting: {
  54882. name: string;
  54883. shader: string;
  54884. };
  54885. }
  54886. declare module BABYLON {
  54887. /** @hidden */
  54888. export var pbrBlockFinalLitComponents: {
  54889. name: string;
  54890. shader: string;
  54891. };
  54892. }
  54893. declare module BABYLON {
  54894. /** @hidden */
  54895. export var pbrBlockFinalUnlitComponents: {
  54896. name: string;
  54897. shader: string;
  54898. };
  54899. }
  54900. declare module BABYLON {
  54901. /** @hidden */
  54902. export var pbrBlockFinalColorComposition: {
  54903. name: string;
  54904. shader: string;
  54905. };
  54906. }
  54907. declare module BABYLON {
  54908. /** @hidden */
  54909. export var pbrBlockImageProcessing: {
  54910. name: string;
  54911. shader: string;
  54912. };
  54913. }
  54914. declare module BABYLON {
  54915. /** @hidden */
  54916. export var pbrDebug: {
  54917. name: string;
  54918. shader: string;
  54919. };
  54920. }
  54921. declare module BABYLON {
  54922. /** @hidden */
  54923. export var pbrPixelShader: {
  54924. name: string;
  54925. shader: string;
  54926. };
  54927. }
  54928. declare module BABYLON {
  54929. /** @hidden */
  54930. export var pbrVertexDeclaration: {
  54931. name: string;
  54932. shader: string;
  54933. };
  54934. }
  54935. declare module BABYLON {
  54936. /** @hidden */
  54937. export var pbrVertexShader: {
  54938. name: string;
  54939. shader: string;
  54940. };
  54941. }
  54942. declare module BABYLON {
  54943. /**
  54944. * Manages the defines for the PBR Material.
  54945. * @hidden
  54946. */
  54947. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  54948. PBR: boolean;
  54949. NUM_SAMPLES: string;
  54950. REALTIME_FILTERING: boolean;
  54951. MAINUV1: boolean;
  54952. MAINUV2: boolean;
  54953. UV1: boolean;
  54954. UV2: boolean;
  54955. ALBEDO: boolean;
  54956. GAMMAALBEDO: boolean;
  54957. ALBEDODIRECTUV: number;
  54958. VERTEXCOLOR: boolean;
  54959. DETAIL: boolean;
  54960. DETAILDIRECTUV: number;
  54961. DETAIL_NORMALBLENDMETHOD: number;
  54962. AMBIENT: boolean;
  54963. AMBIENTDIRECTUV: number;
  54964. AMBIENTINGRAYSCALE: boolean;
  54965. OPACITY: boolean;
  54966. VERTEXALPHA: boolean;
  54967. OPACITYDIRECTUV: number;
  54968. OPACITYRGB: boolean;
  54969. ALPHATEST: boolean;
  54970. DEPTHPREPASS: boolean;
  54971. ALPHABLEND: boolean;
  54972. ALPHAFROMALBEDO: boolean;
  54973. ALPHATESTVALUE: string;
  54974. SPECULAROVERALPHA: boolean;
  54975. RADIANCEOVERALPHA: boolean;
  54976. ALPHAFRESNEL: boolean;
  54977. LINEARALPHAFRESNEL: boolean;
  54978. PREMULTIPLYALPHA: boolean;
  54979. EMISSIVE: boolean;
  54980. EMISSIVEDIRECTUV: number;
  54981. REFLECTIVITY: boolean;
  54982. REFLECTIVITYDIRECTUV: number;
  54983. SPECULARTERM: boolean;
  54984. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  54985. MICROSURFACEAUTOMATIC: boolean;
  54986. LODBASEDMICROSFURACE: boolean;
  54987. MICROSURFACEMAP: boolean;
  54988. MICROSURFACEMAPDIRECTUV: number;
  54989. METALLICWORKFLOW: boolean;
  54990. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  54991. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  54992. METALLNESSSTOREINMETALMAPBLUE: boolean;
  54993. AOSTOREINMETALMAPRED: boolean;
  54994. METALLIC_REFLECTANCE: boolean;
  54995. METALLIC_REFLECTANCEDIRECTUV: number;
  54996. ENVIRONMENTBRDF: boolean;
  54997. ENVIRONMENTBRDF_RGBD: boolean;
  54998. NORMAL: boolean;
  54999. TANGENT: boolean;
  55000. BUMP: boolean;
  55001. BUMPDIRECTUV: number;
  55002. OBJECTSPACE_NORMALMAP: boolean;
  55003. PARALLAX: boolean;
  55004. PARALLAXOCCLUSION: boolean;
  55005. NORMALXYSCALE: boolean;
  55006. LIGHTMAP: boolean;
  55007. LIGHTMAPDIRECTUV: number;
  55008. USELIGHTMAPASSHADOWMAP: boolean;
  55009. GAMMALIGHTMAP: boolean;
  55010. RGBDLIGHTMAP: boolean;
  55011. REFLECTION: boolean;
  55012. REFLECTIONMAP_3D: boolean;
  55013. REFLECTIONMAP_SPHERICAL: boolean;
  55014. REFLECTIONMAP_PLANAR: boolean;
  55015. REFLECTIONMAP_CUBIC: boolean;
  55016. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55017. REFLECTIONMAP_PROJECTION: boolean;
  55018. REFLECTIONMAP_SKYBOX: boolean;
  55019. REFLECTIONMAP_EXPLICIT: boolean;
  55020. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55021. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55022. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55023. INVERTCUBICMAP: boolean;
  55024. USESPHERICALFROMREFLECTIONMAP: boolean;
  55025. USEIRRADIANCEMAP: boolean;
  55026. SPHERICAL_HARMONICS: boolean;
  55027. USESPHERICALINVERTEX: boolean;
  55028. REFLECTIONMAP_OPPOSITEZ: boolean;
  55029. LODINREFLECTIONALPHA: boolean;
  55030. GAMMAREFLECTION: boolean;
  55031. RGBDREFLECTION: boolean;
  55032. LINEARSPECULARREFLECTION: boolean;
  55033. RADIANCEOCCLUSION: boolean;
  55034. HORIZONOCCLUSION: boolean;
  55035. INSTANCES: boolean;
  55036. THIN_INSTANCES: boolean;
  55037. NUM_BONE_INFLUENCERS: number;
  55038. BonesPerMesh: number;
  55039. BONETEXTURE: boolean;
  55040. NONUNIFORMSCALING: boolean;
  55041. MORPHTARGETS: boolean;
  55042. MORPHTARGETS_NORMAL: boolean;
  55043. MORPHTARGETS_TANGENT: boolean;
  55044. MORPHTARGETS_UV: boolean;
  55045. NUM_MORPH_INFLUENCERS: number;
  55046. IMAGEPROCESSING: boolean;
  55047. VIGNETTE: boolean;
  55048. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55049. VIGNETTEBLENDMODEOPAQUE: boolean;
  55050. TONEMAPPING: boolean;
  55051. TONEMAPPING_ACES: boolean;
  55052. CONTRAST: boolean;
  55053. COLORCURVES: boolean;
  55054. COLORGRADING: boolean;
  55055. COLORGRADING3D: boolean;
  55056. SAMPLER3DGREENDEPTH: boolean;
  55057. SAMPLER3DBGRMAP: boolean;
  55058. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55059. EXPOSURE: boolean;
  55060. MULTIVIEW: boolean;
  55061. USEPHYSICALLIGHTFALLOFF: boolean;
  55062. USEGLTFLIGHTFALLOFF: boolean;
  55063. TWOSIDEDLIGHTING: boolean;
  55064. SHADOWFLOAT: boolean;
  55065. CLIPPLANE: boolean;
  55066. CLIPPLANE2: boolean;
  55067. CLIPPLANE3: boolean;
  55068. CLIPPLANE4: boolean;
  55069. CLIPPLANE5: boolean;
  55070. CLIPPLANE6: boolean;
  55071. POINTSIZE: boolean;
  55072. FOG: boolean;
  55073. LOGARITHMICDEPTH: boolean;
  55074. FORCENORMALFORWARD: boolean;
  55075. SPECULARAA: boolean;
  55076. CLEARCOAT: boolean;
  55077. CLEARCOAT_DEFAULTIOR: boolean;
  55078. CLEARCOAT_TEXTURE: boolean;
  55079. CLEARCOAT_TEXTUREDIRECTUV: number;
  55080. CLEARCOAT_BUMP: boolean;
  55081. CLEARCOAT_BUMPDIRECTUV: number;
  55082. CLEARCOAT_TINT: boolean;
  55083. CLEARCOAT_TINT_TEXTURE: boolean;
  55084. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55085. ANISOTROPIC: boolean;
  55086. ANISOTROPIC_TEXTURE: boolean;
  55087. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55088. BRDF_V_HEIGHT_CORRELATED: boolean;
  55089. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55090. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55091. SHEEN: boolean;
  55092. SHEEN_TEXTURE: boolean;
  55093. SHEEN_TEXTUREDIRECTUV: number;
  55094. SHEEN_LINKWITHALBEDO: boolean;
  55095. SHEEN_ROUGHNESS: boolean;
  55096. SHEEN_ALBEDOSCALING: boolean;
  55097. SUBSURFACE: boolean;
  55098. SS_REFRACTION: boolean;
  55099. SS_TRANSLUCENCY: boolean;
  55100. SS_SCATTERING: boolean;
  55101. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55102. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55103. SS_REFRACTIONMAP_3D: boolean;
  55104. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55105. SS_LODINREFRACTIONALPHA: boolean;
  55106. SS_GAMMAREFRACTION: boolean;
  55107. SS_RGBDREFRACTION: boolean;
  55108. SS_LINEARSPECULARREFRACTION: boolean;
  55109. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55110. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55111. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55112. UNLIT: boolean;
  55113. DEBUGMODE: number;
  55114. /**
  55115. * Initializes the PBR Material defines.
  55116. */
  55117. constructor();
  55118. /**
  55119. * Resets the PBR Material defines.
  55120. */
  55121. reset(): void;
  55122. }
  55123. /**
  55124. * The Physically based material base class of BJS.
  55125. *
  55126. * This offers the main features of a standard PBR material.
  55127. * For more information, please refer to the documentation :
  55128. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55129. */
  55130. export abstract class PBRBaseMaterial extends PushMaterial {
  55131. /**
  55132. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55133. */
  55134. static readonly PBRMATERIAL_OPAQUE: number;
  55135. /**
  55136. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55137. */
  55138. static readonly PBRMATERIAL_ALPHATEST: number;
  55139. /**
  55140. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55141. */
  55142. static readonly PBRMATERIAL_ALPHABLEND: number;
  55143. /**
  55144. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55145. * They are also discarded below the alpha cutoff threshold to improve performances.
  55146. */
  55147. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55148. /**
  55149. * Defines the default value of how much AO map is occluding the analytical lights
  55150. * (point spot...).
  55151. */
  55152. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55153. /**
  55154. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55155. */
  55156. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55157. /**
  55158. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55159. * to enhance interoperability with other engines.
  55160. */
  55161. static readonly LIGHTFALLOFF_GLTF: number;
  55162. /**
  55163. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55164. * to enhance interoperability with other materials.
  55165. */
  55166. static readonly LIGHTFALLOFF_STANDARD: number;
  55167. /**
  55168. * Intensity of the direct lights e.g. the four lights available in your scene.
  55169. * This impacts both the direct diffuse and specular highlights.
  55170. */
  55171. protected _directIntensity: number;
  55172. /**
  55173. * Intensity of the emissive part of the material.
  55174. * This helps controlling the emissive effect without modifying the emissive color.
  55175. */
  55176. protected _emissiveIntensity: number;
  55177. /**
  55178. * Intensity of the environment e.g. how much the environment will light the object
  55179. * either through harmonics for rough material or through the refelction for shiny ones.
  55180. */
  55181. protected _environmentIntensity: number;
  55182. /**
  55183. * This is a special control allowing the reduction of the specular highlights coming from the
  55184. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55185. */
  55186. protected _specularIntensity: number;
  55187. /**
  55188. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55189. */
  55190. private _lightingInfos;
  55191. /**
  55192. * Debug Control allowing disabling the bump map on this material.
  55193. */
  55194. protected _disableBumpMap: boolean;
  55195. /**
  55196. * AKA Diffuse Texture in standard nomenclature.
  55197. */
  55198. protected _albedoTexture: Nullable<BaseTexture>;
  55199. /**
  55200. * AKA Occlusion Texture in other nomenclature.
  55201. */
  55202. protected _ambientTexture: Nullable<BaseTexture>;
  55203. /**
  55204. * AKA Occlusion Texture Intensity in other nomenclature.
  55205. */
  55206. protected _ambientTextureStrength: number;
  55207. /**
  55208. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55209. * 1 means it completely occludes it
  55210. * 0 mean it has no impact
  55211. */
  55212. protected _ambientTextureImpactOnAnalyticalLights: number;
  55213. /**
  55214. * Stores the alpha values in a texture.
  55215. */
  55216. protected _opacityTexture: Nullable<BaseTexture>;
  55217. /**
  55218. * Stores the reflection values in a texture.
  55219. */
  55220. protected _reflectionTexture: Nullable<BaseTexture>;
  55221. /**
  55222. * Stores the emissive values in a texture.
  55223. */
  55224. protected _emissiveTexture: Nullable<BaseTexture>;
  55225. /**
  55226. * AKA Specular texture in other nomenclature.
  55227. */
  55228. protected _reflectivityTexture: Nullable<BaseTexture>;
  55229. /**
  55230. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55231. */
  55232. protected _metallicTexture: Nullable<BaseTexture>;
  55233. /**
  55234. * Specifies the metallic scalar of the metallic/roughness workflow.
  55235. * Can also be used to scale the metalness values of the metallic texture.
  55236. */
  55237. protected _metallic: Nullable<number>;
  55238. /**
  55239. * Specifies the roughness scalar of the metallic/roughness workflow.
  55240. * Can also be used to scale the roughness values of the metallic texture.
  55241. */
  55242. protected _roughness: Nullable<number>;
  55243. /**
  55244. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55245. * By default the indexOfrefraction is used to compute F0;
  55246. *
  55247. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55248. *
  55249. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55250. * F90 = metallicReflectanceColor;
  55251. */
  55252. protected _metallicF0Factor: number;
  55253. /**
  55254. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55255. * By default the F90 is always 1;
  55256. *
  55257. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55258. *
  55259. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55260. * F90 = metallicReflectanceColor;
  55261. */
  55262. protected _metallicReflectanceColor: Color3;
  55263. /**
  55264. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55265. * This is multiply against the scalar values defined in the material.
  55266. */
  55267. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55268. /**
  55269. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55270. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55271. */
  55272. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55273. /**
  55274. * Stores surface normal data used to displace a mesh in a texture.
  55275. */
  55276. protected _bumpTexture: Nullable<BaseTexture>;
  55277. /**
  55278. * Stores the pre-calculated light information of a mesh in a texture.
  55279. */
  55280. protected _lightmapTexture: Nullable<BaseTexture>;
  55281. /**
  55282. * The color of a material in ambient lighting.
  55283. */
  55284. protected _ambientColor: Color3;
  55285. /**
  55286. * AKA Diffuse Color in other nomenclature.
  55287. */
  55288. protected _albedoColor: Color3;
  55289. /**
  55290. * AKA Specular Color in other nomenclature.
  55291. */
  55292. protected _reflectivityColor: Color3;
  55293. /**
  55294. * The color applied when light is reflected from a material.
  55295. */
  55296. protected _reflectionColor: Color3;
  55297. /**
  55298. * The color applied when light is emitted from a material.
  55299. */
  55300. protected _emissiveColor: Color3;
  55301. /**
  55302. * AKA Glossiness in other nomenclature.
  55303. */
  55304. protected _microSurface: number;
  55305. /**
  55306. * Specifies that the material will use the light map as a show map.
  55307. */
  55308. protected _useLightmapAsShadowmap: boolean;
  55309. /**
  55310. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55311. * makes the reflect vector face the model (under horizon).
  55312. */
  55313. protected _useHorizonOcclusion: boolean;
  55314. /**
  55315. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55316. * too much the area relying on ambient texture to define their ambient occlusion.
  55317. */
  55318. protected _useRadianceOcclusion: boolean;
  55319. /**
  55320. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55321. */
  55322. protected _useAlphaFromAlbedoTexture: boolean;
  55323. /**
  55324. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55325. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55326. */
  55327. protected _useSpecularOverAlpha: boolean;
  55328. /**
  55329. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55330. */
  55331. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55332. /**
  55333. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55334. */
  55335. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55336. /**
  55337. * Specifies if the metallic texture contains the roughness information in its green channel.
  55338. */
  55339. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55340. /**
  55341. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55342. */
  55343. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55344. /**
  55345. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55346. */
  55347. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55348. /**
  55349. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55350. */
  55351. protected _useAmbientInGrayScale: boolean;
  55352. /**
  55353. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55354. * The material will try to infer what glossiness each pixel should be.
  55355. */
  55356. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55357. /**
  55358. * Defines the falloff type used in this material.
  55359. * It by default is Physical.
  55360. */
  55361. protected _lightFalloff: number;
  55362. /**
  55363. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55364. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55365. */
  55366. protected _useRadianceOverAlpha: boolean;
  55367. /**
  55368. * Allows using an object space normal map (instead of tangent space).
  55369. */
  55370. protected _useObjectSpaceNormalMap: boolean;
  55371. /**
  55372. * Allows using the bump map in parallax mode.
  55373. */
  55374. protected _useParallax: boolean;
  55375. /**
  55376. * Allows using the bump map in parallax occlusion mode.
  55377. */
  55378. protected _useParallaxOcclusion: boolean;
  55379. /**
  55380. * Controls the scale bias of the parallax mode.
  55381. */
  55382. protected _parallaxScaleBias: number;
  55383. /**
  55384. * If sets to true, disables all the lights affecting the material.
  55385. */
  55386. protected _disableLighting: boolean;
  55387. /**
  55388. * Number of Simultaneous lights allowed on the material.
  55389. */
  55390. protected _maxSimultaneousLights: number;
  55391. /**
  55392. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55393. */
  55394. protected _invertNormalMapX: boolean;
  55395. /**
  55396. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55397. */
  55398. protected _invertNormalMapY: boolean;
  55399. /**
  55400. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55401. */
  55402. protected _twoSidedLighting: boolean;
  55403. /**
  55404. * Defines the alpha limits in alpha test mode.
  55405. */
  55406. protected _alphaCutOff: number;
  55407. /**
  55408. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55409. */
  55410. protected _forceAlphaTest: boolean;
  55411. /**
  55412. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55413. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55414. */
  55415. protected _useAlphaFresnel: boolean;
  55416. /**
  55417. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55418. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55419. */
  55420. protected _useLinearAlphaFresnel: boolean;
  55421. /**
  55422. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55423. * from cos thetav and roughness:
  55424. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55425. */
  55426. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55427. /**
  55428. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55429. */
  55430. protected _forceIrradianceInFragment: boolean;
  55431. private _realTimeFiltering;
  55432. /**
  55433. * Enables realtime filtering on the texture.
  55434. */
  55435. get realTimeFiltering(): boolean;
  55436. set realTimeFiltering(b: boolean);
  55437. private _realTimeFilteringQuality;
  55438. /**
  55439. * Quality switch for realtime filtering
  55440. */
  55441. get realTimeFilteringQuality(): number;
  55442. set realTimeFilteringQuality(n: number);
  55443. /**
  55444. * Force normal to face away from face.
  55445. */
  55446. protected _forceNormalForward: boolean;
  55447. /**
  55448. * Enables specular anti aliasing in the PBR shader.
  55449. * It will both interacts on the Geometry for analytical and IBL lighting.
  55450. * It also prefilter the roughness map based on the bump values.
  55451. */
  55452. protected _enableSpecularAntiAliasing: boolean;
  55453. /**
  55454. * Default configuration related to image processing available in the PBR Material.
  55455. */
  55456. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55457. /**
  55458. * Keep track of the image processing observer to allow dispose and replace.
  55459. */
  55460. private _imageProcessingObserver;
  55461. /**
  55462. * Attaches a new image processing configuration to the PBR Material.
  55463. * @param configuration
  55464. */
  55465. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55466. /**
  55467. * Stores the available render targets.
  55468. */
  55469. private _renderTargets;
  55470. /**
  55471. * Sets the global ambient color for the material used in lighting calculations.
  55472. */
  55473. private _globalAmbientColor;
  55474. /**
  55475. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55476. */
  55477. private _useLogarithmicDepth;
  55478. /**
  55479. * If set to true, no lighting calculations will be applied.
  55480. */
  55481. private _unlit;
  55482. private _debugMode;
  55483. /**
  55484. * @hidden
  55485. * This is reserved for the inspector.
  55486. * Defines the material debug mode.
  55487. * It helps seeing only some components of the material while troubleshooting.
  55488. */
  55489. debugMode: number;
  55490. /**
  55491. * @hidden
  55492. * This is reserved for the inspector.
  55493. * Specify from where on screen the debug mode should start.
  55494. * The value goes from -1 (full screen) to 1 (not visible)
  55495. * It helps with side by side comparison against the final render
  55496. * This defaults to -1
  55497. */
  55498. private debugLimit;
  55499. /**
  55500. * @hidden
  55501. * This is reserved for the inspector.
  55502. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55503. * You can use the factor to better multiply the final value.
  55504. */
  55505. private debugFactor;
  55506. /**
  55507. * Defines the clear coat layer parameters for the material.
  55508. */
  55509. readonly clearCoat: PBRClearCoatConfiguration;
  55510. /**
  55511. * Defines the anisotropic parameters for the material.
  55512. */
  55513. readonly anisotropy: PBRAnisotropicConfiguration;
  55514. /**
  55515. * Defines the BRDF parameters for the material.
  55516. */
  55517. readonly brdf: PBRBRDFConfiguration;
  55518. /**
  55519. * Defines the Sheen parameters for the material.
  55520. */
  55521. readonly sheen: PBRSheenConfiguration;
  55522. /**
  55523. * Defines the SubSurface parameters for the material.
  55524. */
  55525. readonly subSurface: PBRSubSurfaceConfiguration;
  55526. /**
  55527. * Defines the detail map parameters for the material.
  55528. */
  55529. readonly detailMap: DetailMapConfiguration;
  55530. protected _rebuildInParallel: boolean;
  55531. /**
  55532. * Instantiates a new PBRMaterial instance.
  55533. *
  55534. * @param name The material name
  55535. * @param scene The scene the material will be use in.
  55536. */
  55537. constructor(name: string, scene: Scene);
  55538. /**
  55539. * Gets a boolean indicating that current material needs to register RTT
  55540. */
  55541. get hasRenderTargetTextures(): boolean;
  55542. /**
  55543. * Gets the name of the material class.
  55544. */
  55545. getClassName(): string;
  55546. /**
  55547. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55548. */
  55549. get useLogarithmicDepth(): boolean;
  55550. /**
  55551. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55552. */
  55553. set useLogarithmicDepth(value: boolean);
  55554. /**
  55555. * Returns true if alpha blending should be disabled.
  55556. */
  55557. protected get _disableAlphaBlending(): boolean;
  55558. /**
  55559. * Specifies whether or not this material should be rendered in alpha blend mode.
  55560. */
  55561. needAlphaBlending(): boolean;
  55562. /**
  55563. * Specifies whether or not this material should be rendered in alpha test mode.
  55564. */
  55565. needAlphaTesting(): boolean;
  55566. /**
  55567. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55568. */
  55569. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55570. /**
  55571. * Gets the texture used for the alpha test.
  55572. */
  55573. getAlphaTestTexture(): Nullable<BaseTexture>;
  55574. /**
  55575. * Specifies that the submesh is ready to be used.
  55576. * @param mesh - BJS mesh.
  55577. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55578. * @param useInstances - Specifies that instances should be used.
  55579. * @returns - boolean indicating that the submesh is ready or not.
  55580. */
  55581. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55582. /**
  55583. * Specifies if the material uses metallic roughness workflow.
  55584. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55585. */
  55586. isMetallicWorkflow(): boolean;
  55587. private _prepareEffect;
  55588. private _prepareDefines;
  55589. /**
  55590. * Force shader compilation
  55591. */
  55592. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55593. /**
  55594. * Initializes the uniform buffer layout for the shader.
  55595. */
  55596. buildUniformLayout(): void;
  55597. /**
  55598. * Unbinds the material from the mesh
  55599. */
  55600. unbind(): void;
  55601. /**
  55602. * Binds the submesh data.
  55603. * @param world - The world matrix.
  55604. * @param mesh - The BJS mesh.
  55605. * @param subMesh - A submesh of the BJS mesh.
  55606. */
  55607. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55608. /**
  55609. * Returns the animatable textures.
  55610. * @returns - Array of animatable textures.
  55611. */
  55612. getAnimatables(): IAnimatable[];
  55613. /**
  55614. * Returns the texture used for reflections.
  55615. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55616. */
  55617. private _getReflectionTexture;
  55618. /**
  55619. * Returns an array of the actively used textures.
  55620. * @returns - Array of BaseTextures
  55621. */
  55622. getActiveTextures(): BaseTexture[];
  55623. /**
  55624. * Checks to see if a texture is used in the material.
  55625. * @param texture - Base texture to use.
  55626. * @returns - Boolean specifying if a texture is used in the material.
  55627. */
  55628. hasTexture(texture: BaseTexture): boolean;
  55629. /**
  55630. * Disposes the resources of the material.
  55631. * @param forceDisposeEffect - Forces the disposal of effects.
  55632. * @param forceDisposeTextures - Forces the disposal of all textures.
  55633. */
  55634. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55635. }
  55636. }
  55637. declare module BABYLON {
  55638. /**
  55639. * The Physically based material of BJS.
  55640. *
  55641. * This offers the main features of a standard PBR material.
  55642. * For more information, please refer to the documentation :
  55643. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55644. */
  55645. export class PBRMaterial extends PBRBaseMaterial {
  55646. /**
  55647. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55648. */
  55649. static readonly PBRMATERIAL_OPAQUE: number;
  55650. /**
  55651. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55652. */
  55653. static readonly PBRMATERIAL_ALPHATEST: number;
  55654. /**
  55655. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55656. */
  55657. static readonly PBRMATERIAL_ALPHABLEND: number;
  55658. /**
  55659. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55660. * They are also discarded below the alpha cutoff threshold to improve performances.
  55661. */
  55662. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55663. /**
  55664. * Defines the default value of how much AO map is occluding the analytical lights
  55665. * (point spot...).
  55666. */
  55667. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55668. /**
  55669. * Intensity of the direct lights e.g. the four lights available in your scene.
  55670. * This impacts both the direct diffuse and specular highlights.
  55671. */
  55672. directIntensity: number;
  55673. /**
  55674. * Intensity of the emissive part of the material.
  55675. * This helps controlling the emissive effect without modifying the emissive color.
  55676. */
  55677. emissiveIntensity: number;
  55678. /**
  55679. * Intensity of the environment e.g. how much the environment will light the object
  55680. * either through harmonics for rough material or through the refelction for shiny ones.
  55681. */
  55682. environmentIntensity: number;
  55683. /**
  55684. * This is a special control allowing the reduction of the specular highlights coming from the
  55685. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55686. */
  55687. specularIntensity: number;
  55688. /**
  55689. * Debug Control allowing disabling the bump map on this material.
  55690. */
  55691. disableBumpMap: boolean;
  55692. /**
  55693. * AKA Diffuse Texture in standard nomenclature.
  55694. */
  55695. albedoTexture: BaseTexture;
  55696. /**
  55697. * AKA Occlusion Texture in other nomenclature.
  55698. */
  55699. ambientTexture: BaseTexture;
  55700. /**
  55701. * AKA Occlusion Texture Intensity in other nomenclature.
  55702. */
  55703. ambientTextureStrength: number;
  55704. /**
  55705. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55706. * 1 means it completely occludes it
  55707. * 0 mean it has no impact
  55708. */
  55709. ambientTextureImpactOnAnalyticalLights: number;
  55710. /**
  55711. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55712. */
  55713. opacityTexture: BaseTexture;
  55714. /**
  55715. * Stores the reflection values in a texture.
  55716. */
  55717. reflectionTexture: Nullable<BaseTexture>;
  55718. /**
  55719. * Stores the emissive values in a texture.
  55720. */
  55721. emissiveTexture: BaseTexture;
  55722. /**
  55723. * AKA Specular texture in other nomenclature.
  55724. */
  55725. reflectivityTexture: BaseTexture;
  55726. /**
  55727. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55728. */
  55729. metallicTexture: BaseTexture;
  55730. /**
  55731. * Specifies the metallic scalar of the metallic/roughness workflow.
  55732. * Can also be used to scale the metalness values of the metallic texture.
  55733. */
  55734. metallic: Nullable<number>;
  55735. /**
  55736. * Specifies the roughness scalar of the metallic/roughness workflow.
  55737. * Can also be used to scale the roughness values of the metallic texture.
  55738. */
  55739. roughness: Nullable<number>;
  55740. /**
  55741. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55742. * By default the indexOfrefraction is used to compute F0;
  55743. *
  55744. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55745. *
  55746. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55747. * F90 = metallicReflectanceColor;
  55748. */
  55749. metallicF0Factor: number;
  55750. /**
  55751. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55752. * By default the F90 is always 1;
  55753. *
  55754. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55755. *
  55756. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55757. * F90 = metallicReflectanceColor;
  55758. */
  55759. metallicReflectanceColor: Color3;
  55760. /**
  55761. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55762. * This is multiply against the scalar values defined in the material.
  55763. */
  55764. metallicReflectanceTexture: Nullable<BaseTexture>;
  55765. /**
  55766. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55767. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55768. */
  55769. microSurfaceTexture: BaseTexture;
  55770. /**
  55771. * Stores surface normal data used to displace a mesh in a texture.
  55772. */
  55773. bumpTexture: BaseTexture;
  55774. /**
  55775. * Stores the pre-calculated light information of a mesh in a texture.
  55776. */
  55777. lightmapTexture: BaseTexture;
  55778. /**
  55779. * Stores the refracted light information in a texture.
  55780. */
  55781. get refractionTexture(): Nullable<BaseTexture>;
  55782. set refractionTexture(value: Nullable<BaseTexture>);
  55783. /**
  55784. * The color of a material in ambient lighting.
  55785. */
  55786. ambientColor: Color3;
  55787. /**
  55788. * AKA Diffuse Color in other nomenclature.
  55789. */
  55790. albedoColor: Color3;
  55791. /**
  55792. * AKA Specular Color in other nomenclature.
  55793. */
  55794. reflectivityColor: Color3;
  55795. /**
  55796. * The color reflected from the material.
  55797. */
  55798. reflectionColor: Color3;
  55799. /**
  55800. * The color emitted from the material.
  55801. */
  55802. emissiveColor: Color3;
  55803. /**
  55804. * AKA Glossiness in other nomenclature.
  55805. */
  55806. microSurface: number;
  55807. /**
  55808. * Index of refraction of the material base layer.
  55809. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55810. *
  55811. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55812. *
  55813. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55814. */
  55815. get indexOfRefraction(): number;
  55816. set indexOfRefraction(value: number);
  55817. /**
  55818. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55819. */
  55820. get invertRefractionY(): boolean;
  55821. set invertRefractionY(value: boolean);
  55822. /**
  55823. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55824. * Materials half opaque for instance using refraction could benefit from this control.
  55825. */
  55826. get linkRefractionWithTransparency(): boolean;
  55827. set linkRefractionWithTransparency(value: boolean);
  55828. /**
  55829. * If true, the light map contains occlusion information instead of lighting info.
  55830. */
  55831. useLightmapAsShadowmap: boolean;
  55832. /**
  55833. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55834. */
  55835. useAlphaFromAlbedoTexture: boolean;
  55836. /**
  55837. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55838. */
  55839. forceAlphaTest: boolean;
  55840. /**
  55841. * Defines the alpha limits in alpha test mode.
  55842. */
  55843. alphaCutOff: number;
  55844. /**
  55845. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  55846. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55847. */
  55848. useSpecularOverAlpha: boolean;
  55849. /**
  55850. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55851. */
  55852. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55853. /**
  55854. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55855. */
  55856. useRoughnessFromMetallicTextureAlpha: boolean;
  55857. /**
  55858. * Specifies if the metallic texture contains the roughness information in its green channel.
  55859. */
  55860. useRoughnessFromMetallicTextureGreen: boolean;
  55861. /**
  55862. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55863. */
  55864. useMetallnessFromMetallicTextureBlue: boolean;
  55865. /**
  55866. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55867. */
  55868. useAmbientOcclusionFromMetallicTextureRed: boolean;
  55869. /**
  55870. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55871. */
  55872. useAmbientInGrayScale: boolean;
  55873. /**
  55874. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55875. * The material will try to infer what glossiness each pixel should be.
  55876. */
  55877. useAutoMicroSurfaceFromReflectivityMap: 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. get usePhysicalLightFalloff(): boolean;
  55884. /**
  55885. * BJS is using an harcoded light falloff based on a manually sets up range.
  55886. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  55887. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  55888. */
  55889. set usePhysicalLightFalloff(value: boolean);
  55890. /**
  55891. * In order to support the falloff compatibility with gltf, a special mode has been added
  55892. * to reproduce the gltf light falloff.
  55893. */
  55894. get useGLTFLightFalloff(): boolean;
  55895. /**
  55896. * In order to support the falloff compatibility with gltf, a special mode has been added
  55897. * to reproduce the gltf light falloff.
  55898. */
  55899. set useGLTFLightFalloff(value: boolean);
  55900. /**
  55901. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55902. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55903. */
  55904. useRadianceOverAlpha: boolean;
  55905. /**
  55906. * Allows using an object space normal map (instead of tangent space).
  55907. */
  55908. useObjectSpaceNormalMap: boolean;
  55909. /**
  55910. * Allows using the bump map in parallax mode.
  55911. */
  55912. useParallax: boolean;
  55913. /**
  55914. * Allows using the bump map in parallax occlusion mode.
  55915. */
  55916. useParallaxOcclusion: boolean;
  55917. /**
  55918. * Controls the scale bias of the parallax mode.
  55919. */
  55920. parallaxScaleBias: number;
  55921. /**
  55922. * If sets to true, disables all the lights affecting the material.
  55923. */
  55924. disableLighting: boolean;
  55925. /**
  55926. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55927. */
  55928. forceIrradianceInFragment: boolean;
  55929. /**
  55930. * Number of Simultaneous lights allowed on the material.
  55931. */
  55932. maxSimultaneousLights: number;
  55933. /**
  55934. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55935. */
  55936. invertNormalMapX: boolean;
  55937. /**
  55938. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55939. */
  55940. invertNormalMapY: boolean;
  55941. /**
  55942. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55943. */
  55944. twoSidedLighting: boolean;
  55945. /**
  55946. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55947. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55948. */
  55949. useAlphaFresnel: boolean;
  55950. /**
  55951. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55952. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55953. */
  55954. useLinearAlphaFresnel: boolean;
  55955. /**
  55956. * Let user defines the brdf lookup texture used for IBL.
  55957. * A default 8bit version is embedded but you could point at :
  55958. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  55959. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  55960. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  55961. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  55962. */
  55963. environmentBRDFTexture: Nullable<BaseTexture>;
  55964. /**
  55965. * Force normal to face away from face.
  55966. */
  55967. forceNormalForward: boolean;
  55968. /**
  55969. * Enables specular anti aliasing in the PBR shader.
  55970. * It will both interacts on the Geometry for analytical and IBL lighting.
  55971. * It also prefilter the roughness map based on the bump values.
  55972. */
  55973. enableSpecularAntiAliasing: boolean;
  55974. /**
  55975. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55976. * makes the reflect vector face the model (under horizon).
  55977. */
  55978. useHorizonOcclusion: boolean;
  55979. /**
  55980. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55981. * too much the area relying on ambient texture to define their ambient occlusion.
  55982. */
  55983. useRadianceOcclusion: boolean;
  55984. /**
  55985. * If set to true, no lighting calculations will be applied.
  55986. */
  55987. unlit: boolean;
  55988. /**
  55989. * Gets the image processing configuration used either in this material.
  55990. */
  55991. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  55992. /**
  55993. * Sets the Default image processing configuration used either in the this material.
  55994. *
  55995. * If sets to null, the scene one is in use.
  55996. */
  55997. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  55998. /**
  55999. * Gets wether the color curves effect is enabled.
  56000. */
  56001. get cameraColorCurvesEnabled(): boolean;
  56002. /**
  56003. * Sets wether the color curves effect is enabled.
  56004. */
  56005. set cameraColorCurvesEnabled(value: boolean);
  56006. /**
  56007. * Gets wether the color grading effect is enabled.
  56008. */
  56009. get cameraColorGradingEnabled(): boolean;
  56010. /**
  56011. * Gets wether the color grading effect is enabled.
  56012. */
  56013. set cameraColorGradingEnabled(value: boolean);
  56014. /**
  56015. * Gets wether tonemapping is enabled or not.
  56016. */
  56017. get cameraToneMappingEnabled(): boolean;
  56018. /**
  56019. * Sets wether tonemapping is enabled or not
  56020. */
  56021. set cameraToneMappingEnabled(value: boolean);
  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. get cameraExposure(): number;
  56028. /**
  56029. * The camera exposure used on this material.
  56030. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56031. * This corresponds to a photographic exposure.
  56032. */
  56033. set cameraExposure(value: number);
  56034. /**
  56035. * Gets The camera contrast used on this material.
  56036. */
  56037. get cameraContrast(): number;
  56038. /**
  56039. * Sets The camera contrast used on this material.
  56040. */
  56041. set cameraContrast(value: number);
  56042. /**
  56043. * Gets the Color Grading 2D Lookup Texture.
  56044. */
  56045. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56046. /**
  56047. * Sets the Color Grading 2D Lookup Texture.
  56048. */
  56049. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56050. /**
  56051. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56052. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56053. * 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;
  56054. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56055. */
  56056. get cameraColorCurves(): Nullable<ColorCurves>;
  56057. /**
  56058. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56059. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56060. * 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;
  56061. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56062. */
  56063. set cameraColorCurves(value: Nullable<ColorCurves>);
  56064. /**
  56065. * Instantiates a new PBRMaterial instance.
  56066. *
  56067. * @param name The material name
  56068. * @param scene The scene the material will be use in.
  56069. */
  56070. constructor(name: string, scene: Scene);
  56071. /**
  56072. * Returns the name of this material class.
  56073. */
  56074. getClassName(): string;
  56075. /**
  56076. * Makes a duplicate of the current material.
  56077. * @param name - name to use for the new material.
  56078. */
  56079. clone(name: string): PBRMaterial;
  56080. /**
  56081. * Serializes this PBR Material.
  56082. * @returns - An object with the serialized material.
  56083. */
  56084. serialize(): any;
  56085. /**
  56086. * Parses a PBR Material from a serialized object.
  56087. * @param source - Serialized object.
  56088. * @param scene - BJS scene instance.
  56089. * @param rootUrl - url for the scene object
  56090. * @returns - PBRMaterial
  56091. */
  56092. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56093. }
  56094. }
  56095. declare module BABYLON {
  56096. /**
  56097. * Direct draw surface info
  56098. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56099. */
  56100. export interface DDSInfo {
  56101. /**
  56102. * Width of the texture
  56103. */
  56104. width: number;
  56105. /**
  56106. * Width of the texture
  56107. */
  56108. height: number;
  56109. /**
  56110. * Number of Mipmaps for the texture
  56111. * @see https://en.wikipedia.org/wiki/Mipmap
  56112. */
  56113. mipmapCount: number;
  56114. /**
  56115. * If the textures format is a known fourCC format
  56116. * @see https://www.fourcc.org/
  56117. */
  56118. isFourCC: boolean;
  56119. /**
  56120. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56121. */
  56122. isRGB: boolean;
  56123. /**
  56124. * If the texture is a lumincance format
  56125. */
  56126. isLuminance: boolean;
  56127. /**
  56128. * If this is a cube texture
  56129. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56130. */
  56131. isCube: boolean;
  56132. /**
  56133. * If the texture is a compressed format eg. FOURCC_DXT1
  56134. */
  56135. isCompressed: boolean;
  56136. /**
  56137. * The dxgiFormat of the texture
  56138. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56139. */
  56140. dxgiFormat: number;
  56141. /**
  56142. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56143. */
  56144. textureType: number;
  56145. /**
  56146. * Sphericle polynomial created for the dds texture
  56147. */
  56148. sphericalPolynomial?: SphericalPolynomial;
  56149. }
  56150. /**
  56151. * Class used to provide DDS decompression tools
  56152. */
  56153. export class DDSTools {
  56154. /**
  56155. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56156. */
  56157. static StoreLODInAlphaChannel: boolean;
  56158. /**
  56159. * Gets DDS information from an array buffer
  56160. * @param data defines the array buffer view to read data from
  56161. * @returns the DDS information
  56162. */
  56163. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56164. private static _FloatView;
  56165. private static _Int32View;
  56166. private static _ToHalfFloat;
  56167. private static _FromHalfFloat;
  56168. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56169. private static _GetHalfFloatRGBAArrayBuffer;
  56170. private static _GetFloatRGBAArrayBuffer;
  56171. private static _GetFloatAsUIntRGBAArrayBuffer;
  56172. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56173. private static _GetRGBAArrayBuffer;
  56174. private static _ExtractLongWordOrder;
  56175. private static _GetRGBArrayBuffer;
  56176. private static _GetLuminanceArrayBuffer;
  56177. /**
  56178. * Uploads DDS Levels to a Babylon Texture
  56179. * @hidden
  56180. */
  56181. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56182. }
  56183. interface ThinEngine {
  56184. /**
  56185. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56186. * @param rootUrl defines the url where the file to load is located
  56187. * @param scene defines the current scene
  56188. * @param lodScale defines scale to apply to the mip map selection
  56189. * @param lodOffset defines offset to apply to the mip map selection
  56190. * @param onLoad defines an optional callback raised when the texture is loaded
  56191. * @param onError defines an optional callback raised if there is an issue to load the texture
  56192. * @param format defines the format of the data
  56193. * @param forcedExtension defines the extension to use to pick the right loader
  56194. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56195. * @returns the cube texture as an InternalTexture
  56196. */
  56197. 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;
  56198. }
  56199. }
  56200. declare module BABYLON {
  56201. /**
  56202. * Implementation of the DDS Texture Loader.
  56203. * @hidden
  56204. */
  56205. export class _DDSTextureLoader implements IInternalTextureLoader {
  56206. /**
  56207. * Defines wether the loader supports cascade loading the different faces.
  56208. */
  56209. readonly supportCascades: boolean;
  56210. /**
  56211. * This returns if the loader support the current file information.
  56212. * @param extension defines the file extension of the file being loaded
  56213. * @returns true if the loader can load the specified file
  56214. */
  56215. canLoad(extension: string): boolean;
  56216. /**
  56217. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56218. * @param data contains the texture data
  56219. * @param texture defines the BabylonJS internal texture
  56220. * @param createPolynomials will be true if polynomials have been requested
  56221. * @param onLoad defines the callback to trigger once the texture is ready
  56222. * @param onError defines the callback to trigger in case of error
  56223. */
  56224. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56225. /**
  56226. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56227. * @param data contains the texture data
  56228. * @param texture defines the BabylonJS internal texture
  56229. * @param callback defines the method to call once ready to upload
  56230. */
  56231. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56232. }
  56233. }
  56234. declare module BABYLON {
  56235. /**
  56236. * Implementation of the ENV Texture Loader.
  56237. * @hidden
  56238. */
  56239. export class _ENVTextureLoader implements IInternalTextureLoader {
  56240. /**
  56241. * Defines wether the loader supports cascade loading the different faces.
  56242. */
  56243. readonly supportCascades: boolean;
  56244. /**
  56245. * This returns if the loader support the current file information.
  56246. * @param extension defines the file extension of the file being loaded
  56247. * @returns true if the loader can load the specified file
  56248. */
  56249. canLoad(extension: string): boolean;
  56250. /**
  56251. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56252. * @param data contains the texture data
  56253. * @param texture defines the BabylonJS internal texture
  56254. * @param createPolynomials will be true if polynomials have been requested
  56255. * @param onLoad defines the callback to trigger once the texture is ready
  56256. * @param onError defines the callback to trigger in case of error
  56257. */
  56258. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56259. /**
  56260. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56261. * @param data contains the texture data
  56262. * @param texture defines the BabylonJS internal texture
  56263. * @param callback defines the method to call once ready to upload
  56264. */
  56265. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56266. }
  56267. }
  56268. declare module BABYLON {
  56269. /**
  56270. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56271. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56272. */
  56273. export class KhronosTextureContainer {
  56274. /** contents of the KTX container file */
  56275. data: ArrayBufferView;
  56276. private static HEADER_LEN;
  56277. private static COMPRESSED_2D;
  56278. private static COMPRESSED_3D;
  56279. private static TEX_2D;
  56280. private static TEX_3D;
  56281. /**
  56282. * Gets the openGL type
  56283. */
  56284. glType: number;
  56285. /**
  56286. * Gets the openGL type size
  56287. */
  56288. glTypeSize: number;
  56289. /**
  56290. * Gets the openGL format
  56291. */
  56292. glFormat: number;
  56293. /**
  56294. * Gets the openGL internal format
  56295. */
  56296. glInternalFormat: number;
  56297. /**
  56298. * Gets the base internal format
  56299. */
  56300. glBaseInternalFormat: number;
  56301. /**
  56302. * Gets image width in pixel
  56303. */
  56304. pixelWidth: number;
  56305. /**
  56306. * Gets image height in pixel
  56307. */
  56308. pixelHeight: number;
  56309. /**
  56310. * Gets image depth in pixels
  56311. */
  56312. pixelDepth: number;
  56313. /**
  56314. * Gets the number of array elements
  56315. */
  56316. numberOfArrayElements: number;
  56317. /**
  56318. * Gets the number of faces
  56319. */
  56320. numberOfFaces: number;
  56321. /**
  56322. * Gets the number of mipmap levels
  56323. */
  56324. numberOfMipmapLevels: number;
  56325. /**
  56326. * Gets the bytes of key value data
  56327. */
  56328. bytesOfKeyValueData: number;
  56329. /**
  56330. * Gets the load type
  56331. */
  56332. loadType: number;
  56333. /**
  56334. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56335. */
  56336. isInvalid: boolean;
  56337. /**
  56338. * Creates a new KhronosTextureContainer
  56339. * @param data contents of the KTX container file
  56340. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56341. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56342. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56343. */
  56344. constructor(
  56345. /** contents of the KTX container file */
  56346. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56347. /**
  56348. * Uploads KTX content to a Babylon Texture.
  56349. * It is assumed that the texture has already been created & is currently bound
  56350. * @hidden
  56351. */
  56352. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56353. private _upload2DCompressedLevels;
  56354. /**
  56355. * Checks if the given data starts with a KTX file identifier.
  56356. * @param data the data to check
  56357. * @returns true if the data is a KTX file or false otherwise
  56358. */
  56359. static IsValid(data: ArrayBufferView): boolean;
  56360. }
  56361. }
  56362. declare module BABYLON {
  56363. /**
  56364. * Class for loading KTX2 files
  56365. * !!! Experimental Extension Subject to Changes !!!
  56366. * @hidden
  56367. */
  56368. export class KhronosTextureContainer2 {
  56369. private static _ModulePromise;
  56370. private static _TranscodeFormat;
  56371. constructor(engine: ThinEngine);
  56372. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56373. private _determineTranscodeFormat;
  56374. /**
  56375. * Checks if the given data starts with a KTX2 file identifier.
  56376. * @param data the data to check
  56377. * @returns true if the data is a KTX2 file or false otherwise
  56378. */
  56379. static IsValid(data: ArrayBufferView): boolean;
  56380. }
  56381. }
  56382. declare module BABYLON {
  56383. /**
  56384. * Implementation of the KTX Texture Loader.
  56385. * @hidden
  56386. */
  56387. export class _KTXTextureLoader implements IInternalTextureLoader {
  56388. /**
  56389. * Defines wether the loader supports cascade loading the different faces.
  56390. */
  56391. readonly supportCascades: boolean;
  56392. /**
  56393. * This returns if the loader support the current file information.
  56394. * @param extension defines the file extension of the file being loaded
  56395. * @returns true if the loader can load the specified file
  56396. */
  56397. canLoad(extension: string): boolean;
  56398. /**
  56399. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56400. * @param data contains the texture data
  56401. * @param texture defines the BabylonJS internal texture
  56402. * @param createPolynomials will be true if polynomials have been requested
  56403. * @param onLoad defines the callback to trigger once the texture is ready
  56404. * @param onError defines the callback to trigger in case of error
  56405. */
  56406. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56407. /**
  56408. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56409. * @param data contains the texture data
  56410. * @param texture defines the BabylonJS internal texture
  56411. * @param callback defines the method to call once ready to upload
  56412. */
  56413. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56414. }
  56415. }
  56416. declare module BABYLON {
  56417. /** @hidden */
  56418. export var _forceSceneHelpersToBundle: boolean;
  56419. interface Scene {
  56420. /**
  56421. * Creates a default light for the scene.
  56422. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56423. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56424. */
  56425. createDefaultLight(replace?: boolean): void;
  56426. /**
  56427. * Creates a default camera for the scene.
  56428. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56429. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56430. * @param replace has default false, when true replaces the active camera in the scene
  56431. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56432. */
  56433. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56434. /**
  56435. * Creates a default camera and a default light.
  56436. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56437. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56438. * @param replace has the default false, when true replaces the active camera/light in the scene
  56439. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56440. */
  56441. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56442. /**
  56443. * Creates a new sky box
  56444. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56445. * @param environmentTexture defines the texture to use as environment texture
  56446. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56447. * @param scale defines the overall scale of the skybox
  56448. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56449. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56450. * @returns a new mesh holding the sky box
  56451. */
  56452. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56453. /**
  56454. * Creates a new environment
  56455. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56456. * @param options defines the options you can use to configure the environment
  56457. * @returns the new EnvironmentHelper
  56458. */
  56459. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56460. /**
  56461. * Creates a new VREXperienceHelper
  56462. * @see http://doc.babylonjs.com/how_to/webvr_helper
  56463. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56464. * @returns a new VREXperienceHelper
  56465. */
  56466. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56467. /**
  56468. * Creates a new WebXRDefaultExperience
  56469. * @see http://doc.babylonjs.com/how_to/webxr
  56470. * @param options experience options
  56471. * @returns a promise for a new WebXRDefaultExperience
  56472. */
  56473. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56474. }
  56475. }
  56476. declare module BABYLON {
  56477. /**
  56478. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56479. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56480. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56481. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56482. */
  56483. export class VideoDome extends TransformNode {
  56484. /**
  56485. * Define the video source as a Monoscopic panoramic 360 video.
  56486. */
  56487. static readonly MODE_MONOSCOPIC: number;
  56488. /**
  56489. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56490. */
  56491. static readonly MODE_TOPBOTTOM: number;
  56492. /**
  56493. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56494. */
  56495. static readonly MODE_SIDEBYSIDE: number;
  56496. private _halfDome;
  56497. private _useDirectMapping;
  56498. /**
  56499. * The video texture being displayed on the sphere
  56500. */
  56501. protected _videoTexture: VideoTexture;
  56502. /**
  56503. * Gets the video texture being displayed on the sphere
  56504. */
  56505. get videoTexture(): VideoTexture;
  56506. /**
  56507. * The skybox material
  56508. */
  56509. protected _material: BackgroundMaterial;
  56510. /**
  56511. * The surface used for the skybox
  56512. */
  56513. protected _mesh: Mesh;
  56514. /**
  56515. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56516. */
  56517. private _halfDomeMask;
  56518. /**
  56519. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56520. * Also see the options.resolution property.
  56521. */
  56522. get fovMultiplier(): number;
  56523. set fovMultiplier(value: number);
  56524. private _videoMode;
  56525. /**
  56526. * Gets or set the current video mode for the video. It can be:
  56527. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56528. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56529. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56530. */
  56531. get videoMode(): number;
  56532. set videoMode(value: number);
  56533. /**
  56534. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56535. *
  56536. */
  56537. get halfDome(): boolean;
  56538. /**
  56539. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56540. */
  56541. set halfDome(enabled: boolean);
  56542. /**
  56543. * Oberserver used in Stereoscopic VR Mode.
  56544. */
  56545. private _onBeforeCameraRenderObserver;
  56546. /**
  56547. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56548. * @param name Element's name, child elements will append suffixes for their own names.
  56549. * @param urlsOrVideo defines the url(s) or the video element to use
  56550. * @param options An object containing optional or exposed sub element properties
  56551. */
  56552. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56553. resolution?: number;
  56554. clickToPlay?: boolean;
  56555. autoPlay?: boolean;
  56556. loop?: boolean;
  56557. size?: number;
  56558. poster?: string;
  56559. faceForward?: boolean;
  56560. useDirectMapping?: boolean;
  56561. halfDomeMode?: boolean;
  56562. }, scene: Scene);
  56563. private _changeVideoMode;
  56564. /**
  56565. * Releases resources associated with this node.
  56566. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56567. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56568. */
  56569. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56570. }
  56571. }
  56572. declare module BABYLON {
  56573. /**
  56574. * This class can be used to get instrumentation data from a Babylon engine
  56575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56576. */
  56577. export class EngineInstrumentation implements IDisposable {
  56578. /**
  56579. * Define the instrumented engine.
  56580. */
  56581. engine: Engine;
  56582. private _captureGPUFrameTime;
  56583. private _gpuFrameTimeToken;
  56584. private _gpuFrameTime;
  56585. private _captureShaderCompilationTime;
  56586. private _shaderCompilationTime;
  56587. private _onBeginFrameObserver;
  56588. private _onEndFrameObserver;
  56589. private _onBeforeShaderCompilationObserver;
  56590. private _onAfterShaderCompilationObserver;
  56591. /**
  56592. * Gets the perf counter used for GPU frame time
  56593. */
  56594. get gpuFrameTimeCounter(): PerfCounter;
  56595. /**
  56596. * Gets the GPU frame time capture status
  56597. */
  56598. get captureGPUFrameTime(): boolean;
  56599. /**
  56600. * Enable or disable the GPU frame time capture
  56601. */
  56602. set captureGPUFrameTime(value: boolean);
  56603. /**
  56604. * Gets the perf counter used for shader compilation time
  56605. */
  56606. get shaderCompilationTimeCounter(): PerfCounter;
  56607. /**
  56608. * Gets the shader compilation time capture status
  56609. */
  56610. get captureShaderCompilationTime(): boolean;
  56611. /**
  56612. * Enable or disable the shader compilation time capture
  56613. */
  56614. set captureShaderCompilationTime(value: boolean);
  56615. /**
  56616. * Instantiates a new engine instrumentation.
  56617. * This class can be used to get instrumentation data from a Babylon engine
  56618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56619. * @param engine Defines the engine to instrument
  56620. */
  56621. constructor(
  56622. /**
  56623. * Define the instrumented engine.
  56624. */
  56625. engine: Engine);
  56626. /**
  56627. * Dispose and release associated resources.
  56628. */
  56629. dispose(): void;
  56630. }
  56631. }
  56632. declare module BABYLON {
  56633. /**
  56634. * This class can be used to get instrumentation data from a Babylon engine
  56635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56636. */
  56637. export class SceneInstrumentation implements IDisposable {
  56638. /**
  56639. * Defines the scene to instrument
  56640. */
  56641. scene: Scene;
  56642. private _captureActiveMeshesEvaluationTime;
  56643. private _activeMeshesEvaluationTime;
  56644. private _captureRenderTargetsRenderTime;
  56645. private _renderTargetsRenderTime;
  56646. private _captureFrameTime;
  56647. private _frameTime;
  56648. private _captureRenderTime;
  56649. private _renderTime;
  56650. private _captureInterFrameTime;
  56651. private _interFrameTime;
  56652. private _captureParticlesRenderTime;
  56653. private _particlesRenderTime;
  56654. private _captureSpritesRenderTime;
  56655. private _spritesRenderTime;
  56656. private _capturePhysicsTime;
  56657. private _physicsTime;
  56658. private _captureAnimationsTime;
  56659. private _animationsTime;
  56660. private _captureCameraRenderTime;
  56661. private _cameraRenderTime;
  56662. private _onBeforeActiveMeshesEvaluationObserver;
  56663. private _onAfterActiveMeshesEvaluationObserver;
  56664. private _onBeforeRenderTargetsRenderObserver;
  56665. private _onAfterRenderTargetsRenderObserver;
  56666. private _onAfterRenderObserver;
  56667. private _onBeforeDrawPhaseObserver;
  56668. private _onAfterDrawPhaseObserver;
  56669. private _onBeforeAnimationsObserver;
  56670. private _onBeforeParticlesRenderingObserver;
  56671. private _onAfterParticlesRenderingObserver;
  56672. private _onBeforeSpritesRenderingObserver;
  56673. private _onAfterSpritesRenderingObserver;
  56674. private _onBeforePhysicsObserver;
  56675. private _onAfterPhysicsObserver;
  56676. private _onAfterAnimationsObserver;
  56677. private _onBeforeCameraRenderObserver;
  56678. private _onAfterCameraRenderObserver;
  56679. /**
  56680. * Gets the perf counter used for active meshes evaluation time
  56681. */
  56682. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56683. /**
  56684. * Gets the active meshes evaluation time capture status
  56685. */
  56686. get captureActiveMeshesEvaluationTime(): boolean;
  56687. /**
  56688. * Enable or disable the active meshes evaluation time capture
  56689. */
  56690. set captureActiveMeshesEvaluationTime(value: boolean);
  56691. /**
  56692. * Gets the perf counter used for render targets render time
  56693. */
  56694. get renderTargetsRenderTimeCounter(): PerfCounter;
  56695. /**
  56696. * Gets the render targets render time capture status
  56697. */
  56698. get captureRenderTargetsRenderTime(): boolean;
  56699. /**
  56700. * Enable or disable the render targets render time capture
  56701. */
  56702. set captureRenderTargetsRenderTime(value: boolean);
  56703. /**
  56704. * Gets the perf counter used for particles render time
  56705. */
  56706. get particlesRenderTimeCounter(): PerfCounter;
  56707. /**
  56708. * Gets the particles render time capture status
  56709. */
  56710. get captureParticlesRenderTime(): boolean;
  56711. /**
  56712. * Enable or disable the particles render time capture
  56713. */
  56714. set captureParticlesRenderTime(value: boolean);
  56715. /**
  56716. * Gets the perf counter used for sprites render time
  56717. */
  56718. get spritesRenderTimeCounter(): PerfCounter;
  56719. /**
  56720. * Gets the sprites render time capture status
  56721. */
  56722. get captureSpritesRenderTime(): boolean;
  56723. /**
  56724. * Enable or disable the sprites render time capture
  56725. */
  56726. set captureSpritesRenderTime(value: boolean);
  56727. /**
  56728. * Gets the perf counter used for physics time
  56729. */
  56730. get physicsTimeCounter(): PerfCounter;
  56731. /**
  56732. * Gets the physics time capture status
  56733. */
  56734. get capturePhysicsTime(): boolean;
  56735. /**
  56736. * Enable or disable the physics time capture
  56737. */
  56738. set capturePhysicsTime(value: boolean);
  56739. /**
  56740. * Gets the perf counter used for animations time
  56741. */
  56742. get animationsTimeCounter(): PerfCounter;
  56743. /**
  56744. * Gets the animations time capture status
  56745. */
  56746. get captureAnimationsTime(): boolean;
  56747. /**
  56748. * Enable or disable the animations time capture
  56749. */
  56750. set captureAnimationsTime(value: boolean);
  56751. /**
  56752. * Gets the perf counter used for frame time capture
  56753. */
  56754. get frameTimeCounter(): PerfCounter;
  56755. /**
  56756. * Gets the frame time capture status
  56757. */
  56758. get captureFrameTime(): boolean;
  56759. /**
  56760. * Enable or disable the frame time capture
  56761. */
  56762. set captureFrameTime(value: boolean);
  56763. /**
  56764. * Gets the perf counter used for inter-frames time capture
  56765. */
  56766. get interFrameTimeCounter(): PerfCounter;
  56767. /**
  56768. * Gets the inter-frames time capture status
  56769. */
  56770. get captureInterFrameTime(): boolean;
  56771. /**
  56772. * Enable or disable the inter-frames time capture
  56773. */
  56774. set captureInterFrameTime(value: boolean);
  56775. /**
  56776. * Gets the perf counter used for render time capture
  56777. */
  56778. get renderTimeCounter(): PerfCounter;
  56779. /**
  56780. * Gets the render time capture status
  56781. */
  56782. get captureRenderTime(): boolean;
  56783. /**
  56784. * Enable or disable the render time capture
  56785. */
  56786. set captureRenderTime(value: boolean);
  56787. /**
  56788. * Gets the perf counter used for camera render time capture
  56789. */
  56790. get cameraRenderTimeCounter(): PerfCounter;
  56791. /**
  56792. * Gets the camera render time capture status
  56793. */
  56794. get captureCameraRenderTime(): boolean;
  56795. /**
  56796. * Enable or disable the camera render time capture
  56797. */
  56798. set captureCameraRenderTime(value: boolean);
  56799. /**
  56800. * Gets the perf counter used for draw calls
  56801. */
  56802. get drawCallsCounter(): PerfCounter;
  56803. /**
  56804. * Instantiates a new scene instrumentation.
  56805. * This class can be used to get instrumentation data from a Babylon engine
  56806. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56807. * @param scene Defines the scene to instrument
  56808. */
  56809. constructor(
  56810. /**
  56811. * Defines the scene to instrument
  56812. */
  56813. scene: Scene);
  56814. /**
  56815. * Dispose and release associated resources.
  56816. */
  56817. dispose(): void;
  56818. }
  56819. }
  56820. declare module BABYLON {
  56821. /** @hidden */
  56822. export var glowMapGenerationPixelShader: {
  56823. name: string;
  56824. shader: string;
  56825. };
  56826. }
  56827. declare module BABYLON {
  56828. /** @hidden */
  56829. export var glowMapGenerationVertexShader: {
  56830. name: string;
  56831. shader: string;
  56832. };
  56833. }
  56834. declare module BABYLON {
  56835. /**
  56836. * Effect layer options. This helps customizing the behaviour
  56837. * of the effect layer.
  56838. */
  56839. export interface IEffectLayerOptions {
  56840. /**
  56841. * Multiplication factor apply to the canvas size to compute the render target size
  56842. * used to generated the objects (the smaller the faster).
  56843. */
  56844. mainTextureRatio: number;
  56845. /**
  56846. * Enforces a fixed size texture to ensure effect stability across devices.
  56847. */
  56848. mainTextureFixedSize?: number;
  56849. /**
  56850. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  56851. */
  56852. alphaBlendingMode: number;
  56853. /**
  56854. * The camera attached to the layer.
  56855. */
  56856. camera: Nullable<Camera>;
  56857. /**
  56858. * The rendering group to draw the layer in.
  56859. */
  56860. renderingGroupId: number;
  56861. }
  56862. /**
  56863. * The effect layer Helps adding post process effect blended with the main pass.
  56864. *
  56865. * This can be for instance use to generate glow or higlight effects on the scene.
  56866. *
  56867. * The effect layer class can not be used directly and is intented to inherited from to be
  56868. * customized per effects.
  56869. */
  56870. export abstract class EffectLayer {
  56871. private _vertexBuffers;
  56872. private _indexBuffer;
  56873. private _cachedDefines;
  56874. private _effectLayerMapGenerationEffect;
  56875. private _effectLayerOptions;
  56876. private _mergeEffect;
  56877. protected _scene: Scene;
  56878. protected _engine: Engine;
  56879. protected _maxSize: number;
  56880. protected _mainTextureDesiredSize: ISize;
  56881. protected _mainTexture: RenderTargetTexture;
  56882. protected _shouldRender: boolean;
  56883. protected _postProcesses: PostProcess[];
  56884. protected _textures: BaseTexture[];
  56885. protected _emissiveTextureAndColor: {
  56886. texture: Nullable<BaseTexture>;
  56887. color: Color4;
  56888. };
  56889. /**
  56890. * The name of the layer
  56891. */
  56892. name: string;
  56893. /**
  56894. * The clear color of the texture used to generate the glow map.
  56895. */
  56896. neutralColor: Color4;
  56897. /**
  56898. * Specifies whether the highlight layer is enabled or not.
  56899. */
  56900. isEnabled: boolean;
  56901. /**
  56902. * Gets the camera attached to the layer.
  56903. */
  56904. get camera(): Nullable<Camera>;
  56905. /**
  56906. * Gets the rendering group id the layer should render in.
  56907. */
  56908. get renderingGroupId(): number;
  56909. set renderingGroupId(renderingGroupId: number);
  56910. /**
  56911. * An event triggered when the effect layer has been disposed.
  56912. */
  56913. onDisposeObservable: Observable<EffectLayer>;
  56914. /**
  56915. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  56916. */
  56917. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  56918. /**
  56919. * An event triggered when the generated texture is being merged in the scene.
  56920. */
  56921. onBeforeComposeObservable: Observable<EffectLayer>;
  56922. /**
  56923. * An event triggered when the mesh is rendered into the effect render target.
  56924. */
  56925. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  56926. /**
  56927. * An event triggered after the mesh has been rendered into the effect render target.
  56928. */
  56929. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  56930. /**
  56931. * An event triggered when the generated texture has been merged in the scene.
  56932. */
  56933. onAfterComposeObservable: Observable<EffectLayer>;
  56934. /**
  56935. * An event triggered when the efffect layer changes its size.
  56936. */
  56937. onSizeChangedObservable: Observable<EffectLayer>;
  56938. /** @hidden */
  56939. static _SceneComponentInitialization: (scene: Scene) => void;
  56940. /**
  56941. * Instantiates a new effect Layer and references it in the scene.
  56942. * @param name The name of the layer
  56943. * @param scene The scene to use the layer in
  56944. */
  56945. constructor(
  56946. /** The Friendly of the effect in the scene */
  56947. name: string, scene: Scene);
  56948. /**
  56949. * Get the effect name of the layer.
  56950. * @return The effect name
  56951. */
  56952. abstract getEffectName(): string;
  56953. /**
  56954. * Checks for the readiness of the element composing the layer.
  56955. * @param subMesh the mesh to check for
  56956. * @param useInstances specify whether or not to use instances to render the mesh
  56957. * @return true if ready otherwise, false
  56958. */
  56959. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56960. /**
  56961. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56962. * @returns true if the effect requires stencil during the main canvas render pass.
  56963. */
  56964. abstract needStencil(): boolean;
  56965. /**
  56966. * Create the merge effect. This is the shader use to blit the information back
  56967. * to the main canvas at the end of the scene rendering.
  56968. * @returns The effect containing the shader used to merge the effect on the main canvas
  56969. */
  56970. protected abstract _createMergeEffect(): Effect;
  56971. /**
  56972. * Creates the render target textures and post processes used in the effect layer.
  56973. */
  56974. protected abstract _createTextureAndPostProcesses(): void;
  56975. /**
  56976. * Implementation specific of rendering the generating effect on the main canvas.
  56977. * @param effect The effect used to render through
  56978. */
  56979. protected abstract _internalRender(effect: Effect): void;
  56980. /**
  56981. * Sets the required values for both the emissive texture and and the main color.
  56982. */
  56983. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56984. /**
  56985. * Free any resources and references associated to a mesh.
  56986. * Internal use
  56987. * @param mesh The mesh to free.
  56988. */
  56989. abstract _disposeMesh(mesh: Mesh): void;
  56990. /**
  56991. * Serializes this layer (Glow or Highlight for example)
  56992. * @returns a serialized layer object
  56993. */
  56994. abstract serialize?(): any;
  56995. /**
  56996. * Initializes the effect layer with the required options.
  56997. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  56998. */
  56999. protected _init(options: Partial<IEffectLayerOptions>): void;
  57000. /**
  57001. * Generates the index buffer of the full screen quad blending to the main canvas.
  57002. */
  57003. private _generateIndexBuffer;
  57004. /**
  57005. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57006. */
  57007. private _generateVertexBuffer;
  57008. /**
  57009. * Sets the main texture desired size which is the closest power of two
  57010. * of the engine canvas size.
  57011. */
  57012. private _setMainTextureSize;
  57013. /**
  57014. * Creates the main texture for the effect layer.
  57015. */
  57016. protected _createMainTexture(): void;
  57017. /**
  57018. * Adds specific effects defines.
  57019. * @param defines The defines to add specifics to.
  57020. */
  57021. protected _addCustomEffectDefines(defines: string[]): void;
  57022. /**
  57023. * Checks for the readiness of the element composing the layer.
  57024. * @param subMesh the mesh to check for
  57025. * @param useInstances specify whether or not to use instances to render the mesh
  57026. * @param emissiveTexture the associated emissive texture used to generate the glow
  57027. * @return true if ready otherwise, false
  57028. */
  57029. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57030. /**
  57031. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57032. */
  57033. render(): void;
  57034. /**
  57035. * Determine if a given mesh will be used in the current effect.
  57036. * @param mesh mesh to test
  57037. * @returns true if the mesh will be used
  57038. */
  57039. hasMesh(mesh: AbstractMesh): boolean;
  57040. /**
  57041. * Returns true if the layer contains information to display, otherwise false.
  57042. * @returns true if the glow layer should be rendered
  57043. */
  57044. shouldRender(): boolean;
  57045. /**
  57046. * Returns true if the mesh should render, otherwise false.
  57047. * @param mesh The mesh to render
  57048. * @returns true if it should render otherwise false
  57049. */
  57050. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57051. /**
  57052. * Returns true if the mesh can be rendered, otherwise false.
  57053. * @param mesh The mesh to render
  57054. * @param material The material used on the mesh
  57055. * @returns true if it can be rendered otherwise false
  57056. */
  57057. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57058. /**
  57059. * Returns true if the mesh should render, otherwise false.
  57060. * @param mesh The mesh to render
  57061. * @returns true if it should render otherwise false
  57062. */
  57063. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57064. /**
  57065. * Renders the submesh passed in parameter to the generation map.
  57066. */
  57067. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57068. /**
  57069. * Defines whether the current material of the mesh should be use to render the effect.
  57070. * @param mesh defines the current mesh to render
  57071. */
  57072. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57073. /**
  57074. * Rebuild the required buffers.
  57075. * @hidden Internal use only.
  57076. */
  57077. _rebuild(): void;
  57078. /**
  57079. * Dispose only the render target textures and post process.
  57080. */
  57081. private _disposeTextureAndPostProcesses;
  57082. /**
  57083. * Dispose the highlight layer and free resources.
  57084. */
  57085. dispose(): void;
  57086. /**
  57087. * Gets the class name of the effect layer
  57088. * @returns the string with the class name of the effect layer
  57089. */
  57090. getClassName(): string;
  57091. /**
  57092. * Creates an effect layer from parsed effect layer data
  57093. * @param parsedEffectLayer defines effect layer data
  57094. * @param scene defines the current scene
  57095. * @param rootUrl defines the root URL containing the effect layer information
  57096. * @returns a parsed effect Layer
  57097. */
  57098. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57099. }
  57100. }
  57101. declare module BABYLON {
  57102. interface AbstractScene {
  57103. /**
  57104. * The list of effect layers (highlights/glow) added to the scene
  57105. * @see http://doc.babylonjs.com/how_to/highlight_layer
  57106. * @see http://doc.babylonjs.com/how_to/glow_layer
  57107. */
  57108. effectLayers: Array<EffectLayer>;
  57109. /**
  57110. * Removes the given effect layer from this scene.
  57111. * @param toRemove defines the effect layer to remove
  57112. * @returns the index of the removed effect layer
  57113. */
  57114. removeEffectLayer(toRemove: EffectLayer): number;
  57115. /**
  57116. * Adds the given effect layer to this scene
  57117. * @param newEffectLayer defines the effect layer to add
  57118. */
  57119. addEffectLayer(newEffectLayer: EffectLayer): void;
  57120. }
  57121. /**
  57122. * Defines the layer scene component responsible to manage any effect layers
  57123. * in a given scene.
  57124. */
  57125. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57126. /**
  57127. * The component name helpfull to identify the component in the list of scene components.
  57128. */
  57129. readonly name: string;
  57130. /**
  57131. * The scene the component belongs to.
  57132. */
  57133. scene: Scene;
  57134. private _engine;
  57135. private _renderEffects;
  57136. private _needStencil;
  57137. private _previousStencilState;
  57138. /**
  57139. * Creates a new instance of the component for the given scene
  57140. * @param scene Defines the scene to register the component in
  57141. */
  57142. constructor(scene: Scene);
  57143. /**
  57144. * Registers the component in a given scene
  57145. */
  57146. register(): void;
  57147. /**
  57148. * Rebuilds the elements related to this component in case of
  57149. * context lost for instance.
  57150. */
  57151. rebuild(): void;
  57152. /**
  57153. * Serializes the component data to the specified json object
  57154. * @param serializationObject The object to serialize to
  57155. */
  57156. serialize(serializationObject: any): void;
  57157. /**
  57158. * Adds all the elements from the container to the scene
  57159. * @param container the container holding the elements
  57160. */
  57161. addFromContainer(container: AbstractScene): void;
  57162. /**
  57163. * Removes all the elements in the container from the scene
  57164. * @param container contains the elements to remove
  57165. * @param dispose if the removed element should be disposed (default: false)
  57166. */
  57167. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57168. /**
  57169. * Disposes the component and the associated ressources.
  57170. */
  57171. dispose(): void;
  57172. private _isReadyForMesh;
  57173. private _renderMainTexture;
  57174. private _setStencil;
  57175. private _setStencilBack;
  57176. private _draw;
  57177. private _drawCamera;
  57178. private _drawRenderingGroup;
  57179. }
  57180. }
  57181. declare module BABYLON {
  57182. /** @hidden */
  57183. export var glowMapMergePixelShader: {
  57184. name: string;
  57185. shader: string;
  57186. };
  57187. }
  57188. declare module BABYLON {
  57189. /** @hidden */
  57190. export var glowMapMergeVertexShader: {
  57191. name: string;
  57192. shader: string;
  57193. };
  57194. }
  57195. declare module BABYLON {
  57196. interface AbstractScene {
  57197. /**
  57198. * Return a the first highlight layer of the scene with a given name.
  57199. * @param name The name of the highlight layer to look for.
  57200. * @return The highlight layer if found otherwise null.
  57201. */
  57202. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57203. }
  57204. /**
  57205. * Glow layer options. This helps customizing the behaviour
  57206. * of the glow layer.
  57207. */
  57208. export interface IGlowLayerOptions {
  57209. /**
  57210. * Multiplication factor apply to the canvas size to compute the render target size
  57211. * used to generated the glowing objects (the smaller the faster).
  57212. */
  57213. mainTextureRatio: number;
  57214. /**
  57215. * Enforces a fixed size texture to ensure resize independant blur.
  57216. */
  57217. mainTextureFixedSize?: number;
  57218. /**
  57219. * How big is the kernel of the blur texture.
  57220. */
  57221. blurKernelSize: number;
  57222. /**
  57223. * The camera attached to the layer.
  57224. */
  57225. camera: Nullable<Camera>;
  57226. /**
  57227. * Enable MSAA by chosing the number of samples.
  57228. */
  57229. mainTextureSamples?: number;
  57230. /**
  57231. * The rendering group to draw the layer in.
  57232. */
  57233. renderingGroupId: number;
  57234. }
  57235. /**
  57236. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57237. *
  57238. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57239. *
  57240. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57241. */
  57242. export class GlowLayer extends EffectLayer {
  57243. /**
  57244. * Effect Name of the layer.
  57245. */
  57246. static readonly EffectName: string;
  57247. /**
  57248. * The default blur kernel size used for the glow.
  57249. */
  57250. static DefaultBlurKernelSize: number;
  57251. /**
  57252. * The default texture size ratio used for the glow.
  57253. */
  57254. static DefaultTextureRatio: number;
  57255. /**
  57256. * Sets the kernel size of the blur.
  57257. */
  57258. set blurKernelSize(value: number);
  57259. /**
  57260. * Gets the kernel size of the blur.
  57261. */
  57262. get blurKernelSize(): number;
  57263. /**
  57264. * Sets the glow intensity.
  57265. */
  57266. set intensity(value: number);
  57267. /**
  57268. * Gets the glow intensity.
  57269. */
  57270. get intensity(): number;
  57271. private _options;
  57272. private _intensity;
  57273. private _horizontalBlurPostprocess1;
  57274. private _verticalBlurPostprocess1;
  57275. private _horizontalBlurPostprocess2;
  57276. private _verticalBlurPostprocess2;
  57277. private _blurTexture1;
  57278. private _blurTexture2;
  57279. private _postProcesses1;
  57280. private _postProcesses2;
  57281. private _includedOnlyMeshes;
  57282. private _excludedMeshes;
  57283. private _meshesUsingTheirOwnMaterials;
  57284. /**
  57285. * Callback used to let the user override the color selection on a per mesh basis
  57286. */
  57287. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57288. /**
  57289. * Callback used to let the user override the texture selection on a per mesh basis
  57290. */
  57291. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57292. /**
  57293. * Instantiates a new glow Layer and references it to the scene.
  57294. * @param name The name of the layer
  57295. * @param scene The scene to use the layer in
  57296. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57297. */
  57298. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57299. /**
  57300. * Get the effect name of the layer.
  57301. * @return The effect name
  57302. */
  57303. getEffectName(): string;
  57304. /**
  57305. * Create the merge effect. This is the shader use to blit the information back
  57306. * to the main canvas at the end of the scene rendering.
  57307. */
  57308. protected _createMergeEffect(): Effect;
  57309. /**
  57310. * Creates the render target textures and post processes used in the glow layer.
  57311. */
  57312. protected _createTextureAndPostProcesses(): void;
  57313. /**
  57314. * Checks for the readiness of the element composing the layer.
  57315. * @param subMesh the mesh to check for
  57316. * @param useInstances specify wether or not to use instances to render the mesh
  57317. * @param emissiveTexture the associated emissive texture used to generate the glow
  57318. * @return true if ready otherwise, false
  57319. */
  57320. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57321. /**
  57322. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57323. */
  57324. needStencil(): boolean;
  57325. /**
  57326. * Returns true if the mesh can be rendered, otherwise false.
  57327. * @param mesh The mesh to render
  57328. * @param material The material used on the mesh
  57329. * @returns true if it can be rendered otherwise false
  57330. */
  57331. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57332. /**
  57333. * Implementation specific of rendering the generating effect on the main canvas.
  57334. * @param effect The effect used to render through
  57335. */
  57336. protected _internalRender(effect: Effect): void;
  57337. /**
  57338. * Sets the required values for both the emissive texture and and the main color.
  57339. */
  57340. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57341. /**
  57342. * Returns true if the mesh should render, otherwise false.
  57343. * @param mesh The mesh to render
  57344. * @returns true if it should render otherwise false
  57345. */
  57346. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57347. /**
  57348. * Adds specific effects defines.
  57349. * @param defines The defines to add specifics to.
  57350. */
  57351. protected _addCustomEffectDefines(defines: string[]): void;
  57352. /**
  57353. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57354. * @param mesh The mesh to exclude from the glow layer
  57355. */
  57356. addExcludedMesh(mesh: Mesh): void;
  57357. /**
  57358. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57359. * @param mesh The mesh to remove
  57360. */
  57361. removeExcludedMesh(mesh: Mesh): void;
  57362. /**
  57363. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57364. * @param mesh The mesh to include in the glow layer
  57365. */
  57366. addIncludedOnlyMesh(mesh: Mesh): void;
  57367. /**
  57368. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57369. * @param mesh The mesh to remove
  57370. */
  57371. removeIncludedOnlyMesh(mesh: Mesh): void;
  57372. /**
  57373. * Determine if a given mesh will be used in the glow layer
  57374. * @param mesh The mesh to test
  57375. * @returns true if the mesh will be highlighted by the current glow layer
  57376. */
  57377. hasMesh(mesh: AbstractMesh): boolean;
  57378. /**
  57379. * Defines whether the current material of the mesh should be use to render the effect.
  57380. * @param mesh defines the current mesh to render
  57381. */
  57382. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57383. /**
  57384. * Add a mesh to be rendered through its own material and not with emissive only.
  57385. * @param mesh The mesh for which we need to use its material
  57386. */
  57387. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57388. /**
  57389. * Remove a mesh from being rendered through its own material and not with emissive only.
  57390. * @param mesh The mesh for which we need to not use its material
  57391. */
  57392. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57393. /**
  57394. * Free any resources and references associated to a mesh.
  57395. * Internal use
  57396. * @param mesh The mesh to free.
  57397. * @hidden
  57398. */
  57399. _disposeMesh(mesh: Mesh): void;
  57400. /**
  57401. * Gets the class name of the effect layer
  57402. * @returns the string with the class name of the effect layer
  57403. */
  57404. getClassName(): string;
  57405. /**
  57406. * Serializes this glow layer
  57407. * @returns a serialized glow layer object
  57408. */
  57409. serialize(): any;
  57410. /**
  57411. * Creates a Glow Layer from parsed glow layer data
  57412. * @param parsedGlowLayer defines glow layer data
  57413. * @param scene defines the current scene
  57414. * @param rootUrl defines the root URL containing the glow layer information
  57415. * @returns a parsed Glow Layer
  57416. */
  57417. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57418. }
  57419. }
  57420. declare module BABYLON {
  57421. /** @hidden */
  57422. export var glowBlurPostProcessPixelShader: {
  57423. name: string;
  57424. shader: string;
  57425. };
  57426. }
  57427. declare module BABYLON {
  57428. interface AbstractScene {
  57429. /**
  57430. * Return a the first highlight layer of the scene with a given name.
  57431. * @param name The name of the highlight layer to look for.
  57432. * @return The highlight layer if found otherwise null.
  57433. */
  57434. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57435. }
  57436. /**
  57437. * Highlight layer options. This helps customizing the behaviour
  57438. * of the highlight layer.
  57439. */
  57440. export interface IHighlightLayerOptions {
  57441. /**
  57442. * Multiplication factor apply to the canvas size to compute the render target size
  57443. * used to generated the glowing objects (the smaller the faster).
  57444. */
  57445. mainTextureRatio: number;
  57446. /**
  57447. * Enforces a fixed size texture to ensure resize independant blur.
  57448. */
  57449. mainTextureFixedSize?: number;
  57450. /**
  57451. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57452. * of the picture to blur (the smaller the faster).
  57453. */
  57454. blurTextureSizeRatio: number;
  57455. /**
  57456. * How big in texel of the blur texture is the vertical blur.
  57457. */
  57458. blurVerticalSize: number;
  57459. /**
  57460. * How big in texel of the blur texture is the horizontal blur.
  57461. */
  57462. blurHorizontalSize: number;
  57463. /**
  57464. * Alpha blending mode used to apply the blur. Default is combine.
  57465. */
  57466. alphaBlendingMode: number;
  57467. /**
  57468. * The camera attached to the layer.
  57469. */
  57470. camera: Nullable<Camera>;
  57471. /**
  57472. * Should we display highlight as a solid stroke?
  57473. */
  57474. isStroke?: boolean;
  57475. /**
  57476. * The rendering group to draw the layer in.
  57477. */
  57478. renderingGroupId: number;
  57479. }
  57480. /**
  57481. * The highlight layer Helps adding a glow effect around a mesh.
  57482. *
  57483. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57484. * glowy meshes to your scene.
  57485. *
  57486. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57487. */
  57488. export class HighlightLayer extends EffectLayer {
  57489. name: string;
  57490. /**
  57491. * Effect Name of the highlight layer.
  57492. */
  57493. static readonly EffectName: string;
  57494. /**
  57495. * The neutral color used during the preparation of the glow effect.
  57496. * This is black by default as the blend operation is a blend operation.
  57497. */
  57498. static NeutralColor: Color4;
  57499. /**
  57500. * Stencil value used for glowing meshes.
  57501. */
  57502. static GlowingMeshStencilReference: number;
  57503. /**
  57504. * Stencil value used for the other meshes in the scene.
  57505. */
  57506. static NormalMeshStencilReference: number;
  57507. /**
  57508. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57509. */
  57510. innerGlow: boolean;
  57511. /**
  57512. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57513. */
  57514. outerGlow: boolean;
  57515. /**
  57516. * Specifies the horizontal size of the blur.
  57517. */
  57518. set blurHorizontalSize(value: number);
  57519. /**
  57520. * Specifies the vertical size of the blur.
  57521. */
  57522. set blurVerticalSize(value: number);
  57523. /**
  57524. * Gets the horizontal size of the blur.
  57525. */
  57526. get blurHorizontalSize(): number;
  57527. /**
  57528. * Gets the vertical size of the blur.
  57529. */
  57530. get blurVerticalSize(): number;
  57531. /**
  57532. * An event triggered when the highlight layer is being blurred.
  57533. */
  57534. onBeforeBlurObservable: Observable<HighlightLayer>;
  57535. /**
  57536. * An event triggered when the highlight layer has been blurred.
  57537. */
  57538. onAfterBlurObservable: Observable<HighlightLayer>;
  57539. private _instanceGlowingMeshStencilReference;
  57540. private _options;
  57541. private _downSamplePostprocess;
  57542. private _horizontalBlurPostprocess;
  57543. private _verticalBlurPostprocess;
  57544. private _blurTexture;
  57545. private _meshes;
  57546. private _excludedMeshes;
  57547. /**
  57548. * Instantiates a new highlight Layer and references it to the scene..
  57549. * @param name The name of the layer
  57550. * @param scene The scene to use the layer in
  57551. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57552. */
  57553. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57554. /**
  57555. * Get the effect name of the layer.
  57556. * @return The effect name
  57557. */
  57558. getEffectName(): string;
  57559. /**
  57560. * Create the merge effect. This is the shader use to blit the information back
  57561. * to the main canvas at the end of the scene rendering.
  57562. */
  57563. protected _createMergeEffect(): Effect;
  57564. /**
  57565. * Creates the render target textures and post processes used in the highlight layer.
  57566. */
  57567. protected _createTextureAndPostProcesses(): void;
  57568. /**
  57569. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57570. */
  57571. needStencil(): boolean;
  57572. /**
  57573. * Checks for the readiness of the element composing the layer.
  57574. * @param subMesh the mesh to check for
  57575. * @param useInstances specify wether or not to use instances to render the mesh
  57576. * @param emissiveTexture the associated emissive texture used to generate the glow
  57577. * @return true if ready otherwise, false
  57578. */
  57579. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57580. /**
  57581. * Implementation specific of rendering the generating effect on the main canvas.
  57582. * @param effect The effect used to render through
  57583. */
  57584. protected _internalRender(effect: Effect): void;
  57585. /**
  57586. * Returns true if the layer contains information to display, otherwise false.
  57587. */
  57588. shouldRender(): boolean;
  57589. /**
  57590. * Returns true if the mesh should render, otherwise false.
  57591. * @param mesh The mesh to render
  57592. * @returns true if it should render otherwise false
  57593. */
  57594. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57595. /**
  57596. * Adds specific effects defines.
  57597. * @param defines The defines to add specifics to.
  57598. */
  57599. protected _addCustomEffectDefines(defines: string[]): void;
  57600. /**
  57601. * Sets the required values for both the emissive texture and and the main color.
  57602. */
  57603. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57604. /**
  57605. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57606. * @param mesh The mesh to exclude from the highlight layer
  57607. */
  57608. addExcludedMesh(mesh: Mesh): void;
  57609. /**
  57610. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57611. * @param mesh The mesh to highlight
  57612. */
  57613. removeExcludedMesh(mesh: Mesh): void;
  57614. /**
  57615. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57616. * @param mesh mesh to test
  57617. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57618. */
  57619. hasMesh(mesh: AbstractMesh): boolean;
  57620. /**
  57621. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57622. * @param mesh The mesh to highlight
  57623. * @param color The color of the highlight
  57624. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57625. */
  57626. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57627. /**
  57628. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57629. * @param mesh The mesh to highlight
  57630. */
  57631. removeMesh(mesh: Mesh): void;
  57632. /**
  57633. * Remove all the meshes currently referenced in the highlight layer
  57634. */
  57635. removeAllMeshes(): void;
  57636. /**
  57637. * Force the stencil to the normal expected value for none glowing parts
  57638. */
  57639. private _defaultStencilReference;
  57640. /**
  57641. * Free any resources and references associated to a mesh.
  57642. * Internal use
  57643. * @param mesh The mesh to free.
  57644. * @hidden
  57645. */
  57646. _disposeMesh(mesh: Mesh): void;
  57647. /**
  57648. * Dispose the highlight layer and free resources.
  57649. */
  57650. dispose(): void;
  57651. /**
  57652. * Gets the class name of the effect layer
  57653. * @returns the string with the class name of the effect layer
  57654. */
  57655. getClassName(): string;
  57656. /**
  57657. * Serializes this Highlight layer
  57658. * @returns a serialized Highlight layer object
  57659. */
  57660. serialize(): any;
  57661. /**
  57662. * Creates a Highlight layer from parsed Highlight layer data
  57663. * @param parsedHightlightLayer defines the Highlight layer data
  57664. * @param scene defines the current scene
  57665. * @param rootUrl defines the root URL containing the Highlight layer information
  57666. * @returns a parsed Highlight layer
  57667. */
  57668. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57669. }
  57670. }
  57671. declare module BABYLON {
  57672. interface AbstractScene {
  57673. /**
  57674. * The list of layers (background and foreground) of the scene
  57675. */
  57676. layers: Array<Layer>;
  57677. }
  57678. /**
  57679. * Defines the layer scene component responsible to manage any layers
  57680. * in a given scene.
  57681. */
  57682. export class LayerSceneComponent implements ISceneComponent {
  57683. /**
  57684. * The component name helpfull to identify the component in the list of scene components.
  57685. */
  57686. readonly name: string;
  57687. /**
  57688. * The scene the component belongs to.
  57689. */
  57690. scene: Scene;
  57691. private _engine;
  57692. /**
  57693. * Creates a new instance of the component for the given scene
  57694. * @param scene Defines the scene to register the component in
  57695. */
  57696. constructor(scene: Scene);
  57697. /**
  57698. * Registers the component in a given scene
  57699. */
  57700. register(): void;
  57701. /**
  57702. * Rebuilds the elements related to this component in case of
  57703. * context lost for instance.
  57704. */
  57705. rebuild(): void;
  57706. /**
  57707. * Disposes the component and the associated ressources.
  57708. */
  57709. dispose(): void;
  57710. private _draw;
  57711. private _drawCameraPredicate;
  57712. private _drawCameraBackground;
  57713. private _drawCameraForeground;
  57714. private _drawRenderTargetPredicate;
  57715. private _drawRenderTargetBackground;
  57716. private _drawRenderTargetForeground;
  57717. /**
  57718. * Adds all the elements from the container to the scene
  57719. * @param container the container holding the elements
  57720. */
  57721. addFromContainer(container: AbstractScene): void;
  57722. /**
  57723. * Removes all the elements in the container from the scene
  57724. * @param container contains the elements to remove
  57725. * @param dispose if the removed element should be disposed (default: false)
  57726. */
  57727. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57728. }
  57729. }
  57730. declare module BABYLON {
  57731. /** @hidden */
  57732. export var layerPixelShader: {
  57733. name: string;
  57734. shader: string;
  57735. };
  57736. }
  57737. declare module BABYLON {
  57738. /** @hidden */
  57739. export var layerVertexShader: {
  57740. name: string;
  57741. shader: string;
  57742. };
  57743. }
  57744. declare module BABYLON {
  57745. /**
  57746. * This represents a full screen 2d layer.
  57747. * This can be useful to display a picture in the background of your scene for instance.
  57748. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57749. */
  57750. export class Layer {
  57751. /**
  57752. * Define the name of the layer.
  57753. */
  57754. name: string;
  57755. /**
  57756. * Define the texture the layer should display.
  57757. */
  57758. texture: Nullable<Texture>;
  57759. /**
  57760. * Is the layer in background or foreground.
  57761. */
  57762. isBackground: boolean;
  57763. /**
  57764. * Define the color of the layer (instead of texture).
  57765. */
  57766. color: Color4;
  57767. /**
  57768. * Define the scale of the layer in order to zoom in out of the texture.
  57769. */
  57770. scale: Vector2;
  57771. /**
  57772. * Define an offset for the layer in order to shift the texture.
  57773. */
  57774. offset: Vector2;
  57775. /**
  57776. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  57777. */
  57778. alphaBlendingMode: number;
  57779. /**
  57780. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  57781. * Alpha test will not mix with the background color in case of transparency.
  57782. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  57783. */
  57784. alphaTest: boolean;
  57785. /**
  57786. * Define a mask to restrict the layer to only some of the scene cameras.
  57787. */
  57788. layerMask: number;
  57789. /**
  57790. * Define the list of render target the layer is visible into.
  57791. */
  57792. renderTargetTextures: RenderTargetTexture[];
  57793. /**
  57794. * Define if the layer is only used in renderTarget or if it also
  57795. * renders in the main frame buffer of the canvas.
  57796. */
  57797. renderOnlyInRenderTargetTextures: boolean;
  57798. private _scene;
  57799. private _vertexBuffers;
  57800. private _indexBuffer;
  57801. private _effect;
  57802. private _previousDefines;
  57803. /**
  57804. * An event triggered when the layer is disposed.
  57805. */
  57806. onDisposeObservable: Observable<Layer>;
  57807. private _onDisposeObserver;
  57808. /**
  57809. * Back compatibility with callback before the onDisposeObservable existed.
  57810. * The set callback will be triggered when the layer has been disposed.
  57811. */
  57812. set onDispose(callback: () => void);
  57813. /**
  57814. * An event triggered before rendering the scene
  57815. */
  57816. onBeforeRenderObservable: Observable<Layer>;
  57817. private _onBeforeRenderObserver;
  57818. /**
  57819. * Back compatibility with callback before the onBeforeRenderObservable existed.
  57820. * The set callback will be triggered just before rendering the layer.
  57821. */
  57822. set onBeforeRender(callback: () => void);
  57823. /**
  57824. * An event triggered after rendering the scene
  57825. */
  57826. onAfterRenderObservable: Observable<Layer>;
  57827. private _onAfterRenderObserver;
  57828. /**
  57829. * Back compatibility with callback before the onAfterRenderObservable existed.
  57830. * The set callback will be triggered just after rendering the layer.
  57831. */
  57832. set onAfterRender(callback: () => void);
  57833. /**
  57834. * Instantiates a new layer.
  57835. * This represents a full screen 2d layer.
  57836. * This can be useful to display a picture in the background of your scene for instance.
  57837. * @see https://www.babylonjs-playground.com/#08A2BS#1
  57838. * @param name Define the name of the layer in the scene
  57839. * @param imgUrl Define the url of the texture to display in the layer
  57840. * @param scene Define the scene the layer belongs to
  57841. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  57842. * @param color Defines a color for the layer
  57843. */
  57844. constructor(
  57845. /**
  57846. * Define the name of the layer.
  57847. */
  57848. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  57849. private _createIndexBuffer;
  57850. /** @hidden */
  57851. _rebuild(): void;
  57852. /**
  57853. * Renders the layer in the scene.
  57854. */
  57855. render(): void;
  57856. /**
  57857. * Disposes and releases the associated ressources.
  57858. */
  57859. dispose(): void;
  57860. }
  57861. }
  57862. declare module BABYLON {
  57863. /** @hidden */
  57864. export var lensFlarePixelShader: {
  57865. name: string;
  57866. shader: string;
  57867. };
  57868. }
  57869. declare module BABYLON {
  57870. /** @hidden */
  57871. export var lensFlareVertexShader: {
  57872. name: string;
  57873. shader: string;
  57874. };
  57875. }
  57876. declare module BABYLON {
  57877. /**
  57878. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57879. * It is usually composed of several `lensFlare`.
  57880. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57881. */
  57882. export class LensFlareSystem {
  57883. /**
  57884. * Define the name of the lens flare system
  57885. */
  57886. name: string;
  57887. /**
  57888. * List of lens flares used in this system.
  57889. */
  57890. lensFlares: LensFlare[];
  57891. /**
  57892. * Define a limit from the border the lens flare can be visible.
  57893. */
  57894. borderLimit: number;
  57895. /**
  57896. * Define a viewport border we do not want to see the lens flare in.
  57897. */
  57898. viewportBorder: number;
  57899. /**
  57900. * Define a predicate which could limit the list of meshes able to occlude the effect.
  57901. */
  57902. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  57903. /**
  57904. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  57905. */
  57906. layerMask: number;
  57907. /**
  57908. * Define the id of the lens flare system in the scene.
  57909. * (equal to name by default)
  57910. */
  57911. id: string;
  57912. private _scene;
  57913. private _emitter;
  57914. private _vertexBuffers;
  57915. private _indexBuffer;
  57916. private _effect;
  57917. private _positionX;
  57918. private _positionY;
  57919. private _isEnabled;
  57920. /** @hidden */
  57921. static _SceneComponentInitialization: (scene: Scene) => void;
  57922. /**
  57923. * Instantiates a lens flare system.
  57924. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  57925. * It is usually composed of several `lensFlare`.
  57926. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57927. * @param name Define the name of the lens flare system in the scene
  57928. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  57929. * @param scene Define the scene the lens flare system belongs to
  57930. */
  57931. constructor(
  57932. /**
  57933. * Define the name of the lens flare system
  57934. */
  57935. name: string, emitter: any, scene: Scene);
  57936. /**
  57937. * Define if the lens flare system is enabled.
  57938. */
  57939. get isEnabled(): boolean;
  57940. set isEnabled(value: boolean);
  57941. /**
  57942. * Get the scene the effects belongs to.
  57943. * @returns the scene holding the lens flare system
  57944. */
  57945. getScene(): Scene;
  57946. /**
  57947. * Get 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. * @returns the emitter of the lens flare system
  57950. */
  57951. getEmitter(): any;
  57952. /**
  57953. * Set the emitter of the lens flare system.
  57954. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  57955. * @param newEmitter Define the new emitter of the system
  57956. */
  57957. setEmitter(newEmitter: any): void;
  57958. /**
  57959. * Get the lens flare system emitter position.
  57960. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  57961. * @returns the position
  57962. */
  57963. getEmitterPosition(): Vector3;
  57964. /**
  57965. * @hidden
  57966. */
  57967. computeEffectivePosition(globalViewport: Viewport): boolean;
  57968. /** @hidden */
  57969. _isVisible(): boolean;
  57970. /**
  57971. * @hidden
  57972. */
  57973. render(): boolean;
  57974. /**
  57975. * Dispose and release the lens flare with its associated resources.
  57976. */
  57977. dispose(): void;
  57978. /**
  57979. * Parse a lens flare system from a JSON repressentation
  57980. * @param parsedLensFlareSystem Define the JSON to parse
  57981. * @param scene Define the scene the parsed system should be instantiated in
  57982. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  57983. * @returns the parsed system
  57984. */
  57985. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  57986. /**
  57987. * Serialize the current Lens Flare System into a JSON representation.
  57988. * @returns the serialized JSON
  57989. */
  57990. serialize(): any;
  57991. }
  57992. }
  57993. declare module BABYLON {
  57994. /**
  57995. * This represents one of the lens effect in a `lensFlareSystem`.
  57996. * It controls one of the indiviual texture used in the effect.
  57997. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  57998. */
  57999. export class LensFlare {
  58000. /**
  58001. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58002. */
  58003. size: number;
  58004. /**
  58005. * 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.
  58006. */
  58007. position: number;
  58008. /**
  58009. * Define the lens color.
  58010. */
  58011. color: Color3;
  58012. /**
  58013. * Define the lens texture.
  58014. */
  58015. texture: Nullable<Texture>;
  58016. /**
  58017. * Define the alpha mode to render this particular lens.
  58018. */
  58019. alphaMode: number;
  58020. private _system;
  58021. /**
  58022. * Creates a new Lens Flare.
  58023. * This represents one of the lens effect in a `lensFlareSystem`.
  58024. * It controls one of the indiviual texture used in the effect.
  58025. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58026. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58027. * @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.
  58028. * @param color Define the lens color
  58029. * @param imgUrl Define the lens texture url
  58030. * @param system Define the `lensFlareSystem` this flare is part of
  58031. * @returns The newly created Lens Flare
  58032. */
  58033. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58034. /**
  58035. * Instantiates a new Lens Flare.
  58036. * This represents one of the lens effect in a `lensFlareSystem`.
  58037. * It controls one of the indiviual texture used in the effect.
  58038. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58039. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58040. * @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.
  58041. * @param color Define the lens color
  58042. * @param imgUrl Define the lens texture url
  58043. * @param system Define the `lensFlareSystem` this flare is part of
  58044. */
  58045. constructor(
  58046. /**
  58047. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58048. */
  58049. size: number,
  58050. /**
  58051. * 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.
  58052. */
  58053. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58054. /**
  58055. * Dispose and release the lens flare with its associated resources.
  58056. */
  58057. dispose(): void;
  58058. }
  58059. }
  58060. declare module BABYLON {
  58061. interface AbstractScene {
  58062. /**
  58063. * The list of lens flare system added to the scene
  58064. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58065. */
  58066. lensFlareSystems: Array<LensFlareSystem>;
  58067. /**
  58068. * Removes the given lens flare system from this scene.
  58069. * @param toRemove The lens flare system to remove
  58070. * @returns The index of the removed lens flare system
  58071. */
  58072. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58073. /**
  58074. * Adds the given lens flare system to this scene
  58075. * @param newLensFlareSystem The lens flare system to add
  58076. */
  58077. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58078. /**
  58079. * Gets a lens flare system using its name
  58080. * @param name defines the name to look for
  58081. * @returns the lens flare system or null if not found
  58082. */
  58083. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58084. /**
  58085. * Gets a lens flare system using its id
  58086. * @param id defines the id to look for
  58087. * @returns the lens flare system or null if not found
  58088. */
  58089. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58090. }
  58091. /**
  58092. * Defines the lens flare scene component responsible to manage any lens flares
  58093. * in a given scene.
  58094. */
  58095. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58096. /**
  58097. * The component name helpfull to identify the component in the list of scene components.
  58098. */
  58099. readonly name: string;
  58100. /**
  58101. * The scene the component belongs to.
  58102. */
  58103. scene: Scene;
  58104. /**
  58105. * Creates a new instance of the component for the given scene
  58106. * @param scene Defines the scene to register the component in
  58107. */
  58108. constructor(scene: Scene);
  58109. /**
  58110. * Registers the component in a given scene
  58111. */
  58112. register(): void;
  58113. /**
  58114. * Rebuilds the elements related to this component in case of
  58115. * context lost for instance.
  58116. */
  58117. rebuild(): void;
  58118. /**
  58119. * Adds all the elements from the container to the scene
  58120. * @param container the container holding the elements
  58121. */
  58122. addFromContainer(container: AbstractScene): void;
  58123. /**
  58124. * Removes all the elements in the container from the scene
  58125. * @param container contains the elements to remove
  58126. * @param dispose if the removed element should be disposed (default: false)
  58127. */
  58128. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58129. /**
  58130. * Serializes the component data to the specified json object
  58131. * @param serializationObject The object to serialize to
  58132. */
  58133. serialize(serializationObject: any): void;
  58134. /**
  58135. * Disposes the component and the associated ressources.
  58136. */
  58137. dispose(): void;
  58138. private _draw;
  58139. }
  58140. }
  58141. declare module BABYLON {
  58142. /** @hidden */
  58143. export var depthPixelShader: {
  58144. name: string;
  58145. shader: string;
  58146. };
  58147. }
  58148. declare module BABYLON {
  58149. /** @hidden */
  58150. export var depthVertexShader: {
  58151. name: string;
  58152. shader: string;
  58153. };
  58154. }
  58155. declare module BABYLON {
  58156. /**
  58157. * This represents a depth renderer in Babylon.
  58158. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58159. */
  58160. export class DepthRenderer {
  58161. private _scene;
  58162. private _depthMap;
  58163. private _effect;
  58164. private readonly _storeNonLinearDepth;
  58165. private readonly _clearColor;
  58166. /** Get if the depth renderer is using packed depth or not */
  58167. readonly isPacked: boolean;
  58168. private _cachedDefines;
  58169. private _camera;
  58170. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58171. enabled: boolean;
  58172. /**
  58173. * Specifiess that the depth renderer will only be used within
  58174. * the camera it is created for.
  58175. * This can help forcing its rendering during the camera processing.
  58176. */
  58177. useOnlyInActiveCamera: boolean;
  58178. /** @hidden */
  58179. static _SceneComponentInitialization: (scene: Scene) => void;
  58180. /**
  58181. * Instantiates a depth renderer
  58182. * @param scene The scene the renderer belongs to
  58183. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58184. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58185. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58186. */
  58187. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58188. /**
  58189. * Creates the depth rendering effect and checks if the effect is ready.
  58190. * @param subMesh The submesh to be used to render the depth map of
  58191. * @param useInstances If multiple world instances should be used
  58192. * @returns if the depth renderer is ready to render the depth map
  58193. */
  58194. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58195. /**
  58196. * Gets the texture which the depth map will be written to.
  58197. * @returns The depth map texture
  58198. */
  58199. getDepthMap(): RenderTargetTexture;
  58200. /**
  58201. * Disposes of the depth renderer.
  58202. */
  58203. dispose(): void;
  58204. }
  58205. }
  58206. declare module BABYLON {
  58207. /** @hidden */
  58208. export var minmaxReduxPixelShader: {
  58209. name: string;
  58210. shader: string;
  58211. };
  58212. }
  58213. declare module BABYLON {
  58214. /**
  58215. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58216. * and maximum values from all values of the texture.
  58217. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58218. * The source values are read from the red channel of the texture.
  58219. */
  58220. export class MinMaxReducer {
  58221. /**
  58222. * Observable triggered when the computation has been performed
  58223. */
  58224. onAfterReductionPerformed: Observable<{
  58225. min: number;
  58226. max: number;
  58227. }>;
  58228. protected _camera: Camera;
  58229. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58230. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58231. protected _postProcessManager: PostProcessManager;
  58232. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58233. protected _forceFullscreenViewport: boolean;
  58234. /**
  58235. * Creates a min/max reducer
  58236. * @param camera The camera to use for the post processes
  58237. */
  58238. constructor(camera: Camera);
  58239. /**
  58240. * Gets the texture used to read the values from.
  58241. */
  58242. get sourceTexture(): Nullable<RenderTargetTexture>;
  58243. /**
  58244. * Sets the source texture to read the values from.
  58245. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58246. * because in such textures '1' value must not be taken into account to compute the maximum
  58247. * as this value is used to clear the texture.
  58248. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58249. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58250. * @param depthRedux Indicates if the texture is a depth texture or not
  58251. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58252. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58253. */
  58254. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58255. /**
  58256. * Defines the refresh rate of the computation.
  58257. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58258. */
  58259. get refreshRate(): number;
  58260. set refreshRate(value: number);
  58261. protected _activated: boolean;
  58262. /**
  58263. * Gets the activation status of the reducer
  58264. */
  58265. get activated(): boolean;
  58266. /**
  58267. * Activates the reduction computation.
  58268. * When activated, the observers registered in onAfterReductionPerformed are
  58269. * called after the compuation is performed
  58270. */
  58271. activate(): void;
  58272. /**
  58273. * Deactivates the reduction computation.
  58274. */
  58275. deactivate(): void;
  58276. /**
  58277. * Disposes the min/max reducer
  58278. * @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.
  58279. */
  58280. dispose(disposeAll?: boolean): void;
  58281. }
  58282. }
  58283. declare module BABYLON {
  58284. /**
  58285. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58286. */
  58287. export class DepthReducer extends MinMaxReducer {
  58288. private _depthRenderer;
  58289. private _depthRendererId;
  58290. /**
  58291. * Gets the depth renderer used for the computation.
  58292. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58293. */
  58294. get depthRenderer(): Nullable<DepthRenderer>;
  58295. /**
  58296. * Creates a depth reducer
  58297. * @param camera The camera used to render the depth texture
  58298. */
  58299. constructor(camera: Camera);
  58300. /**
  58301. * Sets the depth renderer to use to generate the depth map
  58302. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58303. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58304. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58305. */
  58306. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58307. /** @hidden */
  58308. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58309. /**
  58310. * Activates the reduction computation.
  58311. * When activated, the observers registered in onAfterReductionPerformed are
  58312. * called after the compuation is performed
  58313. */
  58314. activate(): void;
  58315. /**
  58316. * Deactivates the reduction computation.
  58317. */
  58318. deactivate(): void;
  58319. /**
  58320. * Disposes the depth reducer
  58321. * @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.
  58322. */
  58323. dispose(disposeAll?: boolean): void;
  58324. }
  58325. }
  58326. declare module BABYLON {
  58327. /**
  58328. * A CSM implementation allowing casting shadows on large scenes.
  58329. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58330. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58331. */
  58332. export class CascadedShadowGenerator extends ShadowGenerator {
  58333. private static readonly frustumCornersNDCSpace;
  58334. /**
  58335. * Name of the CSM class
  58336. */
  58337. static CLASSNAME: string;
  58338. /**
  58339. * Defines the default number of cascades used by the CSM.
  58340. */
  58341. static readonly DEFAULT_CASCADES_COUNT: number;
  58342. /**
  58343. * Defines the minimum number of cascades used by the CSM.
  58344. */
  58345. static readonly MIN_CASCADES_COUNT: number;
  58346. /**
  58347. * Defines the maximum number of cascades used by the CSM.
  58348. */
  58349. static readonly MAX_CASCADES_COUNT: number;
  58350. protected _validateFilter(filter: number): number;
  58351. /**
  58352. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58353. */
  58354. penumbraDarkness: number;
  58355. private _numCascades;
  58356. /**
  58357. * Gets or set the number of cascades used by the CSM.
  58358. */
  58359. get numCascades(): number;
  58360. set numCascades(value: number);
  58361. /**
  58362. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58363. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58364. */
  58365. stabilizeCascades: boolean;
  58366. private _freezeShadowCastersBoundingInfo;
  58367. private _freezeShadowCastersBoundingInfoObservable;
  58368. /**
  58369. * Enables or disables the shadow casters bounding info computation.
  58370. * If your shadow casters don't move, you can disable this feature.
  58371. * If it is enabled, the bounding box computation is done every frame.
  58372. */
  58373. get freezeShadowCastersBoundingInfo(): boolean;
  58374. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58375. private _scbiMin;
  58376. private _scbiMax;
  58377. protected _computeShadowCastersBoundingInfo(): void;
  58378. protected _shadowCastersBoundingInfo: BoundingInfo;
  58379. /**
  58380. * Gets or sets the shadow casters bounding info.
  58381. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58382. * so that the system won't overwrite the bounds you provide
  58383. */
  58384. get shadowCastersBoundingInfo(): BoundingInfo;
  58385. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58386. protected _breaksAreDirty: boolean;
  58387. protected _minDistance: number;
  58388. protected _maxDistance: number;
  58389. /**
  58390. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58391. *
  58392. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58393. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58394. * @param min minimal distance for the breaks (default to 0.)
  58395. * @param max maximal distance for the breaks (default to 1.)
  58396. */
  58397. setMinMaxDistance(min: number, max: number): void;
  58398. /** Gets the minimal distance used in the cascade break computation */
  58399. get minDistance(): number;
  58400. /** Gets the maximal distance used in the cascade break computation */
  58401. get maxDistance(): number;
  58402. /**
  58403. * Gets the class name of that object
  58404. * @returns "CascadedShadowGenerator"
  58405. */
  58406. getClassName(): string;
  58407. private _cascadeMinExtents;
  58408. private _cascadeMaxExtents;
  58409. /**
  58410. * Gets a cascade minimum extents
  58411. * @param cascadeIndex index of the cascade
  58412. * @returns the minimum cascade extents
  58413. */
  58414. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58415. /**
  58416. * Gets a cascade maximum extents
  58417. * @param cascadeIndex index of the cascade
  58418. * @returns the maximum cascade extents
  58419. */
  58420. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58421. private _cascades;
  58422. private _currentLayer;
  58423. private _viewSpaceFrustumsZ;
  58424. private _viewMatrices;
  58425. private _projectionMatrices;
  58426. private _transformMatrices;
  58427. private _transformMatricesAsArray;
  58428. private _frustumLengths;
  58429. private _lightSizeUVCorrection;
  58430. private _depthCorrection;
  58431. private _frustumCornersWorldSpace;
  58432. private _frustumCenter;
  58433. private _shadowCameraPos;
  58434. private _shadowMaxZ;
  58435. /**
  58436. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58437. * It defaults to camera.maxZ
  58438. */
  58439. get shadowMaxZ(): number;
  58440. /**
  58441. * Sets the shadow max z distance.
  58442. */
  58443. set shadowMaxZ(value: number);
  58444. protected _debug: boolean;
  58445. /**
  58446. * Gets or sets the debug flag.
  58447. * When enabled, the cascades are materialized by different colors on the screen.
  58448. */
  58449. get debug(): boolean;
  58450. set debug(dbg: boolean);
  58451. private _depthClamp;
  58452. /**
  58453. * Gets or sets the depth clamping value.
  58454. *
  58455. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58456. * to account for the shadow casters far away.
  58457. *
  58458. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58459. */
  58460. get depthClamp(): boolean;
  58461. set depthClamp(value: boolean);
  58462. private _cascadeBlendPercentage;
  58463. /**
  58464. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58465. * It defaults to 0.1 (10% blending).
  58466. */
  58467. get cascadeBlendPercentage(): number;
  58468. set cascadeBlendPercentage(value: number);
  58469. private _lambda;
  58470. /**
  58471. * Gets or set the lambda parameter.
  58472. * This parameter is used to split the camera frustum and create the cascades.
  58473. * 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.
  58474. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58475. */
  58476. get lambda(): number;
  58477. set lambda(value: number);
  58478. /**
  58479. * Gets the view matrix corresponding to a given cascade
  58480. * @param cascadeNum cascade to retrieve the view matrix from
  58481. * @returns the cascade view matrix
  58482. */
  58483. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58484. /**
  58485. * Gets the projection matrix corresponding to a given cascade
  58486. * @param cascadeNum cascade to retrieve the projection matrix from
  58487. * @returns the cascade projection matrix
  58488. */
  58489. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58490. /**
  58491. * Gets the transformation matrix corresponding to a given cascade
  58492. * @param cascadeNum cascade to retrieve the transformation matrix from
  58493. * @returns the cascade transformation matrix
  58494. */
  58495. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58496. private _depthRenderer;
  58497. /**
  58498. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58499. *
  58500. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58501. *
  58502. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58503. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58504. * @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
  58505. */
  58506. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58507. private _depthReducer;
  58508. private _autoCalcDepthBounds;
  58509. /**
  58510. * Gets or sets the autoCalcDepthBounds property.
  58511. *
  58512. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58513. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58514. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58515. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58516. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58517. */
  58518. get autoCalcDepthBounds(): boolean;
  58519. set autoCalcDepthBounds(value: boolean);
  58520. /**
  58521. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58522. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58523. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58524. * for setting the refresh rate on the renderer yourself!
  58525. */
  58526. get autoCalcDepthBoundsRefreshRate(): number;
  58527. set autoCalcDepthBoundsRefreshRate(value: number);
  58528. /**
  58529. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58530. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58531. * you change the camera near/far planes!
  58532. */
  58533. splitFrustum(): void;
  58534. private _splitFrustum;
  58535. private _computeMatrices;
  58536. private _computeFrustumInWorldSpace;
  58537. private _computeCascadeFrustum;
  58538. /**
  58539. * Support test.
  58540. */
  58541. static get IsSupported(): boolean;
  58542. /** @hidden */
  58543. static _SceneComponentInitialization: (scene: Scene) => void;
  58544. /**
  58545. * Creates a Cascaded Shadow Generator object.
  58546. * A ShadowGenerator is the required tool to use the shadows.
  58547. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58548. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58549. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58550. * @param light The directional light object generating the shadows.
  58551. * @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.
  58552. */
  58553. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58554. protected _initializeGenerator(): void;
  58555. protected _createTargetRenderTexture(): void;
  58556. protected _initializeShadowMap(): void;
  58557. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58558. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58559. /**
  58560. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58561. * @param defines Defines of the material we want to update
  58562. * @param lightIndex Index of the light in the enabled light list of the material
  58563. */
  58564. prepareDefines(defines: any, lightIndex: number): void;
  58565. /**
  58566. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58567. * defined in the generator but impacting the effect).
  58568. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58569. * @param effect The effect we are binfing the information for
  58570. */
  58571. bindShadowLight(lightIndex: string, effect: Effect): void;
  58572. /**
  58573. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58574. * (eq to view projection * shadow projection matrices)
  58575. * @returns The transform matrix used to create the shadow map
  58576. */
  58577. getTransformMatrix(): Matrix;
  58578. /**
  58579. * Disposes the ShadowGenerator.
  58580. * Returns nothing.
  58581. */
  58582. dispose(): void;
  58583. /**
  58584. * Serializes the shadow generator setup to a json object.
  58585. * @returns The serialized JSON object
  58586. */
  58587. serialize(): any;
  58588. /**
  58589. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58590. * @param parsedShadowGenerator The JSON object to parse
  58591. * @param scene The scene to create the shadow map for
  58592. * @returns The parsed shadow generator
  58593. */
  58594. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58595. }
  58596. }
  58597. declare module BABYLON {
  58598. /**
  58599. * Defines the shadow generator component responsible to manage any shadow generators
  58600. * in a given scene.
  58601. */
  58602. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58603. /**
  58604. * The component name helpfull to identify the component in the list of scene components.
  58605. */
  58606. readonly name: string;
  58607. /**
  58608. * The scene the component belongs to.
  58609. */
  58610. scene: Scene;
  58611. /**
  58612. * Creates a new instance of the component for the given scene
  58613. * @param scene Defines the scene to register the component in
  58614. */
  58615. constructor(scene: Scene);
  58616. /**
  58617. * Registers the component in a given scene
  58618. */
  58619. register(): void;
  58620. /**
  58621. * Rebuilds the elements related to this component in case of
  58622. * context lost for instance.
  58623. */
  58624. rebuild(): void;
  58625. /**
  58626. * Serializes the component data to the specified json object
  58627. * @param serializationObject The object to serialize to
  58628. */
  58629. serialize(serializationObject: any): void;
  58630. /**
  58631. * Adds all the elements from the container to the scene
  58632. * @param container the container holding the elements
  58633. */
  58634. addFromContainer(container: AbstractScene): void;
  58635. /**
  58636. * Removes all the elements in the container from the scene
  58637. * @param container contains the elements to remove
  58638. * @param dispose if the removed element should be disposed (default: false)
  58639. */
  58640. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58641. /**
  58642. * Rebuilds the elements related to this component in case of
  58643. * context lost for instance.
  58644. */
  58645. dispose(): void;
  58646. private _gatherRenderTargets;
  58647. }
  58648. }
  58649. declare module BABYLON {
  58650. /**
  58651. * A point light is a light defined by an unique point in world space.
  58652. * The light is emitted in every direction from this point.
  58653. * A good example of a point light is a standard light bulb.
  58654. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58655. */
  58656. export class PointLight extends ShadowLight {
  58657. private _shadowAngle;
  58658. /**
  58659. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58660. * This specifies what angle the shadow will use to be created.
  58661. *
  58662. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58663. */
  58664. get shadowAngle(): number;
  58665. /**
  58666. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58667. * This specifies what angle the shadow will use to be created.
  58668. *
  58669. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58670. */
  58671. set shadowAngle(value: number);
  58672. /**
  58673. * Gets the direction if it has been set.
  58674. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58675. */
  58676. get direction(): Vector3;
  58677. /**
  58678. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58679. */
  58680. set direction(value: Vector3);
  58681. /**
  58682. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58683. * A PointLight emits the light in every direction.
  58684. * It can cast shadows.
  58685. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58686. * ```javascript
  58687. * var pointLight = new PointLight("pl", camera.position, scene);
  58688. * ```
  58689. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58690. * @param name The light friendly name
  58691. * @param position The position of the point light in the scene
  58692. * @param scene The scene the lights belongs to
  58693. */
  58694. constructor(name: string, position: Vector3, scene: Scene);
  58695. /**
  58696. * Returns the string "PointLight"
  58697. * @returns the class name
  58698. */
  58699. getClassName(): string;
  58700. /**
  58701. * Returns the integer 0.
  58702. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58703. */
  58704. getTypeID(): number;
  58705. /**
  58706. * Specifies wether or not the shadowmap should be a cube texture.
  58707. * @returns true if the shadowmap needs to be a cube texture.
  58708. */
  58709. needCube(): boolean;
  58710. /**
  58711. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58712. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58713. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58714. */
  58715. getShadowDirection(faceIndex?: number): Vector3;
  58716. /**
  58717. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58718. * - fov = PI / 2
  58719. * - aspect ratio : 1.0
  58720. * - z-near and far equal to the active camera minZ and maxZ.
  58721. * Returns the PointLight.
  58722. */
  58723. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58724. protected _buildUniformLayout(): void;
  58725. /**
  58726. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58727. * @param effect The effect to update
  58728. * @param lightIndex The index of the light in the effect to update
  58729. * @returns The point light
  58730. */
  58731. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58732. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58733. /**
  58734. * Prepares the list of defines specific to the light type.
  58735. * @param defines the list of defines
  58736. * @param lightIndex defines the index of the light for the effect
  58737. */
  58738. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58739. }
  58740. }
  58741. declare module BABYLON {
  58742. /**
  58743. * Header information of HDR texture files.
  58744. */
  58745. export interface HDRInfo {
  58746. /**
  58747. * The height of the texture in pixels.
  58748. */
  58749. height: number;
  58750. /**
  58751. * The width of the texture in pixels.
  58752. */
  58753. width: number;
  58754. /**
  58755. * The index of the beginning of the data in the binary file.
  58756. */
  58757. dataPosition: number;
  58758. }
  58759. /**
  58760. * This groups tools to convert HDR texture to native colors array.
  58761. */
  58762. export class HDRTools {
  58763. private static Ldexp;
  58764. private static Rgbe2float;
  58765. private static readStringLine;
  58766. /**
  58767. * Reads header information from an RGBE texture stored in a native array.
  58768. * More information on this format are available here:
  58769. * https://en.wikipedia.org/wiki/RGBE_image_format
  58770. *
  58771. * @param uint8array The binary file stored in native array.
  58772. * @return The header information.
  58773. */
  58774. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  58775. /**
  58776. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  58777. * This RGBE texture needs to store the information as a panorama.
  58778. *
  58779. * More information on this format are available here:
  58780. * https://en.wikipedia.org/wiki/RGBE_image_format
  58781. *
  58782. * @param buffer The binary file stored in an array buffer.
  58783. * @param size The expected size of the extracted cubemap.
  58784. * @return The Cube Map information.
  58785. */
  58786. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  58787. /**
  58788. * Returns the pixels data extracted from an RGBE texture.
  58789. * This pixels will be stored left to right up to down in the R G B order in one array.
  58790. *
  58791. * More information on this format are available here:
  58792. * https://en.wikipedia.org/wiki/RGBE_image_format
  58793. *
  58794. * @param uint8array The binary file stored in an array buffer.
  58795. * @param hdrInfo The header information of the file.
  58796. * @return The pixels data in RGB right to left up to down order.
  58797. */
  58798. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  58799. private static RGBE_ReadPixels_RLE;
  58800. }
  58801. }
  58802. declare module BABYLON {
  58803. /**
  58804. * Effect Render Options
  58805. */
  58806. export interface IEffectRendererOptions {
  58807. /**
  58808. * Defines the vertices positions.
  58809. */
  58810. positions?: number[];
  58811. /**
  58812. * Defines the indices.
  58813. */
  58814. indices?: number[];
  58815. }
  58816. /**
  58817. * Helper class to render one or more effects.
  58818. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  58819. */
  58820. export class EffectRenderer {
  58821. private engine;
  58822. private static _DefaultOptions;
  58823. private _vertexBuffers;
  58824. private _indexBuffer;
  58825. private _fullscreenViewport;
  58826. /**
  58827. * Creates an effect renderer
  58828. * @param engine the engine to use for rendering
  58829. * @param options defines the options of the effect renderer
  58830. */
  58831. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58832. /**
  58833. * Sets the current viewport in normalized coordinates 0-1
  58834. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58835. */
  58836. setViewport(viewport?: Viewport): void;
  58837. /**
  58838. * Binds the embedded attributes buffer to the effect.
  58839. * @param effect Defines the effect to bind the attributes for
  58840. */
  58841. bindBuffers(effect: Effect): void;
  58842. /**
  58843. * Sets the current effect wrapper to use during draw.
  58844. * The effect needs to be ready before calling this api.
  58845. * This also sets the default full screen position attribute.
  58846. * @param effectWrapper Defines the effect to draw with
  58847. */
  58848. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58849. /**
  58850. * Restores engine states
  58851. */
  58852. restoreStates(): void;
  58853. /**
  58854. * Draws a full screen quad.
  58855. */
  58856. draw(): void;
  58857. private isRenderTargetTexture;
  58858. /**
  58859. * renders one or more effects to a specified texture
  58860. * @param effectWrapper the effect to renderer
  58861. * @param outputTexture texture to draw to, if null it will render to the screen.
  58862. */
  58863. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  58864. /**
  58865. * Disposes of the effect renderer
  58866. */
  58867. dispose(): void;
  58868. }
  58869. /**
  58870. * Options to create an EffectWrapper
  58871. */
  58872. interface EffectWrapperCreationOptions {
  58873. /**
  58874. * Engine to use to create the effect
  58875. */
  58876. engine: ThinEngine;
  58877. /**
  58878. * Fragment shader for the effect
  58879. */
  58880. fragmentShader: string;
  58881. /**
  58882. * Use the shader store instead of direct source code
  58883. */
  58884. useShaderStore?: boolean;
  58885. /**
  58886. * Vertex shader for the effect
  58887. */
  58888. vertexShader?: string;
  58889. /**
  58890. * Attributes to use in the shader
  58891. */
  58892. attributeNames?: Array<string>;
  58893. /**
  58894. * Uniforms to use in the shader
  58895. */
  58896. uniformNames?: Array<string>;
  58897. /**
  58898. * Texture sampler names to use in the shader
  58899. */
  58900. samplerNames?: Array<string>;
  58901. /**
  58902. * Defines to use in the shader
  58903. */
  58904. defines?: Array<string>;
  58905. /**
  58906. * Callback when effect is compiled
  58907. */
  58908. onCompiled?: Nullable<(effect: Effect) => void>;
  58909. /**
  58910. * The friendly name of the effect displayed in Spector.
  58911. */
  58912. name?: string;
  58913. }
  58914. /**
  58915. * Wraps an effect to be used for rendering
  58916. */
  58917. export class EffectWrapper {
  58918. /**
  58919. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58920. */
  58921. onApplyObservable: Observable<{}>;
  58922. /**
  58923. * The underlying effect
  58924. */
  58925. effect: Effect;
  58926. /**
  58927. * Creates an effect to be renderer
  58928. * @param creationOptions options to create the effect
  58929. */
  58930. constructor(creationOptions: EffectWrapperCreationOptions);
  58931. /**
  58932. * Disposes of the effect wrapper
  58933. */
  58934. dispose(): void;
  58935. }
  58936. }
  58937. declare module BABYLON {
  58938. /** @hidden */
  58939. export var hdrFilteringVertexShader: {
  58940. name: string;
  58941. shader: string;
  58942. };
  58943. }
  58944. declare module BABYLON {
  58945. /** @hidden */
  58946. export var hdrFilteringPixelShader: {
  58947. name: string;
  58948. shader: string;
  58949. };
  58950. }
  58951. declare module BABYLON {
  58952. /**
  58953. * Options for texture filtering
  58954. */
  58955. interface IHDRFilteringOptions {
  58956. /**
  58957. * Scales pixel intensity for the input HDR map.
  58958. */
  58959. hdrScale?: number;
  58960. /**
  58961. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  58962. */
  58963. quality?: number;
  58964. }
  58965. /**
  58966. * Filters HDR maps to get correct renderings of PBR reflections
  58967. */
  58968. export class HDRFiltering {
  58969. private _engine;
  58970. private _effectRenderer;
  58971. private _effectWrapper;
  58972. private _lodGenerationOffset;
  58973. private _lodGenerationScale;
  58974. /**
  58975. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  58976. * you care about baking speed.
  58977. */
  58978. quality: number;
  58979. /**
  58980. * Scales pixel intensity for the input HDR map.
  58981. */
  58982. hdrScale: number;
  58983. /**
  58984. * Instantiates HDR filter for reflection maps
  58985. *
  58986. * @param engine Thin engine
  58987. * @param options Options
  58988. */
  58989. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  58990. private _createRenderTarget;
  58991. private _prefilterInternal;
  58992. private _createEffect;
  58993. /**
  58994. * Get a value indicating if the filter is ready to be used
  58995. * @param texture Texture to filter
  58996. * @returns true if the filter is ready
  58997. */
  58998. isReady(texture: BaseTexture): boolean;
  58999. /**
  59000. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59001. * Prefiltering will be invoked at the end of next rendering pass.
  59002. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59003. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59004. * @param texture Texture to filter
  59005. * @param onFinished Callback when filtering is done
  59006. * @return Promise called when prefiltering is done
  59007. */
  59008. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59009. }
  59010. }
  59011. declare module BABYLON {
  59012. /**
  59013. * This represents a texture coming from an HDR input.
  59014. *
  59015. * The only supported format is currently panorama picture stored in RGBE format.
  59016. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59017. */
  59018. export class HDRCubeTexture extends BaseTexture {
  59019. private static _facesMapping;
  59020. private _generateHarmonics;
  59021. private _noMipmap;
  59022. private _prefilterOnLoad;
  59023. private _textureMatrix;
  59024. private _size;
  59025. private _onLoad;
  59026. private _onError;
  59027. /**
  59028. * The texture URL.
  59029. */
  59030. url: string;
  59031. /**
  59032. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59033. */
  59034. coordinatesMode: number;
  59035. protected _isBlocking: boolean;
  59036. /**
  59037. * Sets wether or not the texture is blocking during loading.
  59038. */
  59039. set isBlocking(value: boolean);
  59040. /**
  59041. * Gets wether or not the texture is blocking during loading.
  59042. */
  59043. get isBlocking(): boolean;
  59044. protected _rotationY: number;
  59045. /**
  59046. * Sets texture matrix rotation angle around Y axis in radians.
  59047. */
  59048. set rotationY(value: number);
  59049. /**
  59050. * Gets texture matrix rotation angle around Y axis radians.
  59051. */
  59052. get rotationY(): number;
  59053. /**
  59054. * Gets or sets the center of the bounding box associated with the cube texture
  59055. * It must define where the camera used to render the texture was set
  59056. */
  59057. boundingBoxPosition: Vector3;
  59058. private _boundingBoxSize;
  59059. /**
  59060. * Gets or sets the size of the bounding box associated with the cube texture
  59061. * When defined, the cubemap will switch to local mode
  59062. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59063. * @example https://www.babylonjs-playground.com/#RNASML
  59064. */
  59065. set boundingBoxSize(value: Vector3);
  59066. get boundingBoxSize(): Vector3;
  59067. /**
  59068. * Instantiates an HDRTexture from the following parameters.
  59069. *
  59070. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59071. * @param sceneOrEngine The scene or engine the texture will be used in
  59072. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59073. * @param noMipmap Forces to not generate the mipmap if true
  59074. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59075. * @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)
  59076. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59077. */
  59078. 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>);
  59079. /**
  59080. * Get the current class name of the texture useful for serialization or dynamic coding.
  59081. * @returns "HDRCubeTexture"
  59082. */
  59083. getClassName(): string;
  59084. /**
  59085. * Occurs when the file is raw .hdr file.
  59086. */
  59087. private loadTexture;
  59088. clone(): HDRCubeTexture;
  59089. delayLoad(): void;
  59090. /**
  59091. * Get the texture reflection matrix used to rotate/transform the reflection.
  59092. * @returns the reflection matrix
  59093. */
  59094. getReflectionTextureMatrix(): Matrix;
  59095. /**
  59096. * Set the texture reflection matrix used to rotate/transform the reflection.
  59097. * @param value Define the reflection matrix to set
  59098. */
  59099. setReflectionTextureMatrix(value: Matrix): void;
  59100. /**
  59101. * Parses a JSON representation of an HDR Texture in order to create the texture
  59102. * @param parsedTexture Define the JSON representation
  59103. * @param scene Define the scene the texture should be created in
  59104. * @param rootUrl Define the root url in case we need to load relative dependencies
  59105. * @returns the newly created texture after parsing
  59106. */
  59107. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59108. serialize(): any;
  59109. }
  59110. }
  59111. declare module BABYLON {
  59112. /**
  59113. * Class used to control physics engine
  59114. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  59115. */
  59116. export class PhysicsEngine implements IPhysicsEngine {
  59117. private _physicsPlugin;
  59118. /**
  59119. * Global value used to control the smallest number supported by the simulation
  59120. */
  59121. static Epsilon: number;
  59122. private _impostors;
  59123. private _joints;
  59124. private _subTimeStep;
  59125. /**
  59126. * Gets the gravity vector used by the simulation
  59127. */
  59128. gravity: Vector3;
  59129. /**
  59130. * Factory used to create the default physics plugin.
  59131. * @returns The default physics plugin
  59132. */
  59133. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59134. /**
  59135. * Creates a new Physics Engine
  59136. * @param gravity defines the gravity vector used by the simulation
  59137. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59138. */
  59139. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59140. /**
  59141. * Sets the gravity vector used by the simulation
  59142. * @param gravity defines the gravity vector to use
  59143. */
  59144. setGravity(gravity: Vector3): void;
  59145. /**
  59146. * Set the time step of the physics engine.
  59147. * Default is 1/60.
  59148. * To slow it down, enter 1/600 for example.
  59149. * To speed it up, 1/30
  59150. * @param newTimeStep defines the new timestep to apply to this world.
  59151. */
  59152. setTimeStep(newTimeStep?: number): void;
  59153. /**
  59154. * Get the time step of the physics engine.
  59155. * @returns the current time step
  59156. */
  59157. getTimeStep(): number;
  59158. /**
  59159. * Set the sub time step of the physics engine.
  59160. * Default is 0 meaning there is no sub steps
  59161. * To increase physics resolution precision, set a small value (like 1 ms)
  59162. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59163. */
  59164. setSubTimeStep(subTimeStep?: number): void;
  59165. /**
  59166. * Get the sub time step of the physics engine.
  59167. * @returns the current sub time step
  59168. */
  59169. getSubTimeStep(): number;
  59170. /**
  59171. * Release all resources
  59172. */
  59173. dispose(): void;
  59174. /**
  59175. * Gets the name of the current physics plugin
  59176. * @returns the name of the plugin
  59177. */
  59178. getPhysicsPluginName(): string;
  59179. /**
  59180. * Adding a new impostor for the impostor tracking.
  59181. * This will be done by the impostor itself.
  59182. * @param impostor the impostor to add
  59183. */
  59184. addImpostor(impostor: PhysicsImpostor): void;
  59185. /**
  59186. * Remove an impostor from the engine.
  59187. * This impostor and its mesh will not longer be updated by the physics engine.
  59188. * @param impostor the impostor to remove
  59189. */
  59190. removeImpostor(impostor: PhysicsImpostor): void;
  59191. /**
  59192. * Add a joint to the physics engine
  59193. * @param mainImpostor defines the main impostor to which the joint is added.
  59194. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59195. * @param joint defines the joint that will connect both impostors.
  59196. */
  59197. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59198. /**
  59199. * Removes a joint from the simulation
  59200. * @param mainImpostor defines the impostor used with the joint
  59201. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59202. * @param joint defines the joint to remove
  59203. */
  59204. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59205. /**
  59206. * Called by the scene. No need to call it.
  59207. * @param delta defines the timespam between frames
  59208. */
  59209. _step(delta: number): void;
  59210. /**
  59211. * Gets the current plugin used to run the simulation
  59212. * @returns current plugin
  59213. */
  59214. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59215. /**
  59216. * Gets the list of physic impostors
  59217. * @returns an array of PhysicsImpostor
  59218. */
  59219. getImpostors(): Array<PhysicsImpostor>;
  59220. /**
  59221. * Gets the impostor for a physics enabled object
  59222. * @param object defines the object impersonated by the impostor
  59223. * @returns the PhysicsImpostor or null if not found
  59224. */
  59225. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59226. /**
  59227. * Gets the impostor for a physics body object
  59228. * @param body defines physics body used by the impostor
  59229. * @returns the PhysicsImpostor or null if not found
  59230. */
  59231. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59232. /**
  59233. * Does a raycast in the physics world
  59234. * @param from when should the ray start?
  59235. * @param to when should the ray end?
  59236. * @returns PhysicsRaycastResult
  59237. */
  59238. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59239. }
  59240. }
  59241. declare module BABYLON {
  59242. /** @hidden */
  59243. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59244. private _useDeltaForWorldStep;
  59245. world: any;
  59246. name: string;
  59247. private _physicsMaterials;
  59248. private _fixedTimeStep;
  59249. private _cannonRaycastResult;
  59250. private _raycastResult;
  59251. private _physicsBodysToRemoveAfterStep;
  59252. private _firstFrame;
  59253. BJSCANNON: any;
  59254. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59255. setGravity(gravity: Vector3): void;
  59256. setTimeStep(timeStep: number): void;
  59257. getTimeStep(): number;
  59258. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59259. private _removeMarkedPhysicsBodiesFromWorld;
  59260. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59261. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59262. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59263. private _processChildMeshes;
  59264. removePhysicsBody(impostor: PhysicsImpostor): void;
  59265. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59266. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59267. private _addMaterial;
  59268. private _checkWithEpsilon;
  59269. private _createShape;
  59270. private _createHeightmap;
  59271. private _minus90X;
  59272. private _plus90X;
  59273. private _tmpPosition;
  59274. private _tmpDeltaPosition;
  59275. private _tmpUnityRotation;
  59276. private _updatePhysicsBodyTransformation;
  59277. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59278. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59279. isSupported(): boolean;
  59280. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59281. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59282. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59283. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59284. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59285. getBodyMass(impostor: PhysicsImpostor): number;
  59286. getBodyFriction(impostor: PhysicsImpostor): number;
  59287. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59288. getBodyRestitution(impostor: PhysicsImpostor): number;
  59289. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59290. sleepBody(impostor: PhysicsImpostor): void;
  59291. wakeUpBody(impostor: PhysicsImpostor): void;
  59292. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59293. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59294. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59295. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59296. getRadius(impostor: PhysicsImpostor): number;
  59297. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59298. dispose(): void;
  59299. private _extendNamespace;
  59300. /**
  59301. * Does a raycast in the physics world
  59302. * @param from when should the ray start?
  59303. * @param to when should the ray end?
  59304. * @returns PhysicsRaycastResult
  59305. */
  59306. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59307. }
  59308. }
  59309. declare module BABYLON {
  59310. /** @hidden */
  59311. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59312. private _useDeltaForWorldStep;
  59313. world: any;
  59314. name: string;
  59315. BJSOIMO: any;
  59316. private _raycastResult;
  59317. private _fixedTimeStep;
  59318. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59319. setGravity(gravity: Vector3): void;
  59320. setTimeStep(timeStep: number): void;
  59321. getTimeStep(): number;
  59322. private _tmpImpostorsArray;
  59323. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59324. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59325. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59326. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59327. private _tmpPositionVector;
  59328. removePhysicsBody(impostor: PhysicsImpostor): void;
  59329. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59330. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59331. isSupported(): boolean;
  59332. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59333. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59334. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59335. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59336. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59337. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59338. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59339. getBodyMass(impostor: PhysicsImpostor): number;
  59340. getBodyFriction(impostor: PhysicsImpostor): number;
  59341. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59342. getBodyRestitution(impostor: PhysicsImpostor): number;
  59343. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59344. sleepBody(impostor: PhysicsImpostor): void;
  59345. wakeUpBody(impostor: PhysicsImpostor): void;
  59346. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59347. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59348. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59349. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59350. getRadius(impostor: PhysicsImpostor): number;
  59351. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59352. dispose(): void;
  59353. /**
  59354. * Does a raycast in the physics world
  59355. * @param from when should the ray start?
  59356. * @param to when should the ray end?
  59357. * @returns PhysicsRaycastResult
  59358. */
  59359. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59360. }
  59361. }
  59362. declare module BABYLON {
  59363. /**
  59364. * Class containing static functions to help procedurally build meshes
  59365. */
  59366. export class RibbonBuilder {
  59367. /**
  59368. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59369. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59370. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59371. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59372. * * 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
  59373. * * 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
  59374. * * 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
  59375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59376. * * 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
  59377. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59378. * * 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
  59379. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59380. * * 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
  59381. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59383. * @param name defines the name of the mesh
  59384. * @param options defines the options used to create the mesh
  59385. * @param scene defines the hosting scene
  59386. * @returns the ribbon mesh
  59387. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59388. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59389. */
  59390. static CreateRibbon(name: string, options: {
  59391. pathArray: Vector3[][];
  59392. closeArray?: boolean;
  59393. closePath?: boolean;
  59394. offset?: number;
  59395. updatable?: boolean;
  59396. sideOrientation?: number;
  59397. frontUVs?: Vector4;
  59398. backUVs?: Vector4;
  59399. instance?: Mesh;
  59400. invertUV?: boolean;
  59401. uvs?: Vector2[];
  59402. colors?: Color4[];
  59403. }, scene?: Nullable<Scene>): Mesh;
  59404. }
  59405. }
  59406. declare module BABYLON {
  59407. /**
  59408. * Class containing static functions to help procedurally build meshes
  59409. */
  59410. export class ShapeBuilder {
  59411. /**
  59412. * 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.
  59413. * * 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.
  59414. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59415. * * 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.
  59416. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59417. * * 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
  59418. * * 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
  59419. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59421. * * 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
  59422. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59424. * @param name defines the name of the mesh
  59425. * @param options defines the options used to create the mesh
  59426. * @param scene defines the hosting scene
  59427. * @returns the extruded shape mesh
  59428. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59430. */
  59431. static ExtrudeShape(name: string, options: {
  59432. shape: Vector3[];
  59433. path: Vector3[];
  59434. scale?: number;
  59435. rotation?: number;
  59436. cap?: number;
  59437. updatable?: boolean;
  59438. sideOrientation?: number;
  59439. frontUVs?: Vector4;
  59440. backUVs?: Vector4;
  59441. instance?: Mesh;
  59442. invertUV?: boolean;
  59443. }, scene?: Nullable<Scene>): Mesh;
  59444. /**
  59445. * Creates an custom extruded shape mesh.
  59446. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59447. * * 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.
  59448. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59449. * * 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
  59450. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59451. * * 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
  59452. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59453. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59454. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59455. * * 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
  59456. * * 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
  59457. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59459. * * 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
  59460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59462. * @param name defines the name of the mesh
  59463. * @param options defines the options used to create the mesh
  59464. * @param scene defines the hosting scene
  59465. * @returns the custom extruded shape mesh
  59466. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59467. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59469. */
  59470. static ExtrudeShapeCustom(name: string, options: {
  59471. shape: Vector3[];
  59472. path: Vector3[];
  59473. scaleFunction?: any;
  59474. rotationFunction?: any;
  59475. ribbonCloseArray?: boolean;
  59476. ribbonClosePath?: boolean;
  59477. cap?: number;
  59478. updatable?: boolean;
  59479. sideOrientation?: number;
  59480. frontUVs?: Vector4;
  59481. backUVs?: Vector4;
  59482. instance?: Mesh;
  59483. invertUV?: boolean;
  59484. }, scene?: Nullable<Scene>): Mesh;
  59485. private static _ExtrudeShapeGeneric;
  59486. }
  59487. }
  59488. declare module BABYLON {
  59489. /**
  59490. * AmmoJS Physics plugin
  59491. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59492. * @see https://github.com/kripken/ammo.js/
  59493. */
  59494. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59495. private _useDeltaForWorldStep;
  59496. /**
  59497. * Reference to the Ammo library
  59498. */
  59499. bjsAMMO: any;
  59500. /**
  59501. * Created ammoJS world which physics bodies are added to
  59502. */
  59503. world: any;
  59504. /**
  59505. * Name of the plugin
  59506. */
  59507. name: string;
  59508. private _timeStep;
  59509. private _fixedTimeStep;
  59510. private _maxSteps;
  59511. private _tmpQuaternion;
  59512. private _tmpAmmoTransform;
  59513. private _tmpAmmoQuaternion;
  59514. private _tmpAmmoConcreteContactResultCallback;
  59515. private _collisionConfiguration;
  59516. private _dispatcher;
  59517. private _overlappingPairCache;
  59518. private _solver;
  59519. private _softBodySolver;
  59520. private _tmpAmmoVectorA;
  59521. private _tmpAmmoVectorB;
  59522. private _tmpAmmoVectorC;
  59523. private _tmpAmmoVectorD;
  59524. private _tmpContactCallbackResult;
  59525. private _tmpAmmoVectorRCA;
  59526. private _tmpAmmoVectorRCB;
  59527. private _raycastResult;
  59528. private static readonly DISABLE_COLLISION_FLAG;
  59529. private static readonly KINEMATIC_FLAG;
  59530. private static readonly DISABLE_DEACTIVATION_FLAG;
  59531. /**
  59532. * Initializes the ammoJS plugin
  59533. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59534. * @param ammoInjection can be used to inject your own ammo reference
  59535. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59536. */
  59537. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59538. /**
  59539. * Sets the gravity of the physics world (m/(s^2))
  59540. * @param gravity Gravity to set
  59541. */
  59542. setGravity(gravity: Vector3): void;
  59543. /**
  59544. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59545. * @param timeStep timestep to use in seconds
  59546. */
  59547. setTimeStep(timeStep: number): void;
  59548. /**
  59549. * 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)
  59550. * @param fixedTimeStep fixedTimeStep to use in seconds
  59551. */
  59552. setFixedTimeStep(fixedTimeStep: number): void;
  59553. /**
  59554. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59555. * @param maxSteps the maximum number of steps by the physics engine per frame
  59556. */
  59557. setMaxSteps(maxSteps: number): void;
  59558. /**
  59559. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59560. * @returns the current timestep in seconds
  59561. */
  59562. getTimeStep(): number;
  59563. /**
  59564. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59565. */
  59566. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59567. private _isImpostorInContact;
  59568. private _isImpostorPairInContact;
  59569. private _stepSimulation;
  59570. /**
  59571. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59572. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59573. * After the step the babylon meshes are set to the position of the physics imposters
  59574. * @param delta amount of time to step forward
  59575. * @param impostors array of imposters to update before/after the step
  59576. */
  59577. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59578. /**
  59579. * Update babylon mesh to match physics world object
  59580. * @param impostor imposter to match
  59581. */
  59582. private _afterSoftStep;
  59583. /**
  59584. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59585. * @param impostor imposter to match
  59586. */
  59587. private _ropeStep;
  59588. /**
  59589. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59590. * @param impostor imposter to match
  59591. */
  59592. private _softbodyOrClothStep;
  59593. private _tmpMatrix;
  59594. /**
  59595. * Applies an impulse on the imposter
  59596. * @param impostor imposter to apply impulse to
  59597. * @param force amount of force to be applied to the imposter
  59598. * @param contactPoint the location to apply the impulse on the imposter
  59599. */
  59600. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59601. /**
  59602. * Applies a force on the imposter
  59603. * @param impostor imposter to apply force
  59604. * @param force amount of force to be applied to the imposter
  59605. * @param contactPoint the location to apply the force on the imposter
  59606. */
  59607. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59608. /**
  59609. * Creates a physics body using the plugin
  59610. * @param impostor the imposter to create the physics body on
  59611. */
  59612. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59613. /**
  59614. * Removes the physics body from the imposter and disposes of the body's memory
  59615. * @param impostor imposter to remove the physics body from
  59616. */
  59617. removePhysicsBody(impostor: PhysicsImpostor): void;
  59618. /**
  59619. * Generates a joint
  59620. * @param impostorJoint the imposter joint to create the joint with
  59621. */
  59622. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59623. /**
  59624. * Removes a joint
  59625. * @param impostorJoint the imposter joint to remove the joint from
  59626. */
  59627. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59628. private _addMeshVerts;
  59629. /**
  59630. * Initialise the soft body vertices to match its object's (mesh) vertices
  59631. * Softbody vertices (nodes) are in world space and to match this
  59632. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59633. * @param impostor to create the softbody for
  59634. */
  59635. private _softVertexData;
  59636. /**
  59637. * Create an impostor's soft body
  59638. * @param impostor to create the softbody for
  59639. */
  59640. private _createSoftbody;
  59641. /**
  59642. * Create cloth for an impostor
  59643. * @param impostor to create the softbody for
  59644. */
  59645. private _createCloth;
  59646. /**
  59647. * Create rope for an impostor
  59648. * @param impostor to create the softbody for
  59649. */
  59650. private _createRope;
  59651. /**
  59652. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59653. * @param impostor to create the custom physics shape for
  59654. */
  59655. private _createCustom;
  59656. private _addHullVerts;
  59657. private _createShape;
  59658. /**
  59659. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59660. * @param impostor imposter containing the physics body and babylon object
  59661. */
  59662. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59663. /**
  59664. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59665. * @param impostor imposter containing the physics body and babylon object
  59666. * @param newPosition new position
  59667. * @param newRotation new rotation
  59668. */
  59669. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59670. /**
  59671. * If this plugin is supported
  59672. * @returns true if its supported
  59673. */
  59674. isSupported(): boolean;
  59675. /**
  59676. * Sets the linear velocity of the physics body
  59677. * @param impostor imposter to set the velocity on
  59678. * @param velocity velocity to set
  59679. */
  59680. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59681. /**
  59682. * Sets the angular velocity of the physics body
  59683. * @param impostor imposter to set the velocity on
  59684. * @param velocity velocity to set
  59685. */
  59686. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59687. /**
  59688. * gets the linear velocity
  59689. * @param impostor imposter to get linear velocity from
  59690. * @returns linear velocity
  59691. */
  59692. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59693. /**
  59694. * gets the angular velocity
  59695. * @param impostor imposter to get angular velocity from
  59696. * @returns angular velocity
  59697. */
  59698. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59699. /**
  59700. * Sets the mass of physics body
  59701. * @param impostor imposter to set the mass on
  59702. * @param mass mass to set
  59703. */
  59704. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59705. /**
  59706. * Gets the mass of the physics body
  59707. * @param impostor imposter to get the mass from
  59708. * @returns mass
  59709. */
  59710. getBodyMass(impostor: PhysicsImpostor): number;
  59711. /**
  59712. * Gets friction of the impostor
  59713. * @param impostor impostor to get friction from
  59714. * @returns friction value
  59715. */
  59716. getBodyFriction(impostor: PhysicsImpostor): number;
  59717. /**
  59718. * Sets friction of the impostor
  59719. * @param impostor impostor to set friction on
  59720. * @param friction friction value
  59721. */
  59722. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59723. /**
  59724. * Gets restitution of the impostor
  59725. * @param impostor impostor to get restitution from
  59726. * @returns restitution value
  59727. */
  59728. getBodyRestitution(impostor: PhysicsImpostor): number;
  59729. /**
  59730. * Sets resitution of the impostor
  59731. * @param impostor impostor to set resitution on
  59732. * @param restitution resitution value
  59733. */
  59734. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59735. /**
  59736. * Gets pressure inside the impostor
  59737. * @param impostor impostor to get pressure from
  59738. * @returns pressure value
  59739. */
  59740. getBodyPressure(impostor: PhysicsImpostor): number;
  59741. /**
  59742. * Sets pressure inside a soft body impostor
  59743. * Cloth and rope must remain 0 pressure
  59744. * @param impostor impostor to set pressure on
  59745. * @param pressure pressure value
  59746. */
  59747. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  59748. /**
  59749. * Gets stiffness of the impostor
  59750. * @param impostor impostor to get stiffness from
  59751. * @returns pressure value
  59752. */
  59753. getBodyStiffness(impostor: PhysicsImpostor): number;
  59754. /**
  59755. * Sets stiffness of the impostor
  59756. * @param impostor impostor to set stiffness on
  59757. * @param stiffness stiffness value from 0 to 1
  59758. */
  59759. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  59760. /**
  59761. * Gets velocityIterations of the impostor
  59762. * @param impostor impostor to get velocity iterations from
  59763. * @returns velocityIterations value
  59764. */
  59765. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  59766. /**
  59767. * Sets velocityIterations of the impostor
  59768. * @param impostor impostor to set velocity iterations on
  59769. * @param velocityIterations velocityIterations value
  59770. */
  59771. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  59772. /**
  59773. * Gets positionIterations of the impostor
  59774. * @param impostor impostor to get position iterations from
  59775. * @returns positionIterations value
  59776. */
  59777. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  59778. /**
  59779. * Sets positionIterations of the impostor
  59780. * @param impostor impostor to set position on
  59781. * @param positionIterations positionIterations value
  59782. */
  59783. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  59784. /**
  59785. * Append an anchor to a cloth object
  59786. * @param impostor is the cloth impostor to add anchor to
  59787. * @param otherImpostor is the rigid impostor to anchor to
  59788. * @param width ratio across width from 0 to 1
  59789. * @param height ratio up height from 0 to 1
  59790. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  59791. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59792. */
  59793. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59794. /**
  59795. * Append an hook to a rope object
  59796. * @param impostor is the rope impostor to add hook to
  59797. * @param otherImpostor is the rigid impostor to hook to
  59798. * @param length ratio along the rope from 0 to 1
  59799. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  59800. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  59801. */
  59802. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  59803. /**
  59804. * Sleeps the physics body and stops it from being active
  59805. * @param impostor impostor to sleep
  59806. */
  59807. sleepBody(impostor: PhysicsImpostor): void;
  59808. /**
  59809. * Activates the physics body
  59810. * @param impostor impostor to activate
  59811. */
  59812. wakeUpBody(impostor: PhysicsImpostor): void;
  59813. /**
  59814. * Updates the distance parameters of the joint
  59815. * @param joint joint to update
  59816. * @param maxDistance maximum distance of the joint
  59817. * @param minDistance minimum distance of the joint
  59818. */
  59819. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59820. /**
  59821. * Sets a motor on the joint
  59822. * @param joint joint to set motor on
  59823. * @param speed speed of the motor
  59824. * @param maxForce maximum force of the motor
  59825. * @param motorIndex index of the motor
  59826. */
  59827. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59828. /**
  59829. * Sets the motors limit
  59830. * @param joint joint to set limit on
  59831. * @param upperLimit upper limit
  59832. * @param lowerLimit lower limit
  59833. */
  59834. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59835. /**
  59836. * Syncs the position and rotation of a mesh with the impostor
  59837. * @param mesh mesh to sync
  59838. * @param impostor impostor to update the mesh with
  59839. */
  59840. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59841. /**
  59842. * Gets the radius of the impostor
  59843. * @param impostor impostor to get radius from
  59844. * @returns the radius
  59845. */
  59846. getRadius(impostor: PhysicsImpostor): number;
  59847. /**
  59848. * Gets the box size of the impostor
  59849. * @param impostor impostor to get box size from
  59850. * @param result the resulting box size
  59851. */
  59852. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59853. /**
  59854. * Disposes of the impostor
  59855. */
  59856. dispose(): void;
  59857. /**
  59858. * Does a raycast in the physics world
  59859. * @param from when should the ray start?
  59860. * @param to when should the ray end?
  59861. * @returns PhysicsRaycastResult
  59862. */
  59863. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59864. }
  59865. }
  59866. declare module BABYLON {
  59867. interface AbstractScene {
  59868. /**
  59869. * The list of reflection probes added to the scene
  59870. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59871. */
  59872. reflectionProbes: Array<ReflectionProbe>;
  59873. /**
  59874. * Removes the given reflection probe from this scene.
  59875. * @param toRemove The reflection probe to remove
  59876. * @returns The index of the removed reflection probe
  59877. */
  59878. removeReflectionProbe(toRemove: ReflectionProbe): number;
  59879. /**
  59880. * Adds the given reflection probe to this scene.
  59881. * @param newReflectionProbe The reflection probe to add
  59882. */
  59883. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  59884. }
  59885. /**
  59886. * Class used to generate realtime reflection / refraction cube textures
  59887. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  59888. */
  59889. export class ReflectionProbe {
  59890. /** defines the name of the probe */
  59891. name: string;
  59892. private _scene;
  59893. private _renderTargetTexture;
  59894. private _projectionMatrix;
  59895. private _viewMatrix;
  59896. private _target;
  59897. private _add;
  59898. private _attachedMesh;
  59899. private _invertYAxis;
  59900. /** Gets or sets probe position (center of the cube map) */
  59901. position: Vector3;
  59902. /**
  59903. * Creates a new reflection probe
  59904. * @param name defines the name of the probe
  59905. * @param size defines the texture resolution (for each face)
  59906. * @param scene defines the hosting scene
  59907. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  59908. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  59909. */
  59910. constructor(
  59911. /** defines the name of the probe */
  59912. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  59913. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  59914. get samples(): number;
  59915. set samples(value: number);
  59916. /** Gets or sets the refresh rate to use (on every frame by default) */
  59917. get refreshRate(): number;
  59918. set refreshRate(value: number);
  59919. /**
  59920. * Gets the hosting scene
  59921. * @returns a Scene
  59922. */
  59923. getScene(): Scene;
  59924. /** Gets the internal CubeTexture used to render to */
  59925. get cubeTexture(): RenderTargetTexture;
  59926. /** Gets the list of meshes to render */
  59927. get renderList(): Nullable<AbstractMesh[]>;
  59928. /**
  59929. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  59930. * @param mesh defines the mesh to attach to
  59931. */
  59932. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59933. /**
  59934. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  59935. * @param renderingGroupId The rendering group id corresponding to its index
  59936. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  59937. */
  59938. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  59939. /**
  59940. * Clean all associated resources
  59941. */
  59942. dispose(): void;
  59943. /**
  59944. * Converts the reflection probe information to a readable string for debug purpose.
  59945. * @param fullDetails Supports for multiple levels of logging within scene loading
  59946. * @returns the human readable reflection probe info
  59947. */
  59948. toString(fullDetails?: boolean): string;
  59949. /**
  59950. * Get the class name of the relfection probe.
  59951. * @returns "ReflectionProbe"
  59952. */
  59953. getClassName(): string;
  59954. /**
  59955. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  59956. * @returns The JSON representation of the texture
  59957. */
  59958. serialize(): any;
  59959. /**
  59960. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  59961. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  59962. * @param scene Define the scene the parsed reflection probe should be instantiated in
  59963. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59964. * @returns The parsed reflection probe if successful
  59965. */
  59966. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  59967. }
  59968. }
  59969. declare module BABYLON {
  59970. /** @hidden */
  59971. export var _BabylonLoaderRegistered: boolean;
  59972. /**
  59973. * Helps setting up some configuration for the babylon file loader.
  59974. */
  59975. export class BabylonFileLoaderConfiguration {
  59976. /**
  59977. * The loader does not allow injecting custom physix engine into the plugins.
  59978. * Unfortunately in ES6, we need to manually inject them into the plugin.
  59979. * So you could set this variable to your engine import to make it work.
  59980. */
  59981. static LoaderInjectedPhysicsEngine: any;
  59982. }
  59983. }
  59984. declare module BABYLON {
  59985. /**
  59986. * The Physically based simple base material of BJS.
  59987. *
  59988. * This enables better naming and convention enforcements on top of the pbrMaterial.
  59989. * It is used as the base class for both the specGloss and metalRough conventions.
  59990. */
  59991. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  59992. /**
  59993. * Number of Simultaneous lights allowed on the material.
  59994. */
  59995. maxSimultaneousLights: number;
  59996. /**
  59997. * If sets to true, disables all the lights affecting the material.
  59998. */
  59999. disableLighting: boolean;
  60000. /**
  60001. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60002. */
  60003. environmentTexture: BaseTexture;
  60004. /**
  60005. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60006. */
  60007. invertNormalMapX: boolean;
  60008. /**
  60009. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60010. */
  60011. invertNormalMapY: boolean;
  60012. /**
  60013. * Normal map used in the model.
  60014. */
  60015. normalTexture: BaseTexture;
  60016. /**
  60017. * Emissivie color used to self-illuminate the model.
  60018. */
  60019. emissiveColor: Color3;
  60020. /**
  60021. * Emissivie texture used to self-illuminate the model.
  60022. */
  60023. emissiveTexture: BaseTexture;
  60024. /**
  60025. * Occlusion Channel Strenght.
  60026. */
  60027. occlusionStrength: number;
  60028. /**
  60029. * Occlusion Texture of the material (adding extra occlusion effects).
  60030. */
  60031. occlusionTexture: BaseTexture;
  60032. /**
  60033. * Defines the alpha limits in alpha test mode.
  60034. */
  60035. alphaCutOff: number;
  60036. /**
  60037. * Gets the current double sided mode.
  60038. */
  60039. get doubleSided(): boolean;
  60040. /**
  60041. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60042. */
  60043. set doubleSided(value: boolean);
  60044. /**
  60045. * Stores the pre-calculated light information of a mesh in a texture.
  60046. */
  60047. lightmapTexture: BaseTexture;
  60048. /**
  60049. * If true, the light map contains occlusion information instead of lighting info.
  60050. */
  60051. useLightmapAsShadowmap: boolean;
  60052. /**
  60053. * Instantiates a new PBRMaterial instance.
  60054. *
  60055. * @param name The material name
  60056. * @param scene The scene the material will be use in.
  60057. */
  60058. constructor(name: string, scene: Scene);
  60059. getClassName(): string;
  60060. }
  60061. }
  60062. declare module BABYLON {
  60063. /**
  60064. * The PBR material of BJS following the metal roughness convention.
  60065. *
  60066. * This fits to the PBR convention in the GLTF definition:
  60067. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60068. */
  60069. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60070. /**
  60071. * The base color has two different interpretations depending on the value of metalness.
  60072. * When the material is a metal, the base color is the specific measured reflectance value
  60073. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60074. * of the material.
  60075. */
  60076. baseColor: Color3;
  60077. /**
  60078. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60079. * well as opacity information in the alpha channel.
  60080. */
  60081. baseTexture: BaseTexture;
  60082. /**
  60083. * Specifies the metallic scalar value of the material.
  60084. * Can also be used to scale the metalness values of the metallic texture.
  60085. */
  60086. metallic: number;
  60087. /**
  60088. * Specifies the roughness scalar value of the material.
  60089. * Can also be used to scale the roughness values of the metallic texture.
  60090. */
  60091. roughness: number;
  60092. /**
  60093. * Texture containing both the metallic value in the B channel and the
  60094. * roughness value in the G channel to keep better precision.
  60095. */
  60096. metallicRoughnessTexture: BaseTexture;
  60097. /**
  60098. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60099. *
  60100. * @param name The material name
  60101. * @param scene The scene the material will be use in.
  60102. */
  60103. constructor(name: string, scene: Scene);
  60104. /**
  60105. * Return the currrent class name of the material.
  60106. */
  60107. getClassName(): string;
  60108. /**
  60109. * Makes a duplicate of the current material.
  60110. * @param name - name to use for the new material.
  60111. */
  60112. clone(name: string): PBRMetallicRoughnessMaterial;
  60113. /**
  60114. * Serialize the material to a parsable JSON object.
  60115. */
  60116. serialize(): any;
  60117. /**
  60118. * Parses a JSON object correponding to the serialize function.
  60119. */
  60120. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60121. }
  60122. }
  60123. declare module BABYLON {
  60124. /**
  60125. * The PBR material of BJS following the specular glossiness convention.
  60126. *
  60127. * This fits to the PBR convention in the GLTF definition:
  60128. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60129. */
  60130. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60131. /**
  60132. * Specifies the diffuse color of the material.
  60133. */
  60134. diffuseColor: Color3;
  60135. /**
  60136. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60137. * channel.
  60138. */
  60139. diffuseTexture: BaseTexture;
  60140. /**
  60141. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60142. */
  60143. specularColor: Color3;
  60144. /**
  60145. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60146. */
  60147. glossiness: number;
  60148. /**
  60149. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60150. */
  60151. specularGlossinessTexture: BaseTexture;
  60152. /**
  60153. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60154. *
  60155. * @param name The material name
  60156. * @param scene The scene the material will be use in.
  60157. */
  60158. constructor(name: string, scene: Scene);
  60159. /**
  60160. * Return the currrent class name of the material.
  60161. */
  60162. getClassName(): string;
  60163. /**
  60164. * Makes a duplicate of the current material.
  60165. * @param name - name to use for the new material.
  60166. */
  60167. clone(name: string): PBRSpecularGlossinessMaterial;
  60168. /**
  60169. * Serialize the material to a parsable JSON object.
  60170. */
  60171. serialize(): any;
  60172. /**
  60173. * Parses a JSON object correponding to the serialize function.
  60174. */
  60175. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60176. }
  60177. }
  60178. declare module BABYLON {
  60179. /**
  60180. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60181. * It can help converting any input color in a desired output one. This can then be used to create effects
  60182. * from sepia, black and white to sixties or futuristic rendering...
  60183. *
  60184. * The only supported format is currently 3dl.
  60185. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60186. */
  60187. export class ColorGradingTexture extends BaseTexture {
  60188. /**
  60189. * The texture URL.
  60190. */
  60191. url: string;
  60192. /**
  60193. * Empty line regex stored for GC.
  60194. */
  60195. private static _noneEmptyLineRegex;
  60196. private _textureMatrix;
  60197. private _onLoad;
  60198. /**
  60199. * Instantiates a ColorGradingTexture from the following parameters.
  60200. *
  60201. * @param url The location of the color gradind data (currently only supporting 3dl)
  60202. * @param sceneOrEngine The scene or engine the texture will be used in
  60203. * @param onLoad defines a callback triggered when the texture has been loaded
  60204. */
  60205. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60206. /**
  60207. * Fires the onload event from the constructor if requested.
  60208. */
  60209. private _triggerOnLoad;
  60210. /**
  60211. * Returns the texture matrix used in most of the material.
  60212. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60213. */
  60214. getTextureMatrix(): Matrix;
  60215. /**
  60216. * Occurs when the file being loaded is a .3dl LUT file.
  60217. */
  60218. private load3dlTexture;
  60219. /**
  60220. * Starts the loading process of the texture.
  60221. */
  60222. private loadTexture;
  60223. /**
  60224. * Clones the color gradind texture.
  60225. */
  60226. clone(): ColorGradingTexture;
  60227. /**
  60228. * Called during delayed load for textures.
  60229. */
  60230. delayLoad(): void;
  60231. /**
  60232. * Parses a color grading texture serialized by Babylon.
  60233. * @param parsedTexture The texture information being parsedTexture
  60234. * @param scene The scene to load the texture in
  60235. * @param rootUrl The root url of the data assets to load
  60236. * @return A color gradind texture
  60237. */
  60238. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60239. /**
  60240. * Serializes the LUT texture to json format.
  60241. */
  60242. serialize(): any;
  60243. }
  60244. }
  60245. declare module BABYLON {
  60246. /**
  60247. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60248. */
  60249. export class EquiRectangularCubeTexture extends BaseTexture {
  60250. /** The six faces of the cube. */
  60251. private static _FacesMapping;
  60252. private _noMipmap;
  60253. private _onLoad;
  60254. private _onError;
  60255. /** The size of the cubemap. */
  60256. private _size;
  60257. /** The buffer of the image. */
  60258. private _buffer;
  60259. /** The width of the input image. */
  60260. private _width;
  60261. /** The height of the input image. */
  60262. private _height;
  60263. /** The URL to the image. */
  60264. url: string;
  60265. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60266. coordinatesMode: number;
  60267. /**
  60268. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60269. * @param url The location of the image
  60270. * @param scene The scene the texture will be used in
  60271. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60272. * @param noMipmap Forces to not generate the mipmap if true
  60273. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60274. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60275. * @param onLoad — defines a callback called when texture is loaded
  60276. * @param onError — defines a callback called if there is an error
  60277. */
  60278. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60279. /**
  60280. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60281. */
  60282. private loadImage;
  60283. /**
  60284. * Convert the image buffer into a cubemap and create a CubeTexture.
  60285. */
  60286. private loadTexture;
  60287. /**
  60288. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60289. * @param buffer The ArrayBuffer that should be converted.
  60290. * @returns The buffer as Float32Array.
  60291. */
  60292. private getFloat32ArrayFromArrayBuffer;
  60293. /**
  60294. * Get the current class name of the texture useful for serialization or dynamic coding.
  60295. * @returns "EquiRectangularCubeTexture"
  60296. */
  60297. getClassName(): string;
  60298. /**
  60299. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60300. * @returns A clone of the current EquiRectangularCubeTexture.
  60301. */
  60302. clone(): EquiRectangularCubeTexture;
  60303. }
  60304. }
  60305. declare module BABYLON {
  60306. /**
  60307. * Defines the options related to the creation of an HtmlElementTexture
  60308. */
  60309. export interface IHtmlElementTextureOptions {
  60310. /**
  60311. * Defines wether mip maps should be created or not.
  60312. */
  60313. generateMipMaps?: boolean;
  60314. /**
  60315. * Defines the sampling mode of the texture.
  60316. */
  60317. samplingMode?: number;
  60318. /**
  60319. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60320. */
  60321. engine: Nullable<ThinEngine>;
  60322. /**
  60323. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60324. */
  60325. scene: Nullable<Scene>;
  60326. }
  60327. /**
  60328. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60329. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60330. * is automatically managed.
  60331. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60332. * in your application.
  60333. *
  60334. * As the update is not automatic, you need to call them manually.
  60335. */
  60336. export class HtmlElementTexture extends BaseTexture {
  60337. /**
  60338. * The texture URL.
  60339. */
  60340. element: HTMLVideoElement | HTMLCanvasElement;
  60341. private static readonly DefaultOptions;
  60342. private _textureMatrix;
  60343. private _isVideo;
  60344. private _generateMipMaps;
  60345. private _samplingMode;
  60346. /**
  60347. * Instantiates a HtmlElementTexture from the following parameters.
  60348. *
  60349. * @param name Defines the name of the texture
  60350. * @param element Defines the video or canvas the texture is filled with
  60351. * @param options Defines the other none mandatory texture creation options
  60352. */
  60353. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60354. private _createInternalTexture;
  60355. /**
  60356. * Returns the texture matrix used in most of the material.
  60357. */
  60358. getTextureMatrix(): Matrix;
  60359. /**
  60360. * Updates the content of the texture.
  60361. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60362. */
  60363. update(invertY?: Nullable<boolean>): void;
  60364. }
  60365. }
  60366. declare module BABYLON {
  60367. /**
  60368. * Based on jsTGALoader - Javascript loader for TGA file
  60369. * By Vincent Thibault
  60370. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60371. */
  60372. export class TGATools {
  60373. private static _TYPE_INDEXED;
  60374. private static _TYPE_RGB;
  60375. private static _TYPE_GREY;
  60376. private static _TYPE_RLE_INDEXED;
  60377. private static _TYPE_RLE_RGB;
  60378. private static _TYPE_RLE_GREY;
  60379. private static _ORIGIN_MASK;
  60380. private static _ORIGIN_SHIFT;
  60381. private static _ORIGIN_BL;
  60382. private static _ORIGIN_BR;
  60383. private static _ORIGIN_UL;
  60384. private static _ORIGIN_UR;
  60385. /**
  60386. * Gets the header of a TGA file
  60387. * @param data defines the TGA data
  60388. * @returns the header
  60389. */
  60390. static GetTGAHeader(data: Uint8Array): any;
  60391. /**
  60392. * Uploads TGA content to a Babylon Texture
  60393. * @hidden
  60394. */
  60395. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60396. /** @hidden */
  60397. 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;
  60398. /** @hidden */
  60399. 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;
  60400. /** @hidden */
  60401. 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;
  60402. /** @hidden */
  60403. 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;
  60404. /** @hidden */
  60405. 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;
  60406. /** @hidden */
  60407. 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;
  60408. }
  60409. }
  60410. declare module BABYLON {
  60411. /**
  60412. * Implementation of the TGA Texture Loader.
  60413. * @hidden
  60414. */
  60415. export class _TGATextureLoader implements IInternalTextureLoader {
  60416. /**
  60417. * Defines wether the loader supports cascade loading the different faces.
  60418. */
  60419. readonly supportCascades: boolean;
  60420. /**
  60421. * This returns if the loader support the current file information.
  60422. * @param extension defines the file extension of the file being loaded
  60423. * @returns true if the loader can load the specified file
  60424. */
  60425. canLoad(extension: string): boolean;
  60426. /**
  60427. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60428. * @param data contains the texture data
  60429. * @param texture defines the BabylonJS internal texture
  60430. * @param createPolynomials will be true if polynomials have been requested
  60431. * @param onLoad defines the callback to trigger once the texture is ready
  60432. * @param onError defines the callback to trigger in case of error
  60433. */
  60434. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60435. /**
  60436. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60437. * @param data contains the texture data
  60438. * @param texture defines the BabylonJS internal texture
  60439. * @param callback defines the method to call once ready to upload
  60440. */
  60441. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60442. }
  60443. }
  60444. declare module BABYLON {
  60445. /**
  60446. * Info about the .basis files
  60447. */
  60448. class BasisFileInfo {
  60449. /**
  60450. * If the file has alpha
  60451. */
  60452. hasAlpha: boolean;
  60453. /**
  60454. * Info about each image of the basis file
  60455. */
  60456. images: Array<{
  60457. levels: Array<{
  60458. width: number;
  60459. height: number;
  60460. transcodedPixels: ArrayBufferView;
  60461. }>;
  60462. }>;
  60463. }
  60464. /**
  60465. * Result of transcoding a basis file
  60466. */
  60467. class TranscodeResult {
  60468. /**
  60469. * Info about the .basis file
  60470. */
  60471. fileInfo: BasisFileInfo;
  60472. /**
  60473. * Format to use when loading the file
  60474. */
  60475. format: number;
  60476. }
  60477. /**
  60478. * Configuration options for the Basis transcoder
  60479. */
  60480. export class BasisTranscodeConfiguration {
  60481. /**
  60482. * Supported compression formats used to determine the supported output format of the transcoder
  60483. */
  60484. supportedCompressionFormats?: {
  60485. /**
  60486. * etc1 compression format
  60487. */
  60488. etc1?: boolean;
  60489. /**
  60490. * s3tc compression format
  60491. */
  60492. s3tc?: boolean;
  60493. /**
  60494. * pvrtc compression format
  60495. */
  60496. pvrtc?: boolean;
  60497. /**
  60498. * etc2 compression format
  60499. */
  60500. etc2?: boolean;
  60501. };
  60502. /**
  60503. * If mipmap levels should be loaded for transcoded images (Default: true)
  60504. */
  60505. loadMipmapLevels?: boolean;
  60506. /**
  60507. * Index of a single image to load (Default: all images)
  60508. */
  60509. loadSingleImage?: number;
  60510. }
  60511. /**
  60512. * Used to load .Basis files
  60513. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60514. */
  60515. export class BasisTools {
  60516. private static _IgnoreSupportedFormats;
  60517. /**
  60518. * URL to use when loading the basis transcoder
  60519. */
  60520. static JSModuleURL: string;
  60521. /**
  60522. * URL to use when loading the wasm module for the transcoder
  60523. */
  60524. static WasmModuleURL: string;
  60525. /**
  60526. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60527. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60528. * @returns internal format corresponding to the Basis format
  60529. */
  60530. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60531. private static _WorkerPromise;
  60532. private static _Worker;
  60533. private static _actionId;
  60534. private static _CreateWorkerAsync;
  60535. /**
  60536. * Transcodes a loaded image file to compressed pixel data
  60537. * @param data image data to transcode
  60538. * @param config configuration options for the transcoding
  60539. * @returns a promise resulting in the transcoded image
  60540. */
  60541. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60542. /**
  60543. * Loads a texture from the transcode result
  60544. * @param texture texture load to
  60545. * @param transcodeResult the result of transcoding the basis file to load from
  60546. */
  60547. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60548. }
  60549. }
  60550. declare module BABYLON {
  60551. /**
  60552. * Loader for .basis file format
  60553. */
  60554. export class _BasisTextureLoader implements IInternalTextureLoader {
  60555. /**
  60556. * Defines whether the loader supports cascade loading the different faces.
  60557. */
  60558. readonly supportCascades: boolean;
  60559. /**
  60560. * This returns if the loader support the current file information.
  60561. * @param extension defines the file extension of the file being loaded
  60562. * @returns true if the loader can load the specified file
  60563. */
  60564. canLoad(extension: string): boolean;
  60565. /**
  60566. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60567. * @param data contains the texture data
  60568. * @param texture defines the BabylonJS internal texture
  60569. * @param createPolynomials will be true if polynomials have been requested
  60570. * @param onLoad defines the callback to trigger once the texture is ready
  60571. * @param onError defines the callback to trigger in case of error
  60572. */
  60573. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60574. /**
  60575. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60576. * @param data contains the texture data
  60577. * @param texture defines the BabylonJS internal texture
  60578. * @param callback defines the method to call once ready to upload
  60579. */
  60580. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60581. }
  60582. }
  60583. declare module BABYLON {
  60584. /**
  60585. * Defines the basic options interface of a TexturePacker Frame
  60586. */
  60587. export interface ITexturePackerFrame {
  60588. /**
  60589. * The frame ID
  60590. */
  60591. id: number;
  60592. /**
  60593. * The frames Scale
  60594. */
  60595. scale: Vector2;
  60596. /**
  60597. * The Frames offset
  60598. */
  60599. offset: Vector2;
  60600. }
  60601. /**
  60602. * This is a support class for frame Data on texture packer sets.
  60603. */
  60604. export class TexturePackerFrame implements ITexturePackerFrame {
  60605. /**
  60606. * The frame ID
  60607. */
  60608. id: number;
  60609. /**
  60610. * The frames Scale
  60611. */
  60612. scale: Vector2;
  60613. /**
  60614. * The Frames offset
  60615. */
  60616. offset: Vector2;
  60617. /**
  60618. * Initializes a texture package frame.
  60619. * @param id The numerical frame identifier
  60620. * @param scale Scalar Vector2 for UV frame
  60621. * @param offset Vector2 for the frame position in UV units.
  60622. * @returns TexturePackerFrame
  60623. */
  60624. constructor(id: number, scale: Vector2, offset: Vector2);
  60625. }
  60626. }
  60627. declare module BABYLON {
  60628. /**
  60629. * Defines the basic options interface of a TexturePacker
  60630. */
  60631. export interface ITexturePackerOptions {
  60632. /**
  60633. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60634. */
  60635. map?: string[];
  60636. /**
  60637. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60638. */
  60639. uvsIn?: string;
  60640. /**
  60641. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60642. */
  60643. uvsOut?: string;
  60644. /**
  60645. * number representing the layout style. Defaults to LAYOUT_STRIP
  60646. */
  60647. layout?: number;
  60648. /**
  60649. * number of columns if using custom column count layout(2). This defaults to 4.
  60650. */
  60651. colnum?: number;
  60652. /**
  60653. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60654. */
  60655. updateInputMeshes?: boolean;
  60656. /**
  60657. * boolean flag to dispose all the source textures. Defaults to true.
  60658. */
  60659. disposeSources?: boolean;
  60660. /**
  60661. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60662. */
  60663. fillBlanks?: boolean;
  60664. /**
  60665. * string value representing the context fill style color. Defaults to 'black'.
  60666. */
  60667. customFillColor?: string;
  60668. /**
  60669. * Width and Height Value of each Frame in the TexturePacker Sets
  60670. */
  60671. frameSize?: number;
  60672. /**
  60673. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60674. */
  60675. paddingRatio?: number;
  60676. /**
  60677. * Number that declares the fill method for the padding gutter.
  60678. */
  60679. paddingMode?: number;
  60680. /**
  60681. * If in SUBUV_COLOR padding mode what color to use.
  60682. */
  60683. paddingColor?: Color3 | Color4;
  60684. }
  60685. /**
  60686. * Defines the basic interface of a TexturePacker JSON File
  60687. */
  60688. export interface ITexturePackerJSON {
  60689. /**
  60690. * The frame ID
  60691. */
  60692. name: string;
  60693. /**
  60694. * The base64 channel data
  60695. */
  60696. sets: any;
  60697. /**
  60698. * The options of the Packer
  60699. */
  60700. options: ITexturePackerOptions;
  60701. /**
  60702. * The frame data of the Packer
  60703. */
  60704. frames: Array<number>;
  60705. }
  60706. /**
  60707. * This is a support class that generates a series of packed texture sets.
  60708. * @see https://doc.babylonjs.com/babylon101/materials
  60709. */
  60710. export class TexturePacker {
  60711. /** Packer Layout Constant 0 */
  60712. static readonly LAYOUT_STRIP: number;
  60713. /** Packer Layout Constant 1 */
  60714. static readonly LAYOUT_POWER2: number;
  60715. /** Packer Layout Constant 2 */
  60716. static readonly LAYOUT_COLNUM: number;
  60717. /** Packer Layout Constant 0 */
  60718. static readonly SUBUV_WRAP: number;
  60719. /** Packer Layout Constant 1 */
  60720. static readonly SUBUV_EXTEND: number;
  60721. /** Packer Layout Constant 2 */
  60722. static readonly SUBUV_COLOR: number;
  60723. /** The Name of the Texture Package */
  60724. name: string;
  60725. /** The scene scope of the TexturePacker */
  60726. scene: Scene;
  60727. /** The Meshes to target */
  60728. meshes: AbstractMesh[];
  60729. /** Arguments passed with the Constructor */
  60730. options: ITexturePackerOptions;
  60731. /** The promise that is started upon initialization */
  60732. promise: Nullable<Promise<TexturePacker | string>>;
  60733. /** The Container object for the channel sets that are generated */
  60734. sets: object;
  60735. /** The Container array for the frames that are generated */
  60736. frames: TexturePackerFrame[];
  60737. /** The expected number of textures the system is parsing. */
  60738. private _expecting;
  60739. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  60740. private _paddingValue;
  60741. /**
  60742. * Initializes a texture package series from an array of meshes or a single mesh.
  60743. * @param name The name of the package
  60744. * @param meshes The target meshes to compose the package from
  60745. * @param options The arguments that texture packer should follow while building.
  60746. * @param scene The scene which the textures are scoped to.
  60747. * @returns TexturePacker
  60748. */
  60749. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  60750. /**
  60751. * Starts the package process
  60752. * @param resolve The promises resolution function
  60753. * @returns TexturePacker
  60754. */
  60755. private _createFrames;
  60756. /**
  60757. * Calculates the Size of the Channel Sets
  60758. * @returns Vector2
  60759. */
  60760. private _calculateSize;
  60761. /**
  60762. * Calculates the UV data for the frames.
  60763. * @param baseSize the base frameSize
  60764. * @param padding the base frame padding
  60765. * @param dtSize size of the Dynamic Texture for that channel
  60766. * @param dtUnits is 1/dtSize
  60767. * @param update flag to update the input meshes
  60768. */
  60769. private _calculateMeshUVFrames;
  60770. /**
  60771. * Calculates the frames Offset.
  60772. * @param index of the frame
  60773. * @returns Vector2
  60774. */
  60775. private _getFrameOffset;
  60776. /**
  60777. * Updates a Mesh to the frame data
  60778. * @param mesh that is the target
  60779. * @param frameID or the frame index
  60780. */
  60781. private _updateMeshUV;
  60782. /**
  60783. * Updates a Meshes materials to use the texture packer channels
  60784. * @param m is the mesh to target
  60785. * @param force all channels on the packer to be set.
  60786. */
  60787. private _updateTextureReferences;
  60788. /**
  60789. * Public method to set a Mesh to a frame
  60790. * @param m that is the target
  60791. * @param frameID or the frame index
  60792. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  60793. */
  60794. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  60795. /**
  60796. * Starts the async promise to compile the texture packer.
  60797. * @returns Promise<void>
  60798. */
  60799. processAsync(): Promise<void>;
  60800. /**
  60801. * Disposes all textures associated with this packer
  60802. */
  60803. dispose(): void;
  60804. /**
  60805. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  60806. * @param imageType is the image type to use.
  60807. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  60808. */
  60809. download(imageType?: string, quality?: number): void;
  60810. /**
  60811. * Public method to load a texturePacker JSON file.
  60812. * @param data of the JSON file in string format.
  60813. */
  60814. updateFromJSON(data: string): void;
  60815. }
  60816. }
  60817. declare module BABYLON {
  60818. /**
  60819. * 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.
  60820. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60821. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60822. */
  60823. export class CustomProceduralTexture extends ProceduralTexture {
  60824. private _animate;
  60825. private _time;
  60826. private _config;
  60827. private _texturePath;
  60828. /**
  60829. * Instantiates a new Custom Procedural Texture.
  60830. * 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.
  60831. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  60832. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  60833. * @param name Define the name of the texture
  60834. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  60835. * @param size Define the size of the texture to create
  60836. * @param scene Define the scene the texture belongs to
  60837. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  60838. * @param generateMipMaps Define if the texture should creates mip maps or not
  60839. */
  60840. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60841. private _loadJson;
  60842. /**
  60843. * Is the texture ready to be used ? (rendered at least once)
  60844. * @returns true if ready, otherwise, false.
  60845. */
  60846. isReady(): boolean;
  60847. /**
  60848. * Render the texture to its associated render target.
  60849. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  60850. */
  60851. render(useCameraPostProcess?: boolean): void;
  60852. /**
  60853. * Update the list of dependant textures samplers in the shader.
  60854. */
  60855. updateTextures(): void;
  60856. /**
  60857. * Update the uniform values of the procedural texture in the shader.
  60858. */
  60859. updateShaderUniforms(): void;
  60860. /**
  60861. * Define if the texture animates or not.
  60862. */
  60863. get animate(): boolean;
  60864. set animate(value: boolean);
  60865. }
  60866. }
  60867. declare module BABYLON {
  60868. /** @hidden */
  60869. export var noisePixelShader: {
  60870. name: string;
  60871. shader: string;
  60872. };
  60873. }
  60874. declare module BABYLON {
  60875. /**
  60876. * Class used to generate noise procedural textures
  60877. */
  60878. export class NoiseProceduralTexture extends ProceduralTexture {
  60879. private _time;
  60880. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  60881. brightness: number;
  60882. /** Defines the number of octaves to process */
  60883. octaves: number;
  60884. /** Defines the level of persistence (0.8 by default) */
  60885. persistence: number;
  60886. /** Gets or sets animation speed factor (default is 1) */
  60887. animationSpeedFactor: number;
  60888. /**
  60889. * Creates a new NoiseProceduralTexture
  60890. * @param name defines the name fo the texture
  60891. * @param size defines the size of the texture (default is 256)
  60892. * @param scene defines the hosting scene
  60893. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  60894. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  60895. */
  60896. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  60897. private _updateShaderUniforms;
  60898. protected _getDefines(): string;
  60899. /** Generate the current state of the procedural texture */
  60900. render(useCameraPostProcess?: boolean): void;
  60901. /**
  60902. * Serializes this noise procedural texture
  60903. * @returns a serialized noise procedural texture object
  60904. */
  60905. serialize(): any;
  60906. /**
  60907. * Clone the texture.
  60908. * @returns the cloned texture
  60909. */
  60910. clone(): NoiseProceduralTexture;
  60911. /**
  60912. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  60913. * @param parsedTexture defines parsed texture data
  60914. * @param scene defines the current scene
  60915. * @param rootUrl defines the root URL containing noise procedural texture information
  60916. * @returns a parsed NoiseProceduralTexture
  60917. */
  60918. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  60919. }
  60920. }
  60921. declare module BABYLON {
  60922. /**
  60923. * Raw cube texture where the raw buffers are passed in
  60924. */
  60925. export class RawCubeTexture extends CubeTexture {
  60926. /**
  60927. * Creates a cube texture where the raw buffers are passed in.
  60928. * @param scene defines the scene the texture is attached to
  60929. * @param data defines the array of data to use to create each face
  60930. * @param size defines the size of the textures
  60931. * @param format defines the format of the data
  60932. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60933. * @param generateMipMaps defines if the engine should generate the mip levels
  60934. * @param invertY defines if data must be stored with Y axis inverted
  60935. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60936. * @param compression defines the compression used (null by default)
  60937. */
  60938. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  60939. /**
  60940. * Updates the raw cube texture.
  60941. * @param data defines the data to store
  60942. * @param format defines the data format
  60943. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60944. * @param invertY defines if data must be stored with Y axis inverted
  60945. * @param compression defines the compression used (null by default)
  60946. * @param level defines which level of the texture to update
  60947. */
  60948. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  60949. /**
  60950. * Updates a raw cube texture with RGBD encoded data.
  60951. * @param data defines the array of data [mipmap][face] to use to create each face
  60952. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60953. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60954. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60955. * @returns a promsie that resolves when the operation is complete
  60956. */
  60957. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  60958. /**
  60959. * Clones the raw cube texture.
  60960. * @return a new cube texture
  60961. */
  60962. clone(): CubeTexture;
  60963. /** @hidden */
  60964. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  60965. }
  60966. }
  60967. declare module BABYLON {
  60968. /**
  60969. * Class used to store 2D array textures containing user data
  60970. */
  60971. export class RawTexture2DArray extends Texture {
  60972. /** Gets or sets the texture format to use */
  60973. format: number;
  60974. /**
  60975. * Create a new RawTexture2DArray
  60976. * @param data defines the data of the texture
  60977. * @param width defines the width of the texture
  60978. * @param height defines the height of the texture
  60979. * @param depth defines the number of layers of the texture
  60980. * @param format defines the texture format to use
  60981. * @param scene defines the hosting scene
  60982. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60983. * @param invertY defines if texture must be stored with Y axis inverted
  60984. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60985. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60986. */
  60987. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  60988. /** Gets or sets the texture format to use */
  60989. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  60990. /**
  60991. * Update the texture with new data
  60992. * @param data defines the data to store in the texture
  60993. */
  60994. update(data: ArrayBufferView): void;
  60995. }
  60996. }
  60997. declare module BABYLON {
  60998. /**
  60999. * Class used to store 3D textures containing user data
  61000. */
  61001. export class RawTexture3D extends Texture {
  61002. /** Gets or sets the texture format to use */
  61003. format: number;
  61004. /**
  61005. * Create a new RawTexture3D
  61006. * @param data defines the data of the texture
  61007. * @param width defines the width of the texture
  61008. * @param height defines the height of the texture
  61009. * @param depth defines the depth of the texture
  61010. * @param format defines the texture format to use
  61011. * @param scene defines the hosting scene
  61012. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61013. * @param invertY defines if texture must be stored with Y axis inverted
  61014. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61015. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61016. */
  61017. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61018. /** Gets or sets the texture format to use */
  61019. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61020. /**
  61021. * Update the texture with new data
  61022. * @param data defines the data to store in the texture
  61023. */
  61024. update(data: ArrayBufferView): void;
  61025. }
  61026. }
  61027. declare module BABYLON {
  61028. /**
  61029. * Creates a refraction texture used by refraction channel of the standard material.
  61030. * It is like a mirror but to see through a material.
  61031. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61032. */
  61033. export class RefractionTexture extends RenderTargetTexture {
  61034. /**
  61035. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61036. * 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.
  61037. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61038. */
  61039. refractionPlane: Plane;
  61040. /**
  61041. * Define how deep under the surface we should see.
  61042. */
  61043. depth: number;
  61044. /**
  61045. * Creates a refraction texture used by refraction channel of the standard material.
  61046. * It is like a mirror but to see through a material.
  61047. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61048. * @param name Define the texture name
  61049. * @param size Define the size of the underlying texture
  61050. * @param scene Define the scene the refraction belongs to
  61051. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61052. */
  61053. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61054. /**
  61055. * Clone the refraction texture.
  61056. * @returns the cloned texture
  61057. */
  61058. clone(): RefractionTexture;
  61059. /**
  61060. * Serialize the texture to a JSON representation you could use in Parse later on
  61061. * @returns the serialized JSON representation
  61062. */
  61063. serialize(): any;
  61064. }
  61065. }
  61066. declare module BABYLON {
  61067. /**
  61068. * Block used to add support for vertex skinning (bones)
  61069. */
  61070. export class BonesBlock extends NodeMaterialBlock {
  61071. /**
  61072. * Creates a new BonesBlock
  61073. * @param name defines the block name
  61074. */
  61075. constructor(name: string);
  61076. /**
  61077. * Initialize the block and prepare the context for build
  61078. * @param state defines the state that will be used for the build
  61079. */
  61080. initialize(state: NodeMaterialBuildState): void;
  61081. /**
  61082. * Gets the current class name
  61083. * @returns the class name
  61084. */
  61085. getClassName(): string;
  61086. /**
  61087. * Gets the matrix indices input component
  61088. */
  61089. get matricesIndices(): NodeMaterialConnectionPoint;
  61090. /**
  61091. * Gets the matrix weights input component
  61092. */
  61093. get matricesWeights(): NodeMaterialConnectionPoint;
  61094. /**
  61095. * Gets the extra matrix indices input component
  61096. */
  61097. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61098. /**
  61099. * Gets the extra matrix weights input component
  61100. */
  61101. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61102. /**
  61103. * Gets the world input component
  61104. */
  61105. get world(): NodeMaterialConnectionPoint;
  61106. /**
  61107. * Gets the output component
  61108. */
  61109. get output(): NodeMaterialConnectionPoint;
  61110. autoConfigure(material: NodeMaterial): void;
  61111. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61112. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61114. protected _buildBlock(state: NodeMaterialBuildState): this;
  61115. }
  61116. }
  61117. declare module BABYLON {
  61118. /**
  61119. * Block used to add support for instances
  61120. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61121. */
  61122. export class InstancesBlock extends NodeMaterialBlock {
  61123. /**
  61124. * Creates a new InstancesBlock
  61125. * @param name defines the block name
  61126. */
  61127. constructor(name: string);
  61128. /**
  61129. * Gets the current class name
  61130. * @returns the class name
  61131. */
  61132. getClassName(): string;
  61133. /**
  61134. * Gets the first world row input component
  61135. */
  61136. get world0(): NodeMaterialConnectionPoint;
  61137. /**
  61138. * Gets the second world row input component
  61139. */
  61140. get world1(): NodeMaterialConnectionPoint;
  61141. /**
  61142. * Gets the third world row input component
  61143. */
  61144. get world2(): NodeMaterialConnectionPoint;
  61145. /**
  61146. * Gets the forth world row input component
  61147. */
  61148. get world3(): NodeMaterialConnectionPoint;
  61149. /**
  61150. * Gets the world input component
  61151. */
  61152. get world(): NodeMaterialConnectionPoint;
  61153. /**
  61154. * Gets the output component
  61155. */
  61156. get output(): NodeMaterialConnectionPoint;
  61157. /**
  61158. * Gets the isntanceID component
  61159. */
  61160. get instanceID(): NodeMaterialConnectionPoint;
  61161. autoConfigure(material: NodeMaterial): void;
  61162. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61163. protected _buildBlock(state: NodeMaterialBuildState): this;
  61164. }
  61165. }
  61166. declare module BABYLON {
  61167. /**
  61168. * Block used to add morph targets support to vertex shader
  61169. */
  61170. export class MorphTargetsBlock extends NodeMaterialBlock {
  61171. private _repeatableContentAnchor;
  61172. /**
  61173. * Create a new MorphTargetsBlock
  61174. * @param name defines the block name
  61175. */
  61176. constructor(name: string);
  61177. /**
  61178. * Gets the current class name
  61179. * @returns the class name
  61180. */
  61181. getClassName(): string;
  61182. /**
  61183. * Gets the position input component
  61184. */
  61185. get position(): NodeMaterialConnectionPoint;
  61186. /**
  61187. * Gets the normal input component
  61188. */
  61189. get normal(): NodeMaterialConnectionPoint;
  61190. /**
  61191. * Gets the tangent input component
  61192. */
  61193. get tangent(): NodeMaterialConnectionPoint;
  61194. /**
  61195. * Gets the tangent input component
  61196. */
  61197. get uv(): NodeMaterialConnectionPoint;
  61198. /**
  61199. * Gets the position output component
  61200. */
  61201. get positionOutput(): NodeMaterialConnectionPoint;
  61202. /**
  61203. * Gets the normal output component
  61204. */
  61205. get normalOutput(): NodeMaterialConnectionPoint;
  61206. /**
  61207. * Gets the tangent output component
  61208. */
  61209. get tangentOutput(): NodeMaterialConnectionPoint;
  61210. /**
  61211. * Gets the tangent output component
  61212. */
  61213. get uvOutput(): NodeMaterialConnectionPoint;
  61214. initialize(state: NodeMaterialBuildState): void;
  61215. autoConfigure(material: NodeMaterial): void;
  61216. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61217. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61218. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61219. protected _buildBlock(state: NodeMaterialBuildState): this;
  61220. }
  61221. }
  61222. declare module BABYLON {
  61223. /**
  61224. * Block used to get data information from a light
  61225. */
  61226. export class LightInformationBlock extends NodeMaterialBlock {
  61227. private _lightDataUniformName;
  61228. private _lightColorUniformName;
  61229. private _lightTypeDefineName;
  61230. /**
  61231. * Gets or sets the light associated with this block
  61232. */
  61233. light: Nullable<Light>;
  61234. /**
  61235. * Creates a new LightInformationBlock
  61236. * @param name defines the block name
  61237. */
  61238. constructor(name: string);
  61239. /**
  61240. * Gets the current class name
  61241. * @returns the class name
  61242. */
  61243. getClassName(): string;
  61244. /**
  61245. * Gets the world position input component
  61246. */
  61247. get worldPosition(): NodeMaterialConnectionPoint;
  61248. /**
  61249. * Gets the direction output component
  61250. */
  61251. get direction(): NodeMaterialConnectionPoint;
  61252. /**
  61253. * Gets the direction output component
  61254. */
  61255. get color(): NodeMaterialConnectionPoint;
  61256. /**
  61257. * Gets the direction output component
  61258. */
  61259. get intensity(): NodeMaterialConnectionPoint;
  61260. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61261. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61262. protected _buildBlock(state: NodeMaterialBuildState): this;
  61263. serialize(): any;
  61264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61265. }
  61266. }
  61267. declare module BABYLON {
  61268. /**
  61269. * Block used to add image processing support to fragment shader
  61270. */
  61271. export class ImageProcessingBlock extends NodeMaterialBlock {
  61272. /**
  61273. * Create a new ImageProcessingBlock
  61274. * @param name defines the block name
  61275. */
  61276. constructor(name: string);
  61277. /**
  61278. * Gets the current class name
  61279. * @returns the class name
  61280. */
  61281. getClassName(): string;
  61282. /**
  61283. * Gets the color input component
  61284. */
  61285. get color(): NodeMaterialConnectionPoint;
  61286. /**
  61287. * Gets the output component
  61288. */
  61289. get output(): NodeMaterialConnectionPoint;
  61290. /**
  61291. * Initialize the block and prepare the context for build
  61292. * @param state defines the state that will be used for the build
  61293. */
  61294. initialize(state: NodeMaterialBuildState): void;
  61295. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61297. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61298. protected _buildBlock(state: NodeMaterialBuildState): this;
  61299. }
  61300. }
  61301. declare module BABYLON {
  61302. /**
  61303. * Block used to pertub normals based on a normal map
  61304. */
  61305. export class PerturbNormalBlock extends NodeMaterialBlock {
  61306. private _tangentSpaceParameterName;
  61307. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61308. invertX: boolean;
  61309. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61310. invertY: boolean;
  61311. /**
  61312. * Create a new PerturbNormalBlock
  61313. * @param name defines the block name
  61314. */
  61315. constructor(name: string);
  61316. /**
  61317. * Gets the current class name
  61318. * @returns the class name
  61319. */
  61320. getClassName(): string;
  61321. /**
  61322. * Gets the world position input component
  61323. */
  61324. get worldPosition(): NodeMaterialConnectionPoint;
  61325. /**
  61326. * Gets the world normal input component
  61327. */
  61328. get worldNormal(): NodeMaterialConnectionPoint;
  61329. /**
  61330. * Gets the world tangent input component
  61331. */
  61332. get worldTangent(): NodeMaterialConnectionPoint;
  61333. /**
  61334. * Gets the uv input component
  61335. */
  61336. get uv(): NodeMaterialConnectionPoint;
  61337. /**
  61338. * Gets the normal map color input component
  61339. */
  61340. get normalMapColor(): NodeMaterialConnectionPoint;
  61341. /**
  61342. * Gets the strength input component
  61343. */
  61344. get strength(): NodeMaterialConnectionPoint;
  61345. /**
  61346. * Gets the output component
  61347. */
  61348. get output(): NodeMaterialConnectionPoint;
  61349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61350. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61351. autoConfigure(material: NodeMaterial): void;
  61352. protected _buildBlock(state: NodeMaterialBuildState): this;
  61353. protected _dumpPropertiesCode(): string;
  61354. serialize(): any;
  61355. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61356. }
  61357. }
  61358. declare module BABYLON {
  61359. /**
  61360. * Block used to discard a pixel if a value is smaller than a cutoff
  61361. */
  61362. export class DiscardBlock extends NodeMaterialBlock {
  61363. /**
  61364. * Create a new DiscardBlock
  61365. * @param name defines the block name
  61366. */
  61367. constructor(name: string);
  61368. /**
  61369. * Gets the current class name
  61370. * @returns the class name
  61371. */
  61372. getClassName(): string;
  61373. /**
  61374. * Gets the color input component
  61375. */
  61376. get value(): NodeMaterialConnectionPoint;
  61377. /**
  61378. * Gets the cutoff input component
  61379. */
  61380. get cutoff(): NodeMaterialConnectionPoint;
  61381. protected _buildBlock(state: NodeMaterialBuildState): this;
  61382. }
  61383. }
  61384. declare module BABYLON {
  61385. /**
  61386. * Block used to test if the fragment shader is front facing
  61387. */
  61388. export class FrontFacingBlock extends NodeMaterialBlock {
  61389. /**
  61390. * Creates a new FrontFacingBlock
  61391. * @param name defines the block name
  61392. */
  61393. constructor(name: string);
  61394. /**
  61395. * Gets the current class name
  61396. * @returns the class name
  61397. */
  61398. getClassName(): string;
  61399. /**
  61400. * Gets the output component
  61401. */
  61402. get output(): NodeMaterialConnectionPoint;
  61403. protected _buildBlock(state: NodeMaterialBuildState): this;
  61404. }
  61405. }
  61406. declare module BABYLON {
  61407. /**
  61408. * Block used to get the derivative value on x and y of a given input
  61409. */
  61410. export class DerivativeBlock extends NodeMaterialBlock {
  61411. /**
  61412. * Create a new DerivativeBlock
  61413. * @param name defines the block name
  61414. */
  61415. constructor(name: string);
  61416. /**
  61417. * Gets the current class name
  61418. * @returns the class name
  61419. */
  61420. getClassName(): string;
  61421. /**
  61422. * Gets the input component
  61423. */
  61424. get input(): NodeMaterialConnectionPoint;
  61425. /**
  61426. * Gets the derivative output on x
  61427. */
  61428. get dx(): NodeMaterialConnectionPoint;
  61429. /**
  61430. * Gets the derivative output on y
  61431. */
  61432. get dy(): NodeMaterialConnectionPoint;
  61433. protected _buildBlock(state: NodeMaterialBuildState): this;
  61434. }
  61435. }
  61436. declare module BABYLON {
  61437. /**
  61438. * Block used to make gl_FragCoord available
  61439. */
  61440. export class FragCoordBlock extends NodeMaterialBlock {
  61441. /**
  61442. * Creates a new FragCoordBlock
  61443. * @param name defines the block name
  61444. */
  61445. constructor(name: string);
  61446. /**
  61447. * Gets the current class name
  61448. * @returns the class name
  61449. */
  61450. getClassName(): string;
  61451. /**
  61452. * Gets the xy component
  61453. */
  61454. get xy(): NodeMaterialConnectionPoint;
  61455. /**
  61456. * Gets the xyz component
  61457. */
  61458. get xyz(): NodeMaterialConnectionPoint;
  61459. /**
  61460. * Gets the xyzw component
  61461. */
  61462. get xyzw(): NodeMaterialConnectionPoint;
  61463. /**
  61464. * Gets the x component
  61465. */
  61466. get x(): NodeMaterialConnectionPoint;
  61467. /**
  61468. * Gets the y component
  61469. */
  61470. get y(): NodeMaterialConnectionPoint;
  61471. /**
  61472. * Gets the z component
  61473. */
  61474. get z(): NodeMaterialConnectionPoint;
  61475. /**
  61476. * Gets the w component
  61477. */
  61478. get output(): NodeMaterialConnectionPoint;
  61479. protected writeOutputs(state: NodeMaterialBuildState): string;
  61480. protected _buildBlock(state: NodeMaterialBuildState): this;
  61481. }
  61482. }
  61483. declare module BABYLON {
  61484. /**
  61485. * Block used to get the screen sizes
  61486. */
  61487. export class ScreenSizeBlock extends NodeMaterialBlock {
  61488. private _varName;
  61489. private _scene;
  61490. /**
  61491. * Creates a new ScreenSizeBlock
  61492. * @param name defines the block name
  61493. */
  61494. constructor(name: string);
  61495. /**
  61496. * Gets the current class name
  61497. * @returns the class name
  61498. */
  61499. getClassName(): string;
  61500. /**
  61501. * Gets the xy component
  61502. */
  61503. get xy(): NodeMaterialConnectionPoint;
  61504. /**
  61505. * Gets the x component
  61506. */
  61507. get x(): NodeMaterialConnectionPoint;
  61508. /**
  61509. * Gets the y component
  61510. */
  61511. get y(): NodeMaterialConnectionPoint;
  61512. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61513. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61514. protected _buildBlock(state: NodeMaterialBuildState): this;
  61515. }
  61516. }
  61517. declare module BABYLON {
  61518. /**
  61519. * Block used to add support for scene fog
  61520. */
  61521. export class FogBlock extends NodeMaterialBlock {
  61522. private _fogDistanceName;
  61523. private _fogParameters;
  61524. /**
  61525. * Create a new FogBlock
  61526. * @param name defines the block name
  61527. */
  61528. constructor(name: string);
  61529. /**
  61530. * Gets the current class name
  61531. * @returns the class name
  61532. */
  61533. getClassName(): string;
  61534. /**
  61535. * Gets the world position input component
  61536. */
  61537. get worldPosition(): NodeMaterialConnectionPoint;
  61538. /**
  61539. * Gets the view input component
  61540. */
  61541. get view(): NodeMaterialConnectionPoint;
  61542. /**
  61543. * Gets the color input component
  61544. */
  61545. get input(): NodeMaterialConnectionPoint;
  61546. /**
  61547. * Gets the fog color input component
  61548. */
  61549. get fogColor(): NodeMaterialConnectionPoint;
  61550. /**
  61551. * Gets the output component
  61552. */
  61553. get output(): NodeMaterialConnectionPoint;
  61554. autoConfigure(material: NodeMaterial): void;
  61555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61556. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61557. protected _buildBlock(state: NodeMaterialBuildState): this;
  61558. }
  61559. }
  61560. declare module BABYLON {
  61561. /**
  61562. * Block used to add light in the fragment shader
  61563. */
  61564. export class LightBlock extends NodeMaterialBlock {
  61565. private _lightId;
  61566. /**
  61567. * Gets or sets the light associated with this block
  61568. */
  61569. light: Nullable<Light>;
  61570. /**
  61571. * Create a new LightBlock
  61572. * @param name defines the block name
  61573. */
  61574. constructor(name: string);
  61575. /**
  61576. * Gets the current class name
  61577. * @returns the class name
  61578. */
  61579. getClassName(): string;
  61580. /**
  61581. * Gets the world position input component
  61582. */
  61583. get worldPosition(): NodeMaterialConnectionPoint;
  61584. /**
  61585. * Gets the world normal input component
  61586. */
  61587. get worldNormal(): NodeMaterialConnectionPoint;
  61588. /**
  61589. * Gets the camera (or eye) position component
  61590. */
  61591. get cameraPosition(): NodeMaterialConnectionPoint;
  61592. /**
  61593. * Gets the glossiness component
  61594. */
  61595. get glossiness(): NodeMaterialConnectionPoint;
  61596. /**
  61597. * Gets the glossinness power component
  61598. */
  61599. get glossPower(): NodeMaterialConnectionPoint;
  61600. /**
  61601. * Gets the diffuse color component
  61602. */
  61603. get diffuseColor(): NodeMaterialConnectionPoint;
  61604. /**
  61605. * Gets the specular color component
  61606. */
  61607. get specularColor(): NodeMaterialConnectionPoint;
  61608. /**
  61609. * Gets the diffuse output component
  61610. */
  61611. get diffuseOutput(): NodeMaterialConnectionPoint;
  61612. /**
  61613. * Gets the specular output component
  61614. */
  61615. get specularOutput(): NodeMaterialConnectionPoint;
  61616. /**
  61617. * Gets the shadow output component
  61618. */
  61619. get shadow(): NodeMaterialConnectionPoint;
  61620. autoConfigure(material: NodeMaterial): void;
  61621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61622. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61623. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61624. private _injectVertexCode;
  61625. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61626. serialize(): any;
  61627. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61628. }
  61629. }
  61630. declare module BABYLON {
  61631. /**
  61632. * Block used to read a reflection texture from a sampler
  61633. */
  61634. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61635. /**
  61636. * Create a new ReflectionTextureBlock
  61637. * @param name defines the block name
  61638. */
  61639. constructor(name: string);
  61640. /**
  61641. * Gets the current class name
  61642. * @returns the class name
  61643. */
  61644. getClassName(): string;
  61645. /**
  61646. * Gets the world position input component
  61647. */
  61648. get position(): NodeMaterialConnectionPoint;
  61649. /**
  61650. * Gets the world position input component
  61651. */
  61652. get worldPosition(): NodeMaterialConnectionPoint;
  61653. /**
  61654. * Gets the world normal input component
  61655. */
  61656. get worldNormal(): NodeMaterialConnectionPoint;
  61657. /**
  61658. * Gets the world input component
  61659. */
  61660. get world(): NodeMaterialConnectionPoint;
  61661. /**
  61662. * Gets the camera (or eye) position component
  61663. */
  61664. get cameraPosition(): NodeMaterialConnectionPoint;
  61665. /**
  61666. * Gets the view input component
  61667. */
  61668. get view(): NodeMaterialConnectionPoint;
  61669. /**
  61670. * Gets the rgb output component
  61671. */
  61672. get rgb(): NodeMaterialConnectionPoint;
  61673. /**
  61674. * Gets the r output component
  61675. */
  61676. get r(): NodeMaterialConnectionPoint;
  61677. /**
  61678. * Gets the g output component
  61679. */
  61680. get g(): NodeMaterialConnectionPoint;
  61681. /**
  61682. * Gets the b output component
  61683. */
  61684. get b(): NodeMaterialConnectionPoint;
  61685. autoConfigure(material: NodeMaterial): void;
  61686. protected _buildBlock(state: NodeMaterialBuildState): this;
  61687. }
  61688. }
  61689. declare module BABYLON {
  61690. /**
  61691. * Block used to add 2 vectors
  61692. */
  61693. export class AddBlock extends NodeMaterialBlock {
  61694. /**
  61695. * Creates a new AddBlock
  61696. * @param name defines the block name
  61697. */
  61698. constructor(name: string);
  61699. /**
  61700. * Gets the current class name
  61701. * @returns the class name
  61702. */
  61703. getClassName(): string;
  61704. /**
  61705. * Gets the left operand input component
  61706. */
  61707. get left(): NodeMaterialConnectionPoint;
  61708. /**
  61709. * Gets the right operand input component
  61710. */
  61711. get right(): NodeMaterialConnectionPoint;
  61712. /**
  61713. * Gets the output component
  61714. */
  61715. get output(): NodeMaterialConnectionPoint;
  61716. protected _buildBlock(state: NodeMaterialBuildState): this;
  61717. }
  61718. }
  61719. declare module BABYLON {
  61720. /**
  61721. * Block used to scale a vector by a float
  61722. */
  61723. export class ScaleBlock extends NodeMaterialBlock {
  61724. /**
  61725. * Creates a new ScaleBlock
  61726. * @param name defines the block name
  61727. */
  61728. constructor(name: string);
  61729. /**
  61730. * Gets the current class name
  61731. * @returns the class name
  61732. */
  61733. getClassName(): string;
  61734. /**
  61735. * Gets the input component
  61736. */
  61737. get input(): NodeMaterialConnectionPoint;
  61738. /**
  61739. * Gets the factor input component
  61740. */
  61741. get factor(): NodeMaterialConnectionPoint;
  61742. /**
  61743. * Gets the output component
  61744. */
  61745. get output(): NodeMaterialConnectionPoint;
  61746. protected _buildBlock(state: NodeMaterialBuildState): this;
  61747. }
  61748. }
  61749. declare module BABYLON {
  61750. /**
  61751. * Block used to clamp a float
  61752. */
  61753. export class ClampBlock extends NodeMaterialBlock {
  61754. /** Gets or sets the minimum range */
  61755. minimum: number;
  61756. /** Gets or sets the maximum range */
  61757. maximum: number;
  61758. /**
  61759. * Creates a new ClampBlock
  61760. * @param name defines the block name
  61761. */
  61762. constructor(name: string);
  61763. /**
  61764. * Gets the current class name
  61765. * @returns the class name
  61766. */
  61767. getClassName(): string;
  61768. /**
  61769. * Gets the value input component
  61770. */
  61771. get value(): NodeMaterialConnectionPoint;
  61772. /**
  61773. * Gets the output component
  61774. */
  61775. get output(): NodeMaterialConnectionPoint;
  61776. protected _buildBlock(state: NodeMaterialBuildState): this;
  61777. protected _dumpPropertiesCode(): string;
  61778. serialize(): any;
  61779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61780. }
  61781. }
  61782. declare module BABYLON {
  61783. /**
  61784. * Block used to apply a cross product between 2 vectors
  61785. */
  61786. export class CrossBlock extends NodeMaterialBlock {
  61787. /**
  61788. * Creates a new CrossBlock
  61789. * @param name defines the block name
  61790. */
  61791. constructor(name: string);
  61792. /**
  61793. * Gets the current class name
  61794. * @returns the class name
  61795. */
  61796. getClassName(): string;
  61797. /**
  61798. * Gets the left operand input component
  61799. */
  61800. get left(): NodeMaterialConnectionPoint;
  61801. /**
  61802. * Gets the right operand input component
  61803. */
  61804. get right(): NodeMaterialConnectionPoint;
  61805. /**
  61806. * Gets the output component
  61807. */
  61808. get output(): NodeMaterialConnectionPoint;
  61809. protected _buildBlock(state: NodeMaterialBuildState): this;
  61810. }
  61811. }
  61812. declare module BABYLON {
  61813. /**
  61814. * Block used to apply a dot product between 2 vectors
  61815. */
  61816. export class DotBlock extends NodeMaterialBlock {
  61817. /**
  61818. * Creates a new DotBlock
  61819. * @param name defines the block name
  61820. */
  61821. constructor(name: string);
  61822. /**
  61823. * Gets the current class name
  61824. * @returns the class name
  61825. */
  61826. getClassName(): string;
  61827. /**
  61828. * Gets the left operand input component
  61829. */
  61830. get left(): NodeMaterialConnectionPoint;
  61831. /**
  61832. * Gets the right operand input component
  61833. */
  61834. get right(): NodeMaterialConnectionPoint;
  61835. /**
  61836. * Gets the output component
  61837. */
  61838. get output(): NodeMaterialConnectionPoint;
  61839. protected _buildBlock(state: NodeMaterialBuildState): this;
  61840. }
  61841. }
  61842. declare module BABYLON {
  61843. /**
  61844. * Block used to normalize a vector
  61845. */
  61846. export class NormalizeBlock extends NodeMaterialBlock {
  61847. /**
  61848. * Creates a new NormalizeBlock
  61849. * @param name defines the block name
  61850. */
  61851. constructor(name: string);
  61852. /**
  61853. * Gets the current class name
  61854. * @returns the class name
  61855. */
  61856. getClassName(): string;
  61857. /**
  61858. * Gets the input component
  61859. */
  61860. get input(): NodeMaterialConnectionPoint;
  61861. /**
  61862. * Gets the output component
  61863. */
  61864. get output(): NodeMaterialConnectionPoint;
  61865. protected _buildBlock(state: NodeMaterialBuildState): this;
  61866. }
  61867. }
  61868. declare module BABYLON {
  61869. /**
  61870. * Operations supported by the Trigonometry block
  61871. */
  61872. export enum TrigonometryBlockOperations {
  61873. /** Cos */
  61874. Cos = 0,
  61875. /** Sin */
  61876. Sin = 1,
  61877. /** Abs */
  61878. Abs = 2,
  61879. /** Exp */
  61880. Exp = 3,
  61881. /** Exp2 */
  61882. Exp2 = 4,
  61883. /** Round */
  61884. Round = 5,
  61885. /** Floor */
  61886. Floor = 6,
  61887. /** Ceiling */
  61888. Ceiling = 7,
  61889. /** Square root */
  61890. Sqrt = 8,
  61891. /** Log */
  61892. Log = 9,
  61893. /** Tangent */
  61894. Tan = 10,
  61895. /** Arc tangent */
  61896. ArcTan = 11,
  61897. /** Arc cosinus */
  61898. ArcCos = 12,
  61899. /** Arc sinus */
  61900. ArcSin = 13,
  61901. /** Fraction */
  61902. Fract = 14,
  61903. /** Sign */
  61904. Sign = 15,
  61905. /** To radians (from degrees) */
  61906. Radians = 16,
  61907. /** To degrees (from radians) */
  61908. Degrees = 17
  61909. }
  61910. /**
  61911. * Block used to apply trigonometry operation to floats
  61912. */
  61913. export class TrigonometryBlock extends NodeMaterialBlock {
  61914. /**
  61915. * Gets or sets the operation applied by the block
  61916. */
  61917. operation: TrigonometryBlockOperations;
  61918. /**
  61919. * Creates a new TrigonometryBlock
  61920. * @param name defines the block name
  61921. */
  61922. constructor(name: string);
  61923. /**
  61924. * Gets the current class name
  61925. * @returns the class name
  61926. */
  61927. getClassName(): string;
  61928. /**
  61929. * Gets the input component
  61930. */
  61931. get input(): NodeMaterialConnectionPoint;
  61932. /**
  61933. * Gets the output component
  61934. */
  61935. get output(): NodeMaterialConnectionPoint;
  61936. protected _buildBlock(state: NodeMaterialBuildState): this;
  61937. serialize(): any;
  61938. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61939. protected _dumpPropertiesCode(): string;
  61940. }
  61941. }
  61942. declare module BABYLON {
  61943. /**
  61944. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61945. */
  61946. export class ColorMergerBlock extends NodeMaterialBlock {
  61947. /**
  61948. * Create a new ColorMergerBlock
  61949. * @param name defines the block name
  61950. */
  61951. constructor(name: string);
  61952. /**
  61953. * Gets the current class name
  61954. * @returns the class name
  61955. */
  61956. getClassName(): string;
  61957. /**
  61958. * Gets the rgb component (input)
  61959. */
  61960. get rgbIn(): NodeMaterialConnectionPoint;
  61961. /**
  61962. * Gets the r component (input)
  61963. */
  61964. get r(): NodeMaterialConnectionPoint;
  61965. /**
  61966. * Gets the g component (input)
  61967. */
  61968. get g(): NodeMaterialConnectionPoint;
  61969. /**
  61970. * Gets the b component (input)
  61971. */
  61972. get b(): NodeMaterialConnectionPoint;
  61973. /**
  61974. * Gets the a component (input)
  61975. */
  61976. get a(): NodeMaterialConnectionPoint;
  61977. /**
  61978. * Gets the rgba component (output)
  61979. */
  61980. get rgba(): NodeMaterialConnectionPoint;
  61981. /**
  61982. * Gets the rgb component (output)
  61983. */
  61984. get rgbOut(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the rgb component (output)
  61987. * @deprecated Please use rgbOut instead.
  61988. */
  61989. get rgb(): NodeMaterialConnectionPoint;
  61990. protected _buildBlock(state: NodeMaterialBuildState): this;
  61991. }
  61992. }
  61993. declare module BABYLON {
  61994. /**
  61995. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61996. */
  61997. export class VectorSplitterBlock extends NodeMaterialBlock {
  61998. /**
  61999. * Create a new VectorSplitterBlock
  62000. * @param name defines the block name
  62001. */
  62002. constructor(name: string);
  62003. /**
  62004. * Gets the current class name
  62005. * @returns the class name
  62006. */
  62007. getClassName(): string;
  62008. /**
  62009. * Gets the xyzw component (input)
  62010. */
  62011. get xyzw(): NodeMaterialConnectionPoint;
  62012. /**
  62013. * Gets the xyz component (input)
  62014. */
  62015. get xyzIn(): NodeMaterialConnectionPoint;
  62016. /**
  62017. * Gets the xy component (input)
  62018. */
  62019. get xyIn(): NodeMaterialConnectionPoint;
  62020. /**
  62021. * Gets the xyz component (output)
  62022. */
  62023. get xyzOut(): NodeMaterialConnectionPoint;
  62024. /**
  62025. * Gets the xy component (output)
  62026. */
  62027. get xyOut(): NodeMaterialConnectionPoint;
  62028. /**
  62029. * Gets the x component (output)
  62030. */
  62031. get x(): NodeMaterialConnectionPoint;
  62032. /**
  62033. * Gets the y component (output)
  62034. */
  62035. get y(): NodeMaterialConnectionPoint;
  62036. /**
  62037. * Gets the z component (output)
  62038. */
  62039. get z(): NodeMaterialConnectionPoint;
  62040. /**
  62041. * Gets the w component (output)
  62042. */
  62043. get w(): NodeMaterialConnectionPoint;
  62044. protected _inputRename(name: string): string;
  62045. protected _outputRename(name: string): string;
  62046. protected _buildBlock(state: NodeMaterialBuildState): this;
  62047. }
  62048. }
  62049. declare module BABYLON {
  62050. /**
  62051. * Block used to lerp between 2 values
  62052. */
  62053. export class LerpBlock extends NodeMaterialBlock {
  62054. /**
  62055. * Creates a new LerpBlock
  62056. * @param name defines the block name
  62057. */
  62058. constructor(name: string);
  62059. /**
  62060. * Gets the current class name
  62061. * @returns the class name
  62062. */
  62063. getClassName(): string;
  62064. /**
  62065. * Gets the left operand input component
  62066. */
  62067. get left(): NodeMaterialConnectionPoint;
  62068. /**
  62069. * Gets the right operand input component
  62070. */
  62071. get right(): NodeMaterialConnectionPoint;
  62072. /**
  62073. * Gets the gradient operand input component
  62074. */
  62075. get gradient(): NodeMaterialConnectionPoint;
  62076. /**
  62077. * Gets the output component
  62078. */
  62079. get output(): NodeMaterialConnectionPoint;
  62080. protected _buildBlock(state: NodeMaterialBuildState): this;
  62081. }
  62082. }
  62083. declare module BABYLON {
  62084. /**
  62085. * Block used to divide 2 vectors
  62086. */
  62087. export class DivideBlock extends NodeMaterialBlock {
  62088. /**
  62089. * Creates a new DivideBlock
  62090. * @param name defines the block name
  62091. */
  62092. constructor(name: string);
  62093. /**
  62094. * Gets the current class name
  62095. * @returns the class name
  62096. */
  62097. getClassName(): string;
  62098. /**
  62099. * Gets the left operand input component
  62100. */
  62101. get left(): NodeMaterialConnectionPoint;
  62102. /**
  62103. * Gets the right operand input component
  62104. */
  62105. get right(): NodeMaterialConnectionPoint;
  62106. /**
  62107. * Gets the output component
  62108. */
  62109. get output(): NodeMaterialConnectionPoint;
  62110. protected _buildBlock(state: NodeMaterialBuildState): this;
  62111. }
  62112. }
  62113. declare module BABYLON {
  62114. /**
  62115. * Block used to subtract 2 vectors
  62116. */
  62117. export class SubtractBlock extends NodeMaterialBlock {
  62118. /**
  62119. * Creates a new SubtractBlock
  62120. * @param name defines the block name
  62121. */
  62122. constructor(name: string);
  62123. /**
  62124. * Gets the current class name
  62125. * @returns the class name
  62126. */
  62127. getClassName(): string;
  62128. /**
  62129. * Gets the left operand input component
  62130. */
  62131. get left(): NodeMaterialConnectionPoint;
  62132. /**
  62133. * Gets the right operand input component
  62134. */
  62135. get right(): NodeMaterialConnectionPoint;
  62136. /**
  62137. * Gets the output component
  62138. */
  62139. get output(): NodeMaterialConnectionPoint;
  62140. protected _buildBlock(state: NodeMaterialBuildState): this;
  62141. }
  62142. }
  62143. declare module BABYLON {
  62144. /**
  62145. * Block used to step a value
  62146. */
  62147. export class StepBlock extends NodeMaterialBlock {
  62148. /**
  62149. * Creates a new StepBlock
  62150. * @param name defines the block name
  62151. */
  62152. constructor(name: string);
  62153. /**
  62154. * Gets the current class name
  62155. * @returns the class name
  62156. */
  62157. getClassName(): string;
  62158. /**
  62159. * Gets the value operand input component
  62160. */
  62161. get value(): NodeMaterialConnectionPoint;
  62162. /**
  62163. * Gets the edge operand input component
  62164. */
  62165. get edge(): NodeMaterialConnectionPoint;
  62166. /**
  62167. * Gets the output component
  62168. */
  62169. get output(): NodeMaterialConnectionPoint;
  62170. protected _buildBlock(state: NodeMaterialBuildState): this;
  62171. }
  62172. }
  62173. declare module BABYLON {
  62174. /**
  62175. * Block used to get the opposite (1 - x) of a value
  62176. */
  62177. export class OneMinusBlock extends NodeMaterialBlock {
  62178. /**
  62179. * Creates a new OneMinusBlock
  62180. * @param name defines the block name
  62181. */
  62182. constructor(name: string);
  62183. /**
  62184. * Gets the current class name
  62185. * @returns the class name
  62186. */
  62187. getClassName(): string;
  62188. /**
  62189. * Gets the input component
  62190. */
  62191. get input(): NodeMaterialConnectionPoint;
  62192. /**
  62193. * Gets the output component
  62194. */
  62195. get output(): NodeMaterialConnectionPoint;
  62196. protected _buildBlock(state: NodeMaterialBuildState): this;
  62197. }
  62198. }
  62199. declare module BABYLON {
  62200. /**
  62201. * Block used to get the view direction
  62202. */
  62203. export class ViewDirectionBlock extends NodeMaterialBlock {
  62204. /**
  62205. * Creates a new ViewDirectionBlock
  62206. * @param name defines the block name
  62207. */
  62208. constructor(name: string);
  62209. /**
  62210. * Gets the current class name
  62211. * @returns the class name
  62212. */
  62213. getClassName(): string;
  62214. /**
  62215. * Gets the world position component
  62216. */
  62217. get worldPosition(): NodeMaterialConnectionPoint;
  62218. /**
  62219. * Gets the camera position component
  62220. */
  62221. get cameraPosition(): NodeMaterialConnectionPoint;
  62222. /**
  62223. * Gets the output component
  62224. */
  62225. get output(): NodeMaterialConnectionPoint;
  62226. autoConfigure(material: NodeMaterial): void;
  62227. protected _buildBlock(state: NodeMaterialBuildState): this;
  62228. }
  62229. }
  62230. declare module BABYLON {
  62231. /**
  62232. * Block used to compute fresnel value
  62233. */
  62234. export class FresnelBlock extends NodeMaterialBlock {
  62235. /**
  62236. * Create a new FresnelBlock
  62237. * @param name defines the block name
  62238. */
  62239. constructor(name: string);
  62240. /**
  62241. * Gets the current class name
  62242. * @returns the class name
  62243. */
  62244. getClassName(): string;
  62245. /**
  62246. * Gets the world normal input component
  62247. */
  62248. get worldNormal(): NodeMaterialConnectionPoint;
  62249. /**
  62250. * Gets the view direction input component
  62251. */
  62252. get viewDirection(): NodeMaterialConnectionPoint;
  62253. /**
  62254. * Gets the bias input component
  62255. */
  62256. get bias(): NodeMaterialConnectionPoint;
  62257. /**
  62258. * Gets the camera (or eye) position component
  62259. */
  62260. get power(): NodeMaterialConnectionPoint;
  62261. /**
  62262. * Gets the fresnel output component
  62263. */
  62264. get fresnel(): NodeMaterialConnectionPoint;
  62265. autoConfigure(material: NodeMaterial): void;
  62266. protected _buildBlock(state: NodeMaterialBuildState): this;
  62267. }
  62268. }
  62269. declare module BABYLON {
  62270. /**
  62271. * Block used to get the max of 2 values
  62272. */
  62273. export class MaxBlock extends NodeMaterialBlock {
  62274. /**
  62275. * Creates a new MaxBlock
  62276. * @param name defines the block name
  62277. */
  62278. constructor(name: string);
  62279. /**
  62280. * Gets the current class name
  62281. * @returns the class name
  62282. */
  62283. getClassName(): string;
  62284. /**
  62285. * Gets the left operand input component
  62286. */
  62287. get left(): NodeMaterialConnectionPoint;
  62288. /**
  62289. * Gets the right operand input component
  62290. */
  62291. get right(): NodeMaterialConnectionPoint;
  62292. /**
  62293. * Gets the output component
  62294. */
  62295. get output(): NodeMaterialConnectionPoint;
  62296. protected _buildBlock(state: NodeMaterialBuildState): this;
  62297. }
  62298. }
  62299. declare module BABYLON {
  62300. /**
  62301. * Block used to get the min of 2 values
  62302. */
  62303. export class MinBlock extends NodeMaterialBlock {
  62304. /**
  62305. * Creates a new MinBlock
  62306. * @param name defines the block name
  62307. */
  62308. constructor(name: string);
  62309. /**
  62310. * Gets the current class name
  62311. * @returns the class name
  62312. */
  62313. getClassName(): string;
  62314. /**
  62315. * Gets the left operand input component
  62316. */
  62317. get left(): NodeMaterialConnectionPoint;
  62318. /**
  62319. * Gets the right operand input component
  62320. */
  62321. get right(): NodeMaterialConnectionPoint;
  62322. /**
  62323. * Gets the output component
  62324. */
  62325. get output(): NodeMaterialConnectionPoint;
  62326. protected _buildBlock(state: NodeMaterialBuildState): this;
  62327. }
  62328. }
  62329. declare module BABYLON {
  62330. /**
  62331. * Block used to get the distance between 2 values
  62332. */
  62333. export class DistanceBlock extends NodeMaterialBlock {
  62334. /**
  62335. * Creates a new DistanceBlock
  62336. * @param name defines the block name
  62337. */
  62338. constructor(name: string);
  62339. /**
  62340. * Gets the current class name
  62341. * @returns the class name
  62342. */
  62343. getClassName(): string;
  62344. /**
  62345. * Gets the left operand input component
  62346. */
  62347. get left(): NodeMaterialConnectionPoint;
  62348. /**
  62349. * Gets the right operand input component
  62350. */
  62351. get right(): NodeMaterialConnectionPoint;
  62352. /**
  62353. * Gets the output component
  62354. */
  62355. get output(): NodeMaterialConnectionPoint;
  62356. protected _buildBlock(state: NodeMaterialBuildState): this;
  62357. }
  62358. }
  62359. declare module BABYLON {
  62360. /**
  62361. * Block used to get the length of a vector
  62362. */
  62363. export class LengthBlock extends NodeMaterialBlock {
  62364. /**
  62365. * Creates a new LengthBlock
  62366. * @param name defines the block name
  62367. */
  62368. constructor(name: string);
  62369. /**
  62370. * Gets the current class name
  62371. * @returns the class name
  62372. */
  62373. getClassName(): string;
  62374. /**
  62375. * Gets the value input component
  62376. */
  62377. get value(): NodeMaterialConnectionPoint;
  62378. /**
  62379. * Gets the output component
  62380. */
  62381. get output(): NodeMaterialConnectionPoint;
  62382. protected _buildBlock(state: NodeMaterialBuildState): this;
  62383. }
  62384. }
  62385. declare module BABYLON {
  62386. /**
  62387. * Block used to get negative version of a value (i.e. x * -1)
  62388. */
  62389. export class NegateBlock extends NodeMaterialBlock {
  62390. /**
  62391. * Creates a new NegateBlock
  62392. * @param name defines the block name
  62393. */
  62394. constructor(name: string);
  62395. /**
  62396. * Gets the current class name
  62397. * @returns the class name
  62398. */
  62399. getClassName(): string;
  62400. /**
  62401. * Gets the value input component
  62402. */
  62403. get value(): NodeMaterialConnectionPoint;
  62404. /**
  62405. * Gets the output component
  62406. */
  62407. get output(): NodeMaterialConnectionPoint;
  62408. protected _buildBlock(state: NodeMaterialBuildState): this;
  62409. }
  62410. }
  62411. declare module BABYLON {
  62412. /**
  62413. * Block used to get the value of the first parameter raised to the power of the second
  62414. */
  62415. export class PowBlock extends NodeMaterialBlock {
  62416. /**
  62417. * Creates a new PowBlock
  62418. * @param name defines the block name
  62419. */
  62420. constructor(name: string);
  62421. /**
  62422. * Gets the current class name
  62423. * @returns the class name
  62424. */
  62425. getClassName(): string;
  62426. /**
  62427. * Gets the value operand input component
  62428. */
  62429. get value(): NodeMaterialConnectionPoint;
  62430. /**
  62431. * Gets the power operand input component
  62432. */
  62433. get power(): NodeMaterialConnectionPoint;
  62434. /**
  62435. * Gets the output component
  62436. */
  62437. get output(): NodeMaterialConnectionPoint;
  62438. protected _buildBlock(state: NodeMaterialBuildState): this;
  62439. }
  62440. }
  62441. declare module BABYLON {
  62442. /**
  62443. * Block used to get a random number
  62444. */
  62445. export class RandomNumberBlock extends NodeMaterialBlock {
  62446. /**
  62447. * Creates a new RandomNumberBlock
  62448. * @param name defines the block name
  62449. */
  62450. constructor(name: string);
  62451. /**
  62452. * Gets the current class name
  62453. * @returns the class name
  62454. */
  62455. getClassName(): string;
  62456. /**
  62457. * Gets the seed input component
  62458. */
  62459. get seed(): NodeMaterialConnectionPoint;
  62460. /**
  62461. * Gets the output component
  62462. */
  62463. get output(): NodeMaterialConnectionPoint;
  62464. protected _buildBlock(state: NodeMaterialBuildState): this;
  62465. }
  62466. }
  62467. declare module BABYLON {
  62468. /**
  62469. * Block used to compute arc tangent of 2 values
  62470. */
  62471. export class ArcTan2Block extends NodeMaterialBlock {
  62472. /**
  62473. * Creates a new ArcTan2Block
  62474. * @param name defines the block name
  62475. */
  62476. constructor(name: string);
  62477. /**
  62478. * Gets the current class name
  62479. * @returns the class name
  62480. */
  62481. getClassName(): string;
  62482. /**
  62483. * Gets the x operand input component
  62484. */
  62485. get x(): NodeMaterialConnectionPoint;
  62486. /**
  62487. * Gets the y operand input component
  62488. */
  62489. get y(): NodeMaterialConnectionPoint;
  62490. /**
  62491. * Gets the output component
  62492. */
  62493. get output(): NodeMaterialConnectionPoint;
  62494. protected _buildBlock(state: NodeMaterialBuildState): this;
  62495. }
  62496. }
  62497. declare module BABYLON {
  62498. /**
  62499. * Block used to smooth step a value
  62500. */
  62501. export class SmoothStepBlock extends NodeMaterialBlock {
  62502. /**
  62503. * Creates a new SmoothStepBlock
  62504. * @param name defines the block name
  62505. */
  62506. constructor(name: string);
  62507. /**
  62508. * Gets the current class name
  62509. * @returns the class name
  62510. */
  62511. getClassName(): string;
  62512. /**
  62513. * Gets the value operand input component
  62514. */
  62515. get value(): NodeMaterialConnectionPoint;
  62516. /**
  62517. * Gets the first edge operand input component
  62518. */
  62519. get edge0(): NodeMaterialConnectionPoint;
  62520. /**
  62521. * Gets the second edge operand input component
  62522. */
  62523. get edge1(): NodeMaterialConnectionPoint;
  62524. /**
  62525. * Gets the output component
  62526. */
  62527. get output(): NodeMaterialConnectionPoint;
  62528. protected _buildBlock(state: NodeMaterialBuildState): this;
  62529. }
  62530. }
  62531. declare module BABYLON {
  62532. /**
  62533. * Block used to get the reciprocal (1 / x) of a value
  62534. */
  62535. export class ReciprocalBlock extends NodeMaterialBlock {
  62536. /**
  62537. * Creates a new ReciprocalBlock
  62538. * @param name defines the block name
  62539. */
  62540. constructor(name: string);
  62541. /**
  62542. * Gets the current class name
  62543. * @returns the class name
  62544. */
  62545. getClassName(): string;
  62546. /**
  62547. * Gets the input component
  62548. */
  62549. get input(): NodeMaterialConnectionPoint;
  62550. /**
  62551. * Gets the output component
  62552. */
  62553. get output(): NodeMaterialConnectionPoint;
  62554. protected _buildBlock(state: NodeMaterialBuildState): this;
  62555. }
  62556. }
  62557. declare module BABYLON {
  62558. /**
  62559. * Block used to replace a color by another one
  62560. */
  62561. export class ReplaceColorBlock extends NodeMaterialBlock {
  62562. /**
  62563. * Creates a new ReplaceColorBlock
  62564. * @param name defines the block name
  62565. */
  62566. constructor(name: string);
  62567. /**
  62568. * Gets the current class name
  62569. * @returns the class name
  62570. */
  62571. getClassName(): string;
  62572. /**
  62573. * Gets the value input component
  62574. */
  62575. get value(): NodeMaterialConnectionPoint;
  62576. /**
  62577. * Gets the reference input component
  62578. */
  62579. get reference(): NodeMaterialConnectionPoint;
  62580. /**
  62581. * Gets the distance input component
  62582. */
  62583. get distance(): NodeMaterialConnectionPoint;
  62584. /**
  62585. * Gets the replacement input component
  62586. */
  62587. get replacement(): NodeMaterialConnectionPoint;
  62588. /**
  62589. * Gets the output component
  62590. */
  62591. get output(): NodeMaterialConnectionPoint;
  62592. protected _buildBlock(state: NodeMaterialBuildState): this;
  62593. }
  62594. }
  62595. declare module BABYLON {
  62596. /**
  62597. * Block used to posterize a value
  62598. * @see https://en.wikipedia.org/wiki/Posterization
  62599. */
  62600. export class PosterizeBlock extends NodeMaterialBlock {
  62601. /**
  62602. * Creates a new PosterizeBlock
  62603. * @param name defines the block name
  62604. */
  62605. constructor(name: string);
  62606. /**
  62607. * Gets the current class name
  62608. * @returns the class name
  62609. */
  62610. getClassName(): string;
  62611. /**
  62612. * Gets the value input component
  62613. */
  62614. get value(): NodeMaterialConnectionPoint;
  62615. /**
  62616. * Gets the steps input component
  62617. */
  62618. get steps(): NodeMaterialConnectionPoint;
  62619. /**
  62620. * Gets the output component
  62621. */
  62622. get output(): NodeMaterialConnectionPoint;
  62623. protected _buildBlock(state: NodeMaterialBuildState): this;
  62624. }
  62625. }
  62626. declare module BABYLON {
  62627. /**
  62628. * Operations supported by the Wave block
  62629. */
  62630. export enum WaveBlockKind {
  62631. /** SawTooth */
  62632. SawTooth = 0,
  62633. /** Square */
  62634. Square = 1,
  62635. /** Triangle */
  62636. Triangle = 2
  62637. }
  62638. /**
  62639. * Block used to apply wave operation to floats
  62640. */
  62641. export class WaveBlock extends NodeMaterialBlock {
  62642. /**
  62643. * Gets or sets the kibnd of wave to be applied by the block
  62644. */
  62645. kind: WaveBlockKind;
  62646. /**
  62647. * Creates a new WaveBlock
  62648. * @param name defines the block name
  62649. */
  62650. constructor(name: string);
  62651. /**
  62652. * Gets the current class name
  62653. * @returns the class name
  62654. */
  62655. getClassName(): string;
  62656. /**
  62657. * Gets the input component
  62658. */
  62659. get input(): NodeMaterialConnectionPoint;
  62660. /**
  62661. * Gets the output component
  62662. */
  62663. get output(): NodeMaterialConnectionPoint;
  62664. protected _buildBlock(state: NodeMaterialBuildState): this;
  62665. serialize(): any;
  62666. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62667. }
  62668. }
  62669. declare module BABYLON {
  62670. /**
  62671. * Class used to store a color step for the GradientBlock
  62672. */
  62673. export class GradientBlockColorStep {
  62674. /**
  62675. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62676. */
  62677. step: number;
  62678. /**
  62679. * Gets or sets the color associated with this step
  62680. */
  62681. color: Color3;
  62682. /**
  62683. * Creates a new GradientBlockColorStep
  62684. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62685. * @param color defines the color associated with this step
  62686. */
  62687. constructor(
  62688. /**
  62689. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62690. */
  62691. step: number,
  62692. /**
  62693. * Gets or sets the color associated with this step
  62694. */
  62695. color: Color3);
  62696. }
  62697. /**
  62698. * Block used to return a color from a gradient based on an input value between 0 and 1
  62699. */
  62700. export class GradientBlock extends NodeMaterialBlock {
  62701. /**
  62702. * Gets or sets the list of color steps
  62703. */
  62704. colorSteps: GradientBlockColorStep[];
  62705. /**
  62706. * Creates a new GradientBlock
  62707. * @param name defines the block name
  62708. */
  62709. constructor(name: string);
  62710. /**
  62711. * Gets the current class name
  62712. * @returns the class name
  62713. */
  62714. getClassName(): string;
  62715. /**
  62716. * Gets the gradient input component
  62717. */
  62718. get gradient(): NodeMaterialConnectionPoint;
  62719. /**
  62720. * Gets the output component
  62721. */
  62722. get output(): NodeMaterialConnectionPoint;
  62723. private _writeColorConstant;
  62724. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62725. serialize(): any;
  62726. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62727. protected _dumpPropertiesCode(): string;
  62728. }
  62729. }
  62730. declare module BABYLON {
  62731. /**
  62732. * Block used to normalize lerp between 2 values
  62733. */
  62734. export class NLerpBlock extends NodeMaterialBlock {
  62735. /**
  62736. * Creates a new NLerpBlock
  62737. * @param name defines the block name
  62738. */
  62739. constructor(name: string);
  62740. /**
  62741. * Gets the current class name
  62742. * @returns the class name
  62743. */
  62744. getClassName(): string;
  62745. /**
  62746. * Gets the left operand input component
  62747. */
  62748. get left(): NodeMaterialConnectionPoint;
  62749. /**
  62750. * Gets the right operand input component
  62751. */
  62752. get right(): NodeMaterialConnectionPoint;
  62753. /**
  62754. * Gets the gradient operand input component
  62755. */
  62756. get gradient(): NodeMaterialConnectionPoint;
  62757. /**
  62758. * Gets the output component
  62759. */
  62760. get output(): NodeMaterialConnectionPoint;
  62761. protected _buildBlock(state: NodeMaterialBuildState): this;
  62762. }
  62763. }
  62764. declare module BABYLON {
  62765. /**
  62766. * block used to Generate a Worley Noise 3D Noise Pattern
  62767. */
  62768. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62769. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62770. manhattanDistance: boolean;
  62771. /**
  62772. * Creates a new WorleyNoise3DBlock
  62773. * @param name defines the block name
  62774. */
  62775. constructor(name: string);
  62776. /**
  62777. * Gets the current class name
  62778. * @returns the class name
  62779. */
  62780. getClassName(): string;
  62781. /**
  62782. * Gets the seed input component
  62783. */
  62784. get seed(): NodeMaterialConnectionPoint;
  62785. /**
  62786. * Gets the jitter input component
  62787. */
  62788. get jitter(): NodeMaterialConnectionPoint;
  62789. /**
  62790. * Gets the output component
  62791. */
  62792. get output(): NodeMaterialConnectionPoint;
  62793. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62794. /**
  62795. * Exposes the properties to the UI?
  62796. */
  62797. protected _dumpPropertiesCode(): string;
  62798. /**
  62799. * Exposes the properties to the Seralize?
  62800. */
  62801. serialize(): any;
  62802. /**
  62803. * Exposes the properties to the deseralize?
  62804. */
  62805. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62806. }
  62807. }
  62808. declare module BABYLON {
  62809. /**
  62810. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62811. */
  62812. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62813. /**
  62814. * Creates a new SimplexPerlin3DBlock
  62815. * @param name defines the block name
  62816. */
  62817. constructor(name: string);
  62818. /**
  62819. * Gets the current class name
  62820. * @returns the class name
  62821. */
  62822. getClassName(): string;
  62823. /**
  62824. * Gets the seed operand input component
  62825. */
  62826. get seed(): NodeMaterialConnectionPoint;
  62827. /**
  62828. * Gets the output component
  62829. */
  62830. get output(): NodeMaterialConnectionPoint;
  62831. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62832. }
  62833. }
  62834. declare module BABYLON {
  62835. /**
  62836. * Block used to blend normals
  62837. */
  62838. export class NormalBlendBlock extends NodeMaterialBlock {
  62839. /**
  62840. * Creates a new NormalBlendBlock
  62841. * @param name defines the block name
  62842. */
  62843. constructor(name: string);
  62844. /**
  62845. * Gets the current class name
  62846. * @returns the class name
  62847. */
  62848. getClassName(): string;
  62849. /**
  62850. * Gets the first input component
  62851. */
  62852. get normalMap0(): NodeMaterialConnectionPoint;
  62853. /**
  62854. * Gets the second input component
  62855. */
  62856. get normalMap1(): NodeMaterialConnectionPoint;
  62857. /**
  62858. * Gets the output component
  62859. */
  62860. get output(): NodeMaterialConnectionPoint;
  62861. protected _buildBlock(state: NodeMaterialBuildState): this;
  62862. }
  62863. }
  62864. declare module BABYLON {
  62865. /**
  62866. * Block used to rotate a 2d vector by a given angle
  62867. */
  62868. export class Rotate2dBlock extends NodeMaterialBlock {
  62869. /**
  62870. * Creates a new Rotate2dBlock
  62871. * @param name defines the block name
  62872. */
  62873. constructor(name: string);
  62874. /**
  62875. * Gets the current class name
  62876. * @returns the class name
  62877. */
  62878. getClassName(): string;
  62879. /**
  62880. * Gets the input vector
  62881. */
  62882. get input(): NodeMaterialConnectionPoint;
  62883. /**
  62884. * Gets the input angle
  62885. */
  62886. get angle(): NodeMaterialConnectionPoint;
  62887. /**
  62888. * Gets the output component
  62889. */
  62890. get output(): NodeMaterialConnectionPoint;
  62891. autoConfigure(material: NodeMaterial): void;
  62892. protected _buildBlock(state: NodeMaterialBuildState): this;
  62893. }
  62894. }
  62895. declare module BABYLON {
  62896. /**
  62897. * Block used to get the reflected vector from a direction and a normal
  62898. */
  62899. export class ReflectBlock extends NodeMaterialBlock {
  62900. /**
  62901. * Creates a new ReflectBlock
  62902. * @param name defines the block name
  62903. */
  62904. constructor(name: string);
  62905. /**
  62906. * Gets the current class name
  62907. * @returns the class name
  62908. */
  62909. getClassName(): string;
  62910. /**
  62911. * Gets the incident component
  62912. */
  62913. get incident(): NodeMaterialConnectionPoint;
  62914. /**
  62915. * Gets the normal component
  62916. */
  62917. get normal(): NodeMaterialConnectionPoint;
  62918. /**
  62919. * Gets the output component
  62920. */
  62921. get output(): NodeMaterialConnectionPoint;
  62922. protected _buildBlock(state: NodeMaterialBuildState): this;
  62923. }
  62924. }
  62925. declare module BABYLON {
  62926. /**
  62927. * Block used to get the refracted vector from a direction and a normal
  62928. */
  62929. export class RefractBlock extends NodeMaterialBlock {
  62930. /**
  62931. * Creates a new RefractBlock
  62932. * @param name defines the block name
  62933. */
  62934. constructor(name: string);
  62935. /**
  62936. * Gets the current class name
  62937. * @returns the class name
  62938. */
  62939. getClassName(): string;
  62940. /**
  62941. * Gets the incident component
  62942. */
  62943. get incident(): NodeMaterialConnectionPoint;
  62944. /**
  62945. * Gets the normal component
  62946. */
  62947. get normal(): NodeMaterialConnectionPoint;
  62948. /**
  62949. * Gets the index of refraction component
  62950. */
  62951. get ior(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the output component
  62954. */
  62955. get output(): NodeMaterialConnectionPoint;
  62956. protected _buildBlock(state: NodeMaterialBuildState): this;
  62957. }
  62958. }
  62959. declare module BABYLON {
  62960. /**
  62961. * Block used to desaturate a color
  62962. */
  62963. export class DesaturateBlock extends NodeMaterialBlock {
  62964. /**
  62965. * Creates a new DesaturateBlock
  62966. * @param name defines the block name
  62967. */
  62968. constructor(name: string);
  62969. /**
  62970. * Gets the current class name
  62971. * @returns the class name
  62972. */
  62973. getClassName(): string;
  62974. /**
  62975. * Gets the color operand input component
  62976. */
  62977. get color(): NodeMaterialConnectionPoint;
  62978. /**
  62979. * Gets the level operand input component
  62980. */
  62981. get level(): NodeMaterialConnectionPoint;
  62982. /**
  62983. * Gets the output component
  62984. */
  62985. get output(): NodeMaterialConnectionPoint;
  62986. protected _buildBlock(state: NodeMaterialBuildState): this;
  62987. }
  62988. }
  62989. declare module BABYLON {
  62990. /**
  62991. * Block used to implement the ambient occlusion module of the PBR material
  62992. */
  62993. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  62994. /**
  62995. * Create a new AmbientOcclusionBlock
  62996. * @param name defines the block name
  62997. */
  62998. constructor(name: string);
  62999. /**
  63000. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63001. */
  63002. useAmbientInGrayScale: boolean;
  63003. /**
  63004. * Initialize the block and prepare the context for build
  63005. * @param state defines the state that will be used for the build
  63006. */
  63007. initialize(state: NodeMaterialBuildState): void;
  63008. /**
  63009. * Gets the current class name
  63010. * @returns the class name
  63011. */
  63012. getClassName(): string;
  63013. /**
  63014. * Gets the texture input component
  63015. */
  63016. get texture(): NodeMaterialConnectionPoint;
  63017. /**
  63018. * Gets the texture intensity component
  63019. */
  63020. get intensity(): NodeMaterialConnectionPoint;
  63021. /**
  63022. * Gets the direct light intensity input component
  63023. */
  63024. get directLightIntensity(): NodeMaterialConnectionPoint;
  63025. /**
  63026. * Gets the ambient occlusion object output component
  63027. */
  63028. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63029. /**
  63030. * Gets the main code of the block (fragment side)
  63031. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63032. * @returns the shader code
  63033. */
  63034. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63036. protected _buildBlock(state: NodeMaterialBuildState): this;
  63037. protected _dumpPropertiesCode(): string;
  63038. serialize(): any;
  63039. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63040. }
  63041. }
  63042. declare module BABYLON {
  63043. /**
  63044. * Block used to implement the reflection module of the PBR material
  63045. */
  63046. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63047. /** @hidden */
  63048. _defineLODReflectionAlpha: string;
  63049. /** @hidden */
  63050. _defineLinearSpecularReflection: string;
  63051. private _vEnvironmentIrradianceName;
  63052. /** @hidden */
  63053. _vReflectionMicrosurfaceInfosName: string;
  63054. /** @hidden */
  63055. _vReflectionInfosName: string;
  63056. /** @hidden */
  63057. _vReflectionFilteringInfoName: string;
  63058. private _scene;
  63059. /**
  63060. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63061. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63062. * It's less burden on the user side in the editor part.
  63063. */
  63064. /** @hidden */
  63065. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63066. /** @hidden */
  63067. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63068. /** @hidden */
  63069. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63070. /**
  63071. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63072. * diffuse part of the IBL.
  63073. */
  63074. useSphericalHarmonics: boolean;
  63075. /**
  63076. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63077. */
  63078. forceIrradianceInFragment: boolean;
  63079. /**
  63080. * Create a new ReflectionBlock
  63081. * @param name defines the block name
  63082. */
  63083. constructor(name: string);
  63084. /**
  63085. * Gets the current class name
  63086. * @returns the class name
  63087. */
  63088. getClassName(): string;
  63089. /**
  63090. * Gets the position input component
  63091. */
  63092. get position(): NodeMaterialConnectionPoint;
  63093. /**
  63094. * Gets the world position input component
  63095. */
  63096. get worldPosition(): NodeMaterialConnectionPoint;
  63097. /**
  63098. * Gets the world normal input component
  63099. */
  63100. get worldNormal(): NodeMaterialConnectionPoint;
  63101. /**
  63102. * Gets the world input component
  63103. */
  63104. get world(): NodeMaterialConnectionPoint;
  63105. /**
  63106. * Gets the camera (or eye) position component
  63107. */
  63108. get cameraPosition(): NodeMaterialConnectionPoint;
  63109. /**
  63110. * Gets the view input component
  63111. */
  63112. get view(): NodeMaterialConnectionPoint;
  63113. /**
  63114. * Gets the color input component
  63115. */
  63116. get color(): NodeMaterialConnectionPoint;
  63117. /**
  63118. * Gets the reflection object output component
  63119. */
  63120. get reflection(): NodeMaterialConnectionPoint;
  63121. /**
  63122. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63123. */
  63124. get hasTexture(): boolean;
  63125. /**
  63126. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63127. */
  63128. get reflectionColor(): string;
  63129. protected _getTexture(): Nullable<BaseTexture>;
  63130. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63131. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63132. /**
  63133. * Gets the code to inject in the vertex shader
  63134. * @param state current state of the node material building
  63135. * @returns the shader code
  63136. */
  63137. handleVertexSide(state: NodeMaterialBuildState): string;
  63138. /**
  63139. * Gets the main code of the block (fragment side)
  63140. * @param state current state of the node material building
  63141. * @param normalVarName name of the existing variable corresponding to the normal
  63142. * @returns the shader code
  63143. */
  63144. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63145. protected _buildBlock(state: NodeMaterialBuildState): this;
  63146. protected _dumpPropertiesCode(): string;
  63147. serialize(): any;
  63148. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63149. }
  63150. }
  63151. declare module BABYLON {
  63152. /**
  63153. * Block used to implement the sheen module of the PBR material
  63154. */
  63155. export class SheenBlock extends NodeMaterialBlock {
  63156. /**
  63157. * Create a new SheenBlock
  63158. * @param name defines the block name
  63159. */
  63160. constructor(name: string);
  63161. /**
  63162. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63163. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63164. * making it easier to setup and tweak the effect
  63165. */
  63166. albedoScaling: boolean;
  63167. /**
  63168. * Defines if the sheen is linked to the sheen color.
  63169. */
  63170. linkSheenWithAlbedo: boolean;
  63171. /**
  63172. * Initialize the block and prepare the context for build
  63173. * @param state defines the state that will be used for the build
  63174. */
  63175. initialize(state: NodeMaterialBuildState): void;
  63176. /**
  63177. * Gets the current class name
  63178. * @returns the class name
  63179. */
  63180. getClassName(): string;
  63181. /**
  63182. * Gets the intensity input component
  63183. */
  63184. get intensity(): NodeMaterialConnectionPoint;
  63185. /**
  63186. * Gets the color input component
  63187. */
  63188. get color(): NodeMaterialConnectionPoint;
  63189. /**
  63190. * Gets the roughness input component
  63191. */
  63192. get roughness(): NodeMaterialConnectionPoint;
  63193. /**
  63194. * Gets the sheen object output component
  63195. */
  63196. get sheen(): NodeMaterialConnectionPoint;
  63197. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63198. /**
  63199. * Gets the main code of the block (fragment side)
  63200. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63201. * @returns the shader code
  63202. */
  63203. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63204. protected _buildBlock(state: NodeMaterialBuildState): this;
  63205. protected _dumpPropertiesCode(): string;
  63206. serialize(): any;
  63207. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63208. }
  63209. }
  63210. declare module BABYLON {
  63211. /**
  63212. * Block used to implement the reflectivity module of the PBR material
  63213. */
  63214. export class ReflectivityBlock extends NodeMaterialBlock {
  63215. private _metallicReflectanceColor;
  63216. private _metallicF0Factor;
  63217. /** @hidden */
  63218. _vMetallicReflectanceFactorsName: string;
  63219. /**
  63220. * The property below is set by the main PBR block prior to calling methods of this class.
  63221. */
  63222. /** @hidden */
  63223. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63224. /**
  63225. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63226. */
  63227. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63228. /**
  63229. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63230. */
  63231. useMetallnessFromMetallicTextureBlue: boolean;
  63232. /**
  63233. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63234. */
  63235. useRoughnessFromMetallicTextureAlpha: boolean;
  63236. /**
  63237. * Specifies if the metallic texture contains the roughness information in its green channel.
  63238. */
  63239. useRoughnessFromMetallicTextureGreen: boolean;
  63240. /**
  63241. * Create a new ReflectivityBlock
  63242. * @param name defines the block name
  63243. */
  63244. constructor(name: string);
  63245. /**
  63246. * Initialize the block and prepare the context for build
  63247. * @param state defines the state that will be used for the build
  63248. */
  63249. initialize(state: NodeMaterialBuildState): void;
  63250. /**
  63251. * Gets the current class name
  63252. * @returns the class name
  63253. */
  63254. getClassName(): string;
  63255. /**
  63256. * Gets the metallic input component
  63257. */
  63258. get metallic(): NodeMaterialConnectionPoint;
  63259. /**
  63260. * Gets the roughness input component
  63261. */
  63262. get roughness(): NodeMaterialConnectionPoint;
  63263. /**
  63264. * Gets the texture input component
  63265. */
  63266. get texture(): NodeMaterialConnectionPoint;
  63267. /**
  63268. * Gets the reflectivity object output component
  63269. */
  63270. get reflectivity(): NodeMaterialConnectionPoint;
  63271. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63272. /**
  63273. * Gets the main code of the block (fragment side)
  63274. * @param state current state of the node material building
  63275. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63276. * @returns the shader code
  63277. */
  63278. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63279. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63280. protected _buildBlock(state: NodeMaterialBuildState): this;
  63281. protected _dumpPropertiesCode(): string;
  63282. serialize(): any;
  63283. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63284. }
  63285. }
  63286. declare module BABYLON {
  63287. /**
  63288. * Block used to implement the anisotropy module of the PBR material
  63289. */
  63290. export class AnisotropyBlock extends NodeMaterialBlock {
  63291. /**
  63292. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63293. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63294. * It's less burden on the user side in the editor part.
  63295. */
  63296. /** @hidden */
  63297. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63298. /** @hidden */
  63299. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63300. /**
  63301. * Create a new AnisotropyBlock
  63302. * @param name defines the block name
  63303. */
  63304. constructor(name: string);
  63305. /**
  63306. * Initialize the block and prepare the context for build
  63307. * @param state defines the state that will be used for the build
  63308. */
  63309. initialize(state: NodeMaterialBuildState): void;
  63310. /**
  63311. * Gets the current class name
  63312. * @returns the class name
  63313. */
  63314. getClassName(): string;
  63315. /**
  63316. * Gets the intensity input component
  63317. */
  63318. get intensity(): NodeMaterialConnectionPoint;
  63319. /**
  63320. * Gets the direction input component
  63321. */
  63322. get direction(): NodeMaterialConnectionPoint;
  63323. /**
  63324. * Gets the texture input component
  63325. */
  63326. get texture(): NodeMaterialConnectionPoint;
  63327. /**
  63328. * Gets the uv input component
  63329. */
  63330. get uv(): NodeMaterialConnectionPoint;
  63331. /**
  63332. * Gets the worldTangent input component
  63333. */
  63334. get worldTangent(): NodeMaterialConnectionPoint;
  63335. /**
  63336. * Gets the anisotropy object output component
  63337. */
  63338. get anisotropy(): NodeMaterialConnectionPoint;
  63339. private _generateTBNSpace;
  63340. /**
  63341. * Gets the main code of the block (fragment side)
  63342. * @param state current state of the node material building
  63343. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63344. * @returns the shader code
  63345. */
  63346. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63347. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63348. protected _buildBlock(state: NodeMaterialBuildState): this;
  63349. }
  63350. }
  63351. declare module BABYLON {
  63352. /**
  63353. * Block used to implement the clear coat module of the PBR material
  63354. */
  63355. export class ClearCoatBlock extends NodeMaterialBlock {
  63356. private _scene;
  63357. /**
  63358. * Create a new ClearCoatBlock
  63359. * @param name defines the block name
  63360. */
  63361. constructor(name: string);
  63362. /**
  63363. * Initialize the block and prepare the context for build
  63364. * @param state defines the state that will be used for the build
  63365. */
  63366. initialize(state: NodeMaterialBuildState): void;
  63367. /**
  63368. * Gets the current class name
  63369. * @returns the class name
  63370. */
  63371. getClassName(): string;
  63372. /**
  63373. * Gets the intensity input component
  63374. */
  63375. get intensity(): NodeMaterialConnectionPoint;
  63376. /**
  63377. * Gets the roughness input component
  63378. */
  63379. get roughness(): NodeMaterialConnectionPoint;
  63380. /**
  63381. * Gets the ior input component
  63382. */
  63383. get ior(): NodeMaterialConnectionPoint;
  63384. /**
  63385. * Gets the texture input component
  63386. */
  63387. get texture(): NodeMaterialConnectionPoint;
  63388. /**
  63389. * Gets the bump texture input component
  63390. */
  63391. get bumpTexture(): NodeMaterialConnectionPoint;
  63392. /**
  63393. * Gets the uv input component
  63394. */
  63395. get uv(): NodeMaterialConnectionPoint;
  63396. /**
  63397. * Gets the tint color input component
  63398. */
  63399. get tintColor(): NodeMaterialConnectionPoint;
  63400. /**
  63401. * Gets the tint "at distance" input component
  63402. */
  63403. get tintAtDistance(): NodeMaterialConnectionPoint;
  63404. /**
  63405. * Gets the tint thickness input component
  63406. */
  63407. get tintThickness(): NodeMaterialConnectionPoint;
  63408. /**
  63409. * Gets the world tangent input component
  63410. */
  63411. get worldTangent(): NodeMaterialConnectionPoint;
  63412. /**
  63413. * Gets the clear coat object output component
  63414. */
  63415. get clearcoat(): NodeMaterialConnectionPoint;
  63416. autoConfigure(material: NodeMaterial): void;
  63417. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63418. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63419. private _generateTBNSpace;
  63420. /**
  63421. * Gets the main code of the block (fragment side)
  63422. * @param state current state of the node material building
  63423. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63424. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63425. * @param worldPosVarName name of the variable holding the world position
  63426. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63427. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63428. * @param worldNormalVarName name of the variable holding the world normal
  63429. * @returns the shader code
  63430. */
  63431. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63432. protected _buildBlock(state: NodeMaterialBuildState): this;
  63433. }
  63434. }
  63435. declare module BABYLON {
  63436. /**
  63437. * Block used to implement the sub surface module of the PBR material
  63438. */
  63439. export class SubSurfaceBlock extends NodeMaterialBlock {
  63440. /**
  63441. * Create a new SubSurfaceBlock
  63442. * @param name defines the block name
  63443. */
  63444. constructor(name: string);
  63445. /**
  63446. * Stores the intensity of the different subsurface effects in the thickness texture.
  63447. * * the green channel is the translucency intensity.
  63448. * * the blue channel is the scattering intensity.
  63449. * * the alpha channel is the refraction intensity.
  63450. */
  63451. useMaskFromThicknessTexture: boolean;
  63452. /**
  63453. * Initialize the block and prepare the context for build
  63454. * @param state defines the state that will be used for the build
  63455. */
  63456. initialize(state: NodeMaterialBuildState): void;
  63457. /**
  63458. * Gets the current class name
  63459. * @returns the class name
  63460. */
  63461. getClassName(): string;
  63462. /**
  63463. * Gets the min thickness input component
  63464. */
  63465. get minThickness(): NodeMaterialConnectionPoint;
  63466. /**
  63467. * Gets the max thickness input component
  63468. */
  63469. get maxThickness(): NodeMaterialConnectionPoint;
  63470. /**
  63471. * Gets the thickness texture component
  63472. */
  63473. get thicknessTexture(): NodeMaterialConnectionPoint;
  63474. /**
  63475. * Gets the tint color input component
  63476. */
  63477. get tintColor(): NodeMaterialConnectionPoint;
  63478. /**
  63479. * Gets the translucency intensity input component
  63480. */
  63481. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63482. /**
  63483. * Gets the translucency diffusion distance input component
  63484. */
  63485. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63486. /**
  63487. * Gets the refraction object parameters
  63488. */
  63489. get refraction(): NodeMaterialConnectionPoint;
  63490. /**
  63491. * Gets the sub surface object output component
  63492. */
  63493. get subsurface(): NodeMaterialConnectionPoint;
  63494. autoConfigure(material: NodeMaterial): void;
  63495. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63496. /**
  63497. * Gets the main code of the block (fragment side)
  63498. * @param state current state of the node material building
  63499. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63500. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63501. * @param worldPosVarName name of the variable holding the world position
  63502. * @returns the shader code
  63503. */
  63504. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63505. protected _buildBlock(state: NodeMaterialBuildState): this;
  63506. }
  63507. }
  63508. declare module BABYLON {
  63509. /**
  63510. * Block used to implement the PBR metallic/roughness model
  63511. */
  63512. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63513. /**
  63514. * Gets or sets the light associated with this block
  63515. */
  63516. light: Nullable<Light>;
  63517. private _lightId;
  63518. private _scene;
  63519. private _environmentBRDFTexture;
  63520. private _environmentBrdfSamplerName;
  63521. private _vNormalWName;
  63522. private _invertNormalName;
  63523. /**
  63524. * Create a new ReflectionBlock
  63525. * @param name defines the block name
  63526. */
  63527. constructor(name: string);
  63528. /**
  63529. * Intensity of the direct lights e.g. the four lights available in your scene.
  63530. * This impacts both the direct diffuse and specular highlights.
  63531. */
  63532. directIntensity: number;
  63533. /**
  63534. * Intensity of the environment e.g. how much the environment will light the object
  63535. * either through harmonics for rough material or through the refelction for shiny ones.
  63536. */
  63537. environmentIntensity: number;
  63538. /**
  63539. * This is a special control allowing the reduction of the specular highlights coming from the
  63540. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63541. */
  63542. specularIntensity: number;
  63543. /**
  63544. * Defines the falloff type used in this material.
  63545. * It by default is Physical.
  63546. */
  63547. lightFalloff: number;
  63548. /**
  63549. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63550. */
  63551. useAlphaFromAlbedoTexture: boolean;
  63552. /**
  63553. * Specifies that alpha test should be used
  63554. */
  63555. useAlphaTest: boolean;
  63556. /**
  63557. * Defines the alpha limits in alpha test mode.
  63558. */
  63559. alphaTestCutoff: number;
  63560. /**
  63561. * Specifies that alpha blending should be used
  63562. */
  63563. useAlphaBlending: boolean;
  63564. /**
  63565. * Defines if the alpha value should be determined via the rgb values.
  63566. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63567. */
  63568. opacityRGB: boolean;
  63569. /**
  63570. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63571. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63572. */
  63573. useRadianceOverAlpha: boolean;
  63574. /**
  63575. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63576. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63577. */
  63578. useSpecularOverAlpha: boolean;
  63579. /**
  63580. * Enables specular anti aliasing in the PBR shader.
  63581. * It will both interacts on the Geometry for analytical and IBL lighting.
  63582. * It also prefilter the roughness map based on the bump values.
  63583. */
  63584. enableSpecularAntiAliasing: boolean;
  63585. /**
  63586. * Enables realtime filtering on the texture.
  63587. */
  63588. realTimeFiltering: boolean;
  63589. /**
  63590. * Quality switch for realtime filtering
  63591. */
  63592. realTimeFilteringQuality: number;
  63593. /**
  63594. * Defines if the material uses energy conservation.
  63595. */
  63596. useEnergyConservation: boolean;
  63597. /**
  63598. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63599. * too much the area relying on ambient texture to define their ambient occlusion.
  63600. */
  63601. useRadianceOcclusion: boolean;
  63602. /**
  63603. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63604. * makes the reflect vector face the model (under horizon).
  63605. */
  63606. useHorizonOcclusion: boolean;
  63607. /**
  63608. * If set to true, no lighting calculations will be applied.
  63609. */
  63610. unlit: boolean;
  63611. /**
  63612. * Force normal to face away from face.
  63613. */
  63614. forceNormalForward: boolean;
  63615. /**
  63616. * Defines the material debug mode.
  63617. * It helps seeing only some components of the material while troubleshooting.
  63618. */
  63619. debugMode: number;
  63620. /**
  63621. * Specify from where on screen the debug mode should start.
  63622. * The value goes from -1 (full screen) to 1 (not visible)
  63623. * It helps with side by side comparison against the final render
  63624. * This defaults to 0
  63625. */
  63626. debugLimit: number;
  63627. /**
  63628. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63629. * You can use the factor to better multiply the final value.
  63630. */
  63631. debugFactor: number;
  63632. /**
  63633. * Initialize the block and prepare the context for build
  63634. * @param state defines the state that will be used for the build
  63635. */
  63636. initialize(state: NodeMaterialBuildState): void;
  63637. /**
  63638. * Gets the current class name
  63639. * @returns the class name
  63640. */
  63641. getClassName(): string;
  63642. /**
  63643. * Gets the world position input component
  63644. */
  63645. get worldPosition(): NodeMaterialConnectionPoint;
  63646. /**
  63647. * Gets the world normal input component
  63648. */
  63649. get worldNormal(): NodeMaterialConnectionPoint;
  63650. /**
  63651. * Gets the perturbed normal input component
  63652. */
  63653. get perturbedNormal(): NodeMaterialConnectionPoint;
  63654. /**
  63655. * Gets the camera position input component
  63656. */
  63657. get cameraPosition(): NodeMaterialConnectionPoint;
  63658. /**
  63659. * Gets the base color input component
  63660. */
  63661. get baseColor(): NodeMaterialConnectionPoint;
  63662. /**
  63663. * Gets the opacity texture input component
  63664. */
  63665. get opacityTexture(): NodeMaterialConnectionPoint;
  63666. /**
  63667. * Gets the ambient color input component
  63668. */
  63669. get ambientColor(): NodeMaterialConnectionPoint;
  63670. /**
  63671. * Gets the reflectivity object parameters
  63672. */
  63673. get reflectivity(): NodeMaterialConnectionPoint;
  63674. /**
  63675. * Gets the ambient occlusion object parameters
  63676. */
  63677. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63678. /**
  63679. * Gets the reflection object parameters
  63680. */
  63681. get reflection(): NodeMaterialConnectionPoint;
  63682. /**
  63683. * Gets the sheen object parameters
  63684. */
  63685. get sheen(): NodeMaterialConnectionPoint;
  63686. /**
  63687. * Gets the clear coat object parameters
  63688. */
  63689. get clearcoat(): NodeMaterialConnectionPoint;
  63690. /**
  63691. * Gets the sub surface object parameters
  63692. */
  63693. get subsurface(): NodeMaterialConnectionPoint;
  63694. /**
  63695. * Gets the anisotropy object parameters
  63696. */
  63697. get anisotropy(): NodeMaterialConnectionPoint;
  63698. /**
  63699. * Gets the ambient output component
  63700. */
  63701. get ambient(): NodeMaterialConnectionPoint;
  63702. /**
  63703. * Gets the diffuse output component
  63704. */
  63705. get diffuse(): NodeMaterialConnectionPoint;
  63706. /**
  63707. * Gets the specular output component
  63708. */
  63709. get specular(): NodeMaterialConnectionPoint;
  63710. /**
  63711. * Gets the sheen output component
  63712. */
  63713. get sheenDir(): NodeMaterialConnectionPoint;
  63714. /**
  63715. * Gets the clear coat output component
  63716. */
  63717. get clearcoatDir(): NodeMaterialConnectionPoint;
  63718. /**
  63719. * Gets the indirect diffuse output component
  63720. */
  63721. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63722. /**
  63723. * Gets the indirect specular output component
  63724. */
  63725. get specularIndirect(): NodeMaterialConnectionPoint;
  63726. /**
  63727. * Gets the indirect sheen output component
  63728. */
  63729. get sheenIndirect(): NodeMaterialConnectionPoint;
  63730. /**
  63731. * Gets the indirect clear coat output component
  63732. */
  63733. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  63734. /**
  63735. * Gets the refraction output component
  63736. */
  63737. get refraction(): NodeMaterialConnectionPoint;
  63738. /**
  63739. * Gets the global lighting output component
  63740. */
  63741. get lighting(): NodeMaterialConnectionPoint;
  63742. /**
  63743. * Gets the shadow output component
  63744. */
  63745. get shadow(): NodeMaterialConnectionPoint;
  63746. /**
  63747. * Gets the alpha output component
  63748. */
  63749. get alpha(): NodeMaterialConnectionPoint;
  63750. autoConfigure(material: NodeMaterial): void;
  63751. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63752. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63753. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63754. private _injectVertexCode;
  63755. /**
  63756. * Gets the code corresponding to the albedo/opacity module
  63757. * @returns the shader code
  63758. */
  63759. getAlbedoOpacityCode(): string;
  63760. protected _buildBlock(state: NodeMaterialBuildState): this;
  63761. protected _dumpPropertiesCode(): string;
  63762. serialize(): any;
  63763. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63764. }
  63765. }
  63766. declare module BABYLON {
  63767. /**
  63768. * Block used to compute value of one parameter modulo another
  63769. */
  63770. export class ModBlock extends NodeMaterialBlock {
  63771. /**
  63772. * Creates a new ModBlock
  63773. * @param name defines the block name
  63774. */
  63775. constructor(name: string);
  63776. /**
  63777. * Gets the current class name
  63778. * @returns the class name
  63779. */
  63780. getClassName(): string;
  63781. /**
  63782. * Gets the left operand input component
  63783. */
  63784. get left(): NodeMaterialConnectionPoint;
  63785. /**
  63786. * Gets the right operand input component
  63787. */
  63788. get right(): NodeMaterialConnectionPoint;
  63789. /**
  63790. * Gets the output component
  63791. */
  63792. get output(): NodeMaterialConnectionPoint;
  63793. protected _buildBlock(state: NodeMaterialBuildState): this;
  63794. }
  63795. }
  63796. declare module BABYLON {
  63797. /**
  63798. * Helper class to push actions to a pool of workers.
  63799. */
  63800. export class WorkerPool implements IDisposable {
  63801. private _workerInfos;
  63802. private _pendingActions;
  63803. /**
  63804. * Constructor
  63805. * @param workers Array of workers to use for actions
  63806. */
  63807. constructor(workers: Array<Worker>);
  63808. /**
  63809. * Terminates all workers and clears any pending actions.
  63810. */
  63811. dispose(): void;
  63812. /**
  63813. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63814. * pended until a worker has completed its action.
  63815. * @param action The action to perform. Call onComplete when the action is complete.
  63816. */
  63817. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63818. private _execute;
  63819. }
  63820. }
  63821. declare module BABYLON {
  63822. /**
  63823. * Configuration for Draco compression
  63824. */
  63825. export interface IDracoCompressionConfiguration {
  63826. /**
  63827. * Configuration for the decoder.
  63828. */
  63829. decoder: {
  63830. /**
  63831. * The url to the WebAssembly module.
  63832. */
  63833. wasmUrl?: string;
  63834. /**
  63835. * The url to the WebAssembly binary.
  63836. */
  63837. wasmBinaryUrl?: string;
  63838. /**
  63839. * The url to the fallback JavaScript module.
  63840. */
  63841. fallbackUrl?: string;
  63842. };
  63843. }
  63844. /**
  63845. * Draco compression (https://google.github.io/draco/)
  63846. *
  63847. * This class wraps the Draco module.
  63848. *
  63849. * **Encoder**
  63850. *
  63851. * The encoder is not currently implemented.
  63852. *
  63853. * **Decoder**
  63854. *
  63855. * 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.
  63856. *
  63857. * To update the configuration, use the following code:
  63858. * ```javascript
  63859. * DracoCompression.Configuration = {
  63860. * decoder: {
  63861. * wasmUrl: "<url to the WebAssembly library>",
  63862. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63863. * fallbackUrl: "<url to the fallback JavaScript library>",
  63864. * }
  63865. * };
  63866. * ```
  63867. *
  63868. * 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.
  63869. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63870. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63871. *
  63872. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63873. * ```javascript
  63874. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63875. * ```
  63876. *
  63877. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63878. */
  63879. export class DracoCompression implements IDisposable {
  63880. private _workerPoolPromise?;
  63881. private _decoderModulePromise?;
  63882. /**
  63883. * The configuration. Defaults to the following urls:
  63884. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63885. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63886. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63887. */
  63888. static Configuration: IDracoCompressionConfiguration;
  63889. /**
  63890. * Returns true if the decoder configuration is available.
  63891. */
  63892. static get DecoderAvailable(): boolean;
  63893. /**
  63894. * Default number of workers to create when creating the draco compression object.
  63895. */
  63896. static DefaultNumWorkers: number;
  63897. private static GetDefaultNumWorkers;
  63898. private static _Default;
  63899. /**
  63900. * Default instance for the draco compression object.
  63901. */
  63902. static get Default(): DracoCompression;
  63903. /**
  63904. * Constructor
  63905. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63906. */
  63907. constructor(numWorkers?: number);
  63908. /**
  63909. * Stop all async operations and release resources.
  63910. */
  63911. dispose(): void;
  63912. /**
  63913. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63914. * @returns a promise that resolves when ready
  63915. */
  63916. whenReadyAsync(): Promise<void>;
  63917. /**
  63918. * Decode Draco compressed mesh data to vertex data.
  63919. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63920. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63921. * @returns A promise that resolves with the decoded vertex data
  63922. */
  63923. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63924. [kind: string]: number;
  63925. }): Promise<VertexData>;
  63926. }
  63927. }
  63928. declare module BABYLON {
  63929. /**
  63930. * Class for building Constructive Solid Geometry
  63931. */
  63932. export class CSG {
  63933. private polygons;
  63934. /**
  63935. * The world matrix
  63936. */
  63937. matrix: Matrix;
  63938. /**
  63939. * Stores the position
  63940. */
  63941. position: Vector3;
  63942. /**
  63943. * Stores the rotation
  63944. */
  63945. rotation: Vector3;
  63946. /**
  63947. * Stores the rotation quaternion
  63948. */
  63949. rotationQuaternion: Nullable<Quaternion>;
  63950. /**
  63951. * Stores the scaling vector
  63952. */
  63953. scaling: Vector3;
  63954. /**
  63955. * Convert the Mesh to CSG
  63956. * @param mesh The Mesh to convert to CSG
  63957. * @returns A new CSG from the Mesh
  63958. */
  63959. static FromMesh(mesh: Mesh): CSG;
  63960. /**
  63961. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63962. * @param polygons Polygons used to construct a CSG solid
  63963. */
  63964. private static FromPolygons;
  63965. /**
  63966. * Clones, or makes a deep copy, of the CSG
  63967. * @returns A new CSG
  63968. */
  63969. clone(): CSG;
  63970. /**
  63971. * Unions this CSG with another CSG
  63972. * @param csg The CSG to union against this CSG
  63973. * @returns The unioned CSG
  63974. */
  63975. union(csg: CSG): CSG;
  63976. /**
  63977. * Unions this CSG with another CSG in place
  63978. * @param csg The CSG to union against this CSG
  63979. */
  63980. unionInPlace(csg: CSG): void;
  63981. /**
  63982. * Subtracts this CSG with another CSG
  63983. * @param csg The CSG to subtract against this CSG
  63984. * @returns A new CSG
  63985. */
  63986. subtract(csg: CSG): CSG;
  63987. /**
  63988. * Subtracts this CSG with another CSG in place
  63989. * @param csg The CSG to subtact against this CSG
  63990. */
  63991. subtractInPlace(csg: CSG): void;
  63992. /**
  63993. * Intersect this CSG with another CSG
  63994. * @param csg The CSG to intersect against this CSG
  63995. * @returns A new CSG
  63996. */
  63997. intersect(csg: CSG): CSG;
  63998. /**
  63999. * Intersects this CSG with another CSG in place
  64000. * @param csg The CSG to intersect against this CSG
  64001. */
  64002. intersectInPlace(csg: CSG): void;
  64003. /**
  64004. * Return a new CSG solid with solid and empty space switched. This solid is
  64005. * not modified.
  64006. * @returns A new CSG solid with solid and empty space switched
  64007. */
  64008. inverse(): CSG;
  64009. /**
  64010. * Inverses the CSG in place
  64011. */
  64012. inverseInPlace(): void;
  64013. /**
  64014. * This is used to keep meshes transformations so they can be restored
  64015. * when we build back a Babylon Mesh
  64016. * NB : All CSG operations are performed in world coordinates
  64017. * @param csg The CSG to copy the transform attributes from
  64018. * @returns This CSG
  64019. */
  64020. copyTransformAttributes(csg: CSG): CSG;
  64021. /**
  64022. * Build Raw mesh from CSG
  64023. * Coordinates here are in world space
  64024. * @param name The name of the mesh geometry
  64025. * @param scene The Scene
  64026. * @param keepSubMeshes Specifies if the submeshes should be kept
  64027. * @returns A new Mesh
  64028. */
  64029. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64030. /**
  64031. * Build Mesh from CSG taking material and transforms into account
  64032. * @param name The name of the Mesh
  64033. * @param material The material of the Mesh
  64034. * @param scene The Scene
  64035. * @param keepSubMeshes Specifies if submeshes should be kept
  64036. * @returns The new Mesh
  64037. */
  64038. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64039. }
  64040. }
  64041. declare module BABYLON {
  64042. /**
  64043. * Class used to create a trail following a mesh
  64044. */
  64045. export class TrailMesh extends Mesh {
  64046. private _generator;
  64047. private _autoStart;
  64048. private _running;
  64049. private _diameter;
  64050. private _length;
  64051. private _sectionPolygonPointsCount;
  64052. private _sectionVectors;
  64053. private _sectionNormalVectors;
  64054. private _beforeRenderObserver;
  64055. /**
  64056. * @constructor
  64057. * @param name The value used by scene.getMeshByName() to do a lookup.
  64058. * @param generator The mesh or transform node to generate a trail.
  64059. * @param scene The scene to add this mesh to.
  64060. * @param diameter Diameter of trailing mesh. Default is 1.
  64061. * @param length Length of trailing mesh. Default is 60.
  64062. * @param autoStart Automatically start trailing mesh. Default true.
  64063. */
  64064. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64065. /**
  64066. * "TrailMesh"
  64067. * @returns "TrailMesh"
  64068. */
  64069. getClassName(): string;
  64070. private _createMesh;
  64071. /**
  64072. * Start trailing mesh.
  64073. */
  64074. start(): void;
  64075. /**
  64076. * Stop trailing mesh.
  64077. */
  64078. stop(): void;
  64079. /**
  64080. * Update trailing mesh geometry.
  64081. */
  64082. update(): void;
  64083. /**
  64084. * Returns a new TrailMesh object.
  64085. * @param name is a string, the name given to the new mesh
  64086. * @param newGenerator use new generator object for cloned trail mesh
  64087. * @returns a new mesh
  64088. */
  64089. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64090. /**
  64091. * Serializes this trail mesh
  64092. * @param serializationObject object to write serialization to
  64093. */
  64094. serialize(serializationObject: any): void;
  64095. /**
  64096. * Parses a serialized trail mesh
  64097. * @param parsedMesh the serialized mesh
  64098. * @param scene the scene to create the trail mesh in
  64099. * @returns the created trail mesh
  64100. */
  64101. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64102. }
  64103. }
  64104. declare module BABYLON {
  64105. /**
  64106. * Class containing static functions to help procedurally build meshes
  64107. */
  64108. export class TiledBoxBuilder {
  64109. /**
  64110. * Creates a box mesh
  64111. * 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)
  64112. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64114. * * 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
  64115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64116. * @param name defines the name of the mesh
  64117. * @param options defines the options used to create the mesh
  64118. * @param scene defines the hosting scene
  64119. * @returns the box mesh
  64120. */
  64121. static CreateTiledBox(name: string, options: {
  64122. pattern?: number;
  64123. width?: number;
  64124. height?: number;
  64125. depth?: number;
  64126. tileSize?: number;
  64127. tileWidth?: number;
  64128. tileHeight?: number;
  64129. alignHorizontal?: number;
  64130. alignVertical?: number;
  64131. faceUV?: Vector4[];
  64132. faceColors?: Color4[];
  64133. sideOrientation?: number;
  64134. updatable?: boolean;
  64135. }, scene?: Nullable<Scene>): Mesh;
  64136. }
  64137. }
  64138. declare module BABYLON {
  64139. /**
  64140. * Class containing static functions to help procedurally build meshes
  64141. */
  64142. export class TorusKnotBuilder {
  64143. /**
  64144. * Creates a torus knot mesh
  64145. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64146. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64147. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64148. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64149. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64150. * * 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
  64151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64152. * @param name defines the name of the mesh
  64153. * @param options defines the options used to create the mesh
  64154. * @param scene defines the hosting scene
  64155. * @returns the torus knot mesh
  64156. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64157. */
  64158. static CreateTorusKnot(name: string, options: {
  64159. radius?: number;
  64160. tube?: number;
  64161. radialSegments?: number;
  64162. tubularSegments?: number;
  64163. p?: number;
  64164. q?: number;
  64165. updatable?: boolean;
  64166. sideOrientation?: number;
  64167. frontUVs?: Vector4;
  64168. backUVs?: Vector4;
  64169. }, scene: any): Mesh;
  64170. }
  64171. }
  64172. declare module BABYLON {
  64173. /**
  64174. * Polygon
  64175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64176. */
  64177. export class Polygon {
  64178. /**
  64179. * Creates a rectangle
  64180. * @param xmin bottom X coord
  64181. * @param ymin bottom Y coord
  64182. * @param xmax top X coord
  64183. * @param ymax top Y coord
  64184. * @returns points that make the resulting rectation
  64185. */
  64186. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64187. /**
  64188. * Creates a circle
  64189. * @param radius radius of circle
  64190. * @param cx scale in x
  64191. * @param cy scale in y
  64192. * @param numberOfSides number of sides that make up the circle
  64193. * @returns points that make the resulting circle
  64194. */
  64195. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64196. /**
  64197. * Creates a polygon from input string
  64198. * @param input Input polygon data
  64199. * @returns the parsed points
  64200. */
  64201. static Parse(input: string): Vector2[];
  64202. /**
  64203. * Starts building a polygon from x and y coordinates
  64204. * @param x x coordinate
  64205. * @param y y coordinate
  64206. * @returns the started path2
  64207. */
  64208. static StartingAt(x: number, y: number): Path2;
  64209. }
  64210. /**
  64211. * Builds a polygon
  64212. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64213. */
  64214. export class PolygonMeshBuilder {
  64215. private _points;
  64216. private _outlinepoints;
  64217. private _holes;
  64218. private _name;
  64219. private _scene;
  64220. private _epoints;
  64221. private _eholes;
  64222. private _addToepoint;
  64223. /**
  64224. * Babylon reference to the earcut plugin.
  64225. */
  64226. bjsEarcut: any;
  64227. /**
  64228. * Creates a PolygonMeshBuilder
  64229. * @param name name of the builder
  64230. * @param contours Path of the polygon
  64231. * @param scene scene to add to when creating the mesh
  64232. * @param earcutInjection can be used to inject your own earcut reference
  64233. */
  64234. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64235. /**
  64236. * Adds a whole within the polygon
  64237. * @param hole Array of points defining the hole
  64238. * @returns this
  64239. */
  64240. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64241. /**
  64242. * Creates the polygon
  64243. * @param updatable If the mesh should be updatable
  64244. * @param depth The depth of the mesh created
  64245. * @returns the created mesh
  64246. */
  64247. build(updatable?: boolean, depth?: number): Mesh;
  64248. /**
  64249. * Creates the polygon
  64250. * @param depth The depth of the mesh created
  64251. * @returns the created VertexData
  64252. */
  64253. buildVertexData(depth?: number): VertexData;
  64254. /**
  64255. * Adds a side to the polygon
  64256. * @param positions points that make the polygon
  64257. * @param normals normals of the polygon
  64258. * @param uvs uvs of the polygon
  64259. * @param indices indices of the polygon
  64260. * @param bounds bounds of the polygon
  64261. * @param points points of the polygon
  64262. * @param depth depth of the polygon
  64263. * @param flip flip of the polygon
  64264. */
  64265. private addSide;
  64266. }
  64267. }
  64268. declare module BABYLON {
  64269. /**
  64270. * Class containing static functions to help procedurally build meshes
  64271. */
  64272. export class PolygonBuilder {
  64273. /**
  64274. * Creates a polygon mesh
  64275. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64276. * * 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
  64277. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64279. * * 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)
  64280. * * Remember you can only change the shape positions, not their number when updating a polygon
  64281. * @param name defines the name of the mesh
  64282. * @param options defines the options used to create the mesh
  64283. * @param scene defines the hosting scene
  64284. * @param earcutInjection can be used to inject your own earcut reference
  64285. * @returns the polygon mesh
  64286. */
  64287. static CreatePolygon(name: string, options: {
  64288. shape: Vector3[];
  64289. holes?: Vector3[][];
  64290. depth?: number;
  64291. faceUV?: Vector4[];
  64292. faceColors?: Color4[];
  64293. updatable?: boolean;
  64294. sideOrientation?: number;
  64295. frontUVs?: Vector4;
  64296. backUVs?: Vector4;
  64297. wrap?: boolean;
  64298. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64299. /**
  64300. * Creates an extruded polygon mesh, with depth in the Y direction.
  64301. * * 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)
  64302. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64303. * @param name defines the name of the mesh
  64304. * @param options defines the options used to create the mesh
  64305. * @param scene defines the hosting scene
  64306. * @param earcutInjection can be used to inject your own earcut reference
  64307. * @returns the polygon mesh
  64308. */
  64309. static ExtrudePolygon(name: string, options: {
  64310. shape: Vector3[];
  64311. holes?: Vector3[][];
  64312. depth?: number;
  64313. faceUV?: Vector4[];
  64314. faceColors?: Color4[];
  64315. updatable?: boolean;
  64316. sideOrientation?: number;
  64317. frontUVs?: Vector4;
  64318. backUVs?: Vector4;
  64319. wrap?: boolean;
  64320. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64321. }
  64322. }
  64323. declare module BABYLON {
  64324. /**
  64325. * Class containing static functions to help procedurally build meshes
  64326. */
  64327. export class LatheBuilder {
  64328. /**
  64329. * Creates lathe mesh.
  64330. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64331. * * 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
  64332. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64333. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64334. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64335. * * 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
  64336. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64337. * * 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
  64338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64339. * * 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
  64340. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64342. * @param name defines the name of the mesh
  64343. * @param options defines the options used to create the mesh
  64344. * @param scene defines the hosting scene
  64345. * @returns the lathe mesh
  64346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64347. */
  64348. static CreateLathe(name: string, options: {
  64349. shape: Vector3[];
  64350. radius?: number;
  64351. tessellation?: number;
  64352. clip?: number;
  64353. arc?: number;
  64354. closed?: boolean;
  64355. updatable?: boolean;
  64356. sideOrientation?: number;
  64357. frontUVs?: Vector4;
  64358. backUVs?: Vector4;
  64359. cap?: number;
  64360. invertUV?: boolean;
  64361. }, scene?: Nullable<Scene>): Mesh;
  64362. }
  64363. }
  64364. declare module BABYLON {
  64365. /**
  64366. * Class containing static functions to help procedurally build meshes
  64367. */
  64368. export class TiledPlaneBuilder {
  64369. /**
  64370. * Creates a tiled plane mesh
  64371. * * The parameter `pattern` will, depending on value, do nothing or
  64372. * * * flip (reflect about central vertical) alternate tiles across and up
  64373. * * * flip every tile on alternate rows
  64374. * * * rotate (180 degs) alternate tiles across and up
  64375. * * * rotate every tile on alternate rows
  64376. * * * flip and rotate alternate tiles across and up
  64377. * * * flip and rotate every tile on alternate rows
  64378. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64379. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64380. * * 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
  64381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64382. * * 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)
  64383. * * 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)
  64384. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64385. * @param name defines the name of the mesh
  64386. * @param options defines the options used to create the mesh
  64387. * @param scene defines the hosting scene
  64388. * @returns the box mesh
  64389. */
  64390. static CreateTiledPlane(name: string, options: {
  64391. pattern?: number;
  64392. tileSize?: number;
  64393. tileWidth?: number;
  64394. tileHeight?: number;
  64395. size?: number;
  64396. width?: number;
  64397. height?: number;
  64398. alignHorizontal?: number;
  64399. alignVertical?: number;
  64400. sideOrientation?: number;
  64401. frontUVs?: Vector4;
  64402. backUVs?: Vector4;
  64403. updatable?: boolean;
  64404. }, scene?: Nullable<Scene>): Mesh;
  64405. }
  64406. }
  64407. declare module BABYLON {
  64408. /**
  64409. * Class containing static functions to help procedurally build meshes
  64410. */
  64411. export class TubeBuilder {
  64412. /**
  64413. * Creates a tube mesh.
  64414. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64415. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64416. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64417. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64418. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64419. * * 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)
  64420. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64421. * * 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
  64422. * * 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
  64423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64424. * * 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
  64425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64427. * @param name defines the name of the mesh
  64428. * @param options defines the options used to create the mesh
  64429. * @param scene defines the hosting scene
  64430. * @returns the tube mesh
  64431. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64432. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64433. */
  64434. static CreateTube(name: string, options: {
  64435. path: Vector3[];
  64436. radius?: number;
  64437. tessellation?: number;
  64438. radiusFunction?: {
  64439. (i: number, distance: number): number;
  64440. };
  64441. cap?: number;
  64442. arc?: number;
  64443. updatable?: boolean;
  64444. sideOrientation?: number;
  64445. frontUVs?: Vector4;
  64446. backUVs?: Vector4;
  64447. instance?: Mesh;
  64448. invertUV?: boolean;
  64449. }, scene?: Nullable<Scene>): Mesh;
  64450. }
  64451. }
  64452. declare module BABYLON {
  64453. /**
  64454. * Class containing static functions to help procedurally build meshes
  64455. */
  64456. export class IcoSphereBuilder {
  64457. /**
  64458. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64459. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64460. * * 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`)
  64461. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64462. * * 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
  64463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64464. * * 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
  64465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64466. * @param name defines the name of the mesh
  64467. * @param options defines the options used to create the mesh
  64468. * @param scene defines the hosting scene
  64469. * @returns the icosahedron mesh
  64470. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64471. */
  64472. static CreateIcoSphere(name: string, options: {
  64473. radius?: number;
  64474. radiusX?: number;
  64475. radiusY?: number;
  64476. radiusZ?: number;
  64477. flat?: boolean;
  64478. subdivisions?: number;
  64479. sideOrientation?: number;
  64480. frontUVs?: Vector4;
  64481. backUVs?: Vector4;
  64482. updatable?: boolean;
  64483. }, scene?: Nullable<Scene>): Mesh;
  64484. }
  64485. }
  64486. declare module BABYLON {
  64487. /**
  64488. * Class containing static functions to help procedurally build meshes
  64489. */
  64490. export class DecalBuilder {
  64491. /**
  64492. * Creates a decal mesh.
  64493. * 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
  64494. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64495. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64496. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64497. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64498. * @param name defines the name of the mesh
  64499. * @param sourceMesh defines the mesh where the decal must be applied
  64500. * @param options defines the options used to create the mesh
  64501. * @param scene defines the hosting scene
  64502. * @returns the decal mesh
  64503. * @see https://doc.babylonjs.com/how_to/decals
  64504. */
  64505. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64506. position?: Vector3;
  64507. normal?: Vector3;
  64508. size?: Vector3;
  64509. angle?: number;
  64510. }): Mesh;
  64511. }
  64512. }
  64513. declare module BABYLON {
  64514. /**
  64515. * Class containing static functions to help procedurally build meshes
  64516. */
  64517. export class MeshBuilder {
  64518. /**
  64519. * Creates a box mesh
  64520. * * The parameter `size` sets the size (float) of each box side (default 1)
  64521. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64522. * * 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)
  64523. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64524. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64525. * * 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
  64526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64527. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64528. * @param name defines the name of the mesh
  64529. * @param options defines the options used to create the mesh
  64530. * @param scene defines the hosting scene
  64531. * @returns the box mesh
  64532. */
  64533. static CreateBox(name: string, options: {
  64534. size?: number;
  64535. width?: number;
  64536. height?: number;
  64537. depth?: number;
  64538. faceUV?: Vector4[];
  64539. faceColors?: Color4[];
  64540. sideOrientation?: number;
  64541. frontUVs?: Vector4;
  64542. backUVs?: Vector4;
  64543. wrap?: boolean;
  64544. topBaseAt?: number;
  64545. bottomBaseAt?: number;
  64546. updatable?: boolean;
  64547. }, scene?: Nullable<Scene>): Mesh;
  64548. /**
  64549. * Creates a tiled box mesh
  64550. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64552. * @param name defines the name of the mesh
  64553. * @param options defines the options used to create the mesh
  64554. * @param scene defines the hosting scene
  64555. * @returns the tiled box mesh
  64556. */
  64557. static CreateTiledBox(name: string, options: {
  64558. pattern?: number;
  64559. size?: number;
  64560. width?: number;
  64561. height?: number;
  64562. depth: number;
  64563. tileSize?: number;
  64564. tileWidth?: number;
  64565. tileHeight?: number;
  64566. faceUV?: Vector4[];
  64567. faceColors?: Color4[];
  64568. alignHorizontal?: number;
  64569. alignVertical?: number;
  64570. sideOrientation?: number;
  64571. updatable?: boolean;
  64572. }, scene?: Nullable<Scene>): Mesh;
  64573. /**
  64574. * Creates a sphere mesh
  64575. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64576. * * 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`)
  64577. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64578. * * 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
  64579. * * 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)
  64580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64581. * * 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
  64582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64583. * @param name defines the name of the mesh
  64584. * @param options defines the options used to create the mesh
  64585. * @param scene defines the hosting scene
  64586. * @returns the sphere mesh
  64587. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64588. */
  64589. static CreateSphere(name: string, options: {
  64590. segments?: number;
  64591. diameter?: number;
  64592. diameterX?: number;
  64593. diameterY?: number;
  64594. diameterZ?: number;
  64595. arc?: number;
  64596. slice?: number;
  64597. sideOrientation?: number;
  64598. frontUVs?: Vector4;
  64599. backUVs?: Vector4;
  64600. updatable?: boolean;
  64601. }, scene?: Nullable<Scene>): Mesh;
  64602. /**
  64603. * Creates a plane polygonal mesh. By default, this is a disc
  64604. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64605. * * 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
  64606. * * 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
  64607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64608. * * 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
  64609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64610. * @param name defines the name of the mesh
  64611. * @param options defines the options used to create the mesh
  64612. * @param scene defines the hosting scene
  64613. * @returns the plane polygonal mesh
  64614. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64615. */
  64616. static CreateDisc(name: string, options: {
  64617. radius?: number;
  64618. tessellation?: number;
  64619. arc?: number;
  64620. updatable?: boolean;
  64621. sideOrientation?: number;
  64622. frontUVs?: Vector4;
  64623. backUVs?: Vector4;
  64624. }, scene?: Nullable<Scene>): Mesh;
  64625. /**
  64626. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64627. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64628. * * 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`)
  64629. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64630. * * 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
  64631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64632. * * 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
  64633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64634. * @param name defines the name of the mesh
  64635. * @param options defines the options used to create the mesh
  64636. * @param scene defines the hosting scene
  64637. * @returns the icosahedron mesh
  64638. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64639. */
  64640. static CreateIcoSphere(name: string, options: {
  64641. radius?: number;
  64642. radiusX?: number;
  64643. radiusY?: number;
  64644. radiusZ?: number;
  64645. flat?: boolean;
  64646. subdivisions?: number;
  64647. sideOrientation?: number;
  64648. frontUVs?: Vector4;
  64649. backUVs?: Vector4;
  64650. updatable?: boolean;
  64651. }, scene?: Nullable<Scene>): Mesh;
  64652. /**
  64653. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64654. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64655. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64656. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64657. * * 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
  64658. * * 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
  64659. * * 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
  64660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64661. * * 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
  64662. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64663. * * 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
  64664. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64665. * * 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
  64666. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64668. * @param name defines the name of the mesh
  64669. * @param options defines the options used to create the mesh
  64670. * @param scene defines the hosting scene
  64671. * @returns the ribbon mesh
  64672. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64673. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64674. */
  64675. static CreateRibbon(name: string, options: {
  64676. pathArray: Vector3[][];
  64677. closeArray?: boolean;
  64678. closePath?: boolean;
  64679. offset?: number;
  64680. updatable?: boolean;
  64681. sideOrientation?: number;
  64682. frontUVs?: Vector4;
  64683. backUVs?: Vector4;
  64684. instance?: Mesh;
  64685. invertUV?: boolean;
  64686. uvs?: Vector2[];
  64687. colors?: Color4[];
  64688. }, scene?: Nullable<Scene>): Mesh;
  64689. /**
  64690. * Creates a cylinder or a cone mesh
  64691. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64692. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64693. * * 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.
  64694. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64695. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64696. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64697. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64698. * * 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).
  64699. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64700. * * 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).
  64701. * * 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
  64702. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64703. * * 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
  64704. * * 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.
  64705. * * If `enclose` is false, a ring surface is one element.
  64706. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64707. * * 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
  64708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64709. * * 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
  64710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64711. * @param name defines the name of the mesh
  64712. * @param options defines the options used to create the mesh
  64713. * @param scene defines the hosting scene
  64714. * @returns the cylinder mesh
  64715. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64716. */
  64717. static CreateCylinder(name: string, options: {
  64718. height?: number;
  64719. diameterTop?: number;
  64720. diameterBottom?: number;
  64721. diameter?: number;
  64722. tessellation?: number;
  64723. subdivisions?: number;
  64724. arc?: number;
  64725. faceColors?: Color4[];
  64726. faceUV?: Vector4[];
  64727. updatable?: boolean;
  64728. hasRings?: boolean;
  64729. enclose?: boolean;
  64730. cap?: number;
  64731. sideOrientation?: number;
  64732. frontUVs?: Vector4;
  64733. backUVs?: Vector4;
  64734. }, scene?: Nullable<Scene>): Mesh;
  64735. /**
  64736. * Creates a torus mesh
  64737. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64738. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64739. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64741. * * 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
  64742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64743. * @param name defines the name of the mesh
  64744. * @param options defines the options used to create the mesh
  64745. * @param scene defines the hosting scene
  64746. * @returns the torus mesh
  64747. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64748. */
  64749. static CreateTorus(name: string, options: {
  64750. diameter?: number;
  64751. thickness?: number;
  64752. tessellation?: number;
  64753. updatable?: boolean;
  64754. sideOrientation?: number;
  64755. frontUVs?: Vector4;
  64756. backUVs?: Vector4;
  64757. }, scene?: Nullable<Scene>): Mesh;
  64758. /**
  64759. * Creates a torus knot mesh
  64760. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64761. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64762. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64763. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64765. * * 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
  64766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64767. * @param name defines the name of the mesh
  64768. * @param options defines the options used to create the mesh
  64769. * @param scene defines the hosting scene
  64770. * @returns the torus knot mesh
  64771. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64772. */
  64773. static CreateTorusKnot(name: string, options: {
  64774. radius?: number;
  64775. tube?: number;
  64776. radialSegments?: number;
  64777. tubularSegments?: number;
  64778. p?: number;
  64779. q?: number;
  64780. updatable?: boolean;
  64781. sideOrientation?: number;
  64782. frontUVs?: Vector4;
  64783. backUVs?: Vector4;
  64784. }, scene?: Nullable<Scene>): Mesh;
  64785. /**
  64786. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64787. * * 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
  64788. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64789. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64790. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64791. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64792. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64793. * * 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
  64794. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64797. * @param name defines the name of the new line system
  64798. * @param options defines the options used to create the line system
  64799. * @param scene defines the hosting scene
  64800. * @returns a new line system mesh
  64801. */
  64802. static CreateLineSystem(name: string, options: {
  64803. lines: Vector3[][];
  64804. updatable?: boolean;
  64805. instance?: Nullable<LinesMesh>;
  64806. colors?: Nullable<Color4[][]>;
  64807. useVertexAlpha?: boolean;
  64808. }, scene: Nullable<Scene>): LinesMesh;
  64809. /**
  64810. * Creates a line mesh
  64811. * 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
  64812. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64813. * * The parameter `points` is an array successive Vector3
  64814. * * 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
  64815. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64816. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64817. * * When updating an instance, remember that only point positions can change, not the number of points
  64818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64820. * @param name defines the name of the new line system
  64821. * @param options defines the options used to create the line system
  64822. * @param scene defines the hosting scene
  64823. * @returns a new line mesh
  64824. */
  64825. static CreateLines(name: string, options: {
  64826. points: Vector3[];
  64827. updatable?: boolean;
  64828. instance?: Nullable<LinesMesh>;
  64829. colors?: Color4[];
  64830. useVertexAlpha?: boolean;
  64831. }, scene?: Nullable<Scene>): LinesMesh;
  64832. /**
  64833. * Creates a dashed line mesh
  64834. * * 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
  64835. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64836. * * The parameter `points` is an array successive Vector3
  64837. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64838. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64839. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64840. * * 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
  64841. * * When updating an instance, remember that only point positions can change, not the number of points
  64842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64843. * @param name defines the name of the mesh
  64844. * @param options defines the options used to create the mesh
  64845. * @param scene defines the hosting scene
  64846. * @returns the dashed line mesh
  64847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64848. */
  64849. static CreateDashedLines(name: string, options: {
  64850. points: Vector3[];
  64851. dashSize?: number;
  64852. gapSize?: number;
  64853. dashNb?: number;
  64854. updatable?: boolean;
  64855. instance?: LinesMesh;
  64856. }, scene?: Nullable<Scene>): LinesMesh;
  64857. /**
  64858. * 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.
  64859. * * 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.
  64860. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64861. * * 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.
  64862. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64863. * * 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
  64864. * * 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
  64865. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64866. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64867. * * 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
  64868. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64870. * @param name defines the name of the mesh
  64871. * @param options defines the options used to create the mesh
  64872. * @param scene defines the hosting scene
  64873. * @returns the extruded shape mesh
  64874. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64876. */
  64877. static ExtrudeShape(name: string, options: {
  64878. shape: Vector3[];
  64879. path: Vector3[];
  64880. scale?: number;
  64881. rotation?: number;
  64882. cap?: number;
  64883. updatable?: boolean;
  64884. sideOrientation?: number;
  64885. frontUVs?: Vector4;
  64886. backUVs?: Vector4;
  64887. instance?: Mesh;
  64888. invertUV?: boolean;
  64889. }, scene?: Nullable<Scene>): Mesh;
  64890. /**
  64891. * Creates an custom extruded shape mesh.
  64892. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64893. * * 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.
  64894. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64895. * * 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
  64896. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64897. * * 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
  64898. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64899. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64900. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64901. * * 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
  64902. * * 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
  64903. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64905. * * 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
  64906. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64908. * @param name defines the name of the mesh
  64909. * @param options defines the options used to create the mesh
  64910. * @param scene defines the hosting scene
  64911. * @returns the custom extruded shape mesh
  64912. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64913. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64914. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64915. */
  64916. static ExtrudeShapeCustom(name: string, options: {
  64917. shape: Vector3[];
  64918. path: Vector3[];
  64919. scaleFunction?: any;
  64920. rotationFunction?: any;
  64921. ribbonCloseArray?: boolean;
  64922. ribbonClosePath?: boolean;
  64923. cap?: number;
  64924. updatable?: boolean;
  64925. sideOrientation?: number;
  64926. frontUVs?: Vector4;
  64927. backUVs?: Vector4;
  64928. instance?: Mesh;
  64929. invertUV?: boolean;
  64930. }, scene?: Nullable<Scene>): Mesh;
  64931. /**
  64932. * Creates lathe mesh.
  64933. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64934. * * 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
  64935. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64936. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64937. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64938. * * 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
  64939. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64940. * * 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
  64941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64942. * * 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
  64943. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64945. * @param name defines the name of the mesh
  64946. * @param options defines the options used to create the mesh
  64947. * @param scene defines the hosting scene
  64948. * @returns the lathe mesh
  64949. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64950. */
  64951. static CreateLathe(name: string, options: {
  64952. shape: Vector3[];
  64953. radius?: number;
  64954. tessellation?: number;
  64955. clip?: number;
  64956. arc?: number;
  64957. closed?: boolean;
  64958. updatable?: boolean;
  64959. sideOrientation?: number;
  64960. frontUVs?: Vector4;
  64961. backUVs?: Vector4;
  64962. cap?: number;
  64963. invertUV?: boolean;
  64964. }, scene?: Nullable<Scene>): Mesh;
  64965. /**
  64966. * Creates a tiled plane mesh
  64967. * * You can set a limited pattern arrangement with the tiles
  64968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64969. * * 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
  64970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64971. * @param name defines the name of the mesh
  64972. * @param options defines the options used to create the mesh
  64973. * @param scene defines the hosting scene
  64974. * @returns the plane mesh
  64975. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64976. */
  64977. static CreateTiledPlane(name: string, options: {
  64978. pattern?: number;
  64979. tileSize?: number;
  64980. tileWidth?: number;
  64981. tileHeight?: number;
  64982. size?: number;
  64983. width?: number;
  64984. height?: number;
  64985. alignHorizontal?: number;
  64986. alignVertical?: number;
  64987. sideOrientation?: number;
  64988. frontUVs?: Vector4;
  64989. backUVs?: Vector4;
  64990. updatable?: boolean;
  64991. }, scene?: Nullable<Scene>): Mesh;
  64992. /**
  64993. * Creates a plane mesh
  64994. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64995. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64996. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64998. * * 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
  64999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65000. * @param name defines the name of the mesh
  65001. * @param options defines the options used to create the mesh
  65002. * @param scene defines the hosting scene
  65003. * @returns the plane mesh
  65004. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65005. */
  65006. static CreatePlane(name: string, options: {
  65007. size?: number;
  65008. width?: number;
  65009. height?: number;
  65010. sideOrientation?: number;
  65011. frontUVs?: Vector4;
  65012. backUVs?: Vector4;
  65013. updatable?: boolean;
  65014. sourcePlane?: Plane;
  65015. }, scene?: Nullable<Scene>): Mesh;
  65016. /**
  65017. * Creates a ground mesh
  65018. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65019. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65021. * @param name defines the name of the mesh
  65022. * @param options defines the options used to create the mesh
  65023. * @param scene defines the hosting scene
  65024. * @returns the ground mesh
  65025. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65026. */
  65027. static CreateGround(name: string, options: {
  65028. width?: number;
  65029. height?: number;
  65030. subdivisions?: number;
  65031. subdivisionsX?: number;
  65032. subdivisionsY?: number;
  65033. updatable?: boolean;
  65034. }, scene?: Nullable<Scene>): Mesh;
  65035. /**
  65036. * Creates a tiled ground mesh
  65037. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65038. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65039. * * 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
  65040. * * 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
  65041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65042. * @param name defines the name of the mesh
  65043. * @param options defines the options used to create the mesh
  65044. * @param scene defines the hosting scene
  65045. * @returns the tiled ground mesh
  65046. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65047. */
  65048. static CreateTiledGround(name: string, options: {
  65049. xmin: number;
  65050. zmin: number;
  65051. xmax: number;
  65052. zmax: number;
  65053. subdivisions?: {
  65054. w: number;
  65055. h: number;
  65056. };
  65057. precision?: {
  65058. w: number;
  65059. h: number;
  65060. };
  65061. updatable?: boolean;
  65062. }, scene?: Nullable<Scene>): Mesh;
  65063. /**
  65064. * Creates a ground mesh from a height map
  65065. * * The parameter `url` sets the URL of the height map image resource.
  65066. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65067. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65068. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65069. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65070. * * 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.
  65071. * * 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).
  65072. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65073. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65074. * @param name defines the name of the mesh
  65075. * @param url defines the url to the height map
  65076. * @param options defines the options used to create the mesh
  65077. * @param scene defines the hosting scene
  65078. * @returns the ground mesh
  65079. * @see https://doc.babylonjs.com/babylon101/height_map
  65080. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65081. */
  65082. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65083. width?: number;
  65084. height?: number;
  65085. subdivisions?: number;
  65086. minHeight?: number;
  65087. maxHeight?: number;
  65088. colorFilter?: Color3;
  65089. alphaFilter?: number;
  65090. updatable?: boolean;
  65091. onReady?: (mesh: GroundMesh) => void;
  65092. }, scene?: Nullable<Scene>): GroundMesh;
  65093. /**
  65094. * Creates a polygon mesh
  65095. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65096. * * 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
  65097. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65099. * * 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)
  65100. * * Remember you can only change the shape positions, not their number when updating a polygon
  65101. * @param name defines the name of the mesh
  65102. * @param options defines the options used to create the mesh
  65103. * @param scene defines the hosting scene
  65104. * @param earcutInjection can be used to inject your own earcut reference
  65105. * @returns the polygon mesh
  65106. */
  65107. static CreatePolygon(name: string, options: {
  65108. shape: Vector3[];
  65109. holes?: Vector3[][];
  65110. depth?: number;
  65111. faceUV?: Vector4[];
  65112. faceColors?: Color4[];
  65113. updatable?: boolean;
  65114. sideOrientation?: number;
  65115. frontUVs?: Vector4;
  65116. backUVs?: Vector4;
  65117. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65118. /**
  65119. * Creates an extruded polygon mesh, with depth in the Y direction.
  65120. * * 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)
  65121. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65122. * @param name defines the name of the mesh
  65123. * @param options defines the options used to create the mesh
  65124. * @param scene defines the hosting scene
  65125. * @param earcutInjection can be used to inject your own earcut reference
  65126. * @returns the polygon mesh
  65127. */
  65128. static ExtrudePolygon(name: string, options: {
  65129. shape: Vector3[];
  65130. holes?: Vector3[][];
  65131. depth?: number;
  65132. faceUV?: Vector4[];
  65133. faceColors?: Color4[];
  65134. updatable?: boolean;
  65135. sideOrientation?: number;
  65136. frontUVs?: Vector4;
  65137. backUVs?: Vector4;
  65138. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65139. /**
  65140. * Creates a tube mesh.
  65141. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65142. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65143. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65144. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65145. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65146. * * 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)
  65147. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65148. * * 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
  65149. * * 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
  65150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65151. * * 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
  65152. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65154. * @param name defines the name of the mesh
  65155. * @param options defines the options used to create the mesh
  65156. * @param scene defines the hosting scene
  65157. * @returns the tube mesh
  65158. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65159. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65160. */
  65161. static CreateTube(name: string, options: {
  65162. path: Vector3[];
  65163. radius?: number;
  65164. tessellation?: number;
  65165. radiusFunction?: {
  65166. (i: number, distance: number): number;
  65167. };
  65168. cap?: number;
  65169. arc?: number;
  65170. updatable?: boolean;
  65171. sideOrientation?: number;
  65172. frontUVs?: Vector4;
  65173. backUVs?: Vector4;
  65174. instance?: Mesh;
  65175. invertUV?: boolean;
  65176. }, scene?: Nullable<Scene>): Mesh;
  65177. /**
  65178. * Creates a polyhedron mesh
  65179. * * 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
  65180. * * The parameter `size` (positive float, default 1) sets the polygon size
  65181. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65182. * * 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`
  65183. * * 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
  65184. * * 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)`)
  65185. * * 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
  65186. * * 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
  65187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65188. * * 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
  65189. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65190. * @param name defines the name of the mesh
  65191. * @param options defines the options used to create the mesh
  65192. * @param scene defines the hosting scene
  65193. * @returns the polyhedron mesh
  65194. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65195. */
  65196. static CreatePolyhedron(name: string, options: {
  65197. type?: number;
  65198. size?: number;
  65199. sizeX?: number;
  65200. sizeY?: number;
  65201. sizeZ?: number;
  65202. custom?: any;
  65203. faceUV?: Vector4[];
  65204. faceColors?: Color4[];
  65205. flat?: boolean;
  65206. updatable?: boolean;
  65207. sideOrientation?: number;
  65208. frontUVs?: Vector4;
  65209. backUVs?: Vector4;
  65210. }, scene?: Nullable<Scene>): Mesh;
  65211. /**
  65212. * Creates a decal mesh.
  65213. * 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
  65214. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65215. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65216. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65217. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65218. * @param name defines the name of the mesh
  65219. * @param sourceMesh defines the mesh where the decal must be applied
  65220. * @param options defines the options used to create the mesh
  65221. * @param scene defines the hosting scene
  65222. * @returns the decal mesh
  65223. * @see https://doc.babylonjs.com/how_to/decals
  65224. */
  65225. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65226. position?: Vector3;
  65227. normal?: Vector3;
  65228. size?: Vector3;
  65229. angle?: number;
  65230. }): Mesh;
  65231. }
  65232. }
  65233. declare module BABYLON {
  65234. /**
  65235. * A simplifier interface for future simplification implementations
  65236. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65237. */
  65238. export interface ISimplifier {
  65239. /**
  65240. * Simplification of a given mesh according to the given settings.
  65241. * Since this requires computation, it is assumed that the function runs async.
  65242. * @param settings The settings of the simplification, including quality and distance
  65243. * @param successCallback A callback that will be called after the mesh was simplified.
  65244. * @param errorCallback in case of an error, this callback will be called. optional.
  65245. */
  65246. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65247. }
  65248. /**
  65249. * Expected simplification settings.
  65250. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65251. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65252. */
  65253. export interface ISimplificationSettings {
  65254. /**
  65255. * Gets or sets the expected quality
  65256. */
  65257. quality: number;
  65258. /**
  65259. * Gets or sets the distance when this optimized version should be used
  65260. */
  65261. distance: number;
  65262. /**
  65263. * Gets an already optimized mesh
  65264. */
  65265. optimizeMesh?: boolean;
  65266. }
  65267. /**
  65268. * Class used to specify simplification options
  65269. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65270. */
  65271. export class SimplificationSettings implements ISimplificationSettings {
  65272. /** expected quality */
  65273. quality: number;
  65274. /** distance when this optimized version should be used */
  65275. distance: number;
  65276. /** already optimized mesh */
  65277. optimizeMesh?: boolean | undefined;
  65278. /**
  65279. * Creates a SimplificationSettings
  65280. * @param quality expected quality
  65281. * @param distance distance when this optimized version should be used
  65282. * @param optimizeMesh already optimized mesh
  65283. */
  65284. constructor(
  65285. /** expected quality */
  65286. quality: number,
  65287. /** distance when this optimized version should be used */
  65288. distance: number,
  65289. /** already optimized mesh */
  65290. optimizeMesh?: boolean | undefined);
  65291. }
  65292. /**
  65293. * Interface used to define a simplification task
  65294. */
  65295. export interface ISimplificationTask {
  65296. /**
  65297. * Array of settings
  65298. */
  65299. settings: Array<ISimplificationSettings>;
  65300. /**
  65301. * Simplification type
  65302. */
  65303. simplificationType: SimplificationType;
  65304. /**
  65305. * Mesh to simplify
  65306. */
  65307. mesh: Mesh;
  65308. /**
  65309. * Callback called on success
  65310. */
  65311. successCallback?: () => void;
  65312. /**
  65313. * Defines if parallel processing can be used
  65314. */
  65315. parallelProcessing: boolean;
  65316. }
  65317. /**
  65318. * Queue used to order the simplification tasks
  65319. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65320. */
  65321. export class SimplificationQueue {
  65322. private _simplificationArray;
  65323. /**
  65324. * Gets a boolean indicating that the process is still running
  65325. */
  65326. running: boolean;
  65327. /**
  65328. * Creates a new queue
  65329. */
  65330. constructor();
  65331. /**
  65332. * Adds a new simplification task
  65333. * @param task defines a task to add
  65334. */
  65335. addTask(task: ISimplificationTask): void;
  65336. /**
  65337. * Execute next task
  65338. */
  65339. executeNext(): void;
  65340. /**
  65341. * Execute a simplification task
  65342. * @param task defines the task to run
  65343. */
  65344. runSimplification(task: ISimplificationTask): void;
  65345. private getSimplifier;
  65346. }
  65347. /**
  65348. * The implemented types of simplification
  65349. * At the moment only Quadratic Error Decimation is implemented
  65350. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65351. */
  65352. export enum SimplificationType {
  65353. /** Quadratic error decimation */
  65354. QUADRATIC = 0
  65355. }
  65356. /**
  65357. * An implementation of the Quadratic Error simplification algorithm.
  65358. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65359. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65360. * @author RaananW
  65361. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65362. */
  65363. export class QuadraticErrorSimplification implements ISimplifier {
  65364. private _mesh;
  65365. private triangles;
  65366. private vertices;
  65367. private references;
  65368. private _reconstructedMesh;
  65369. /** Gets or sets the number pf sync interations */
  65370. syncIterations: number;
  65371. /** Gets or sets the aggressiveness of the simplifier */
  65372. aggressiveness: number;
  65373. /** Gets or sets the number of allowed iterations for decimation */
  65374. decimationIterations: number;
  65375. /** Gets or sets the espilon to use for bounding box computation */
  65376. boundingBoxEpsilon: number;
  65377. /**
  65378. * Creates a new QuadraticErrorSimplification
  65379. * @param _mesh defines the target mesh
  65380. */
  65381. constructor(_mesh: Mesh);
  65382. /**
  65383. * Simplification of a given mesh according to the given settings.
  65384. * Since this requires computation, it is assumed that the function runs async.
  65385. * @param settings The settings of the simplification, including quality and distance
  65386. * @param successCallback A callback that will be called after the mesh was simplified.
  65387. */
  65388. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65389. private runDecimation;
  65390. private initWithMesh;
  65391. private init;
  65392. private reconstructMesh;
  65393. private initDecimatedMesh;
  65394. private isFlipped;
  65395. private updateTriangles;
  65396. private identifyBorder;
  65397. private updateMesh;
  65398. private vertexError;
  65399. private calculateError;
  65400. }
  65401. }
  65402. declare module BABYLON {
  65403. interface Scene {
  65404. /** @hidden (Backing field) */
  65405. _simplificationQueue: SimplificationQueue;
  65406. /**
  65407. * Gets or sets the simplification queue attached to the scene
  65408. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65409. */
  65410. simplificationQueue: SimplificationQueue;
  65411. }
  65412. interface Mesh {
  65413. /**
  65414. * Simplify the mesh according to the given array of settings.
  65415. * Function will return immediately and will simplify async
  65416. * @param settings a collection of simplification settings
  65417. * @param parallelProcessing should all levels calculate parallel or one after the other
  65418. * @param simplificationType the type of simplification to run
  65419. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65420. * @returns the current mesh
  65421. */
  65422. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65423. }
  65424. /**
  65425. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65426. * created in a scene
  65427. */
  65428. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65429. /**
  65430. * The component name helpfull to identify the component in the list of scene components.
  65431. */
  65432. readonly name: string;
  65433. /**
  65434. * The scene the component belongs to.
  65435. */
  65436. scene: Scene;
  65437. /**
  65438. * Creates a new instance of the component for the given scene
  65439. * @param scene Defines the scene to register the component in
  65440. */
  65441. constructor(scene: Scene);
  65442. /**
  65443. * Registers the component in a given scene
  65444. */
  65445. register(): void;
  65446. /**
  65447. * Rebuilds the elements related to this component in case of
  65448. * context lost for instance.
  65449. */
  65450. rebuild(): void;
  65451. /**
  65452. * Disposes the component and the associated ressources
  65453. */
  65454. dispose(): void;
  65455. private _beforeCameraUpdate;
  65456. }
  65457. }
  65458. declare module BABYLON {
  65459. interface Mesh {
  65460. /**
  65461. * Creates a new thin instance
  65462. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  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. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65465. */
  65466. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65467. /**
  65468. * Adds the transformation (matrix) of the current mesh as a thin instance
  65469. * @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
  65470. * @returns the thin instance index number
  65471. */
  65472. thinInstanceAddSelf(refresh: boolean): number;
  65473. /**
  65474. * Registers a custom attribute to be used with thin instances
  65475. * @param kind name of the attribute
  65476. * @param stride size in floats of the attribute
  65477. */
  65478. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65479. /**
  65480. * Sets the matrix of a thin instance
  65481. * @param index index of the thin instance
  65482. * @param matrix matrix to set
  65483. * @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
  65484. */
  65485. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65486. /**
  65487. * Sets the value of a custom attribute for a thin instance
  65488. * @param kind name of the attribute
  65489. * @param index index of the thin instance
  65490. * @param value value to set
  65491. * @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
  65492. */
  65493. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65494. /**
  65495. * 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.
  65496. */
  65497. thinInstanceCount: number;
  65498. /**
  65499. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65500. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65501. * @param buffer buffer to set
  65502. * @param stride size in floats of each value of the buffer
  65503. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65504. */
  65505. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65506. /**
  65507. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65508. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65509. */
  65510. thinInstanceBufferUpdated(kind: string): void;
  65511. /**
  65512. * Refreshes the bounding info, taking into account all the thin instances defined
  65513. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65514. */
  65515. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65516. /** @hidden */
  65517. _thinInstanceInitializeUserStorage(): void;
  65518. /** @hidden */
  65519. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65520. /** @hidden */
  65521. _userThinInstanceBuffersStorage: {
  65522. data: {
  65523. [key: string]: Float32Array;
  65524. };
  65525. sizes: {
  65526. [key: string]: number;
  65527. };
  65528. vertexBuffers: {
  65529. [key: string]: Nullable<VertexBuffer>;
  65530. };
  65531. strides: {
  65532. [key: string]: number;
  65533. };
  65534. };
  65535. }
  65536. }
  65537. declare module BABYLON {
  65538. /**
  65539. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65540. */
  65541. export interface INavigationEnginePlugin {
  65542. /**
  65543. * plugin name
  65544. */
  65545. name: string;
  65546. /**
  65547. * Creates a navigation mesh
  65548. * @param meshes array of all the geometry used to compute the navigatio mesh
  65549. * @param parameters bunch of parameters used to filter geometry
  65550. */
  65551. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65552. /**
  65553. * Create a navigation mesh debug mesh
  65554. * @param scene is where the mesh will be added
  65555. * @returns debug display mesh
  65556. */
  65557. createDebugNavMesh(scene: Scene): Mesh;
  65558. /**
  65559. * Get a navigation mesh constrained position, closest to the parameter position
  65560. * @param position world position
  65561. * @returns the closest point to position constrained by the navigation mesh
  65562. */
  65563. getClosestPoint(position: Vector3): Vector3;
  65564. /**
  65565. * Get a navigation mesh constrained position, closest to the parameter position
  65566. * @param position world position
  65567. * @param result output the closest point to position constrained by the navigation mesh
  65568. */
  65569. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65570. /**
  65571. * Get a navigation mesh constrained position, within a particular radius
  65572. * @param position world position
  65573. * @param maxRadius the maximum distance to the constrained world position
  65574. * @returns the closest point to position constrained by the navigation mesh
  65575. */
  65576. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65577. /**
  65578. * Get a navigation mesh constrained position, within a particular radius
  65579. * @param position world position
  65580. * @param maxRadius the maximum distance to the constrained world position
  65581. * @param result output the closest point to position constrained by the navigation mesh
  65582. */
  65583. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65584. /**
  65585. * Compute the final position from a segment made of destination-position
  65586. * @param position world position
  65587. * @param destination world position
  65588. * @returns the resulting point along the navmesh
  65589. */
  65590. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65591. /**
  65592. * Compute the final position from a segment made of destination-position
  65593. * @param position world position
  65594. * @param destination world position
  65595. * @param result output the resulting point along the navmesh
  65596. */
  65597. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65598. /**
  65599. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65600. * @param start world position
  65601. * @param end world position
  65602. * @returns array containing world position composing the path
  65603. */
  65604. computePath(start: Vector3, end: Vector3): Vector3[];
  65605. /**
  65606. * If this plugin is supported
  65607. * @returns true if plugin is supported
  65608. */
  65609. isSupported(): boolean;
  65610. /**
  65611. * Create a new Crowd so you can add agents
  65612. * @param maxAgents the maximum agent count in the crowd
  65613. * @param maxAgentRadius the maximum radius an agent can have
  65614. * @param scene to attach the crowd to
  65615. * @returns the crowd you can add agents to
  65616. */
  65617. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65618. /**
  65619. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65620. * The queries will try to find a solution within those bounds
  65621. * default is (1,1,1)
  65622. * @param extent x,y,z value that define the extent around the queries point of reference
  65623. */
  65624. setDefaultQueryExtent(extent: Vector3): void;
  65625. /**
  65626. * Get the Bounding box extent specified by setDefaultQueryExtent
  65627. * @returns the box extent values
  65628. */
  65629. getDefaultQueryExtent(): Vector3;
  65630. /**
  65631. * build the navmesh from a previously saved state using getNavmeshData
  65632. * @param data the Uint8Array returned by getNavmeshData
  65633. */
  65634. buildFromNavmeshData(data: Uint8Array): void;
  65635. /**
  65636. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65637. * @returns data the Uint8Array that can be saved and reused
  65638. */
  65639. getNavmeshData(): Uint8Array;
  65640. /**
  65641. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65642. * @param result output the box extent values
  65643. */
  65644. getDefaultQueryExtentToRef(result: Vector3): void;
  65645. /**
  65646. * Release all resources
  65647. */
  65648. dispose(): void;
  65649. }
  65650. /**
  65651. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65652. */
  65653. export interface ICrowd {
  65654. /**
  65655. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65656. * You can attach anything to that node. The node position is updated in the scene update tick.
  65657. * @param pos world position that will be constrained by the navigation mesh
  65658. * @param parameters agent parameters
  65659. * @param transform hooked to the agent that will be update by the scene
  65660. * @returns agent index
  65661. */
  65662. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65663. /**
  65664. * Returns the agent position in world space
  65665. * @param index agent index returned by addAgent
  65666. * @returns world space position
  65667. */
  65668. getAgentPosition(index: number): Vector3;
  65669. /**
  65670. * Gets the agent position result in world space
  65671. * @param index agent index returned by addAgent
  65672. * @param result output world space position
  65673. */
  65674. getAgentPositionToRef(index: number, result: Vector3): void;
  65675. /**
  65676. * Gets the agent velocity in world space
  65677. * @param index agent index returned by addAgent
  65678. * @returns world space velocity
  65679. */
  65680. getAgentVelocity(index: number): Vector3;
  65681. /**
  65682. * Gets the agent velocity result in world space
  65683. * @param index agent index returned by addAgent
  65684. * @param result output world space velocity
  65685. */
  65686. getAgentVelocityToRef(index: number, result: Vector3): void;
  65687. /**
  65688. * remove a particular agent previously created
  65689. * @param index agent index returned by addAgent
  65690. */
  65691. removeAgent(index: number): void;
  65692. /**
  65693. * get the list of all agents attached to this crowd
  65694. * @returns list of agent indices
  65695. */
  65696. getAgents(): number[];
  65697. /**
  65698. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65699. * @param deltaTime in seconds
  65700. */
  65701. update(deltaTime: number): void;
  65702. /**
  65703. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65704. * @param index agent index returned by addAgent
  65705. * @param destination targeted world position
  65706. */
  65707. agentGoto(index: number, destination: Vector3): void;
  65708. /**
  65709. * Teleport the agent to a new position
  65710. * @param index agent index returned by addAgent
  65711. * @param destination targeted world position
  65712. */
  65713. agentTeleport(index: number, destination: Vector3): void;
  65714. /**
  65715. * Update agent parameters
  65716. * @param index agent index returned by addAgent
  65717. * @param parameters agent parameters
  65718. */
  65719. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65720. /**
  65721. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65722. * The queries will try to find a solution within those bounds
  65723. * default is (1,1,1)
  65724. * @param extent x,y,z value that define the extent around the queries point of reference
  65725. */
  65726. setDefaultQueryExtent(extent: Vector3): void;
  65727. /**
  65728. * Get the Bounding box extent specified by setDefaultQueryExtent
  65729. * @returns the box extent values
  65730. */
  65731. getDefaultQueryExtent(): Vector3;
  65732. /**
  65733. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65734. * @param result output the box extent values
  65735. */
  65736. getDefaultQueryExtentToRef(result: Vector3): void;
  65737. /**
  65738. * Release all resources
  65739. */
  65740. dispose(): void;
  65741. }
  65742. /**
  65743. * Configures an agent
  65744. */
  65745. export interface IAgentParameters {
  65746. /**
  65747. * Agent radius. [Limit: >= 0]
  65748. */
  65749. radius: number;
  65750. /**
  65751. * Agent height. [Limit: > 0]
  65752. */
  65753. height: number;
  65754. /**
  65755. * Maximum allowed acceleration. [Limit: >= 0]
  65756. */
  65757. maxAcceleration: number;
  65758. /**
  65759. * Maximum allowed speed. [Limit: >= 0]
  65760. */
  65761. maxSpeed: number;
  65762. /**
  65763. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65764. */
  65765. collisionQueryRange: number;
  65766. /**
  65767. * The path visibility optimization range. [Limit: > 0]
  65768. */
  65769. pathOptimizationRange: number;
  65770. /**
  65771. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65772. */
  65773. separationWeight: number;
  65774. }
  65775. /**
  65776. * Configures the navigation mesh creation
  65777. */
  65778. export interface INavMeshParameters {
  65779. /**
  65780. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65781. */
  65782. cs: number;
  65783. /**
  65784. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65785. */
  65786. ch: number;
  65787. /**
  65788. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65789. */
  65790. walkableSlopeAngle: number;
  65791. /**
  65792. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65793. * be considered walkable. [Limit: >= 3] [Units: vx]
  65794. */
  65795. walkableHeight: number;
  65796. /**
  65797. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65798. */
  65799. walkableClimb: number;
  65800. /**
  65801. * The distance to erode/shrink the walkable area of the heightfield away from
  65802. * obstructions. [Limit: >=0] [Units: vx]
  65803. */
  65804. walkableRadius: number;
  65805. /**
  65806. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65807. */
  65808. maxEdgeLen: number;
  65809. /**
  65810. * The maximum distance a simplfied contour's border edges should deviate
  65811. * the original raw contour. [Limit: >=0] [Units: vx]
  65812. */
  65813. maxSimplificationError: number;
  65814. /**
  65815. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65816. */
  65817. minRegionArea: number;
  65818. /**
  65819. * Any regions with a span count smaller than this value will, if possible,
  65820. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65821. */
  65822. mergeRegionArea: number;
  65823. /**
  65824. * The maximum number of vertices allowed for polygons generated during the
  65825. * contour to polygon conversion process. [Limit: >= 3]
  65826. */
  65827. maxVertsPerPoly: number;
  65828. /**
  65829. * Sets the sampling distance to use when generating the detail mesh.
  65830. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65831. */
  65832. detailSampleDist: number;
  65833. /**
  65834. * The maximum distance the detail mesh surface should deviate from heightfield
  65835. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65836. */
  65837. detailSampleMaxError: number;
  65838. }
  65839. }
  65840. declare module BABYLON {
  65841. /**
  65842. * RecastJS navigation plugin
  65843. */
  65844. export class RecastJSPlugin implements INavigationEnginePlugin {
  65845. /**
  65846. * Reference to the Recast library
  65847. */
  65848. bjsRECAST: any;
  65849. /**
  65850. * plugin name
  65851. */
  65852. name: string;
  65853. /**
  65854. * the first navmesh created. We might extend this to support multiple navmeshes
  65855. */
  65856. navMesh: any;
  65857. /**
  65858. * Initializes the recastJS plugin
  65859. * @param recastInjection can be used to inject your own recast reference
  65860. */
  65861. constructor(recastInjection?: any);
  65862. /**
  65863. * Creates a navigation mesh
  65864. * @param meshes array of all the geometry used to compute the navigatio mesh
  65865. * @param parameters bunch of parameters used to filter geometry
  65866. */
  65867. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65868. /**
  65869. * Create a navigation mesh debug mesh
  65870. * @param scene is where the mesh will be added
  65871. * @returns debug display mesh
  65872. */
  65873. createDebugNavMesh(scene: Scene): Mesh;
  65874. /**
  65875. * Get a navigation mesh constrained position, closest to the parameter position
  65876. * @param position world position
  65877. * @returns the closest point to position constrained by the navigation mesh
  65878. */
  65879. getClosestPoint(position: Vector3): Vector3;
  65880. /**
  65881. * Get a navigation mesh constrained position, closest to the parameter position
  65882. * @param position world position
  65883. * @param result output the closest point to position constrained by the navigation mesh
  65884. */
  65885. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65886. /**
  65887. * Get a navigation mesh constrained position, within a particular radius
  65888. * @param position world position
  65889. * @param maxRadius the maximum distance to the constrained world position
  65890. * @returns the closest point to position constrained by the navigation mesh
  65891. */
  65892. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65893. /**
  65894. * Get a navigation mesh constrained position, within a particular radius
  65895. * @param position world position
  65896. * @param maxRadius the maximum distance to the constrained world position
  65897. * @param result output the closest point to position constrained by the navigation mesh
  65898. */
  65899. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65900. /**
  65901. * Compute the final position from a segment made of destination-position
  65902. * @param position world position
  65903. * @param destination world position
  65904. * @returns the resulting point along the navmesh
  65905. */
  65906. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65907. /**
  65908. * Compute the final position from a segment made of destination-position
  65909. * @param position world position
  65910. * @param destination world position
  65911. * @param result output the resulting point along the navmesh
  65912. */
  65913. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65914. /**
  65915. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65916. * @param start world position
  65917. * @param end world position
  65918. * @returns array containing world position composing the path
  65919. */
  65920. computePath(start: Vector3, end: Vector3): Vector3[];
  65921. /**
  65922. * Create a new Crowd so you can add agents
  65923. * @param maxAgents the maximum agent count in the crowd
  65924. * @param maxAgentRadius the maximum radius an agent can have
  65925. * @param scene to attach the crowd to
  65926. * @returns the crowd you can add agents to
  65927. */
  65928. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65929. /**
  65930. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65931. * The queries will try to find a solution within those bounds
  65932. * default is (1,1,1)
  65933. * @param extent x,y,z value that define the extent around the queries point of reference
  65934. */
  65935. setDefaultQueryExtent(extent: Vector3): void;
  65936. /**
  65937. * Get the Bounding box extent specified by setDefaultQueryExtent
  65938. * @returns the box extent values
  65939. */
  65940. getDefaultQueryExtent(): Vector3;
  65941. /**
  65942. * build the navmesh from a previously saved state using getNavmeshData
  65943. * @param data the Uint8Array returned by getNavmeshData
  65944. */
  65945. buildFromNavmeshData(data: Uint8Array): void;
  65946. /**
  65947. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65948. * @returns data the Uint8Array that can be saved and reused
  65949. */
  65950. getNavmeshData(): Uint8Array;
  65951. /**
  65952. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65953. * @param result output the box extent values
  65954. */
  65955. getDefaultQueryExtentToRef(result: Vector3): void;
  65956. /**
  65957. * Disposes
  65958. */
  65959. dispose(): void;
  65960. /**
  65961. * If this plugin is supported
  65962. * @returns true if plugin is supported
  65963. */
  65964. isSupported(): boolean;
  65965. }
  65966. /**
  65967. * Recast detour crowd implementation
  65968. */
  65969. export class RecastJSCrowd implements ICrowd {
  65970. /**
  65971. * Recast/detour plugin
  65972. */
  65973. bjsRECASTPlugin: RecastJSPlugin;
  65974. /**
  65975. * Link to the detour crowd
  65976. */
  65977. recastCrowd: any;
  65978. /**
  65979. * One transform per agent
  65980. */
  65981. transforms: TransformNode[];
  65982. /**
  65983. * All agents created
  65984. */
  65985. agents: number[];
  65986. /**
  65987. * Link to the scene is kept to unregister the crowd from the scene
  65988. */
  65989. private _scene;
  65990. /**
  65991. * Observer for crowd updates
  65992. */
  65993. private _onBeforeAnimationsObserver;
  65994. /**
  65995. * Constructor
  65996. * @param plugin recastJS plugin
  65997. * @param maxAgents the maximum agent count in the crowd
  65998. * @param maxAgentRadius the maximum radius an agent can have
  65999. * @param scene to attach the crowd to
  66000. * @returns the crowd you can add agents to
  66001. */
  66002. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66003. /**
  66004. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66005. * You can attach anything to that node. The node position is updated in the scene update tick.
  66006. * @param pos world position that will be constrained by the navigation mesh
  66007. * @param parameters agent parameters
  66008. * @param transform hooked to the agent that will be update by the scene
  66009. * @returns agent index
  66010. */
  66011. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66012. /**
  66013. * Returns the agent position in world space
  66014. * @param index agent index returned by addAgent
  66015. * @returns world space position
  66016. */
  66017. getAgentPosition(index: number): Vector3;
  66018. /**
  66019. * Returns the agent position result in world space
  66020. * @param index agent index returned by addAgent
  66021. * @param result output world space position
  66022. */
  66023. getAgentPositionToRef(index: number, result: Vector3): void;
  66024. /**
  66025. * Returns the agent velocity in world space
  66026. * @param index agent index returned by addAgent
  66027. * @returns world space velocity
  66028. */
  66029. getAgentVelocity(index: number): Vector3;
  66030. /**
  66031. * Returns the agent velocity result in world space
  66032. * @param index agent index returned by addAgent
  66033. * @param result output world space velocity
  66034. */
  66035. getAgentVelocityToRef(index: number, result: Vector3): void;
  66036. /**
  66037. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66038. * @param index agent index returned by addAgent
  66039. * @param destination targeted world position
  66040. */
  66041. agentGoto(index: number, destination: Vector3): void;
  66042. /**
  66043. * Teleport the agent to a new position
  66044. * @param index agent index returned by addAgent
  66045. * @param destination targeted world position
  66046. */
  66047. agentTeleport(index: number, destination: Vector3): void;
  66048. /**
  66049. * Update agent parameters
  66050. * @param index agent index returned by addAgent
  66051. * @param parameters agent parameters
  66052. */
  66053. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66054. /**
  66055. * remove a particular agent previously created
  66056. * @param index agent index returned by addAgent
  66057. */
  66058. removeAgent(index: number): void;
  66059. /**
  66060. * get the list of all agents attached to this crowd
  66061. * @returns list of agent indices
  66062. */
  66063. getAgents(): number[];
  66064. /**
  66065. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66066. * @param deltaTime in seconds
  66067. */
  66068. update(deltaTime: number): void;
  66069. /**
  66070. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66071. * The queries will try to find a solution within those bounds
  66072. * default is (1,1,1)
  66073. * @param extent x,y,z value that define the extent around the queries point of reference
  66074. */
  66075. setDefaultQueryExtent(extent: Vector3): void;
  66076. /**
  66077. * Get the Bounding box extent specified by setDefaultQueryExtent
  66078. * @returns the box extent values
  66079. */
  66080. getDefaultQueryExtent(): Vector3;
  66081. /**
  66082. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66083. * @param result output the box extent values
  66084. */
  66085. getDefaultQueryExtentToRef(result: Vector3): void;
  66086. /**
  66087. * Release all resources
  66088. */
  66089. dispose(): void;
  66090. }
  66091. }
  66092. declare module BABYLON {
  66093. /**
  66094. * Class used to enable access to IndexedDB
  66095. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66096. */
  66097. export class Database implements IOfflineProvider {
  66098. private _callbackManifestChecked;
  66099. private _currentSceneUrl;
  66100. private _db;
  66101. private _enableSceneOffline;
  66102. private _enableTexturesOffline;
  66103. private _manifestVersionFound;
  66104. private _mustUpdateRessources;
  66105. private _hasReachedQuota;
  66106. private _isSupported;
  66107. private _idbFactory;
  66108. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66109. private static IsUASupportingBlobStorage;
  66110. /**
  66111. * Gets a boolean indicating if Database storate is enabled (off by default)
  66112. */
  66113. static IDBStorageEnabled: boolean;
  66114. /**
  66115. * Gets a boolean indicating if scene must be saved in the database
  66116. */
  66117. get enableSceneOffline(): boolean;
  66118. /**
  66119. * Gets a boolean indicating if textures must be saved in the database
  66120. */
  66121. get enableTexturesOffline(): boolean;
  66122. /**
  66123. * Creates a new Database
  66124. * @param urlToScene defines the url to load the scene
  66125. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66126. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66127. */
  66128. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66129. private static _ParseURL;
  66130. private static _ReturnFullUrlLocation;
  66131. private _checkManifestFile;
  66132. /**
  66133. * Open the database and make it available
  66134. * @param successCallback defines the callback to call on success
  66135. * @param errorCallback defines the callback to call on error
  66136. */
  66137. open(successCallback: () => void, errorCallback: () => void): void;
  66138. /**
  66139. * Loads an image from the database
  66140. * @param url defines the url to load from
  66141. * @param image defines the target DOM image
  66142. */
  66143. loadImage(url: string, image: HTMLImageElement): void;
  66144. private _loadImageFromDBAsync;
  66145. private _saveImageIntoDBAsync;
  66146. private _checkVersionFromDB;
  66147. private _loadVersionFromDBAsync;
  66148. private _saveVersionIntoDBAsync;
  66149. /**
  66150. * Loads a file from database
  66151. * @param url defines the URL to load from
  66152. * @param sceneLoaded defines a callback to call on success
  66153. * @param progressCallBack defines a callback to call when progress changed
  66154. * @param errorCallback defines a callback to call on error
  66155. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66156. */
  66157. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66158. private _loadFileAsync;
  66159. private _saveFileAsync;
  66160. /**
  66161. * Validates if xhr data is correct
  66162. * @param xhr defines the request to validate
  66163. * @param dataType defines the expected data type
  66164. * @returns true if data is correct
  66165. */
  66166. private static _ValidateXHRData;
  66167. }
  66168. }
  66169. declare module BABYLON {
  66170. /** @hidden */
  66171. export var gpuUpdateParticlesPixelShader: {
  66172. name: string;
  66173. shader: string;
  66174. };
  66175. }
  66176. declare module BABYLON {
  66177. /** @hidden */
  66178. export var gpuUpdateParticlesVertexShader: {
  66179. name: string;
  66180. shader: string;
  66181. };
  66182. }
  66183. declare module BABYLON {
  66184. /** @hidden */
  66185. export var clipPlaneFragmentDeclaration2: {
  66186. name: string;
  66187. shader: string;
  66188. };
  66189. }
  66190. declare module BABYLON {
  66191. /** @hidden */
  66192. export var gpuRenderParticlesPixelShader: {
  66193. name: string;
  66194. shader: string;
  66195. };
  66196. }
  66197. declare module BABYLON {
  66198. /** @hidden */
  66199. export var clipPlaneVertexDeclaration2: {
  66200. name: string;
  66201. shader: string;
  66202. };
  66203. }
  66204. declare module BABYLON {
  66205. /** @hidden */
  66206. export var gpuRenderParticlesVertexShader: {
  66207. name: string;
  66208. shader: string;
  66209. };
  66210. }
  66211. declare module BABYLON {
  66212. /**
  66213. * This represents a GPU particle system in Babylon
  66214. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66215. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66216. */
  66217. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66218. /**
  66219. * The layer mask we are rendering the particles through.
  66220. */
  66221. layerMask: number;
  66222. private _capacity;
  66223. private _activeCount;
  66224. private _currentActiveCount;
  66225. private _accumulatedCount;
  66226. private _renderEffect;
  66227. private _updateEffect;
  66228. private _buffer0;
  66229. private _buffer1;
  66230. private _spriteBuffer;
  66231. private _updateVAO;
  66232. private _renderVAO;
  66233. private _targetIndex;
  66234. private _sourceBuffer;
  66235. private _targetBuffer;
  66236. private _engine;
  66237. private _currentRenderId;
  66238. private _started;
  66239. private _stopped;
  66240. private _timeDelta;
  66241. private _randomTexture;
  66242. private _randomTexture2;
  66243. private _attributesStrideSize;
  66244. private _updateEffectOptions;
  66245. private _randomTextureSize;
  66246. private _actualFrame;
  66247. private _customEffect;
  66248. private readonly _rawTextureWidth;
  66249. /**
  66250. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66251. */
  66252. static get IsSupported(): boolean;
  66253. /**
  66254. * An event triggered when the system is disposed.
  66255. */
  66256. onDisposeObservable: Observable<IParticleSystem>;
  66257. /**
  66258. * Gets the maximum number of particles active at the same time.
  66259. * @returns The max number of active particles.
  66260. */
  66261. getCapacity(): number;
  66262. /**
  66263. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66264. * to override the particles.
  66265. */
  66266. forceDepthWrite: boolean;
  66267. /**
  66268. * Gets or set the number of active particles
  66269. */
  66270. get activeParticleCount(): number;
  66271. set activeParticleCount(value: number);
  66272. private _preWarmDone;
  66273. /**
  66274. * Specifies if the particles are updated in emitter local space or world space.
  66275. */
  66276. isLocal: boolean;
  66277. /**
  66278. * Is this system ready to be used/rendered
  66279. * @return true if the system is ready
  66280. */
  66281. isReady(): boolean;
  66282. /**
  66283. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66284. * @returns True if it has been started, otherwise false.
  66285. */
  66286. isStarted(): boolean;
  66287. /**
  66288. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66289. * @returns True if it has been stopped, otherwise false.
  66290. */
  66291. isStopped(): boolean;
  66292. /**
  66293. * Gets a boolean indicating that the system is stopping
  66294. * @returns true if the system is currently stopping
  66295. */
  66296. isStopping(): boolean;
  66297. /**
  66298. * Gets the number of particles active at the same time.
  66299. * @returns The number of active particles.
  66300. */
  66301. getActiveCount(): number;
  66302. /**
  66303. * Starts the particle system and begins to emit
  66304. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66305. */
  66306. start(delay?: number): void;
  66307. /**
  66308. * Stops the particle system.
  66309. */
  66310. stop(): void;
  66311. /**
  66312. * Remove all active particles
  66313. */
  66314. reset(): void;
  66315. /**
  66316. * Returns the string "GPUParticleSystem"
  66317. * @returns a string containing the class name
  66318. */
  66319. getClassName(): string;
  66320. /**
  66321. * Gets the custom effect used to render the particles
  66322. * @param blendMode Blend mode for which the effect should be retrieved
  66323. * @returns The effect
  66324. */
  66325. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66326. /**
  66327. * Sets the custom effect used to render the particles
  66328. * @param effect The effect to set
  66329. * @param blendMode Blend mode for which the effect should be set
  66330. */
  66331. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66332. /** @hidden */
  66333. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66334. /**
  66335. * Observable that will be called just before the particles are drawn
  66336. */
  66337. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66338. /**
  66339. * Gets the name of the particle vertex shader
  66340. */
  66341. get vertexShaderName(): string;
  66342. private _colorGradientsTexture;
  66343. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66344. /**
  66345. * Adds a new color gradient
  66346. * @param gradient defines the gradient to use (between 0 and 1)
  66347. * @param color1 defines the color to affect to the specified gradient
  66348. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66349. * @returns the current particle system
  66350. */
  66351. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66352. private _refreshColorGradient;
  66353. /** Force the system to rebuild all gradients that need to be resync */
  66354. forceRefreshGradients(): void;
  66355. /**
  66356. * Remove a specific color gradient
  66357. * @param gradient defines the gradient to remove
  66358. * @returns the current particle system
  66359. */
  66360. removeColorGradient(gradient: number): GPUParticleSystem;
  66361. private _angularSpeedGradientsTexture;
  66362. private _sizeGradientsTexture;
  66363. private _velocityGradientsTexture;
  66364. private _limitVelocityGradientsTexture;
  66365. private _dragGradientsTexture;
  66366. private _addFactorGradient;
  66367. /**
  66368. * Adds a new size gradient
  66369. * @param gradient defines the gradient to use (between 0 and 1)
  66370. * @param factor defines the size factor to affect to the specified gradient
  66371. * @returns the current particle system
  66372. */
  66373. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66374. /**
  66375. * Remove a specific size gradient
  66376. * @param gradient defines the gradient to remove
  66377. * @returns the current particle system
  66378. */
  66379. removeSizeGradient(gradient: number): GPUParticleSystem;
  66380. private _refreshFactorGradient;
  66381. /**
  66382. * Adds a new angular speed gradient
  66383. * @param gradient defines the gradient to use (between 0 and 1)
  66384. * @param factor defines the angular speed to affect to the specified gradient
  66385. * @returns the current particle system
  66386. */
  66387. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66388. /**
  66389. * Remove a specific angular speed gradient
  66390. * @param gradient defines the gradient to remove
  66391. * @returns the current particle system
  66392. */
  66393. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66394. /**
  66395. * Adds a new velocity gradient
  66396. * @param gradient defines the gradient to use (between 0 and 1)
  66397. * @param factor defines the velocity to affect to the specified gradient
  66398. * @returns the current particle system
  66399. */
  66400. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66401. /**
  66402. * Remove a specific velocity gradient
  66403. * @param gradient defines the gradient to remove
  66404. * @returns the current particle system
  66405. */
  66406. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66407. /**
  66408. * Adds a new limit velocity gradient
  66409. * @param gradient defines the gradient to use (between 0 and 1)
  66410. * @param factor defines the limit velocity value to affect to the specified gradient
  66411. * @returns the current particle system
  66412. */
  66413. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66414. /**
  66415. * Remove a specific limit velocity gradient
  66416. * @param gradient defines the gradient to remove
  66417. * @returns the current particle system
  66418. */
  66419. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66420. /**
  66421. * Adds a new drag gradient
  66422. * @param gradient defines the gradient to use (between 0 and 1)
  66423. * @param factor defines the drag value to affect to the specified gradient
  66424. * @returns the current particle system
  66425. */
  66426. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66427. /**
  66428. * Remove a specific drag gradient
  66429. * @param gradient defines the gradient to remove
  66430. * @returns the current particle system
  66431. */
  66432. removeDragGradient(gradient: number): GPUParticleSystem;
  66433. /**
  66434. * Not supported by GPUParticleSystem
  66435. * @param gradient defines the gradient to use (between 0 and 1)
  66436. * @param factor defines the emit rate value to affect to the specified gradient
  66437. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66438. * @returns the current particle system
  66439. */
  66440. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66441. /**
  66442. * Not supported by GPUParticleSystem
  66443. * @param gradient defines the gradient to remove
  66444. * @returns the current particle system
  66445. */
  66446. removeEmitRateGradient(gradient: number): IParticleSystem;
  66447. /**
  66448. * Not supported by GPUParticleSystem
  66449. * @param gradient defines the gradient to use (between 0 and 1)
  66450. * @param factor defines the start size value to affect to the specified gradient
  66451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66452. * @returns the current particle system
  66453. */
  66454. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66455. /**
  66456. * Not supported by GPUParticleSystem
  66457. * @param gradient defines the gradient to remove
  66458. * @returns the current particle system
  66459. */
  66460. removeStartSizeGradient(gradient: number): IParticleSystem;
  66461. /**
  66462. * Not supported by GPUParticleSystem
  66463. * @param gradient defines the gradient to use (between 0 and 1)
  66464. * @param min defines the color remap minimal range
  66465. * @param max defines the color remap maximal range
  66466. * @returns the current particle system
  66467. */
  66468. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66469. /**
  66470. * Not supported by GPUParticleSystem
  66471. * @param gradient defines the gradient to remove
  66472. * @returns the current particle system
  66473. */
  66474. removeColorRemapGradient(): IParticleSystem;
  66475. /**
  66476. * Not supported by GPUParticleSystem
  66477. * @param gradient defines the gradient to use (between 0 and 1)
  66478. * @param min defines the alpha remap minimal range
  66479. * @param max defines the alpha remap maximal range
  66480. * @returns the current particle system
  66481. */
  66482. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66483. /**
  66484. * Not supported by GPUParticleSystem
  66485. * @param gradient defines the gradient to remove
  66486. * @returns the current particle system
  66487. */
  66488. removeAlphaRemapGradient(): IParticleSystem;
  66489. /**
  66490. * Not supported by GPUParticleSystem
  66491. * @param gradient defines the gradient to use (between 0 and 1)
  66492. * @param color defines the color to affect to the specified gradient
  66493. * @returns the current particle system
  66494. */
  66495. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66496. /**
  66497. * Not supported by GPUParticleSystem
  66498. * @param gradient defines the gradient to remove
  66499. * @returns the current particle system
  66500. */
  66501. removeRampGradient(): IParticleSystem;
  66502. /**
  66503. * Not supported by GPUParticleSystem
  66504. * @returns the list of ramp gradients
  66505. */
  66506. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66507. /**
  66508. * Not supported by GPUParticleSystem
  66509. * Gets or sets a boolean indicating that ramp gradients must be used
  66510. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66511. */
  66512. get useRampGradients(): boolean;
  66513. set useRampGradients(value: boolean);
  66514. /**
  66515. * Not supported by GPUParticleSystem
  66516. * @param gradient defines the gradient to use (between 0 and 1)
  66517. * @param factor defines the life time factor to affect to the specified gradient
  66518. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66519. * @returns the current particle system
  66520. */
  66521. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66522. /**
  66523. * Not supported by GPUParticleSystem
  66524. * @param gradient defines the gradient to remove
  66525. * @returns the current particle system
  66526. */
  66527. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66528. /**
  66529. * Instantiates a GPU particle system.
  66530. * 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.
  66531. * @param name The name of the particle system
  66532. * @param options The options used to create the system
  66533. * @param scene The scene the particle system belongs to
  66534. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66535. * @param customEffect a custom effect used to change the way particles are rendered by default
  66536. */
  66537. constructor(name: string, options: Partial<{
  66538. capacity: number;
  66539. randomTextureSize: number;
  66540. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66541. protected _reset(): void;
  66542. private _createUpdateVAO;
  66543. private _createRenderVAO;
  66544. private _initialize;
  66545. /** @hidden */
  66546. _recreateUpdateEffect(): void;
  66547. private _getEffect;
  66548. /**
  66549. * Fill the defines array according to the current settings of the particle system
  66550. * @param defines Array to be updated
  66551. * @param blendMode blend mode to take into account when updating the array
  66552. */
  66553. fillDefines(defines: Array<string>, blendMode?: number): void;
  66554. /**
  66555. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66556. * @param uniforms Uniforms array to fill
  66557. * @param attributes Attributes array to fill
  66558. * @param samplers Samplers array to fill
  66559. */
  66560. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66561. /** @hidden */
  66562. _recreateRenderEffect(): Effect;
  66563. /**
  66564. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66565. * @param preWarm defines if we are in the pre-warmimg phase
  66566. */
  66567. animate(preWarm?: boolean): void;
  66568. private _createFactorGradientTexture;
  66569. private _createSizeGradientTexture;
  66570. private _createAngularSpeedGradientTexture;
  66571. private _createVelocityGradientTexture;
  66572. private _createLimitVelocityGradientTexture;
  66573. private _createDragGradientTexture;
  66574. private _createColorGradientTexture;
  66575. /**
  66576. * Renders the particle system in its current state
  66577. * @param preWarm defines if the system should only update the particles but not render them
  66578. * @returns the current number of particles
  66579. */
  66580. render(preWarm?: boolean): number;
  66581. /**
  66582. * Rebuilds the particle system
  66583. */
  66584. rebuild(): void;
  66585. private _releaseBuffers;
  66586. private _releaseVAOs;
  66587. /**
  66588. * Disposes the particle system and free the associated resources
  66589. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66590. */
  66591. dispose(disposeTexture?: boolean): void;
  66592. /**
  66593. * Clones the particle system.
  66594. * @param name The name of the cloned object
  66595. * @param newEmitter The new emitter to use
  66596. * @returns the cloned particle system
  66597. */
  66598. clone(name: string, newEmitter: any): GPUParticleSystem;
  66599. /**
  66600. * Serializes the particle system to a JSON object
  66601. * @param serializeTexture defines if the texture must be serialized as well
  66602. * @returns the JSON object
  66603. */
  66604. serialize(serializeTexture?: boolean): any;
  66605. /**
  66606. * Parses a JSON object to create a GPU particle system.
  66607. * @param parsedParticleSystem The JSON object to parse
  66608. * @param scene The scene to create the particle system in
  66609. * @param rootUrl The root url to use to load external dependencies like texture
  66610. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66611. * @returns the parsed GPU particle system
  66612. */
  66613. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66614. }
  66615. }
  66616. declare module BABYLON {
  66617. /**
  66618. * Represents a set of particle systems working together to create a specific effect
  66619. */
  66620. export class ParticleSystemSet implements IDisposable {
  66621. /**
  66622. * Gets or sets base Assets URL
  66623. */
  66624. static BaseAssetsUrl: string;
  66625. private _emitterCreationOptions;
  66626. private _emitterNode;
  66627. /**
  66628. * Gets the particle system list
  66629. */
  66630. systems: IParticleSystem[];
  66631. /**
  66632. * Gets the emitter node used with this set
  66633. */
  66634. get emitterNode(): Nullable<TransformNode>;
  66635. /**
  66636. * Creates a new emitter mesh as a sphere
  66637. * @param options defines the options used to create the sphere
  66638. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66639. * @param scene defines the hosting scene
  66640. */
  66641. setEmitterAsSphere(options: {
  66642. diameter: number;
  66643. segments: number;
  66644. color: Color3;
  66645. }, renderingGroupId: number, scene: Scene): void;
  66646. /**
  66647. * Starts all particle systems of the set
  66648. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66649. */
  66650. start(emitter?: AbstractMesh): void;
  66651. /**
  66652. * Release all associated resources
  66653. */
  66654. dispose(): void;
  66655. /**
  66656. * Serialize the set into a JSON compatible object
  66657. * @param serializeTexture defines if the texture must be serialized as well
  66658. * @returns a JSON compatible representation of the set
  66659. */
  66660. serialize(serializeTexture?: boolean): any;
  66661. /**
  66662. * Parse a new ParticleSystemSet from a serialized source
  66663. * @param data defines a JSON compatible representation of the set
  66664. * @param scene defines the hosting scene
  66665. * @param gpu defines if we want GPU particles or CPU particles
  66666. * @returns a new ParticleSystemSet
  66667. */
  66668. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66669. }
  66670. }
  66671. declare module BABYLON {
  66672. /**
  66673. * This class is made for on one-liner static method to help creating particle system set.
  66674. */
  66675. export class ParticleHelper {
  66676. /**
  66677. * Gets or sets base Assets URL
  66678. */
  66679. static BaseAssetsUrl: string;
  66680. /** Define the Url to load snippets */
  66681. static SnippetUrl: string;
  66682. /**
  66683. * Create a default particle system that you can tweak
  66684. * @param emitter defines the emitter to use
  66685. * @param capacity defines the system capacity (default is 500 particles)
  66686. * @param scene defines the hosting scene
  66687. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66688. * @returns the new Particle system
  66689. */
  66690. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66691. /**
  66692. * This is the main static method (one-liner) of this helper to create different particle systems
  66693. * @param type This string represents the type to the particle system to create
  66694. * @param scene The scene where the particle system should live
  66695. * @param gpu If the system will use gpu
  66696. * @returns the ParticleSystemSet created
  66697. */
  66698. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66699. /**
  66700. * Static function used to export a particle system to a ParticleSystemSet variable.
  66701. * Please note that the emitter shape is not exported
  66702. * @param systems defines the particle systems to export
  66703. * @returns the created particle system set
  66704. */
  66705. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66706. /**
  66707. * Creates a particle system from a snippet saved in a remote file
  66708. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66709. * @param url defines the url to load from
  66710. * @param scene defines the hosting scene
  66711. * @param gpu If the system will use gpu
  66712. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66713. * @returns a promise that will resolve to the new particle system
  66714. */
  66715. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66716. /**
  66717. * Creates a particle system from a snippet saved by the particle system editor
  66718. * @param snippetId defines the snippet to load
  66719. * @param scene defines the hosting scene
  66720. * @param gpu If the system will use gpu
  66721. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66722. * @returns a promise that will resolve to the new particle system
  66723. */
  66724. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66725. }
  66726. }
  66727. declare module BABYLON {
  66728. interface Engine {
  66729. /**
  66730. * Create an effect to use with particle systems.
  66731. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  66732. * the particle system for which you want to create a custom effect in the last parameter
  66733. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66734. * @param uniformsNames defines a list of attribute names
  66735. * @param samplers defines an array of string used to represent textures
  66736. * @param defines defines the string containing the defines to use to compile the shaders
  66737. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66738. * @param onCompiled defines a function to call when the effect creation is successful
  66739. * @param onError defines a function to call when the effect creation has failed
  66740. * @param particleSystem the particle system you want to create the effect for
  66741. * @returns the new Effect
  66742. */
  66743. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  66744. }
  66745. interface Mesh {
  66746. /**
  66747. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66748. * @returns an array of IParticleSystem
  66749. */
  66750. getEmittedParticleSystems(): IParticleSystem[];
  66751. /**
  66752. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66753. * @returns an array of IParticleSystem
  66754. */
  66755. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66756. }
  66757. }
  66758. declare module BABYLON {
  66759. /** Defines the 4 color options */
  66760. export enum PointColor {
  66761. /** color value */
  66762. Color = 2,
  66763. /** uv value */
  66764. UV = 1,
  66765. /** random value */
  66766. Random = 0,
  66767. /** stated value */
  66768. Stated = 3
  66769. }
  66770. /**
  66771. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66772. * 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.
  66773. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66774. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66775. *
  66776. * Full documentation here : TO BE ENTERED
  66777. */
  66778. export class PointsCloudSystem implements IDisposable {
  66779. /**
  66780. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66781. * Example : var p = SPS.particles[i];
  66782. */
  66783. particles: CloudPoint[];
  66784. /**
  66785. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66786. */
  66787. nbParticles: number;
  66788. /**
  66789. * This a counter for your own usage. It's not set by any SPS functions.
  66790. */
  66791. counter: number;
  66792. /**
  66793. * The PCS name. This name is also given to the underlying mesh.
  66794. */
  66795. name: string;
  66796. /**
  66797. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66798. */
  66799. mesh: Mesh;
  66800. /**
  66801. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66802. * Please read :
  66803. */
  66804. vars: any;
  66805. /**
  66806. * @hidden
  66807. */
  66808. _size: number;
  66809. private _scene;
  66810. private _promises;
  66811. private _positions;
  66812. private _indices;
  66813. private _normals;
  66814. private _colors;
  66815. private _uvs;
  66816. private _indices32;
  66817. private _positions32;
  66818. private _colors32;
  66819. private _uvs32;
  66820. private _updatable;
  66821. private _isVisibilityBoxLocked;
  66822. private _alwaysVisible;
  66823. private _groups;
  66824. private _groupCounter;
  66825. private _computeParticleColor;
  66826. private _computeParticleTexture;
  66827. private _computeParticleRotation;
  66828. private _computeBoundingBox;
  66829. private _isReady;
  66830. /**
  66831. * Creates a PCS (Points Cloud System) object
  66832. * @param name (String) is the PCS name, this will be the underlying mesh name
  66833. * @param pointSize (number) is the size for each point
  66834. * @param scene (Scene) is the scene in which the PCS is added
  66835. * @param options defines the options of the PCS e.g.
  66836. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66837. */
  66838. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66839. updatable?: boolean;
  66840. });
  66841. /**
  66842. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66843. * If no points were added to the PCS, the returned mesh is just a single point.
  66844. * @returns a promise for the created mesh
  66845. */
  66846. buildMeshAsync(): Promise<Mesh>;
  66847. /**
  66848. * @hidden
  66849. */
  66850. private _buildMesh;
  66851. private _addParticle;
  66852. private _randomUnitVector;
  66853. private _getColorIndicesForCoord;
  66854. private _setPointsColorOrUV;
  66855. private _colorFromTexture;
  66856. private _calculateDensity;
  66857. /**
  66858. * Adds points to the PCS in random positions within a unit sphere
  66859. * @param nb (positive integer) the number of particles to be created from this model
  66860. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66861. * @returns the number of groups in the system
  66862. */
  66863. addPoints(nb: number, pointFunction?: any): number;
  66864. /**
  66865. * Adds points to the PCS from the surface of the model shape
  66866. * @param mesh is any Mesh object that will be used as a surface model for the points
  66867. * @param nb (positive integer) the number of particles to be created from this model
  66868. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66869. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66870. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66871. * @returns the number of groups in the system
  66872. */
  66873. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66874. /**
  66875. * Adds points to the PCS inside the model shape
  66876. * @param mesh is any Mesh object that will be used as a surface model for the points
  66877. * @param nb (positive integer) the number of particles to be created from this model
  66878. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66879. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66880. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66881. * @returns the number of groups in the system
  66882. */
  66883. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66884. /**
  66885. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66886. * This method calls `updateParticle()` for each particle of the SPS.
  66887. * For an animated SPS, it is usually called within the render loop.
  66888. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66889. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66890. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66891. * @returns the PCS.
  66892. */
  66893. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66894. /**
  66895. * Disposes the PCS.
  66896. */
  66897. dispose(): void;
  66898. /**
  66899. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66900. * doc :
  66901. * @returns the PCS.
  66902. */
  66903. refreshVisibleSize(): PointsCloudSystem;
  66904. /**
  66905. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66906. * @param size the size (float) of the visibility box
  66907. * note : this doesn't lock the PCS mesh bounding box.
  66908. * doc :
  66909. */
  66910. setVisibilityBox(size: number): void;
  66911. /**
  66912. * Gets whether the PCS is always visible or not
  66913. * doc :
  66914. */
  66915. get isAlwaysVisible(): boolean;
  66916. /**
  66917. * Sets the PCS as always visible or not
  66918. * doc :
  66919. */
  66920. set isAlwaysVisible(val: boolean);
  66921. /**
  66922. * Tells to `setParticles()` to compute the particle rotations or not
  66923. * Default value : false. The PCS is faster when it's set to false
  66924. * Note : particle rotations are only applied to parent particles
  66925. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66926. */
  66927. set computeParticleRotation(val: boolean);
  66928. /**
  66929. * Tells to `setParticles()` to compute the particle colors or not.
  66930. * Default value : true. The PCS is faster when it's set to false.
  66931. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66932. */
  66933. set computeParticleColor(val: boolean);
  66934. set computeParticleTexture(val: boolean);
  66935. /**
  66936. * Gets if `setParticles()` computes the particle colors or not.
  66937. * Default value : false. The PCS is faster when it's set to false.
  66938. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66939. */
  66940. get computeParticleColor(): boolean;
  66941. /**
  66942. * Gets if `setParticles()` computes the particle textures or not.
  66943. * Default value : false. The PCS is faster when it's set to false.
  66944. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66945. */
  66946. get computeParticleTexture(): boolean;
  66947. /**
  66948. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66949. */
  66950. set computeBoundingBox(val: boolean);
  66951. /**
  66952. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66953. */
  66954. get computeBoundingBox(): boolean;
  66955. /**
  66956. * This function does nothing. It may be overwritten to set all the particle first values.
  66957. * The PCS doesn't call this function, you may have to call it by your own.
  66958. * doc :
  66959. */
  66960. initParticles(): void;
  66961. /**
  66962. * This function does nothing. It may be overwritten to recycle a particle
  66963. * The PCS doesn't call this function, you can to call it
  66964. * doc :
  66965. * @param particle The particle to recycle
  66966. * @returns the recycled particle
  66967. */
  66968. recycleParticle(particle: CloudPoint): CloudPoint;
  66969. /**
  66970. * Updates a particle : this function should be overwritten by the user.
  66971. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66972. * doc :
  66973. * @example : just set a particle position or velocity and recycle conditions
  66974. * @param particle The particle to update
  66975. * @returns the updated particle
  66976. */
  66977. updateParticle(particle: CloudPoint): CloudPoint;
  66978. /**
  66979. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66980. * This does nothing and may be overwritten by the user.
  66981. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66982. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66983. * @param update the boolean update value actually passed to setParticles()
  66984. */
  66985. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66986. /**
  66987. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66988. * This will be passed three parameters.
  66989. * This does nothing and may be overwritten by the user.
  66990. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66991. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66992. * @param update the boolean update value actually passed to setParticles()
  66993. */
  66994. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66995. }
  66996. }
  66997. declare module BABYLON {
  66998. /**
  66999. * Represents one particle of a points cloud system.
  67000. */
  67001. export class CloudPoint {
  67002. /**
  67003. * particle global index
  67004. */
  67005. idx: number;
  67006. /**
  67007. * The color of the particle
  67008. */
  67009. color: Nullable<Color4>;
  67010. /**
  67011. * The world space position of the particle.
  67012. */
  67013. position: Vector3;
  67014. /**
  67015. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67016. */
  67017. rotation: Vector3;
  67018. /**
  67019. * The world space rotation quaternion of the particle.
  67020. */
  67021. rotationQuaternion: Nullable<Quaternion>;
  67022. /**
  67023. * The uv of the particle.
  67024. */
  67025. uv: Nullable<Vector2>;
  67026. /**
  67027. * The current speed of the particle.
  67028. */
  67029. velocity: Vector3;
  67030. /**
  67031. * The pivot point in the particle local space.
  67032. */
  67033. pivot: Vector3;
  67034. /**
  67035. * Must the particle be translated from its pivot point in its local space ?
  67036. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67037. * Default : false
  67038. */
  67039. translateFromPivot: boolean;
  67040. /**
  67041. * Index of this particle in the global "positions" array (Internal use)
  67042. * @hidden
  67043. */
  67044. _pos: number;
  67045. /**
  67046. * @hidden Index of this particle in the global "indices" array (Internal use)
  67047. */
  67048. _ind: number;
  67049. /**
  67050. * Group this particle belongs to
  67051. */
  67052. _group: PointsGroup;
  67053. /**
  67054. * Group id of this particle
  67055. */
  67056. groupId: number;
  67057. /**
  67058. * Index of the particle in its group id (Internal use)
  67059. */
  67060. idxInGroup: number;
  67061. /**
  67062. * @hidden Particle BoundingInfo object (Internal use)
  67063. */
  67064. _boundingInfo: BoundingInfo;
  67065. /**
  67066. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67067. */
  67068. _pcs: PointsCloudSystem;
  67069. /**
  67070. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67071. */
  67072. _stillInvisible: boolean;
  67073. /**
  67074. * @hidden Last computed particle rotation matrix
  67075. */
  67076. _rotationMatrix: number[];
  67077. /**
  67078. * Parent particle Id, if any.
  67079. * Default null.
  67080. */
  67081. parentId: Nullable<number>;
  67082. /**
  67083. * @hidden Internal global position in the PCS.
  67084. */
  67085. _globalPosition: Vector3;
  67086. /**
  67087. * Creates a Point Cloud object.
  67088. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67089. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67090. * @param group (PointsGroup) is the group the particle belongs to
  67091. * @param groupId (integer) is the group identifier in the PCS.
  67092. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67093. * @param pcs defines the PCS it is associated to
  67094. */
  67095. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67096. /**
  67097. * get point size
  67098. */
  67099. get size(): Vector3;
  67100. /**
  67101. * Set point size
  67102. */
  67103. set size(scale: Vector3);
  67104. /**
  67105. * Legacy support, changed quaternion to rotationQuaternion
  67106. */
  67107. get quaternion(): Nullable<Quaternion>;
  67108. /**
  67109. * Legacy support, changed quaternion to rotationQuaternion
  67110. */
  67111. set quaternion(q: Nullable<Quaternion>);
  67112. /**
  67113. * Returns a boolean. True if the particle intersects a mesh, else false
  67114. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67115. * @param target is the object (point or mesh) what the intersection is computed against
  67116. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67117. * @returns true if it intersects
  67118. */
  67119. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67120. /**
  67121. * get the rotation matrix of the particle
  67122. * @hidden
  67123. */
  67124. getRotationMatrix(m: Matrix): void;
  67125. }
  67126. /**
  67127. * Represents a group of points in a points cloud system
  67128. * * PCS internal tool, don't use it manually.
  67129. */
  67130. export class PointsGroup {
  67131. /**
  67132. * The group id
  67133. * @hidden
  67134. */
  67135. groupID: number;
  67136. /**
  67137. * image data for group (internal use)
  67138. * @hidden
  67139. */
  67140. _groupImageData: Nullable<ArrayBufferView>;
  67141. /**
  67142. * Image Width (internal use)
  67143. * @hidden
  67144. */
  67145. _groupImgWidth: number;
  67146. /**
  67147. * Image Height (internal use)
  67148. * @hidden
  67149. */
  67150. _groupImgHeight: number;
  67151. /**
  67152. * Custom position function (internal use)
  67153. * @hidden
  67154. */
  67155. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67156. /**
  67157. * density per facet for surface points
  67158. * @hidden
  67159. */
  67160. _groupDensity: number[];
  67161. /**
  67162. * Only when points are colored by texture carries pointer to texture list array
  67163. * @hidden
  67164. */
  67165. _textureNb: number;
  67166. /**
  67167. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67168. * PCS internal tool, don't use it manually.
  67169. * @hidden
  67170. */
  67171. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67172. }
  67173. }
  67174. declare module BABYLON {
  67175. interface Scene {
  67176. /** @hidden (Backing field) */
  67177. _physicsEngine: Nullable<IPhysicsEngine>;
  67178. /** @hidden */
  67179. _physicsTimeAccumulator: number;
  67180. /**
  67181. * Gets the current physics engine
  67182. * @returns a IPhysicsEngine or null if none attached
  67183. */
  67184. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67185. /**
  67186. * Enables physics to the current scene
  67187. * @param gravity defines the scene's gravity for the physics engine
  67188. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67189. * @return a boolean indicating if the physics engine was initialized
  67190. */
  67191. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67192. /**
  67193. * Disables and disposes the physics engine associated with the scene
  67194. */
  67195. disablePhysicsEngine(): void;
  67196. /**
  67197. * Gets a boolean indicating if there is an active physics engine
  67198. * @returns a boolean indicating if there is an active physics engine
  67199. */
  67200. isPhysicsEnabled(): boolean;
  67201. /**
  67202. * Deletes a physics compound impostor
  67203. * @param compound defines the compound to delete
  67204. */
  67205. deleteCompoundImpostor(compound: any): void;
  67206. /**
  67207. * An event triggered when physic simulation is about to be run
  67208. */
  67209. onBeforePhysicsObservable: Observable<Scene>;
  67210. /**
  67211. * An event triggered when physic simulation has been done
  67212. */
  67213. onAfterPhysicsObservable: Observable<Scene>;
  67214. }
  67215. interface AbstractMesh {
  67216. /** @hidden */
  67217. _physicsImpostor: Nullable<PhysicsImpostor>;
  67218. /**
  67219. * Gets or sets impostor used for physic simulation
  67220. * @see http://doc.babylonjs.com/features/physics_engine
  67221. */
  67222. physicsImpostor: Nullable<PhysicsImpostor>;
  67223. /**
  67224. * Gets the current physics impostor
  67225. * @see http://doc.babylonjs.com/features/physics_engine
  67226. * @returns a physics impostor or null
  67227. */
  67228. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67229. /** Apply a physic impulse to the mesh
  67230. * @param force defines the force to apply
  67231. * @param contactPoint defines where to apply the force
  67232. * @returns the current mesh
  67233. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67234. */
  67235. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67236. /**
  67237. * Creates a physic joint between two meshes
  67238. * @param otherMesh defines the other mesh to use
  67239. * @param pivot1 defines the pivot to use on this mesh
  67240. * @param pivot2 defines the pivot to use on the other mesh
  67241. * @param options defines additional options (can be plugin dependent)
  67242. * @returns the current mesh
  67243. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67244. */
  67245. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67246. /** @hidden */
  67247. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67248. }
  67249. /**
  67250. * Defines the physics engine scene component responsible to manage a physics engine
  67251. */
  67252. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67253. /**
  67254. * The component name helpful to identify the component in the list of scene components.
  67255. */
  67256. readonly name: string;
  67257. /**
  67258. * The scene the component belongs to.
  67259. */
  67260. scene: Scene;
  67261. /**
  67262. * Creates a new instance of the component for the given scene
  67263. * @param scene Defines the scene to register the component in
  67264. */
  67265. constructor(scene: Scene);
  67266. /**
  67267. * Registers the component in a given scene
  67268. */
  67269. register(): void;
  67270. /**
  67271. * Rebuilds the elements related to this component in case of
  67272. * context lost for instance.
  67273. */
  67274. rebuild(): void;
  67275. /**
  67276. * Disposes the component and the associated ressources
  67277. */
  67278. dispose(): void;
  67279. }
  67280. }
  67281. declare module BABYLON {
  67282. /**
  67283. * A helper for physics simulations
  67284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67285. */
  67286. export class PhysicsHelper {
  67287. private _scene;
  67288. private _physicsEngine;
  67289. /**
  67290. * Initializes the Physics helper
  67291. * @param scene Babylon.js scene
  67292. */
  67293. constructor(scene: Scene);
  67294. /**
  67295. * Applies a radial explosion impulse
  67296. * @param origin the origin of the explosion
  67297. * @param radiusOrEventOptions the radius or the options of radial explosion
  67298. * @param strength the explosion strength
  67299. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67300. * @returns A physics radial explosion event, or null
  67301. */
  67302. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67303. /**
  67304. * Applies a radial explosion force
  67305. * @param origin the origin of the explosion
  67306. * @param radiusOrEventOptions the radius or the options of radial explosion
  67307. * @param strength the explosion strength
  67308. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67309. * @returns A physics radial explosion event, or null
  67310. */
  67311. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67312. /**
  67313. * Creates a gravitational field
  67314. * @param origin the origin of the explosion
  67315. * @param radiusOrEventOptions the radius or the options of radial explosion
  67316. * @param strength the explosion strength
  67317. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67318. * @returns A physics gravitational field event, or null
  67319. */
  67320. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67321. /**
  67322. * Creates a physics updraft event
  67323. * @param origin the origin of the updraft
  67324. * @param radiusOrEventOptions the radius or the options of the updraft
  67325. * @param strength the strength of the updraft
  67326. * @param height the height of the updraft
  67327. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67328. * @returns A physics updraft event, or null
  67329. */
  67330. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67331. /**
  67332. * Creates a physics vortex event
  67333. * @param origin the of the vortex
  67334. * @param radiusOrEventOptions the radius or the options of the vortex
  67335. * @param strength the strength of the vortex
  67336. * @param height the height of the vortex
  67337. * @returns a Physics vortex event, or null
  67338. * A physics vortex event or null
  67339. */
  67340. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67341. }
  67342. /**
  67343. * Represents a physics radial explosion event
  67344. */
  67345. class PhysicsRadialExplosionEvent {
  67346. private _scene;
  67347. private _options;
  67348. private _sphere;
  67349. private _dataFetched;
  67350. /**
  67351. * Initializes a radial explosioin event
  67352. * @param _scene BabylonJS scene
  67353. * @param _options The options for the vortex event
  67354. */
  67355. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67356. /**
  67357. * Returns the data related to the radial explosion event (sphere).
  67358. * @returns The radial explosion event data
  67359. */
  67360. getData(): PhysicsRadialExplosionEventData;
  67361. /**
  67362. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67363. * @param impostor A physics imposter
  67364. * @param origin the origin of the explosion
  67365. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67366. */
  67367. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67368. /**
  67369. * Triggers affecterd impostors callbacks
  67370. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67371. */
  67372. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67373. /**
  67374. * Disposes the sphere.
  67375. * @param force Specifies if the sphere should be disposed by force
  67376. */
  67377. dispose(force?: boolean): void;
  67378. /*** Helpers ***/
  67379. private _prepareSphere;
  67380. private _intersectsWithSphere;
  67381. }
  67382. /**
  67383. * Represents a gravitational field event
  67384. */
  67385. class PhysicsGravitationalFieldEvent {
  67386. private _physicsHelper;
  67387. private _scene;
  67388. private _origin;
  67389. private _options;
  67390. private _tickCallback;
  67391. private _sphere;
  67392. private _dataFetched;
  67393. /**
  67394. * Initializes the physics gravitational field event
  67395. * @param _physicsHelper A physics helper
  67396. * @param _scene BabylonJS scene
  67397. * @param _origin The origin position of the gravitational field event
  67398. * @param _options The options for the vortex event
  67399. */
  67400. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67401. /**
  67402. * Returns the data related to the gravitational field event (sphere).
  67403. * @returns A gravitational field event
  67404. */
  67405. getData(): PhysicsGravitationalFieldEventData;
  67406. /**
  67407. * Enables the gravitational field.
  67408. */
  67409. enable(): void;
  67410. /**
  67411. * Disables the gravitational field.
  67412. */
  67413. disable(): void;
  67414. /**
  67415. * Disposes the sphere.
  67416. * @param force The force to dispose from the gravitational field event
  67417. */
  67418. dispose(force?: boolean): void;
  67419. private _tick;
  67420. }
  67421. /**
  67422. * Represents a physics updraft event
  67423. */
  67424. class PhysicsUpdraftEvent {
  67425. private _scene;
  67426. private _origin;
  67427. private _options;
  67428. private _physicsEngine;
  67429. private _originTop;
  67430. private _originDirection;
  67431. private _tickCallback;
  67432. private _cylinder;
  67433. private _cylinderPosition;
  67434. private _dataFetched;
  67435. /**
  67436. * Initializes the physics updraft event
  67437. * @param _scene BabylonJS scene
  67438. * @param _origin The origin position of the updraft
  67439. * @param _options The options for the updraft event
  67440. */
  67441. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67442. /**
  67443. * Returns the data related to the updraft event (cylinder).
  67444. * @returns A physics updraft event
  67445. */
  67446. getData(): PhysicsUpdraftEventData;
  67447. /**
  67448. * Enables the updraft.
  67449. */
  67450. enable(): void;
  67451. /**
  67452. * Disables the updraft.
  67453. */
  67454. disable(): void;
  67455. /**
  67456. * Disposes the cylinder.
  67457. * @param force Specifies if the updraft should be disposed by force
  67458. */
  67459. dispose(force?: boolean): void;
  67460. private getImpostorHitData;
  67461. private _tick;
  67462. /*** Helpers ***/
  67463. private _prepareCylinder;
  67464. private _intersectsWithCylinder;
  67465. }
  67466. /**
  67467. * Represents a physics vortex event
  67468. */
  67469. class PhysicsVortexEvent {
  67470. private _scene;
  67471. private _origin;
  67472. private _options;
  67473. private _physicsEngine;
  67474. private _originTop;
  67475. private _tickCallback;
  67476. private _cylinder;
  67477. private _cylinderPosition;
  67478. private _dataFetched;
  67479. /**
  67480. * Initializes the physics vortex event
  67481. * @param _scene The BabylonJS scene
  67482. * @param _origin The origin position of the vortex
  67483. * @param _options The options for the vortex event
  67484. */
  67485. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67486. /**
  67487. * Returns the data related to the vortex event (cylinder).
  67488. * @returns The physics vortex event data
  67489. */
  67490. getData(): PhysicsVortexEventData;
  67491. /**
  67492. * Enables the vortex.
  67493. */
  67494. enable(): void;
  67495. /**
  67496. * Disables the cortex.
  67497. */
  67498. disable(): void;
  67499. /**
  67500. * Disposes the sphere.
  67501. * @param force
  67502. */
  67503. dispose(force?: boolean): void;
  67504. private getImpostorHitData;
  67505. private _tick;
  67506. /*** Helpers ***/
  67507. private _prepareCylinder;
  67508. private _intersectsWithCylinder;
  67509. }
  67510. /**
  67511. * Options fot the radial explosion event
  67512. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67513. */
  67514. export class PhysicsRadialExplosionEventOptions {
  67515. /**
  67516. * The radius of the sphere for the radial explosion.
  67517. */
  67518. radius: number;
  67519. /**
  67520. * The strenth of the explosion.
  67521. */
  67522. strength: number;
  67523. /**
  67524. * The strenght of the force in correspondence to the distance of the affected object
  67525. */
  67526. falloff: PhysicsRadialImpulseFalloff;
  67527. /**
  67528. * Sphere options for the radial explosion.
  67529. */
  67530. sphere: {
  67531. segments: number;
  67532. diameter: number;
  67533. };
  67534. /**
  67535. * Sphere options for the radial explosion.
  67536. */
  67537. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67538. }
  67539. /**
  67540. * Options fot the updraft event
  67541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67542. */
  67543. export class PhysicsUpdraftEventOptions {
  67544. /**
  67545. * The radius of the cylinder for the vortex
  67546. */
  67547. radius: number;
  67548. /**
  67549. * The strenth of the updraft.
  67550. */
  67551. strength: number;
  67552. /**
  67553. * The height of the cylinder for the updraft.
  67554. */
  67555. height: number;
  67556. /**
  67557. * The mode for the the updraft.
  67558. */
  67559. updraftMode: PhysicsUpdraftMode;
  67560. }
  67561. /**
  67562. * Options fot the vortex event
  67563. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67564. */
  67565. export class PhysicsVortexEventOptions {
  67566. /**
  67567. * The radius of the cylinder for the vortex
  67568. */
  67569. radius: number;
  67570. /**
  67571. * The strenth of the vortex.
  67572. */
  67573. strength: number;
  67574. /**
  67575. * The height of the cylinder for the vortex.
  67576. */
  67577. height: number;
  67578. /**
  67579. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67580. */
  67581. centripetalForceThreshold: number;
  67582. /**
  67583. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67584. */
  67585. centripetalForceMultiplier: number;
  67586. /**
  67587. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67588. */
  67589. centrifugalForceMultiplier: number;
  67590. /**
  67591. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67592. */
  67593. updraftForceMultiplier: number;
  67594. }
  67595. /**
  67596. * The strenght of the force in correspondence to the distance of the affected object
  67597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67598. */
  67599. export enum PhysicsRadialImpulseFalloff {
  67600. /** Defines that impulse is constant in strength across it's whole radius */
  67601. Constant = 0,
  67602. /** Defines that impulse gets weaker if it's further from the origin */
  67603. Linear = 1
  67604. }
  67605. /**
  67606. * The strength of the force in correspondence to the distance of the affected object
  67607. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67608. */
  67609. export enum PhysicsUpdraftMode {
  67610. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67611. Center = 0,
  67612. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67613. Perpendicular = 1
  67614. }
  67615. /**
  67616. * Interface for a physics hit data
  67617. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67618. */
  67619. export interface PhysicsHitData {
  67620. /**
  67621. * The force applied at the contact point
  67622. */
  67623. force: Vector3;
  67624. /**
  67625. * The contact point
  67626. */
  67627. contactPoint: Vector3;
  67628. /**
  67629. * The distance from the origin to the contact point
  67630. */
  67631. distanceFromOrigin: number;
  67632. }
  67633. /**
  67634. * Interface for radial explosion event data
  67635. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67636. */
  67637. export interface PhysicsRadialExplosionEventData {
  67638. /**
  67639. * A sphere used for the radial explosion event
  67640. */
  67641. sphere: Mesh;
  67642. }
  67643. /**
  67644. * Interface for gravitational field event data
  67645. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67646. */
  67647. export interface PhysicsGravitationalFieldEventData {
  67648. /**
  67649. * A sphere mesh used for the gravitational field event
  67650. */
  67651. sphere: Mesh;
  67652. }
  67653. /**
  67654. * Interface for updraft event data
  67655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67656. */
  67657. export interface PhysicsUpdraftEventData {
  67658. /**
  67659. * A cylinder used for the updraft event
  67660. */
  67661. cylinder: Mesh;
  67662. }
  67663. /**
  67664. * Interface for vortex event data
  67665. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67666. */
  67667. export interface PhysicsVortexEventData {
  67668. /**
  67669. * A cylinder used for the vortex event
  67670. */
  67671. cylinder: Mesh;
  67672. }
  67673. /**
  67674. * Interface for an affected physics impostor
  67675. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67676. */
  67677. export interface PhysicsAffectedImpostorWithData {
  67678. /**
  67679. * The impostor affected by the effect
  67680. */
  67681. impostor: PhysicsImpostor;
  67682. /**
  67683. * The data about the hit/horce from the explosion
  67684. */
  67685. hitData: PhysicsHitData;
  67686. }
  67687. }
  67688. declare module BABYLON {
  67689. /** @hidden */
  67690. export var blackAndWhitePixelShader: {
  67691. name: string;
  67692. shader: string;
  67693. };
  67694. }
  67695. declare module BABYLON {
  67696. /**
  67697. * Post process used to render in black and white
  67698. */
  67699. export class BlackAndWhitePostProcess extends PostProcess {
  67700. /**
  67701. * Linear about to convert he result to black and white (default: 1)
  67702. */
  67703. degree: number;
  67704. /**
  67705. * Creates a black and white post process
  67706. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67707. * @param name The name of the effect.
  67708. * @param options The required width/height ratio to downsize to before computing the render pass.
  67709. * @param camera The camera to apply the render pass to.
  67710. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67711. * @param engine The engine which the post process will be applied. (default: current engine)
  67712. * @param reusable If the post process can be reused on the same frame. (default: false)
  67713. */
  67714. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67715. }
  67716. }
  67717. declare module BABYLON {
  67718. /**
  67719. * This represents a set of one or more post processes in Babylon.
  67720. * A post process can be used to apply a shader to a texture after it is rendered.
  67721. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67722. */
  67723. export class PostProcessRenderEffect {
  67724. private _postProcesses;
  67725. private _getPostProcesses;
  67726. private _singleInstance;
  67727. private _cameras;
  67728. private _indicesForCamera;
  67729. /**
  67730. * Name of the effect
  67731. * @hidden
  67732. */
  67733. _name: string;
  67734. /**
  67735. * Instantiates a post process render effect.
  67736. * A post process can be used to apply a shader to a texture after it is rendered.
  67737. * @param engine The engine the effect is tied to
  67738. * @param name The name of the effect
  67739. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67740. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67741. */
  67742. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67743. /**
  67744. * Checks if all the post processes in the effect are supported.
  67745. */
  67746. get isSupported(): boolean;
  67747. /**
  67748. * Updates the current state of the effect
  67749. * @hidden
  67750. */
  67751. _update(): 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. * Attaches the effect on cameras
  67760. * @param cameras The camera to attach to.
  67761. * @hidden
  67762. */
  67763. _attachCameras(cameras: Camera[]): void;
  67764. /**
  67765. * Detaches the effect on cameras
  67766. * @param cameras The camera to detatch from.
  67767. * @hidden
  67768. */
  67769. _detachCameras(cameras: Camera): void;
  67770. /**
  67771. * Detatches the effect on cameras
  67772. * @param cameras The camera to detatch from.
  67773. * @hidden
  67774. */
  67775. _detachCameras(cameras: Camera[]): void;
  67776. /**
  67777. * Enables the effect on given cameras
  67778. * @param cameras The camera to enable.
  67779. * @hidden
  67780. */
  67781. _enable(cameras: Camera): void;
  67782. /**
  67783. * Enables the effect on given cameras
  67784. * @param cameras The camera to enable.
  67785. * @hidden
  67786. */
  67787. _enable(cameras: Nullable<Camera[]>): void;
  67788. /**
  67789. * Disables the effect on the given cameras
  67790. * @param cameras The camera to disable.
  67791. * @hidden
  67792. */
  67793. _disable(cameras: Camera): void;
  67794. /**
  67795. * Disables the effect on the given cameras
  67796. * @param cameras The camera to disable.
  67797. * @hidden
  67798. */
  67799. _disable(cameras: Nullable<Camera[]>): void;
  67800. /**
  67801. * Gets a list of the post processes contained in the effect.
  67802. * @param camera The camera to get the post processes on.
  67803. * @returns The list of the post processes in the effect.
  67804. */
  67805. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67806. }
  67807. }
  67808. declare module BABYLON {
  67809. /** @hidden */
  67810. export var extractHighlightsPixelShader: {
  67811. name: string;
  67812. shader: string;
  67813. };
  67814. }
  67815. declare module BABYLON {
  67816. /**
  67817. * 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.
  67818. */
  67819. export class ExtractHighlightsPostProcess extends PostProcess {
  67820. /**
  67821. * The luminance threshold, pixels below this value will be set to black.
  67822. */
  67823. threshold: number;
  67824. /** @hidden */
  67825. _exposure: number;
  67826. /**
  67827. * Post process which has the input texture to be used when performing highlight extraction
  67828. * @hidden
  67829. */
  67830. _inputPostProcess: Nullable<PostProcess>;
  67831. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67832. }
  67833. }
  67834. declare module BABYLON {
  67835. /** @hidden */
  67836. export var bloomMergePixelShader: {
  67837. name: string;
  67838. shader: string;
  67839. };
  67840. }
  67841. declare module BABYLON {
  67842. /**
  67843. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67844. */
  67845. export class BloomMergePostProcess extends PostProcess {
  67846. /** Weight of the bloom to be added to the original input. */
  67847. weight: number;
  67848. /**
  67849. * Creates a new instance of @see BloomMergePostProcess
  67850. * @param name The name of the effect.
  67851. * @param originalFromInput Post process which's input will be used for the merge.
  67852. * @param blurred Blurred highlights post process which's output will be used.
  67853. * @param weight Weight of the bloom to be added to the original input.
  67854. * @param options The required width/height ratio to downsize to before computing the render pass.
  67855. * @param camera The camera to apply the render pass to.
  67856. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67857. * @param engine The engine which the post process will be applied. (default: current engine)
  67858. * @param reusable If the post process can be reused on the same frame. (default: false)
  67859. * @param textureType Type of textures used when performing the post process. (default: 0)
  67860. * @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)
  67861. */
  67862. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67863. /** Weight of the bloom to be added to the original input. */
  67864. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67865. }
  67866. }
  67867. declare module BABYLON {
  67868. /**
  67869. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67870. */
  67871. export class BloomEffect extends PostProcessRenderEffect {
  67872. private bloomScale;
  67873. /**
  67874. * @hidden Internal
  67875. */
  67876. _effects: Array<PostProcess>;
  67877. /**
  67878. * @hidden Internal
  67879. */
  67880. _downscale: ExtractHighlightsPostProcess;
  67881. private _blurX;
  67882. private _blurY;
  67883. private _merge;
  67884. /**
  67885. * The luminance threshold to find bright areas of the image to bloom.
  67886. */
  67887. get threshold(): number;
  67888. set threshold(value: number);
  67889. /**
  67890. * The strength of the bloom.
  67891. */
  67892. get weight(): number;
  67893. set weight(value: number);
  67894. /**
  67895. * Specifies the size of the bloom blur kernel, relative to the final output size
  67896. */
  67897. get kernel(): number;
  67898. set kernel(value: number);
  67899. /**
  67900. * Creates a new instance of @see BloomEffect
  67901. * @param scene The scene the effect belongs to.
  67902. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67903. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67904. * @param bloomWeight The the strength of bloom.
  67905. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67906. * @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)
  67907. */
  67908. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67909. /**
  67910. * Disposes each of the internal effects for a given camera.
  67911. * @param camera The camera to dispose the effect on.
  67912. */
  67913. disposeEffects(camera: Camera): void;
  67914. /**
  67915. * @hidden Internal
  67916. */
  67917. _updateEffects(): void;
  67918. /**
  67919. * Internal
  67920. * @returns if all the contained post processes are ready.
  67921. * @hidden
  67922. */
  67923. _isReady(): boolean;
  67924. }
  67925. }
  67926. declare module BABYLON {
  67927. /** @hidden */
  67928. export var chromaticAberrationPixelShader: {
  67929. name: string;
  67930. shader: string;
  67931. };
  67932. }
  67933. declare module BABYLON {
  67934. /**
  67935. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67936. */
  67937. export class ChromaticAberrationPostProcess extends PostProcess {
  67938. /**
  67939. * The amount of seperation of rgb channels (default: 30)
  67940. */
  67941. aberrationAmount: number;
  67942. /**
  67943. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67944. */
  67945. radialIntensity: number;
  67946. /**
  67947. * 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))
  67948. */
  67949. direction: Vector2;
  67950. /**
  67951. * 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))
  67952. */
  67953. centerPosition: Vector2;
  67954. /**
  67955. * Creates a new instance ChromaticAberrationPostProcess
  67956. * @param name The name of the effect.
  67957. * @param screenWidth The width of the screen to apply the effect on.
  67958. * @param screenHeight The height of the screen to apply the effect on.
  67959. * @param options The required width/height ratio to downsize to before computing the render pass.
  67960. * @param camera The camera to apply the render pass to.
  67961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67962. * @param engine The engine which the post process will be applied. (default: current engine)
  67963. * @param reusable If the post process can be reused on the same frame. (default: false)
  67964. * @param textureType Type of textures used when performing the post process. (default: 0)
  67965. * @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)
  67966. */
  67967. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67968. }
  67969. }
  67970. declare module BABYLON {
  67971. /** @hidden */
  67972. export var circleOfConfusionPixelShader: {
  67973. name: string;
  67974. shader: string;
  67975. };
  67976. }
  67977. declare module BABYLON {
  67978. /**
  67979. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67980. */
  67981. export class CircleOfConfusionPostProcess extends PostProcess {
  67982. /**
  67983. * 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.
  67984. */
  67985. lensSize: number;
  67986. /**
  67987. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67988. */
  67989. fStop: number;
  67990. /**
  67991. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67992. */
  67993. focusDistance: number;
  67994. /**
  67995. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67996. */
  67997. focalLength: number;
  67998. private _depthTexture;
  67999. /**
  68000. * Creates a new instance CircleOfConfusionPostProcess
  68001. * @param name The name of the effect.
  68002. * @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.
  68003. * @param options The required width/height ratio to downsize to before computing the render pass.
  68004. * @param camera The camera to apply the render pass to.
  68005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68006. * @param engine The engine which the post process will be applied. (default: current engine)
  68007. * @param reusable If the post process can be reused on the same frame. (default: false)
  68008. * @param textureType Type of textures used when performing the post process. (default: 0)
  68009. * @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)
  68010. */
  68011. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68012. /**
  68013. * 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.
  68014. */
  68015. set depthTexture(value: RenderTargetTexture);
  68016. }
  68017. }
  68018. declare module BABYLON {
  68019. /** @hidden */
  68020. export var colorCorrectionPixelShader: {
  68021. name: string;
  68022. shader: string;
  68023. };
  68024. }
  68025. declare module BABYLON {
  68026. /**
  68027. *
  68028. * This post-process allows the modification of rendered colors by using
  68029. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68030. *
  68031. * The object needs to be provided an url to a texture containing the color
  68032. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68033. * Use an image editing software to tweak the LUT to match your needs.
  68034. *
  68035. * For an example of a color LUT, see here:
  68036. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68037. * For explanations on color grading, see here:
  68038. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68039. *
  68040. */
  68041. export class ColorCorrectionPostProcess extends PostProcess {
  68042. private _colorTableTexture;
  68043. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68044. }
  68045. }
  68046. declare module BABYLON {
  68047. /** @hidden */
  68048. export var convolutionPixelShader: {
  68049. name: string;
  68050. shader: string;
  68051. };
  68052. }
  68053. declare module BABYLON {
  68054. /**
  68055. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68056. * input texture to perform effects such as edge detection or sharpening
  68057. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68058. */
  68059. export class ConvolutionPostProcess extends PostProcess {
  68060. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68061. kernel: number[];
  68062. /**
  68063. * Creates a new instance ConvolutionPostProcess
  68064. * @param name The name of the effect.
  68065. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68066. * @param options The required width/height ratio to downsize to before computing the render pass.
  68067. * @param camera The camera to apply the render pass to.
  68068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68069. * @param engine The engine which the post process will be applied. (default: current engine)
  68070. * @param reusable If the post process can be reused on the same frame. (default: false)
  68071. * @param textureType Type of textures used when performing the post process. (default: 0)
  68072. */
  68073. constructor(name: string,
  68074. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68075. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68076. /**
  68077. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68078. */
  68079. static EdgeDetect0Kernel: number[];
  68080. /**
  68081. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68082. */
  68083. static EdgeDetect1Kernel: number[];
  68084. /**
  68085. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68086. */
  68087. static EdgeDetect2Kernel: number[];
  68088. /**
  68089. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68090. */
  68091. static SharpenKernel: number[];
  68092. /**
  68093. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68094. */
  68095. static EmbossKernel: number[];
  68096. /**
  68097. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68098. */
  68099. static GaussianKernel: number[];
  68100. }
  68101. }
  68102. declare module BABYLON {
  68103. /**
  68104. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68105. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68106. * based on samples that have a large difference in distance than the center pixel.
  68107. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68108. */
  68109. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68110. direction: Vector2;
  68111. /**
  68112. * Creates a new instance CircleOfConfusionPostProcess
  68113. * @param name The name of the effect.
  68114. * @param scene The scene the effect belongs to.
  68115. * @param direction The direction the blur should be applied.
  68116. * @param kernel The size of the kernel used to blur.
  68117. * @param options The required width/height ratio to downsize to before computing the render pass.
  68118. * @param camera The camera to apply the render pass to.
  68119. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68120. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68121. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68122. * @param engine The engine which the post process will be applied. (default: current engine)
  68123. * @param reusable If the post process can be reused on the same frame. (default: false)
  68124. * @param textureType Type of textures used when performing the post process. (default: 0)
  68125. * @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)
  68126. */
  68127. 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);
  68128. }
  68129. }
  68130. declare module BABYLON {
  68131. /** @hidden */
  68132. export var depthOfFieldMergePixelShader: {
  68133. name: string;
  68134. shader: string;
  68135. };
  68136. }
  68137. declare module BABYLON {
  68138. /**
  68139. * Options to be set when merging outputs from the default pipeline.
  68140. */
  68141. export class DepthOfFieldMergePostProcessOptions {
  68142. /**
  68143. * The original image to merge on top of
  68144. */
  68145. originalFromInput: PostProcess;
  68146. /**
  68147. * Parameters to perform the merge of the depth of field effect
  68148. */
  68149. depthOfField?: {
  68150. circleOfConfusion: PostProcess;
  68151. blurSteps: Array<PostProcess>;
  68152. };
  68153. /**
  68154. * Parameters to perform the merge of bloom effect
  68155. */
  68156. bloom?: {
  68157. blurred: PostProcess;
  68158. weight: number;
  68159. };
  68160. }
  68161. /**
  68162. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68163. */
  68164. export class DepthOfFieldMergePostProcess extends PostProcess {
  68165. private blurSteps;
  68166. /**
  68167. * Creates a new instance of DepthOfFieldMergePostProcess
  68168. * @param name The name of the effect.
  68169. * @param originalFromInput Post process which's input will be used for the merge.
  68170. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68171. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68172. * @param options The required width/height ratio to downsize to before computing the render pass.
  68173. * @param camera The camera to apply the render pass to.
  68174. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68175. * @param engine The engine which the post process will be applied. (default: current engine)
  68176. * @param reusable If the post process can be reused on the same frame. (default: false)
  68177. * @param textureType Type of textures used when performing the post process. (default: 0)
  68178. * @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)
  68179. */
  68180. 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);
  68181. /**
  68182. * Updates the effect with the current post process compile time values and recompiles the shader.
  68183. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68184. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68185. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68186. * @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
  68187. * @param onCompiled Called when the shader has been compiled.
  68188. * @param onError Called if there is an error when compiling a shader.
  68189. */
  68190. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68191. }
  68192. }
  68193. declare module BABYLON {
  68194. /**
  68195. * Specifies the level of max blur that should be applied when using the depth of field effect
  68196. */
  68197. export enum DepthOfFieldEffectBlurLevel {
  68198. /**
  68199. * Subtle blur
  68200. */
  68201. Low = 0,
  68202. /**
  68203. * Medium blur
  68204. */
  68205. Medium = 1,
  68206. /**
  68207. * Large blur
  68208. */
  68209. High = 2
  68210. }
  68211. /**
  68212. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68213. */
  68214. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68215. private _circleOfConfusion;
  68216. /**
  68217. * @hidden Internal, blurs from high to low
  68218. */
  68219. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68220. private _depthOfFieldBlurY;
  68221. private _dofMerge;
  68222. /**
  68223. * @hidden Internal post processes in depth of field effect
  68224. */
  68225. _effects: Array<PostProcess>;
  68226. /**
  68227. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68228. */
  68229. set focalLength(value: number);
  68230. get focalLength(): number;
  68231. /**
  68232. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68233. */
  68234. set fStop(value: number);
  68235. get fStop(): number;
  68236. /**
  68237. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68238. */
  68239. set focusDistance(value: number);
  68240. get focusDistance(): number;
  68241. /**
  68242. * 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.
  68243. */
  68244. set lensSize(value: number);
  68245. get lensSize(): number;
  68246. /**
  68247. * Creates a new instance DepthOfFieldEffect
  68248. * @param scene The scene the effect belongs to.
  68249. * @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.
  68250. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68251. * @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)
  68252. */
  68253. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68254. /**
  68255. * Get the current class name of the current effet
  68256. * @returns "DepthOfFieldEffect"
  68257. */
  68258. getClassName(): string;
  68259. /**
  68260. * 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.
  68261. */
  68262. set depthTexture(value: RenderTargetTexture);
  68263. /**
  68264. * Disposes each of the internal effects for a given camera.
  68265. * @param camera The camera to dispose the effect on.
  68266. */
  68267. disposeEffects(camera: Camera): void;
  68268. /**
  68269. * @hidden Internal
  68270. */
  68271. _updateEffects(): void;
  68272. /**
  68273. * Internal
  68274. * @returns if all the contained post processes are ready.
  68275. * @hidden
  68276. */
  68277. _isReady(): boolean;
  68278. }
  68279. }
  68280. declare module BABYLON {
  68281. /** @hidden */
  68282. export var displayPassPixelShader: {
  68283. name: string;
  68284. shader: string;
  68285. };
  68286. }
  68287. declare module BABYLON {
  68288. /**
  68289. * DisplayPassPostProcess which produces an output the same as it's input
  68290. */
  68291. export class DisplayPassPostProcess extends PostProcess {
  68292. /**
  68293. * Creates the DisplayPassPostProcess
  68294. * @param name The name of the effect.
  68295. * @param options The required width/height ratio to downsize to before computing the render pass.
  68296. * @param camera The camera to apply the render pass to.
  68297. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68298. * @param engine The engine which the post process will be applied. (default: current engine)
  68299. * @param reusable If the post process can be reused on the same frame. (default: false)
  68300. */
  68301. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68302. }
  68303. }
  68304. declare module BABYLON {
  68305. /** @hidden */
  68306. export var filterPixelShader: {
  68307. name: string;
  68308. shader: string;
  68309. };
  68310. }
  68311. declare module BABYLON {
  68312. /**
  68313. * Applies a kernel filter to the image
  68314. */
  68315. export class FilterPostProcess extends PostProcess {
  68316. /** The matrix to be applied to the image */
  68317. kernelMatrix: Matrix;
  68318. /**
  68319. *
  68320. * @param name The name of the effect.
  68321. * @param kernelMatrix The matrix to be applied to the image
  68322. * @param options The required width/height ratio to downsize to before computing the render pass.
  68323. * @param camera The camera to apply the render pass to.
  68324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68325. * @param engine The engine which the post process will be applied. (default: current engine)
  68326. * @param reusable If the post process can be reused on the same frame. (default: false)
  68327. */
  68328. constructor(name: string,
  68329. /** The matrix to be applied to the image */
  68330. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68331. }
  68332. }
  68333. declare module BABYLON {
  68334. /** @hidden */
  68335. export var fxaaPixelShader: {
  68336. name: string;
  68337. shader: string;
  68338. };
  68339. }
  68340. declare module BABYLON {
  68341. /** @hidden */
  68342. export var fxaaVertexShader: {
  68343. name: string;
  68344. shader: string;
  68345. };
  68346. }
  68347. declare module BABYLON {
  68348. /**
  68349. * Fxaa post process
  68350. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68351. */
  68352. export class FxaaPostProcess extends PostProcess {
  68353. /** @hidden */
  68354. texelWidth: number;
  68355. /** @hidden */
  68356. texelHeight: number;
  68357. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68358. private _getDefines;
  68359. }
  68360. }
  68361. declare module BABYLON {
  68362. /** @hidden */
  68363. export var grainPixelShader: {
  68364. name: string;
  68365. shader: string;
  68366. };
  68367. }
  68368. declare module BABYLON {
  68369. /**
  68370. * The GrainPostProcess adds noise to the image at mid luminance levels
  68371. */
  68372. export class GrainPostProcess extends PostProcess {
  68373. /**
  68374. * The intensity of the grain added (default: 30)
  68375. */
  68376. intensity: number;
  68377. /**
  68378. * If the grain should be randomized on every frame
  68379. */
  68380. animated: boolean;
  68381. /**
  68382. * Creates a new instance of @see GrainPostProcess
  68383. * @param name The name of the effect.
  68384. * @param options The required width/height ratio to downsize to before computing the render pass.
  68385. * @param camera The camera to apply the render pass to.
  68386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68387. * @param engine The engine which the post process will be applied. (default: current engine)
  68388. * @param reusable If the post process can be reused on the same frame. (default: false)
  68389. * @param textureType Type of textures used when performing the post process. (default: 0)
  68390. * @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)
  68391. */
  68392. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68393. }
  68394. }
  68395. declare module BABYLON {
  68396. /** @hidden */
  68397. export var highlightsPixelShader: {
  68398. name: string;
  68399. shader: string;
  68400. };
  68401. }
  68402. declare module BABYLON {
  68403. /**
  68404. * Extracts highlights from the image
  68405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68406. */
  68407. export class HighlightsPostProcess extends PostProcess {
  68408. /**
  68409. * Extracts highlights from the image
  68410. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68411. * @param name The name of the effect.
  68412. * @param options The required width/height ratio to downsize to before computing the render pass.
  68413. * @param camera The camera to apply the render pass to.
  68414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68415. * @param engine The engine which the post process will be applied. (default: current engine)
  68416. * @param reusable If the post process can be reused on the same frame. (default: false)
  68417. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68418. */
  68419. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68420. }
  68421. }
  68422. declare module BABYLON {
  68423. /** @hidden */
  68424. export var mrtFragmentDeclaration: {
  68425. name: string;
  68426. shader: string;
  68427. };
  68428. }
  68429. declare module BABYLON {
  68430. /** @hidden */
  68431. export var geometryPixelShader: {
  68432. name: string;
  68433. shader: string;
  68434. };
  68435. }
  68436. declare module BABYLON {
  68437. /** @hidden */
  68438. export var geometryVertexShader: {
  68439. name: string;
  68440. shader: string;
  68441. };
  68442. }
  68443. declare module BABYLON {
  68444. /** @hidden */
  68445. interface ISavedTransformationMatrix {
  68446. world: Matrix;
  68447. viewProjection: Matrix;
  68448. }
  68449. /**
  68450. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68451. */
  68452. export class GeometryBufferRenderer {
  68453. /**
  68454. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68455. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68456. */
  68457. static readonly POSITION_TEXTURE_TYPE: number;
  68458. /**
  68459. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68460. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68461. */
  68462. static readonly VELOCITY_TEXTURE_TYPE: number;
  68463. /**
  68464. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68465. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68466. */
  68467. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68468. /**
  68469. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68470. * in order to compute objects velocities when enableVelocity is set to "true"
  68471. * @hidden
  68472. */
  68473. _previousTransformationMatrices: {
  68474. [index: number]: ISavedTransformationMatrix;
  68475. };
  68476. /**
  68477. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68478. * in order to compute objects velocities when enableVelocity is set to "true"
  68479. * @hidden
  68480. */
  68481. _previousBonesTransformationMatrices: {
  68482. [index: number]: Float32Array;
  68483. };
  68484. /**
  68485. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68486. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68487. */
  68488. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68489. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68490. renderTransparentMeshes: boolean;
  68491. private _scene;
  68492. private _multiRenderTarget;
  68493. private _ratio;
  68494. private _enablePosition;
  68495. private _enableVelocity;
  68496. private _enableReflectivity;
  68497. private _positionIndex;
  68498. private _velocityIndex;
  68499. private _reflectivityIndex;
  68500. protected _effect: Effect;
  68501. protected _cachedDefines: string;
  68502. /**
  68503. * Set the render list (meshes to be rendered) used in the G buffer.
  68504. */
  68505. set renderList(meshes: Mesh[]);
  68506. /**
  68507. * Gets wether or not G buffer are supported by the running hardware.
  68508. * This requires draw buffer supports
  68509. */
  68510. get isSupported(): boolean;
  68511. /**
  68512. * Returns the index of the given texture type in the G-Buffer textures array
  68513. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68514. * @returns the index of the given texture type in the G-Buffer textures array
  68515. */
  68516. getTextureIndex(textureType: number): number;
  68517. /**
  68518. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68519. */
  68520. get enablePosition(): boolean;
  68521. /**
  68522. * Sets whether or not objects positions are enabled for the G buffer.
  68523. */
  68524. set enablePosition(enable: boolean);
  68525. /**
  68526. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68527. */
  68528. get enableVelocity(): boolean;
  68529. /**
  68530. * Sets wether or not objects velocities are enabled for the G buffer.
  68531. */
  68532. set enableVelocity(enable: boolean);
  68533. /**
  68534. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68535. */
  68536. get enableReflectivity(): boolean;
  68537. /**
  68538. * Sets wether or not objects roughness are enabled for the G buffer.
  68539. */
  68540. set enableReflectivity(enable: boolean);
  68541. /**
  68542. * Gets the scene associated with the buffer.
  68543. */
  68544. get scene(): Scene;
  68545. /**
  68546. * Gets the ratio used by the buffer during its creation.
  68547. * How big is the buffer related to the main canvas.
  68548. */
  68549. get ratio(): number;
  68550. /** @hidden */
  68551. static _SceneComponentInitialization: (scene: Scene) => void;
  68552. /**
  68553. * Creates a new G Buffer for the scene
  68554. * @param scene The scene the buffer belongs to
  68555. * @param ratio How big is the buffer related to the main canvas.
  68556. */
  68557. constructor(scene: Scene, ratio?: number);
  68558. /**
  68559. * Checks wether everything is ready to render a submesh to the G buffer.
  68560. * @param subMesh the submesh to check readiness for
  68561. * @param useInstances is the mesh drawn using instance or not
  68562. * @returns true if ready otherwise false
  68563. */
  68564. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68565. /**
  68566. * Gets the current underlying G Buffer.
  68567. * @returns the buffer
  68568. */
  68569. getGBuffer(): MultiRenderTarget;
  68570. /**
  68571. * Gets the number of samples used to render the buffer (anti aliasing).
  68572. */
  68573. get samples(): number;
  68574. /**
  68575. * Sets the number of samples used to render the buffer (anti aliasing).
  68576. */
  68577. set samples(value: number);
  68578. /**
  68579. * Disposes the renderer and frees up associated resources.
  68580. */
  68581. dispose(): void;
  68582. protected _createRenderTargets(): void;
  68583. private _copyBonesTransformationMatrices;
  68584. }
  68585. }
  68586. declare module BABYLON {
  68587. interface Scene {
  68588. /** @hidden (Backing field) */
  68589. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68590. /**
  68591. * Gets or Sets the current geometry buffer associated to the scene.
  68592. */
  68593. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68594. /**
  68595. * Enables a GeometryBufferRender and associates it with the scene
  68596. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68597. * @returns the GeometryBufferRenderer
  68598. */
  68599. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68600. /**
  68601. * Disables the GeometryBufferRender associated with the scene
  68602. */
  68603. disableGeometryBufferRenderer(): void;
  68604. }
  68605. /**
  68606. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68607. * in several rendering techniques.
  68608. */
  68609. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68610. /**
  68611. * The component name helpful to identify the component in the list of scene components.
  68612. */
  68613. readonly name: string;
  68614. /**
  68615. * The scene the component belongs to.
  68616. */
  68617. scene: Scene;
  68618. /**
  68619. * Creates a new instance of the component for the given scene
  68620. * @param scene Defines the scene to register the component in
  68621. */
  68622. constructor(scene: Scene);
  68623. /**
  68624. * Registers the component in a given scene
  68625. */
  68626. register(): void;
  68627. /**
  68628. * Rebuilds the elements related to this component in case of
  68629. * context lost for instance.
  68630. */
  68631. rebuild(): void;
  68632. /**
  68633. * Disposes the component and the associated ressources
  68634. */
  68635. dispose(): void;
  68636. private _gatherRenderTargets;
  68637. }
  68638. }
  68639. declare module BABYLON {
  68640. /** @hidden */
  68641. export var motionBlurPixelShader: {
  68642. name: string;
  68643. shader: string;
  68644. };
  68645. }
  68646. declare module BABYLON {
  68647. /**
  68648. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68649. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68650. * As an example, all you have to do is to create the post-process:
  68651. * var mb = new BABYLON.MotionBlurPostProcess(
  68652. * 'mb', // The name of the effect.
  68653. * scene, // The scene containing the objects to blur according to their velocity.
  68654. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68655. * camera // The camera to apply the render pass to.
  68656. * );
  68657. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68658. */
  68659. export class MotionBlurPostProcess extends PostProcess {
  68660. /**
  68661. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68662. */
  68663. motionStrength: number;
  68664. /**
  68665. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68666. */
  68667. get motionBlurSamples(): number;
  68668. /**
  68669. * Sets the number of iterations to be used for motion blur quality
  68670. */
  68671. set motionBlurSamples(samples: number);
  68672. private _motionBlurSamples;
  68673. private _geometryBufferRenderer;
  68674. /**
  68675. * Creates a new instance MotionBlurPostProcess
  68676. * @param name The name of the effect.
  68677. * @param scene The scene containing the objects to blur according to their velocity.
  68678. * @param options The required width/height ratio to downsize to before computing the render pass.
  68679. * @param camera The camera to apply the render pass to.
  68680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68681. * @param engine The engine which the post process will be applied. (default: current engine)
  68682. * @param reusable If the post process can be reused on the same frame. (default: false)
  68683. * @param textureType Type of textures used when performing the post process. (default: 0)
  68684. * @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)
  68685. */
  68686. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68687. /**
  68688. * Excludes the given skinned mesh from computing bones velocities.
  68689. * 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.
  68690. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68691. */
  68692. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68693. /**
  68694. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68695. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68696. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68697. */
  68698. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68699. /**
  68700. * Disposes the post process.
  68701. * @param camera The camera to dispose the post process on.
  68702. */
  68703. dispose(camera?: Camera): void;
  68704. }
  68705. }
  68706. declare module BABYLON {
  68707. /** @hidden */
  68708. export var refractionPixelShader: {
  68709. name: string;
  68710. shader: string;
  68711. };
  68712. }
  68713. declare module BABYLON {
  68714. /**
  68715. * Post process which applies a refractin texture
  68716. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68717. */
  68718. export class RefractionPostProcess extends PostProcess {
  68719. /** the base color of the refraction (used to taint the rendering) */
  68720. color: Color3;
  68721. /** simulated refraction depth */
  68722. depth: number;
  68723. /** the coefficient of the base color (0 to remove base color tainting) */
  68724. colorLevel: number;
  68725. private _refTexture;
  68726. private _ownRefractionTexture;
  68727. /**
  68728. * Gets or sets the refraction texture
  68729. * Please note that you are responsible for disposing the texture if you set it manually
  68730. */
  68731. get refractionTexture(): Texture;
  68732. set refractionTexture(value: Texture);
  68733. /**
  68734. * Initializes the RefractionPostProcess
  68735. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68736. * @param name The name of the effect.
  68737. * @param refractionTextureUrl Url of the refraction texture to use
  68738. * @param color the base color of the refraction (used to taint the rendering)
  68739. * @param depth simulated refraction depth
  68740. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68741. * @param camera The camera to apply the render pass to.
  68742. * @param options The required width/height ratio to downsize to before computing the render pass.
  68743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68744. * @param engine The engine which the post process will be applied. (default: current engine)
  68745. * @param reusable If the post process can be reused on the same frame. (default: false)
  68746. */
  68747. constructor(name: string, refractionTextureUrl: string,
  68748. /** the base color of the refraction (used to taint the rendering) */
  68749. color: Color3,
  68750. /** simulated refraction depth */
  68751. depth: number,
  68752. /** the coefficient of the base color (0 to remove base color tainting) */
  68753. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68754. /**
  68755. * Disposes of the post process
  68756. * @param camera Camera to dispose post process on
  68757. */
  68758. dispose(camera: Camera): void;
  68759. }
  68760. }
  68761. declare module BABYLON {
  68762. /** @hidden */
  68763. export var sharpenPixelShader: {
  68764. name: string;
  68765. shader: string;
  68766. };
  68767. }
  68768. declare module BABYLON {
  68769. /**
  68770. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68771. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68772. */
  68773. export class SharpenPostProcess extends PostProcess {
  68774. /**
  68775. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68776. */
  68777. colorAmount: number;
  68778. /**
  68779. * How much sharpness should be applied (default: 0.3)
  68780. */
  68781. edgeAmount: number;
  68782. /**
  68783. * Creates a new instance ConvolutionPostProcess
  68784. * @param name The name of the effect.
  68785. * @param options The required width/height ratio to downsize to before computing the render pass.
  68786. * @param camera The camera to apply the render pass to.
  68787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68788. * @param engine The engine which the post process will be applied. (default: current engine)
  68789. * @param reusable If the post process can be reused on the same frame. (default: false)
  68790. * @param textureType Type of textures used when performing the post process. (default: 0)
  68791. * @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)
  68792. */
  68793. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68794. }
  68795. }
  68796. declare module BABYLON {
  68797. /**
  68798. * PostProcessRenderPipeline
  68799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68800. */
  68801. export class PostProcessRenderPipeline {
  68802. private engine;
  68803. private _renderEffects;
  68804. private _renderEffectsForIsolatedPass;
  68805. /**
  68806. * List of inspectable custom properties (used by the Inspector)
  68807. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68808. */
  68809. inspectableCustomProperties: IInspectable[];
  68810. /**
  68811. * @hidden
  68812. */
  68813. protected _cameras: Camera[];
  68814. /** @hidden */
  68815. _name: string;
  68816. /**
  68817. * Gets pipeline name
  68818. */
  68819. get name(): string;
  68820. /** Gets the list of attached cameras */
  68821. get cameras(): Camera[];
  68822. /**
  68823. * Initializes a PostProcessRenderPipeline
  68824. * @param engine engine to add the pipeline to
  68825. * @param name name of the pipeline
  68826. */
  68827. constructor(engine: Engine, name: string);
  68828. /**
  68829. * Gets the class name
  68830. * @returns "PostProcessRenderPipeline"
  68831. */
  68832. getClassName(): string;
  68833. /**
  68834. * If all the render effects in the pipeline are supported
  68835. */
  68836. get isSupported(): boolean;
  68837. /**
  68838. * Adds an effect to the pipeline
  68839. * @param renderEffect the effect to add
  68840. */
  68841. addEffect(renderEffect: PostProcessRenderEffect): void;
  68842. /** @hidden */
  68843. _rebuild(): void;
  68844. /** @hidden */
  68845. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68846. /** @hidden */
  68847. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68848. /** @hidden */
  68849. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68850. /** @hidden */
  68851. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68852. /** @hidden */
  68853. _attachCameras(cameras: Camera, unique: boolean): void;
  68854. /** @hidden */
  68855. _attachCameras(cameras: Camera[], unique: boolean): void;
  68856. /** @hidden */
  68857. _detachCameras(cameras: Camera): void;
  68858. /** @hidden */
  68859. _detachCameras(cameras: Nullable<Camera[]>): void;
  68860. /** @hidden */
  68861. _update(): void;
  68862. /** @hidden */
  68863. _reset(): void;
  68864. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68865. /**
  68866. * Disposes of the pipeline
  68867. */
  68868. dispose(): void;
  68869. }
  68870. }
  68871. declare module BABYLON {
  68872. /**
  68873. * PostProcessRenderPipelineManager class
  68874. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68875. */
  68876. export class PostProcessRenderPipelineManager {
  68877. private _renderPipelines;
  68878. /**
  68879. * Initializes a PostProcessRenderPipelineManager
  68880. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68881. */
  68882. constructor();
  68883. /**
  68884. * Gets the list of supported render pipelines
  68885. */
  68886. get supportedPipelines(): PostProcessRenderPipeline[];
  68887. /**
  68888. * Adds a pipeline to the manager
  68889. * @param renderPipeline The pipeline to add
  68890. */
  68891. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68892. /**
  68893. * Attaches a camera to the pipeline
  68894. * @param renderPipelineName The name of the pipeline to attach to
  68895. * @param cameras the camera to attach
  68896. * @param unique if the camera can be attached multiple times to the pipeline
  68897. */
  68898. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68899. /**
  68900. * Detaches a camera from the pipeline
  68901. * @param renderPipelineName The name of the pipeline to detach from
  68902. * @param cameras the camera to detach
  68903. */
  68904. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68905. /**
  68906. * Enables an effect by name on a pipeline
  68907. * @param renderPipelineName the name of the pipeline to enable the effect in
  68908. * @param renderEffectName the name of the effect to enable
  68909. * @param cameras the cameras that the effect should be enabled on
  68910. */
  68911. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68912. /**
  68913. * Disables an effect by name on a pipeline
  68914. * @param renderPipelineName the name of the pipeline to disable the effect in
  68915. * @param renderEffectName the name of the effect to disable
  68916. * @param cameras the cameras that the effect should be disabled on
  68917. */
  68918. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68919. /**
  68920. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68921. */
  68922. update(): void;
  68923. /** @hidden */
  68924. _rebuild(): void;
  68925. /**
  68926. * Disposes of the manager and pipelines
  68927. */
  68928. dispose(): void;
  68929. }
  68930. }
  68931. declare module BABYLON {
  68932. interface Scene {
  68933. /** @hidden (Backing field) */
  68934. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68935. /**
  68936. * Gets the postprocess render pipeline manager
  68937. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68938. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68939. */
  68940. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68941. }
  68942. /**
  68943. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68944. */
  68945. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68946. /**
  68947. * The component name helpfull to identify the component in the list of scene components.
  68948. */
  68949. readonly name: string;
  68950. /**
  68951. * The scene the component belongs to.
  68952. */
  68953. scene: Scene;
  68954. /**
  68955. * Creates a new instance of the component for the given scene
  68956. * @param scene Defines the scene to register the component in
  68957. */
  68958. constructor(scene: Scene);
  68959. /**
  68960. * Registers the component in a given scene
  68961. */
  68962. register(): void;
  68963. /**
  68964. * Rebuilds the elements related to this component in case of
  68965. * context lost for instance.
  68966. */
  68967. rebuild(): void;
  68968. /**
  68969. * Disposes the component and the associated ressources
  68970. */
  68971. dispose(): void;
  68972. private _gatherRenderTargets;
  68973. }
  68974. }
  68975. declare module BABYLON {
  68976. /**
  68977. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68978. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68979. */
  68980. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68981. private _scene;
  68982. private _camerasToBeAttached;
  68983. /**
  68984. * ID of the sharpen post process,
  68985. */
  68986. private readonly SharpenPostProcessId;
  68987. /**
  68988. * @ignore
  68989. * ID of the image processing post process;
  68990. */
  68991. readonly ImageProcessingPostProcessId: string;
  68992. /**
  68993. * @ignore
  68994. * ID of the Fast Approximate Anti-Aliasing post process;
  68995. */
  68996. readonly FxaaPostProcessId: string;
  68997. /**
  68998. * ID of the chromatic aberration post process,
  68999. */
  69000. private readonly ChromaticAberrationPostProcessId;
  69001. /**
  69002. * ID of the grain post process
  69003. */
  69004. private readonly GrainPostProcessId;
  69005. /**
  69006. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69007. */
  69008. sharpen: SharpenPostProcess;
  69009. private _sharpenEffect;
  69010. private bloom;
  69011. /**
  69012. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69013. */
  69014. depthOfField: DepthOfFieldEffect;
  69015. /**
  69016. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69017. */
  69018. fxaa: FxaaPostProcess;
  69019. /**
  69020. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69021. */
  69022. imageProcessing: ImageProcessingPostProcess;
  69023. /**
  69024. * Chromatic aberration post process which will shift rgb colors in the image
  69025. */
  69026. chromaticAberration: ChromaticAberrationPostProcess;
  69027. private _chromaticAberrationEffect;
  69028. /**
  69029. * Grain post process which add noise to the image
  69030. */
  69031. grain: GrainPostProcess;
  69032. private _grainEffect;
  69033. /**
  69034. * Glow post process which adds a glow to emissive areas of the image
  69035. */
  69036. private _glowLayer;
  69037. /**
  69038. * Animations which can be used to tweak settings over a period of time
  69039. */
  69040. animations: Animation[];
  69041. private _imageProcessingConfigurationObserver;
  69042. private _sharpenEnabled;
  69043. private _bloomEnabled;
  69044. private _depthOfFieldEnabled;
  69045. private _depthOfFieldBlurLevel;
  69046. private _fxaaEnabled;
  69047. private _imageProcessingEnabled;
  69048. private _defaultPipelineTextureType;
  69049. private _bloomScale;
  69050. private _chromaticAberrationEnabled;
  69051. private _grainEnabled;
  69052. private _buildAllowed;
  69053. /**
  69054. * Gets active scene
  69055. */
  69056. get scene(): Scene;
  69057. /**
  69058. * Enable or disable the sharpen process from the pipeline
  69059. */
  69060. set sharpenEnabled(enabled: boolean);
  69061. get sharpenEnabled(): boolean;
  69062. private _resizeObserver;
  69063. private _hardwareScaleLevel;
  69064. private _bloomKernel;
  69065. /**
  69066. * Specifies the size of the bloom blur kernel, relative to the final output size
  69067. */
  69068. get bloomKernel(): number;
  69069. set bloomKernel(value: number);
  69070. /**
  69071. * Specifies the weight of the bloom in the final rendering
  69072. */
  69073. private _bloomWeight;
  69074. /**
  69075. * Specifies the luma threshold for the area that will be blurred by the bloom
  69076. */
  69077. private _bloomThreshold;
  69078. private _hdr;
  69079. /**
  69080. * The strength of the bloom.
  69081. */
  69082. set bloomWeight(value: number);
  69083. get bloomWeight(): number;
  69084. /**
  69085. * The strength of the bloom.
  69086. */
  69087. set bloomThreshold(value: number);
  69088. get bloomThreshold(): number;
  69089. /**
  69090. * The scale of the bloom, lower value will provide better performance.
  69091. */
  69092. set bloomScale(value: number);
  69093. get bloomScale(): number;
  69094. /**
  69095. * Enable or disable the bloom from the pipeline
  69096. */
  69097. set bloomEnabled(enabled: boolean);
  69098. get bloomEnabled(): boolean;
  69099. private _rebuildBloom;
  69100. /**
  69101. * If the depth of field is enabled.
  69102. */
  69103. get depthOfFieldEnabled(): boolean;
  69104. set depthOfFieldEnabled(enabled: boolean);
  69105. /**
  69106. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69107. */
  69108. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69109. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69110. /**
  69111. * If the anti aliasing is enabled.
  69112. */
  69113. set fxaaEnabled(enabled: boolean);
  69114. get fxaaEnabled(): boolean;
  69115. private _samples;
  69116. /**
  69117. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69118. */
  69119. set samples(sampleCount: number);
  69120. get samples(): number;
  69121. /**
  69122. * If image processing is enabled.
  69123. */
  69124. set imageProcessingEnabled(enabled: boolean);
  69125. get imageProcessingEnabled(): boolean;
  69126. /**
  69127. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69128. */
  69129. set glowLayerEnabled(enabled: boolean);
  69130. get glowLayerEnabled(): boolean;
  69131. /**
  69132. * Gets the glow layer (or null if not defined)
  69133. */
  69134. get glowLayer(): Nullable<GlowLayer>;
  69135. /**
  69136. * Enable or disable the chromaticAberration process from the pipeline
  69137. */
  69138. set chromaticAberrationEnabled(enabled: boolean);
  69139. get chromaticAberrationEnabled(): boolean;
  69140. /**
  69141. * Enable or disable the grain process from the pipeline
  69142. */
  69143. set grainEnabled(enabled: boolean);
  69144. get grainEnabled(): boolean;
  69145. /**
  69146. * @constructor
  69147. * @param name - The rendering pipeline name (default: "")
  69148. * @param hdr - If high dynamic range textures should be used (default: true)
  69149. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69150. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69151. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69152. */
  69153. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69154. /**
  69155. * Get the class name
  69156. * @returns "DefaultRenderingPipeline"
  69157. */
  69158. getClassName(): string;
  69159. /**
  69160. * Force the compilation of the entire pipeline.
  69161. */
  69162. prepare(): void;
  69163. private _hasCleared;
  69164. private _prevPostProcess;
  69165. private _prevPrevPostProcess;
  69166. private _setAutoClearAndTextureSharing;
  69167. private _depthOfFieldSceneObserver;
  69168. private _buildPipeline;
  69169. private _disposePostProcesses;
  69170. /**
  69171. * Adds a camera to the pipeline
  69172. * @param camera the camera to be added
  69173. */
  69174. addCamera(camera: Camera): void;
  69175. /**
  69176. * Removes a camera from the pipeline
  69177. * @param camera the camera to remove
  69178. */
  69179. removeCamera(camera: Camera): void;
  69180. /**
  69181. * Dispose of the pipeline and stop all post processes
  69182. */
  69183. dispose(): void;
  69184. /**
  69185. * Serialize the rendering pipeline (Used when exporting)
  69186. * @returns the serialized object
  69187. */
  69188. serialize(): any;
  69189. /**
  69190. * Parse the serialized pipeline
  69191. * @param source Source pipeline.
  69192. * @param scene The scene to load the pipeline to.
  69193. * @param rootUrl The URL of the serialized pipeline.
  69194. * @returns An instantiated pipeline from the serialized object.
  69195. */
  69196. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69197. }
  69198. }
  69199. declare module BABYLON {
  69200. /** @hidden */
  69201. export var lensHighlightsPixelShader: {
  69202. name: string;
  69203. shader: string;
  69204. };
  69205. }
  69206. declare module BABYLON {
  69207. /** @hidden */
  69208. export var depthOfFieldPixelShader: {
  69209. name: string;
  69210. shader: string;
  69211. };
  69212. }
  69213. declare module BABYLON {
  69214. /**
  69215. * BABYLON.JS Chromatic Aberration GLSL Shader
  69216. * Author: Olivier Guyot
  69217. * Separates very slightly R, G and B colors on the edges of the screen
  69218. * Inspired by Francois Tarlier & Martins Upitis
  69219. */
  69220. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69221. /**
  69222. * @ignore
  69223. * The chromatic aberration PostProcess id in the pipeline
  69224. */
  69225. LensChromaticAberrationEffect: string;
  69226. /**
  69227. * @ignore
  69228. * The highlights enhancing PostProcess id in the pipeline
  69229. */
  69230. HighlightsEnhancingEffect: string;
  69231. /**
  69232. * @ignore
  69233. * The depth-of-field PostProcess id in the pipeline
  69234. */
  69235. LensDepthOfFieldEffect: string;
  69236. private _scene;
  69237. private _depthTexture;
  69238. private _grainTexture;
  69239. private _chromaticAberrationPostProcess;
  69240. private _highlightsPostProcess;
  69241. private _depthOfFieldPostProcess;
  69242. private _edgeBlur;
  69243. private _grainAmount;
  69244. private _chromaticAberration;
  69245. private _distortion;
  69246. private _highlightsGain;
  69247. private _highlightsThreshold;
  69248. private _dofDistance;
  69249. private _dofAperture;
  69250. private _dofDarken;
  69251. private _dofPentagon;
  69252. private _blurNoise;
  69253. /**
  69254. * @constructor
  69255. *
  69256. * Effect parameters are as follow:
  69257. * {
  69258. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69259. * edge_blur: number; // from 0 to x (1 for realism)
  69260. * distortion: number; // from 0 to x (1 for realism)
  69261. * grain_amount: number; // from 0 to 1
  69262. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69263. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69264. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69265. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69266. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69267. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69268. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69269. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69270. * }
  69271. * Note: if an effect parameter is unset, effect is disabled
  69272. *
  69273. * @param name The rendering pipeline name
  69274. * @param parameters - An object containing all parameters (see above)
  69275. * @param scene The scene linked to this pipeline
  69276. * @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)
  69277. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69278. */
  69279. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69280. /**
  69281. * Get the class name
  69282. * @returns "LensRenderingPipeline"
  69283. */
  69284. getClassName(): string;
  69285. /**
  69286. * Gets associated scene
  69287. */
  69288. get scene(): Scene;
  69289. /**
  69290. * Gets or sets the edge blur
  69291. */
  69292. get edgeBlur(): number;
  69293. set edgeBlur(value: number);
  69294. /**
  69295. * Gets or sets the grain amount
  69296. */
  69297. get grainAmount(): number;
  69298. set grainAmount(value: number);
  69299. /**
  69300. * Gets or sets the chromatic aberration amount
  69301. */
  69302. get chromaticAberration(): number;
  69303. set chromaticAberration(value: number);
  69304. /**
  69305. * Gets or sets the depth of field aperture
  69306. */
  69307. get dofAperture(): number;
  69308. set dofAperture(value: number);
  69309. /**
  69310. * Gets or sets the edge distortion
  69311. */
  69312. get edgeDistortion(): number;
  69313. set edgeDistortion(value: number);
  69314. /**
  69315. * Gets or sets the depth of field distortion
  69316. */
  69317. get dofDistortion(): number;
  69318. set dofDistortion(value: number);
  69319. /**
  69320. * Gets or sets the darken out of focus amount
  69321. */
  69322. get darkenOutOfFocus(): number;
  69323. set darkenOutOfFocus(value: number);
  69324. /**
  69325. * Gets or sets a boolean indicating if blur noise is enabled
  69326. */
  69327. get blurNoise(): boolean;
  69328. set blurNoise(value: boolean);
  69329. /**
  69330. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69331. */
  69332. get pentagonBokeh(): boolean;
  69333. set pentagonBokeh(value: boolean);
  69334. /**
  69335. * Gets or sets the highlight grain amount
  69336. */
  69337. get highlightsGain(): number;
  69338. set highlightsGain(value: number);
  69339. /**
  69340. * Gets or sets the highlight threshold
  69341. */
  69342. get highlightsThreshold(): number;
  69343. set highlightsThreshold(value: number);
  69344. /**
  69345. * Sets the amount of blur at the edges
  69346. * @param amount blur amount
  69347. */
  69348. setEdgeBlur(amount: number): void;
  69349. /**
  69350. * Sets edge blur to 0
  69351. */
  69352. disableEdgeBlur(): void;
  69353. /**
  69354. * Sets the amout of grain
  69355. * @param amount Amount of grain
  69356. */
  69357. setGrainAmount(amount: number): void;
  69358. /**
  69359. * Set grain amount to 0
  69360. */
  69361. disableGrain(): void;
  69362. /**
  69363. * Sets the chromatic aberration amount
  69364. * @param amount amount of chromatic aberration
  69365. */
  69366. setChromaticAberration(amount: number): void;
  69367. /**
  69368. * Sets chromatic aberration amount to 0
  69369. */
  69370. disableChromaticAberration(): void;
  69371. /**
  69372. * Sets the EdgeDistortion amount
  69373. * @param amount amount of EdgeDistortion
  69374. */
  69375. setEdgeDistortion(amount: number): void;
  69376. /**
  69377. * Sets edge distortion to 0
  69378. */
  69379. disableEdgeDistortion(): void;
  69380. /**
  69381. * Sets the FocusDistance amount
  69382. * @param amount amount of FocusDistance
  69383. */
  69384. setFocusDistance(amount: number): void;
  69385. /**
  69386. * Disables depth of field
  69387. */
  69388. disableDepthOfField(): void;
  69389. /**
  69390. * Sets the Aperture amount
  69391. * @param amount amount of Aperture
  69392. */
  69393. setAperture(amount: number): void;
  69394. /**
  69395. * Sets the DarkenOutOfFocus amount
  69396. * @param amount amount of DarkenOutOfFocus
  69397. */
  69398. setDarkenOutOfFocus(amount: number): void;
  69399. private _pentagonBokehIsEnabled;
  69400. /**
  69401. * Creates a pentagon bokeh effect
  69402. */
  69403. enablePentagonBokeh(): void;
  69404. /**
  69405. * Disables the pentagon bokeh effect
  69406. */
  69407. disablePentagonBokeh(): void;
  69408. /**
  69409. * Enables noise blur
  69410. */
  69411. enableNoiseBlur(): void;
  69412. /**
  69413. * Disables noise blur
  69414. */
  69415. disableNoiseBlur(): void;
  69416. /**
  69417. * Sets the HighlightsGain amount
  69418. * @param amount amount of HighlightsGain
  69419. */
  69420. setHighlightsGain(amount: number): void;
  69421. /**
  69422. * Sets the HighlightsThreshold amount
  69423. * @param amount amount of HighlightsThreshold
  69424. */
  69425. setHighlightsThreshold(amount: number): void;
  69426. /**
  69427. * Disables highlights
  69428. */
  69429. disableHighlights(): void;
  69430. /**
  69431. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69432. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69433. */
  69434. dispose(disableDepthRender?: boolean): void;
  69435. private _createChromaticAberrationPostProcess;
  69436. private _createHighlightsPostProcess;
  69437. private _createDepthOfFieldPostProcess;
  69438. private _createGrainTexture;
  69439. }
  69440. }
  69441. declare module BABYLON {
  69442. /** @hidden */
  69443. export var ssao2PixelShader: {
  69444. name: string;
  69445. shader: string;
  69446. };
  69447. }
  69448. declare module BABYLON {
  69449. /** @hidden */
  69450. export var ssaoCombinePixelShader: {
  69451. name: string;
  69452. shader: string;
  69453. };
  69454. }
  69455. declare module BABYLON {
  69456. /**
  69457. * Render pipeline to produce ssao effect
  69458. */
  69459. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69460. /**
  69461. * @ignore
  69462. * The PassPostProcess id in the pipeline that contains the original scene color
  69463. */
  69464. SSAOOriginalSceneColorEffect: string;
  69465. /**
  69466. * @ignore
  69467. * The SSAO PostProcess id in the pipeline
  69468. */
  69469. SSAORenderEffect: string;
  69470. /**
  69471. * @ignore
  69472. * The horizontal blur PostProcess id in the pipeline
  69473. */
  69474. SSAOBlurHRenderEffect: string;
  69475. /**
  69476. * @ignore
  69477. * The vertical blur PostProcess id in the pipeline
  69478. */
  69479. SSAOBlurVRenderEffect: string;
  69480. /**
  69481. * @ignore
  69482. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69483. */
  69484. SSAOCombineRenderEffect: string;
  69485. /**
  69486. * The output strength of the SSAO post-process. Default value is 1.0.
  69487. */
  69488. totalStrength: number;
  69489. /**
  69490. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69491. */
  69492. maxZ: number;
  69493. /**
  69494. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69495. */
  69496. minZAspect: number;
  69497. private _samples;
  69498. /**
  69499. * Number of samples used for the SSAO calculations. Default value is 8
  69500. */
  69501. set samples(n: number);
  69502. get samples(): number;
  69503. private _textureSamples;
  69504. /**
  69505. * Number of samples to use for antialiasing
  69506. */
  69507. set textureSamples(n: number);
  69508. get textureSamples(): number;
  69509. /**
  69510. * Ratio object used for SSAO ratio and blur ratio
  69511. */
  69512. private _ratio;
  69513. /**
  69514. * Dynamically generated sphere sampler.
  69515. */
  69516. private _sampleSphere;
  69517. /**
  69518. * Blur filter offsets
  69519. */
  69520. private _samplerOffsets;
  69521. private _expensiveBlur;
  69522. /**
  69523. * If bilateral blur should be used
  69524. */
  69525. set expensiveBlur(b: boolean);
  69526. get expensiveBlur(): boolean;
  69527. /**
  69528. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69529. */
  69530. radius: number;
  69531. /**
  69532. * The base color of the SSAO post-process
  69533. * The final result is "base + ssao" between [0, 1]
  69534. */
  69535. base: number;
  69536. /**
  69537. * Support test.
  69538. */
  69539. static get IsSupported(): boolean;
  69540. private _scene;
  69541. private _depthTexture;
  69542. private _normalTexture;
  69543. private _randomTexture;
  69544. private _originalColorPostProcess;
  69545. private _ssaoPostProcess;
  69546. private _blurHPostProcess;
  69547. private _blurVPostProcess;
  69548. private _ssaoCombinePostProcess;
  69549. /**
  69550. * Gets active scene
  69551. */
  69552. get scene(): Scene;
  69553. /**
  69554. * @constructor
  69555. * @param name The rendering pipeline name
  69556. * @param scene The scene linked to this pipeline
  69557. * @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 }
  69558. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69559. */
  69560. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69561. /**
  69562. * Get the class name
  69563. * @returns "SSAO2RenderingPipeline"
  69564. */
  69565. getClassName(): string;
  69566. /**
  69567. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69568. */
  69569. dispose(disableGeometryBufferRenderer?: boolean): void;
  69570. private _createBlurPostProcess;
  69571. /** @hidden */
  69572. _rebuild(): void;
  69573. private _bits;
  69574. private _radicalInverse_VdC;
  69575. private _hammersley;
  69576. private _hemisphereSample_uniform;
  69577. private _generateHemisphere;
  69578. private _createSSAOPostProcess;
  69579. private _createSSAOCombinePostProcess;
  69580. private _createRandomTexture;
  69581. /**
  69582. * Serialize the rendering pipeline (Used when exporting)
  69583. * @returns the serialized object
  69584. */
  69585. serialize(): any;
  69586. /**
  69587. * Parse the serialized pipeline
  69588. * @param source Source pipeline.
  69589. * @param scene The scene to load the pipeline to.
  69590. * @param rootUrl The URL of the serialized pipeline.
  69591. * @returns An instantiated pipeline from the serialized object.
  69592. */
  69593. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69594. }
  69595. }
  69596. declare module BABYLON {
  69597. /** @hidden */
  69598. export var ssaoPixelShader: {
  69599. name: string;
  69600. shader: string;
  69601. };
  69602. }
  69603. declare module BABYLON {
  69604. /**
  69605. * Render pipeline to produce ssao effect
  69606. */
  69607. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69608. /**
  69609. * @ignore
  69610. * The PassPostProcess id in the pipeline that contains the original scene color
  69611. */
  69612. SSAOOriginalSceneColorEffect: string;
  69613. /**
  69614. * @ignore
  69615. * The SSAO PostProcess id in the pipeline
  69616. */
  69617. SSAORenderEffect: string;
  69618. /**
  69619. * @ignore
  69620. * The horizontal blur PostProcess id in the pipeline
  69621. */
  69622. SSAOBlurHRenderEffect: string;
  69623. /**
  69624. * @ignore
  69625. * The vertical blur PostProcess id in the pipeline
  69626. */
  69627. SSAOBlurVRenderEffect: string;
  69628. /**
  69629. * @ignore
  69630. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69631. */
  69632. SSAOCombineRenderEffect: string;
  69633. /**
  69634. * The output strength of the SSAO post-process. Default value is 1.0.
  69635. */
  69636. totalStrength: number;
  69637. /**
  69638. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69639. */
  69640. radius: number;
  69641. /**
  69642. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69643. * Must not be equal to fallOff and superior to fallOff.
  69644. * Default value is 0.0075
  69645. */
  69646. area: number;
  69647. /**
  69648. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69649. * Must not be equal to area and inferior to area.
  69650. * Default value is 0.000001
  69651. */
  69652. fallOff: number;
  69653. /**
  69654. * The base color of the SSAO post-process
  69655. * The final result is "base + ssao" between [0, 1]
  69656. */
  69657. base: number;
  69658. private _scene;
  69659. private _depthTexture;
  69660. private _randomTexture;
  69661. private _originalColorPostProcess;
  69662. private _ssaoPostProcess;
  69663. private _blurHPostProcess;
  69664. private _blurVPostProcess;
  69665. private _ssaoCombinePostProcess;
  69666. private _firstUpdate;
  69667. /**
  69668. * Gets active scene
  69669. */
  69670. get scene(): Scene;
  69671. /**
  69672. * @constructor
  69673. * @param name - The rendering pipeline name
  69674. * @param scene - The scene linked to this pipeline
  69675. * @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 }
  69676. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69677. */
  69678. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69679. /**
  69680. * Get the class name
  69681. * @returns "SSAORenderingPipeline"
  69682. */
  69683. getClassName(): string;
  69684. /**
  69685. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69686. */
  69687. dispose(disableDepthRender?: boolean): void;
  69688. private _createBlurPostProcess;
  69689. /** @hidden */
  69690. _rebuild(): void;
  69691. private _createSSAOPostProcess;
  69692. private _createSSAOCombinePostProcess;
  69693. private _createRandomTexture;
  69694. }
  69695. }
  69696. declare module BABYLON {
  69697. /** @hidden */
  69698. export var screenSpaceReflectionPixelShader: {
  69699. name: string;
  69700. shader: string;
  69701. };
  69702. }
  69703. declare module BABYLON {
  69704. /**
  69705. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69706. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69707. */
  69708. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69709. /**
  69710. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69711. */
  69712. threshold: number;
  69713. /**
  69714. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69715. */
  69716. strength: number;
  69717. /**
  69718. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69719. */
  69720. reflectionSpecularFalloffExponent: number;
  69721. /**
  69722. * 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]
  69723. */
  69724. step: number;
  69725. /**
  69726. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69727. */
  69728. roughnessFactor: number;
  69729. private _geometryBufferRenderer;
  69730. private _enableSmoothReflections;
  69731. private _reflectionSamples;
  69732. private _smoothSteps;
  69733. /**
  69734. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69735. * @param name The name of the effect.
  69736. * @param scene The scene containing the objects to calculate reflections.
  69737. * @param options The required width/height ratio to downsize to before computing the render pass.
  69738. * @param camera The camera to apply the render pass to.
  69739. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69740. * @param engine The engine which the post process will be applied. (default: current engine)
  69741. * @param reusable If the post process can be reused on the same frame. (default: false)
  69742. * @param textureType Type of textures used when performing the post process. (default: 0)
  69743. * @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)
  69744. */
  69745. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69746. /**
  69747. * Gets wether or not smoothing reflections is enabled.
  69748. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69749. */
  69750. get enableSmoothReflections(): boolean;
  69751. /**
  69752. * Sets wether or not smoothing reflections is enabled.
  69753. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69754. */
  69755. set enableSmoothReflections(enabled: boolean);
  69756. /**
  69757. * Gets the number of samples taken while computing reflections. More samples count is high,
  69758. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69759. */
  69760. get reflectionSamples(): number;
  69761. /**
  69762. * Sets the number of samples taken while computing reflections. More samples count is high,
  69763. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69764. */
  69765. set reflectionSamples(samples: number);
  69766. /**
  69767. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69768. * more the post-process will require GPU power and can generate a drop in FPS.
  69769. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69770. */
  69771. get smoothSteps(): number;
  69772. set smoothSteps(steps: number);
  69773. private _updateEffectDefines;
  69774. }
  69775. }
  69776. declare module BABYLON {
  69777. /** @hidden */
  69778. export var standardPixelShader: {
  69779. name: string;
  69780. shader: string;
  69781. };
  69782. }
  69783. declare module BABYLON {
  69784. /**
  69785. * Standard rendering pipeline
  69786. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69787. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69788. */
  69789. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69790. /**
  69791. * Public members
  69792. */
  69793. /**
  69794. * Post-process which contains the original scene color before the pipeline applies all the effects
  69795. */
  69796. originalPostProcess: Nullable<PostProcess>;
  69797. /**
  69798. * Post-process used to down scale an image x4
  69799. */
  69800. downSampleX4PostProcess: Nullable<PostProcess>;
  69801. /**
  69802. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69803. */
  69804. brightPassPostProcess: Nullable<PostProcess>;
  69805. /**
  69806. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69807. */
  69808. blurHPostProcesses: PostProcess[];
  69809. /**
  69810. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69811. */
  69812. blurVPostProcesses: PostProcess[];
  69813. /**
  69814. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69815. */
  69816. textureAdderPostProcess: Nullable<PostProcess>;
  69817. /**
  69818. * Post-process used to create volumetric lighting effect
  69819. */
  69820. volumetricLightPostProcess: Nullable<PostProcess>;
  69821. /**
  69822. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69823. */
  69824. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69825. /**
  69826. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69827. */
  69828. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69829. /**
  69830. * Post-process used to merge the volumetric light effect and the real scene color
  69831. */
  69832. volumetricLightMergePostProces: Nullable<PostProcess>;
  69833. /**
  69834. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69835. */
  69836. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69837. /**
  69838. * Base post-process used to calculate the average luminance of the final image for HDR
  69839. */
  69840. luminancePostProcess: Nullable<PostProcess>;
  69841. /**
  69842. * Post-processes used to create down sample post-processes in order to get
  69843. * the average luminance of the final image for HDR
  69844. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69845. */
  69846. luminanceDownSamplePostProcesses: PostProcess[];
  69847. /**
  69848. * Post-process used to create a HDR effect (light adaptation)
  69849. */
  69850. hdrPostProcess: Nullable<PostProcess>;
  69851. /**
  69852. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69853. */
  69854. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69855. /**
  69856. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69857. */
  69858. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69859. /**
  69860. * Post-process used to merge the final HDR post-process and the real scene color
  69861. */
  69862. hdrFinalPostProcess: Nullable<PostProcess>;
  69863. /**
  69864. * Post-process used to create a lens flare effect
  69865. */
  69866. lensFlarePostProcess: Nullable<PostProcess>;
  69867. /**
  69868. * Post-process that merges the result of the lens flare post-process and the real scene color
  69869. */
  69870. lensFlareComposePostProcess: Nullable<PostProcess>;
  69871. /**
  69872. * Post-process used to create a motion blur effect
  69873. */
  69874. motionBlurPostProcess: Nullable<PostProcess>;
  69875. /**
  69876. * Post-process used to create a depth of field effect
  69877. */
  69878. depthOfFieldPostProcess: Nullable<PostProcess>;
  69879. /**
  69880. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69881. */
  69882. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69883. /**
  69884. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69885. */
  69886. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69887. /**
  69888. * Represents the brightness threshold in order to configure the illuminated surfaces
  69889. */
  69890. brightThreshold: number;
  69891. /**
  69892. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69893. */
  69894. blurWidth: number;
  69895. /**
  69896. * Sets if the blur for highlighted surfaces must be only horizontal
  69897. */
  69898. horizontalBlur: boolean;
  69899. /**
  69900. * Gets the overall exposure used by the pipeline
  69901. */
  69902. get exposure(): number;
  69903. /**
  69904. * Sets the overall exposure used by the pipeline
  69905. */
  69906. set exposure(value: number);
  69907. /**
  69908. * Texture used typically to simulate "dirty" on camera lens
  69909. */
  69910. lensTexture: Nullable<Texture>;
  69911. /**
  69912. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69913. */
  69914. volumetricLightCoefficient: number;
  69915. /**
  69916. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69917. */
  69918. volumetricLightPower: number;
  69919. /**
  69920. * Used the set the blur intensity to smooth the volumetric lights
  69921. */
  69922. volumetricLightBlurScale: number;
  69923. /**
  69924. * Light (spot or directional) used to generate the volumetric lights rays
  69925. * The source light must have a shadow generate so the pipeline can get its
  69926. * depth map
  69927. */
  69928. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69929. /**
  69930. * For eye adaptation, represents the minimum luminance the eye can see
  69931. */
  69932. hdrMinimumLuminance: number;
  69933. /**
  69934. * For eye adaptation, represents the decrease luminance speed
  69935. */
  69936. hdrDecreaseRate: number;
  69937. /**
  69938. * For eye adaptation, represents the increase luminance speed
  69939. */
  69940. hdrIncreaseRate: number;
  69941. /**
  69942. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69943. */
  69944. get hdrAutoExposure(): boolean;
  69945. /**
  69946. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69947. */
  69948. set hdrAutoExposure(value: boolean);
  69949. /**
  69950. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69951. */
  69952. lensColorTexture: Nullable<Texture>;
  69953. /**
  69954. * The overall strengh for the lens flare effect
  69955. */
  69956. lensFlareStrength: number;
  69957. /**
  69958. * Dispersion coefficient for lens flare ghosts
  69959. */
  69960. lensFlareGhostDispersal: number;
  69961. /**
  69962. * Main lens flare halo width
  69963. */
  69964. lensFlareHaloWidth: number;
  69965. /**
  69966. * Based on the lens distortion effect, defines how much the lens flare result
  69967. * is distorted
  69968. */
  69969. lensFlareDistortionStrength: number;
  69970. /**
  69971. * Configures the blur intensity used for for lens flare (halo)
  69972. */
  69973. lensFlareBlurWidth: number;
  69974. /**
  69975. * Lens star texture must be used to simulate rays on the flares and is available
  69976. * in the documentation
  69977. */
  69978. lensStarTexture: Nullable<Texture>;
  69979. /**
  69980. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69981. * flare effect by taking account of the dirt texture
  69982. */
  69983. lensFlareDirtTexture: Nullable<Texture>;
  69984. /**
  69985. * Represents the focal length for the depth of field effect
  69986. */
  69987. depthOfFieldDistance: number;
  69988. /**
  69989. * Represents the blur intensity for the blurred part of the depth of field effect
  69990. */
  69991. depthOfFieldBlurWidth: number;
  69992. /**
  69993. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69994. */
  69995. get motionStrength(): number;
  69996. /**
  69997. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69998. */
  69999. set motionStrength(strength: number);
  70000. /**
  70001. * Gets wether or not the motion blur post-process is object based or screen based.
  70002. */
  70003. get objectBasedMotionBlur(): boolean;
  70004. /**
  70005. * Sets wether or not the motion blur post-process should be object based or screen based
  70006. */
  70007. set objectBasedMotionBlur(value: boolean);
  70008. /**
  70009. * List of animations for the pipeline (IAnimatable implementation)
  70010. */
  70011. animations: Animation[];
  70012. /**
  70013. * Private members
  70014. */
  70015. private _scene;
  70016. private _currentDepthOfFieldSource;
  70017. private _basePostProcess;
  70018. private _fixedExposure;
  70019. private _currentExposure;
  70020. private _hdrAutoExposure;
  70021. private _hdrCurrentLuminance;
  70022. private _motionStrength;
  70023. private _isObjectBasedMotionBlur;
  70024. private _floatTextureType;
  70025. private _camerasToBeAttached;
  70026. private _ratio;
  70027. private _bloomEnabled;
  70028. private _depthOfFieldEnabled;
  70029. private _vlsEnabled;
  70030. private _lensFlareEnabled;
  70031. private _hdrEnabled;
  70032. private _motionBlurEnabled;
  70033. private _fxaaEnabled;
  70034. private _screenSpaceReflectionsEnabled;
  70035. private _motionBlurSamples;
  70036. private _volumetricLightStepsCount;
  70037. private _samples;
  70038. /**
  70039. * @ignore
  70040. * Specifies if the bloom pipeline is enabled
  70041. */
  70042. get BloomEnabled(): boolean;
  70043. set BloomEnabled(enabled: boolean);
  70044. /**
  70045. * @ignore
  70046. * Specifies if the depth of field pipeline is enabed
  70047. */
  70048. get DepthOfFieldEnabled(): boolean;
  70049. set DepthOfFieldEnabled(enabled: boolean);
  70050. /**
  70051. * @ignore
  70052. * Specifies if the lens flare pipeline is enabed
  70053. */
  70054. get LensFlareEnabled(): boolean;
  70055. set LensFlareEnabled(enabled: boolean);
  70056. /**
  70057. * @ignore
  70058. * Specifies if the HDR pipeline is enabled
  70059. */
  70060. get HDREnabled(): boolean;
  70061. set HDREnabled(enabled: boolean);
  70062. /**
  70063. * @ignore
  70064. * Specifies if the volumetric lights scattering effect is enabled
  70065. */
  70066. get VLSEnabled(): boolean;
  70067. set VLSEnabled(enabled: boolean);
  70068. /**
  70069. * @ignore
  70070. * Specifies if the motion blur effect is enabled
  70071. */
  70072. get MotionBlurEnabled(): boolean;
  70073. set MotionBlurEnabled(enabled: boolean);
  70074. /**
  70075. * Specifies if anti-aliasing is enabled
  70076. */
  70077. get fxaaEnabled(): boolean;
  70078. set fxaaEnabled(enabled: boolean);
  70079. /**
  70080. * Specifies if screen space reflections are enabled.
  70081. */
  70082. get screenSpaceReflectionsEnabled(): boolean;
  70083. set screenSpaceReflectionsEnabled(enabled: boolean);
  70084. /**
  70085. * Specifies the number of steps used to calculate the volumetric lights
  70086. * Typically in interval [50, 200]
  70087. */
  70088. get volumetricLightStepsCount(): number;
  70089. set volumetricLightStepsCount(count: number);
  70090. /**
  70091. * Specifies the number of samples used for the motion blur effect
  70092. * Typically in interval [16, 64]
  70093. */
  70094. get motionBlurSamples(): number;
  70095. set motionBlurSamples(samples: number);
  70096. /**
  70097. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70098. */
  70099. get samples(): number;
  70100. set samples(sampleCount: number);
  70101. /**
  70102. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70103. * @constructor
  70104. * @param name The rendering pipeline name
  70105. * @param scene The scene linked to this pipeline
  70106. * @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)
  70107. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70108. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70109. */
  70110. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70111. private _buildPipeline;
  70112. private _createDownSampleX4PostProcess;
  70113. private _createBrightPassPostProcess;
  70114. private _createBlurPostProcesses;
  70115. private _createTextureAdderPostProcess;
  70116. private _createVolumetricLightPostProcess;
  70117. private _createLuminancePostProcesses;
  70118. private _createHdrPostProcess;
  70119. private _createLensFlarePostProcess;
  70120. private _createDepthOfFieldPostProcess;
  70121. private _createMotionBlurPostProcess;
  70122. private _getDepthTexture;
  70123. private _disposePostProcesses;
  70124. /**
  70125. * Dispose of the pipeline and stop all post processes
  70126. */
  70127. dispose(): void;
  70128. /**
  70129. * Serialize the rendering pipeline (Used when exporting)
  70130. * @returns the serialized object
  70131. */
  70132. serialize(): any;
  70133. /**
  70134. * Parse the serialized pipeline
  70135. * @param source Source pipeline.
  70136. * @param scene The scene to load the pipeline to.
  70137. * @param rootUrl The URL of the serialized pipeline.
  70138. * @returns An instantiated pipeline from the serialized object.
  70139. */
  70140. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70141. /**
  70142. * Luminance steps
  70143. */
  70144. static LuminanceSteps: number;
  70145. }
  70146. }
  70147. declare module BABYLON {
  70148. /** @hidden */
  70149. export var stereoscopicInterlacePixelShader: {
  70150. name: string;
  70151. shader: string;
  70152. };
  70153. }
  70154. declare module BABYLON {
  70155. /**
  70156. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70157. */
  70158. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70159. private _stepSize;
  70160. private _passedProcess;
  70161. /**
  70162. * Initializes a StereoscopicInterlacePostProcessI
  70163. * @param name The name of the effect.
  70164. * @param rigCameras The rig cameras to be appled to the post process
  70165. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70166. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70168. * @param engine The engine which the post process will be applied. (default: current engine)
  70169. * @param reusable If the post process can be reused on the same frame. (default: false)
  70170. */
  70171. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70172. }
  70173. /**
  70174. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70175. */
  70176. export class StereoscopicInterlacePostProcess extends PostProcess {
  70177. private _stepSize;
  70178. private _passedProcess;
  70179. /**
  70180. * Initializes a StereoscopicInterlacePostProcess
  70181. * @param name The name of the effect.
  70182. * @param rigCameras The rig cameras to be appled to the post process
  70183. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70184. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70185. * @param engine The engine which the post process will be applied. (default: current engine)
  70186. * @param reusable If the post process can be reused on the same frame. (default: false)
  70187. */
  70188. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70189. }
  70190. }
  70191. declare module BABYLON {
  70192. /** @hidden */
  70193. export var tonemapPixelShader: {
  70194. name: string;
  70195. shader: string;
  70196. };
  70197. }
  70198. declare module BABYLON {
  70199. /** Defines operator used for tonemapping */
  70200. export enum TonemappingOperator {
  70201. /** Hable */
  70202. Hable = 0,
  70203. /** Reinhard */
  70204. Reinhard = 1,
  70205. /** HejiDawson */
  70206. HejiDawson = 2,
  70207. /** Photographic */
  70208. Photographic = 3
  70209. }
  70210. /**
  70211. * Defines a post process to apply tone mapping
  70212. */
  70213. export class TonemapPostProcess extends PostProcess {
  70214. private _operator;
  70215. /** Defines the required exposure adjustement */
  70216. exposureAdjustment: number;
  70217. /**
  70218. * Creates a new TonemapPostProcess
  70219. * @param name defines the name of the postprocess
  70220. * @param _operator defines the operator to use
  70221. * @param exposureAdjustment defines the required exposure adjustement
  70222. * @param camera defines the camera to use (can be null)
  70223. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70224. * @param engine defines the hosting engine (can be ignore if camera is set)
  70225. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70226. */
  70227. constructor(name: string, _operator: TonemappingOperator,
  70228. /** Defines the required exposure adjustement */
  70229. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70230. }
  70231. }
  70232. declare module BABYLON {
  70233. /** @hidden */
  70234. export var volumetricLightScatteringPixelShader: {
  70235. name: string;
  70236. shader: string;
  70237. };
  70238. }
  70239. declare module BABYLON {
  70240. /** @hidden */
  70241. export var volumetricLightScatteringPassVertexShader: {
  70242. name: string;
  70243. shader: string;
  70244. };
  70245. }
  70246. declare module BABYLON {
  70247. /** @hidden */
  70248. export var volumetricLightScatteringPassPixelShader: {
  70249. name: string;
  70250. shader: string;
  70251. };
  70252. }
  70253. declare module BABYLON {
  70254. /**
  70255. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70256. */
  70257. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70258. private _volumetricLightScatteringPass;
  70259. private _volumetricLightScatteringRTT;
  70260. private _viewPort;
  70261. private _screenCoordinates;
  70262. private _cachedDefines;
  70263. /**
  70264. * If not undefined, the mesh position is computed from the attached node position
  70265. */
  70266. attachedNode: {
  70267. position: Vector3;
  70268. };
  70269. /**
  70270. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70271. */
  70272. customMeshPosition: Vector3;
  70273. /**
  70274. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70275. */
  70276. useCustomMeshPosition: boolean;
  70277. /**
  70278. * If the post-process should inverse the light scattering direction
  70279. */
  70280. invert: boolean;
  70281. /**
  70282. * The internal mesh used by the post-process
  70283. */
  70284. mesh: Mesh;
  70285. /**
  70286. * @hidden
  70287. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70288. */
  70289. get useDiffuseColor(): boolean;
  70290. set useDiffuseColor(useDiffuseColor: boolean);
  70291. /**
  70292. * Array containing the excluded meshes not rendered in the internal pass
  70293. */
  70294. excludedMeshes: AbstractMesh[];
  70295. /**
  70296. * Controls the overall intensity of the post-process
  70297. */
  70298. exposure: number;
  70299. /**
  70300. * Dissipates each sample's contribution in range [0, 1]
  70301. */
  70302. decay: number;
  70303. /**
  70304. * Controls the overall intensity of each sample
  70305. */
  70306. weight: number;
  70307. /**
  70308. * Controls the density of each sample
  70309. */
  70310. density: number;
  70311. /**
  70312. * @constructor
  70313. * @param name The post-process name
  70314. * @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)
  70315. * @param camera The camera that the post-process will be attached to
  70316. * @param mesh The mesh used to create the light scattering
  70317. * @param samples The post-process quality, default 100
  70318. * @param samplingModeThe post-process filtering mode
  70319. * @param engine The babylon engine
  70320. * @param reusable If the post-process is reusable
  70321. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70322. */
  70323. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70324. /**
  70325. * Returns the string "VolumetricLightScatteringPostProcess"
  70326. * @returns "VolumetricLightScatteringPostProcess"
  70327. */
  70328. getClassName(): string;
  70329. private _isReady;
  70330. /**
  70331. * Sets the new light position for light scattering effect
  70332. * @param position The new custom light position
  70333. */
  70334. setCustomMeshPosition(position: Vector3): void;
  70335. /**
  70336. * Returns the light position for light scattering effect
  70337. * @return Vector3 The custom light position
  70338. */
  70339. getCustomMeshPosition(): Vector3;
  70340. /**
  70341. * Disposes the internal assets and detaches the post-process from the camera
  70342. */
  70343. dispose(camera: Camera): void;
  70344. /**
  70345. * Returns the render target texture used by the post-process
  70346. * @return the render target texture used by the post-process
  70347. */
  70348. getPass(): RenderTargetTexture;
  70349. private _meshExcluded;
  70350. private _createPass;
  70351. private _updateMeshScreenCoordinates;
  70352. /**
  70353. * Creates a default mesh for the Volumeric Light Scattering post-process
  70354. * @param name The mesh name
  70355. * @param scene The scene where to create the mesh
  70356. * @return the default mesh
  70357. */
  70358. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70359. }
  70360. }
  70361. declare module BABYLON {
  70362. interface Scene {
  70363. /** @hidden (Backing field) */
  70364. _boundingBoxRenderer: BoundingBoxRenderer;
  70365. /** @hidden (Backing field) */
  70366. _forceShowBoundingBoxes: boolean;
  70367. /**
  70368. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70369. */
  70370. forceShowBoundingBoxes: boolean;
  70371. /**
  70372. * Gets the bounding box renderer associated with the scene
  70373. * @returns a BoundingBoxRenderer
  70374. */
  70375. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70376. }
  70377. interface AbstractMesh {
  70378. /** @hidden (Backing field) */
  70379. _showBoundingBox: boolean;
  70380. /**
  70381. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70382. */
  70383. showBoundingBox: boolean;
  70384. }
  70385. /**
  70386. * Component responsible of rendering the bounding box of the meshes in a scene.
  70387. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70388. */
  70389. export class BoundingBoxRenderer implements ISceneComponent {
  70390. /**
  70391. * The component name helpfull to identify the component in the list of scene components.
  70392. */
  70393. readonly name: string;
  70394. /**
  70395. * The scene the component belongs to.
  70396. */
  70397. scene: Scene;
  70398. /**
  70399. * Color of the bounding box lines placed in front of an object
  70400. */
  70401. frontColor: Color3;
  70402. /**
  70403. * Color of the bounding box lines placed behind an object
  70404. */
  70405. backColor: Color3;
  70406. /**
  70407. * Defines if the renderer should show the back lines or not
  70408. */
  70409. showBackLines: boolean;
  70410. /**
  70411. * Observable raised before rendering a bounding box
  70412. */
  70413. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70414. /**
  70415. * Observable raised after rendering a bounding box
  70416. */
  70417. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70418. /**
  70419. * @hidden
  70420. */
  70421. renderList: SmartArray<BoundingBox>;
  70422. private _colorShader;
  70423. private _vertexBuffers;
  70424. private _indexBuffer;
  70425. private _fillIndexBuffer;
  70426. private _fillIndexData;
  70427. /**
  70428. * Instantiates a new bounding box renderer in a scene.
  70429. * @param scene the scene the renderer renders in
  70430. */
  70431. constructor(scene: Scene);
  70432. /**
  70433. * Registers the component in a given scene
  70434. */
  70435. register(): void;
  70436. private _evaluateSubMesh;
  70437. private _activeMesh;
  70438. private _prepareRessources;
  70439. private _createIndexBuffer;
  70440. /**
  70441. * Rebuilds the elements related to this component in case of
  70442. * context lost for instance.
  70443. */
  70444. rebuild(): void;
  70445. /**
  70446. * @hidden
  70447. */
  70448. reset(): void;
  70449. /**
  70450. * Render the bounding boxes of a specific rendering group
  70451. * @param renderingGroupId defines the rendering group to render
  70452. */
  70453. render(renderingGroupId: number): void;
  70454. /**
  70455. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70456. * @param mesh Define the mesh to render the occlusion bounding box for
  70457. */
  70458. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70459. /**
  70460. * Dispose and release the resources attached to this renderer.
  70461. */
  70462. dispose(): void;
  70463. }
  70464. }
  70465. declare module BABYLON {
  70466. interface Scene {
  70467. /** @hidden (Backing field) */
  70468. _depthRenderer: {
  70469. [id: string]: DepthRenderer;
  70470. };
  70471. /**
  70472. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70473. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70474. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70475. * @returns the created depth renderer
  70476. */
  70477. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70478. /**
  70479. * Disables a depth renderer for a given camera
  70480. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70481. */
  70482. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70483. }
  70484. /**
  70485. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70486. * in several rendering techniques.
  70487. */
  70488. export class DepthRendererSceneComponent implements ISceneComponent {
  70489. /**
  70490. * The component name helpfull to identify the component in the list of scene components.
  70491. */
  70492. readonly name: string;
  70493. /**
  70494. * The scene the component belongs to.
  70495. */
  70496. scene: Scene;
  70497. /**
  70498. * Creates a new instance of the component for the given scene
  70499. * @param scene Defines the scene to register the component in
  70500. */
  70501. constructor(scene: Scene);
  70502. /**
  70503. * Registers the component in a given scene
  70504. */
  70505. register(): void;
  70506. /**
  70507. * Rebuilds the elements related to this component in case of
  70508. * context lost for instance.
  70509. */
  70510. rebuild(): void;
  70511. /**
  70512. * Disposes the component and the associated ressources
  70513. */
  70514. dispose(): void;
  70515. private _gatherRenderTargets;
  70516. private _gatherActiveCameraRenderTargets;
  70517. }
  70518. }
  70519. declare module BABYLON {
  70520. /** @hidden */
  70521. export var outlinePixelShader: {
  70522. name: string;
  70523. shader: string;
  70524. };
  70525. }
  70526. declare module BABYLON {
  70527. /** @hidden */
  70528. export var outlineVertexShader: {
  70529. name: string;
  70530. shader: string;
  70531. };
  70532. }
  70533. declare module BABYLON {
  70534. interface Scene {
  70535. /** @hidden */
  70536. _outlineRenderer: OutlineRenderer;
  70537. /**
  70538. * Gets the outline renderer associated with the scene
  70539. * @returns a OutlineRenderer
  70540. */
  70541. getOutlineRenderer(): OutlineRenderer;
  70542. }
  70543. interface AbstractMesh {
  70544. /** @hidden (Backing field) */
  70545. _renderOutline: boolean;
  70546. /**
  70547. * Gets or sets a boolean indicating if the outline must be rendered as well
  70548. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70549. */
  70550. renderOutline: boolean;
  70551. /** @hidden (Backing field) */
  70552. _renderOverlay: boolean;
  70553. /**
  70554. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70555. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70556. */
  70557. renderOverlay: boolean;
  70558. }
  70559. /**
  70560. * This class is responsible to draw bothe outline/overlay of meshes.
  70561. * It should not be used directly but through the available method on mesh.
  70562. */
  70563. export class OutlineRenderer implements ISceneComponent {
  70564. /**
  70565. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70566. */
  70567. private static _StencilReference;
  70568. /**
  70569. * The name of the component. Each component must have a unique name.
  70570. */
  70571. name: string;
  70572. /**
  70573. * The scene the component belongs to.
  70574. */
  70575. scene: Scene;
  70576. /**
  70577. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70578. */
  70579. zOffset: number;
  70580. private _engine;
  70581. private _effect;
  70582. private _cachedDefines;
  70583. private _savedDepthWrite;
  70584. /**
  70585. * Instantiates a new outline renderer. (There could be only one per scene).
  70586. * @param scene Defines the scene it belongs to
  70587. */
  70588. constructor(scene: Scene);
  70589. /**
  70590. * Register the component to one instance of a scene.
  70591. */
  70592. register(): void;
  70593. /**
  70594. * Rebuilds the elements related to this component in case of
  70595. * context lost for instance.
  70596. */
  70597. rebuild(): void;
  70598. /**
  70599. * Disposes the component and the associated ressources.
  70600. */
  70601. dispose(): void;
  70602. /**
  70603. * Renders the outline in the canvas.
  70604. * @param subMesh Defines the sumesh to render
  70605. * @param batch Defines the batch of meshes in case of instances
  70606. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70607. */
  70608. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70609. /**
  70610. * Returns whether or not the outline renderer is ready for a given submesh.
  70611. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70612. * @param subMesh Defines the submesh to check readyness for
  70613. * @param useInstances Defines wheter wee are trying to render instances or not
  70614. * @returns true if ready otherwise false
  70615. */
  70616. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70617. private _beforeRenderingMesh;
  70618. private _afterRenderingMesh;
  70619. }
  70620. }
  70621. declare module BABYLON {
  70622. /**
  70623. * Defines the basic options interface of a Sprite Frame Source Size.
  70624. */
  70625. export interface ISpriteJSONSpriteSourceSize {
  70626. /**
  70627. * number of the original width of the Frame
  70628. */
  70629. w: number;
  70630. /**
  70631. * number of the original height of the Frame
  70632. */
  70633. h: number;
  70634. }
  70635. /**
  70636. * Defines the basic options interface of a Sprite Frame Data.
  70637. */
  70638. export interface ISpriteJSONSpriteFrameData {
  70639. /**
  70640. * number of the x offset of the Frame
  70641. */
  70642. x: number;
  70643. /**
  70644. * number of the y offset of the Frame
  70645. */
  70646. y: number;
  70647. /**
  70648. * number of the width of the Frame
  70649. */
  70650. w: number;
  70651. /**
  70652. * number of the height of the Frame
  70653. */
  70654. h: number;
  70655. }
  70656. /**
  70657. * Defines the basic options interface of a JSON Sprite.
  70658. */
  70659. export interface ISpriteJSONSprite {
  70660. /**
  70661. * string name of the Frame
  70662. */
  70663. filename: string;
  70664. /**
  70665. * ISpriteJSONSpriteFrame basic object of the frame data
  70666. */
  70667. frame: ISpriteJSONSpriteFrameData;
  70668. /**
  70669. * boolean to flag is the frame was rotated.
  70670. */
  70671. rotated: boolean;
  70672. /**
  70673. * boolean to flag is the frame was trimmed.
  70674. */
  70675. trimmed: boolean;
  70676. /**
  70677. * ISpriteJSONSpriteFrame basic object of the source data
  70678. */
  70679. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70680. /**
  70681. * ISpriteJSONSpriteFrame basic object of the source data
  70682. */
  70683. sourceSize: ISpriteJSONSpriteSourceSize;
  70684. }
  70685. /**
  70686. * Defines the basic options interface of a JSON atlas.
  70687. */
  70688. export interface ISpriteJSONAtlas {
  70689. /**
  70690. * Array of objects that contain the frame data.
  70691. */
  70692. frames: Array<ISpriteJSONSprite>;
  70693. /**
  70694. * object basic object containing the sprite meta data.
  70695. */
  70696. meta?: object;
  70697. }
  70698. }
  70699. declare module BABYLON {
  70700. /** @hidden */
  70701. export var spriteMapPixelShader: {
  70702. name: string;
  70703. shader: string;
  70704. };
  70705. }
  70706. declare module BABYLON {
  70707. /** @hidden */
  70708. export var spriteMapVertexShader: {
  70709. name: string;
  70710. shader: string;
  70711. };
  70712. }
  70713. declare module BABYLON {
  70714. /**
  70715. * Defines the basic options interface of a SpriteMap
  70716. */
  70717. export interface ISpriteMapOptions {
  70718. /**
  70719. * Vector2 of the number of cells in the grid.
  70720. */
  70721. stageSize?: Vector2;
  70722. /**
  70723. * Vector2 of the size of the output plane in World Units.
  70724. */
  70725. outputSize?: Vector2;
  70726. /**
  70727. * Vector3 of the position of the output plane in World Units.
  70728. */
  70729. outputPosition?: Vector3;
  70730. /**
  70731. * Vector3 of the rotation of the output plane.
  70732. */
  70733. outputRotation?: Vector3;
  70734. /**
  70735. * number of layers that the system will reserve in resources.
  70736. */
  70737. layerCount?: number;
  70738. /**
  70739. * number of max animation frames a single cell will reserve in resources.
  70740. */
  70741. maxAnimationFrames?: number;
  70742. /**
  70743. * number cell index of the base tile when the system compiles.
  70744. */
  70745. baseTile?: number;
  70746. /**
  70747. * boolean flip the sprite after its been repositioned by the framing data.
  70748. */
  70749. flipU?: boolean;
  70750. /**
  70751. * Vector3 scalar of the global RGB values of the SpriteMap.
  70752. */
  70753. colorMultiply?: Vector3;
  70754. }
  70755. /**
  70756. * Defines the IDisposable interface in order to be cleanable from resources.
  70757. */
  70758. export interface ISpriteMap extends IDisposable {
  70759. /**
  70760. * String name of the SpriteMap.
  70761. */
  70762. name: string;
  70763. /**
  70764. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70765. */
  70766. atlasJSON: ISpriteJSONAtlas;
  70767. /**
  70768. * Texture of the SpriteMap.
  70769. */
  70770. spriteSheet: Texture;
  70771. /**
  70772. * The parameters to initialize the SpriteMap with.
  70773. */
  70774. options: ISpriteMapOptions;
  70775. }
  70776. /**
  70777. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70778. */
  70779. export class SpriteMap implements ISpriteMap {
  70780. /** The Name of the spriteMap */
  70781. name: string;
  70782. /** The JSON file with the frame and meta data */
  70783. atlasJSON: ISpriteJSONAtlas;
  70784. /** The systems Sprite Sheet Texture */
  70785. spriteSheet: Texture;
  70786. /** Arguments passed with the Constructor */
  70787. options: ISpriteMapOptions;
  70788. /** Public Sprite Storage array, parsed from atlasJSON */
  70789. sprites: Array<ISpriteJSONSprite>;
  70790. /** Returns the Number of Sprites in the System */
  70791. get spriteCount(): number;
  70792. /** Returns the Position of Output Plane*/
  70793. get position(): Vector3;
  70794. /** Returns the Position of Output Plane*/
  70795. set position(v: Vector3);
  70796. /** Returns the Rotation of Output Plane*/
  70797. get rotation(): Vector3;
  70798. /** Returns the Rotation of Output Plane*/
  70799. set rotation(v: Vector3);
  70800. /** Sets the AnimationMap*/
  70801. get animationMap(): RawTexture;
  70802. /** Sets the AnimationMap*/
  70803. set animationMap(v: RawTexture);
  70804. /** Scene that the SpriteMap was created in */
  70805. private _scene;
  70806. /** Texture Buffer of Float32 that holds tile frame data*/
  70807. private _frameMap;
  70808. /** Texture Buffers of Float32 that holds tileMap data*/
  70809. private _tileMaps;
  70810. /** Texture Buffer of Float32 that holds Animation Data*/
  70811. private _animationMap;
  70812. /** Custom ShaderMaterial Central to the System*/
  70813. private _material;
  70814. /** Custom ShaderMaterial Central to the System*/
  70815. private _output;
  70816. /** Systems Time Ticker*/
  70817. private _time;
  70818. /**
  70819. * Creates a new SpriteMap
  70820. * @param name defines the SpriteMaps Name
  70821. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70822. * @param spriteSheet is the Texture that the Sprites are on.
  70823. * @param options a basic deployment configuration
  70824. * @param scene The Scene that the map is deployed on
  70825. */
  70826. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70827. /**
  70828. * Returns tileID location
  70829. * @returns Vector2 the cell position ID
  70830. */
  70831. getTileID(): Vector2;
  70832. /**
  70833. * Gets the UV location of the mouse over the SpriteMap.
  70834. * @returns Vector2 the UV position of the mouse interaction
  70835. */
  70836. getMousePosition(): Vector2;
  70837. /**
  70838. * Creates the "frame" texture Buffer
  70839. * -------------------------------------
  70840. * Structure of frames
  70841. * "filename": "Falling-Water-2.png",
  70842. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70843. * "rotated": true,
  70844. * "trimmed": true,
  70845. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70846. * "sourceSize": {"w":32,"h":32}
  70847. * @returns RawTexture of the frameMap
  70848. */
  70849. private _createFrameBuffer;
  70850. /**
  70851. * Creates the tileMap texture Buffer
  70852. * @param buffer normally and array of numbers, or a false to generate from scratch
  70853. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70854. * @returns RawTexture of the tileMap
  70855. */
  70856. private _createTileBuffer;
  70857. /**
  70858. * Modifies the data of the tileMaps
  70859. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70860. * @param pos is the iVector2 Coordinates of the Tile
  70861. * @param tile The SpriteIndex of the new Tile
  70862. */
  70863. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70864. /**
  70865. * Creates the animationMap texture Buffer
  70866. * @param buffer normally and array of numbers, or a false to generate from scratch
  70867. * @returns RawTexture of the animationMap
  70868. */
  70869. private _createTileAnimationBuffer;
  70870. /**
  70871. * Modifies the data of the animationMap
  70872. * @param cellID is the Index of the Sprite
  70873. * @param _frame is the target Animation frame
  70874. * @param toCell is the Target Index of the next frame of the animation
  70875. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70876. * @param speed is a global scalar of the time variable on the map.
  70877. */
  70878. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70879. /**
  70880. * Exports the .tilemaps file
  70881. */
  70882. saveTileMaps(): void;
  70883. /**
  70884. * Imports the .tilemaps file
  70885. * @param url of the .tilemaps file
  70886. */
  70887. loadTileMaps(url: string): void;
  70888. /**
  70889. * Release associated resources
  70890. */
  70891. dispose(): void;
  70892. }
  70893. }
  70894. declare module BABYLON {
  70895. /**
  70896. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70897. * @see http://doc.babylonjs.com/babylon101/sprites
  70898. */
  70899. export class SpritePackedManager extends SpriteManager {
  70900. /** defines the packed manager's name */
  70901. name: string;
  70902. /**
  70903. * Creates a new sprite manager from a packed sprite sheet
  70904. * @param name defines the manager's name
  70905. * @param imgUrl defines the sprite sheet url
  70906. * @param capacity defines the maximum allowed number of sprites
  70907. * @param scene defines the hosting scene
  70908. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70909. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70910. * @param samplingMode defines the smapling mode to use with spritesheet
  70911. * @param fromPacked set to true; do not alter
  70912. */
  70913. constructor(
  70914. /** defines the packed manager's name */
  70915. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70916. }
  70917. }
  70918. declare module BABYLON {
  70919. /**
  70920. * Defines the list of states available for a task inside a AssetsManager
  70921. */
  70922. export enum AssetTaskState {
  70923. /**
  70924. * Initialization
  70925. */
  70926. INIT = 0,
  70927. /**
  70928. * Running
  70929. */
  70930. RUNNING = 1,
  70931. /**
  70932. * Done
  70933. */
  70934. DONE = 2,
  70935. /**
  70936. * Error
  70937. */
  70938. ERROR = 3
  70939. }
  70940. /**
  70941. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70942. */
  70943. export abstract class AbstractAssetTask {
  70944. /**
  70945. * Task name
  70946. */ name: string;
  70947. /**
  70948. * Callback called when the task is successful
  70949. */
  70950. onSuccess: (task: any) => void;
  70951. /**
  70952. * Callback called when the task is not successful
  70953. */
  70954. onError: (task: any, message?: string, exception?: any) => void;
  70955. /**
  70956. * Creates a new AssetsManager
  70957. * @param name defines the name of the task
  70958. */
  70959. constructor(
  70960. /**
  70961. * Task name
  70962. */ name: string);
  70963. private _isCompleted;
  70964. private _taskState;
  70965. private _errorObject;
  70966. /**
  70967. * Get if the task is completed
  70968. */
  70969. get isCompleted(): boolean;
  70970. /**
  70971. * Gets the current state of the task
  70972. */
  70973. get taskState(): AssetTaskState;
  70974. /**
  70975. * Gets the current error object (if task is in error)
  70976. */
  70977. get errorObject(): {
  70978. message?: string;
  70979. exception?: any;
  70980. };
  70981. /**
  70982. * Internal only
  70983. * @hidden
  70984. */
  70985. _setErrorObject(message?: string, exception?: any): void;
  70986. /**
  70987. * Execute the current task
  70988. * @param scene defines the scene where you want your assets to be loaded
  70989. * @param onSuccess is a callback called when the task is successfully executed
  70990. * @param onError is a callback called if an error occurs
  70991. */
  70992. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70993. /**
  70994. * Execute the current task
  70995. * @param scene defines the scene where you want your assets to be loaded
  70996. * @param onSuccess is a callback called when the task is successfully executed
  70997. * @param onError is a callback called if an error occurs
  70998. */
  70999. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71000. /**
  71001. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71002. * This can be used with failed tasks that have the reason for failure fixed.
  71003. */
  71004. reset(): void;
  71005. private onErrorCallback;
  71006. private onDoneCallback;
  71007. }
  71008. /**
  71009. * Define the interface used by progress events raised during assets loading
  71010. */
  71011. export interface IAssetsProgressEvent {
  71012. /**
  71013. * Defines the number of remaining tasks to process
  71014. */
  71015. remainingCount: number;
  71016. /**
  71017. * Defines the total number of tasks
  71018. */
  71019. totalCount: number;
  71020. /**
  71021. * Defines the task that was just processed
  71022. */
  71023. task: AbstractAssetTask;
  71024. }
  71025. /**
  71026. * Class used to share progress information about assets loading
  71027. */
  71028. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71029. /**
  71030. * Defines the number of remaining tasks to process
  71031. */
  71032. remainingCount: number;
  71033. /**
  71034. * Defines the total number of tasks
  71035. */
  71036. totalCount: number;
  71037. /**
  71038. * Defines the task that was just processed
  71039. */
  71040. task: AbstractAssetTask;
  71041. /**
  71042. * Creates a AssetsProgressEvent
  71043. * @param remainingCount defines the number of remaining tasks to process
  71044. * @param totalCount defines the total number of tasks
  71045. * @param task defines the task that was just processed
  71046. */
  71047. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71048. }
  71049. /**
  71050. * Define a task used by AssetsManager to load meshes
  71051. */
  71052. export class MeshAssetTask extends AbstractAssetTask {
  71053. /**
  71054. * Defines the name of the task
  71055. */
  71056. name: string;
  71057. /**
  71058. * Defines the list of mesh's names you want to load
  71059. */
  71060. meshesNames: any;
  71061. /**
  71062. * Defines the root url to use as a base to load your meshes and associated resources
  71063. */
  71064. rootUrl: string;
  71065. /**
  71066. * Defines the filename or File of the scene to load from
  71067. */
  71068. sceneFilename: string | File;
  71069. /**
  71070. * Gets the list of loaded meshes
  71071. */
  71072. loadedMeshes: Array<AbstractMesh>;
  71073. /**
  71074. * Gets the list of loaded particle systems
  71075. */
  71076. loadedParticleSystems: Array<IParticleSystem>;
  71077. /**
  71078. * Gets the list of loaded skeletons
  71079. */
  71080. loadedSkeletons: Array<Skeleton>;
  71081. /**
  71082. * Gets the list of loaded animation groups
  71083. */
  71084. loadedAnimationGroups: Array<AnimationGroup>;
  71085. /**
  71086. * Callback called when the task is successful
  71087. */
  71088. onSuccess: (task: MeshAssetTask) => void;
  71089. /**
  71090. * Callback called when the task is successful
  71091. */
  71092. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71093. /**
  71094. * Creates a new MeshAssetTask
  71095. * @param name defines the name of the task
  71096. * @param meshesNames defines the list of mesh's names you want to load
  71097. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71098. * @param sceneFilename defines the filename or File of the scene to load from
  71099. */
  71100. constructor(
  71101. /**
  71102. * Defines the name of the task
  71103. */
  71104. name: string,
  71105. /**
  71106. * Defines the list of mesh's names you want to load
  71107. */
  71108. meshesNames: any,
  71109. /**
  71110. * Defines the root url to use as a base to load your meshes and associated resources
  71111. */
  71112. rootUrl: string,
  71113. /**
  71114. * Defines the filename or File of the scene to load from
  71115. */
  71116. sceneFilename: string | File);
  71117. /**
  71118. * Execute the current task
  71119. * @param scene defines the scene where you want your assets to be loaded
  71120. * @param onSuccess is a callback called when the task is successfully executed
  71121. * @param onError is a callback called if an error occurs
  71122. */
  71123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71124. }
  71125. /**
  71126. * Define a task used by AssetsManager to load text content
  71127. */
  71128. export class TextFileAssetTask extends AbstractAssetTask {
  71129. /**
  71130. * Defines the name of the task
  71131. */
  71132. name: string;
  71133. /**
  71134. * Defines the location of the file to load
  71135. */
  71136. url: string;
  71137. /**
  71138. * Gets the loaded text string
  71139. */
  71140. text: string;
  71141. /**
  71142. * Callback called when the task is successful
  71143. */
  71144. onSuccess: (task: TextFileAssetTask) => void;
  71145. /**
  71146. * Callback called when the task is successful
  71147. */
  71148. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71149. /**
  71150. * Creates a new TextFileAssetTask object
  71151. * @param name defines the name of the task
  71152. * @param url defines the location of the file to load
  71153. */
  71154. constructor(
  71155. /**
  71156. * Defines the name of the task
  71157. */
  71158. name: string,
  71159. /**
  71160. * Defines the location of the file to load
  71161. */
  71162. url: string);
  71163. /**
  71164. * Execute the current task
  71165. * @param scene defines the scene where you want your assets to be loaded
  71166. * @param onSuccess is a callback called when the task is successfully executed
  71167. * @param onError is a callback called if an error occurs
  71168. */
  71169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71170. }
  71171. /**
  71172. * Define a task used by AssetsManager to load binary data
  71173. */
  71174. export class BinaryFileAssetTask extends AbstractAssetTask {
  71175. /**
  71176. * Defines the name of the task
  71177. */
  71178. name: string;
  71179. /**
  71180. * Defines the location of the file to load
  71181. */
  71182. url: string;
  71183. /**
  71184. * Gets the lodaded data (as an array buffer)
  71185. */
  71186. data: ArrayBuffer;
  71187. /**
  71188. * Callback called when the task is successful
  71189. */
  71190. onSuccess: (task: BinaryFileAssetTask) => void;
  71191. /**
  71192. * Callback called when the task is successful
  71193. */
  71194. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71195. /**
  71196. * Creates a new BinaryFileAssetTask object
  71197. * @param name defines the name of the new task
  71198. * @param url defines the location of the file to load
  71199. */
  71200. constructor(
  71201. /**
  71202. * Defines the name of the task
  71203. */
  71204. name: string,
  71205. /**
  71206. * Defines the location of the file to load
  71207. */
  71208. url: string);
  71209. /**
  71210. * Execute the current task
  71211. * @param scene defines the scene where you want your assets to be loaded
  71212. * @param onSuccess is a callback called when the task is successfully executed
  71213. * @param onError is a callback called if an error occurs
  71214. */
  71215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71216. }
  71217. /**
  71218. * Define a task used by AssetsManager to load images
  71219. */
  71220. export class ImageAssetTask extends AbstractAssetTask {
  71221. /**
  71222. * Defines the name of the task
  71223. */
  71224. name: string;
  71225. /**
  71226. * Defines the location of the image to load
  71227. */
  71228. url: string;
  71229. /**
  71230. * Gets the loaded images
  71231. */
  71232. image: HTMLImageElement;
  71233. /**
  71234. * Callback called when the task is successful
  71235. */
  71236. onSuccess: (task: ImageAssetTask) => void;
  71237. /**
  71238. * Callback called when the task is successful
  71239. */
  71240. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71241. /**
  71242. * Creates a new ImageAssetTask
  71243. * @param name defines the name of the task
  71244. * @param url defines the location of the image to load
  71245. */
  71246. constructor(
  71247. /**
  71248. * Defines the name of the task
  71249. */
  71250. name: string,
  71251. /**
  71252. * Defines the location of the image to load
  71253. */
  71254. url: string);
  71255. /**
  71256. * Execute the current task
  71257. * @param scene defines the scene where you want your assets to be loaded
  71258. * @param onSuccess is a callback called when the task is successfully executed
  71259. * @param onError is a callback called if an error occurs
  71260. */
  71261. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71262. }
  71263. /**
  71264. * Defines the interface used by texture loading tasks
  71265. */
  71266. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71267. /**
  71268. * Gets the loaded texture
  71269. */
  71270. texture: TEX;
  71271. }
  71272. /**
  71273. * Define a task used by AssetsManager to load 2D textures
  71274. */
  71275. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71276. /**
  71277. * Defines the name of the task
  71278. */
  71279. name: string;
  71280. /**
  71281. * Defines the location of the file to load
  71282. */
  71283. url: string;
  71284. /**
  71285. * Defines if mipmap should not be generated (default is false)
  71286. */
  71287. noMipmap?: boolean | undefined;
  71288. /**
  71289. * Defines if texture must be inverted on Y axis (default is true)
  71290. */
  71291. invertY: boolean;
  71292. /**
  71293. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71294. */
  71295. samplingMode: number;
  71296. /**
  71297. * Gets the loaded texture
  71298. */
  71299. texture: Texture;
  71300. /**
  71301. * Callback called when the task is successful
  71302. */
  71303. onSuccess: (task: TextureAssetTask) => void;
  71304. /**
  71305. * Callback called when the task is successful
  71306. */
  71307. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71308. /**
  71309. * Creates a new TextureAssetTask object
  71310. * @param name defines the name of the task
  71311. * @param url defines the location of the file to load
  71312. * @param noMipmap defines if mipmap should not be generated (default is false)
  71313. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71314. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71315. */
  71316. constructor(
  71317. /**
  71318. * Defines the name of the task
  71319. */
  71320. name: string,
  71321. /**
  71322. * Defines the location of the file to load
  71323. */
  71324. url: string,
  71325. /**
  71326. * Defines if mipmap should not be generated (default is false)
  71327. */
  71328. noMipmap?: boolean | undefined,
  71329. /**
  71330. * Defines if texture must be inverted on Y axis (default is true)
  71331. */
  71332. invertY?: boolean,
  71333. /**
  71334. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71335. */
  71336. samplingMode?: number);
  71337. /**
  71338. * Execute the current task
  71339. * @param scene defines the scene where you want your assets to be loaded
  71340. * @param onSuccess is a callback called when the task is successfully executed
  71341. * @param onError is a callback called if an error occurs
  71342. */
  71343. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71344. }
  71345. /**
  71346. * Define a task used by AssetsManager to load cube textures
  71347. */
  71348. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71349. /**
  71350. * Defines the name of the task
  71351. */
  71352. name: string;
  71353. /**
  71354. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71355. */
  71356. url: string;
  71357. /**
  71358. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71359. */
  71360. extensions?: string[] | undefined;
  71361. /**
  71362. * Defines if mipmaps should not be generated (default is false)
  71363. */
  71364. noMipmap?: boolean | undefined;
  71365. /**
  71366. * Defines the explicit list of files (undefined by default)
  71367. */
  71368. files?: string[] | undefined;
  71369. /**
  71370. * Gets the loaded texture
  71371. */
  71372. texture: CubeTexture;
  71373. /**
  71374. * Callback called when the task is successful
  71375. */
  71376. onSuccess: (task: CubeTextureAssetTask) => void;
  71377. /**
  71378. * Callback called when the task is successful
  71379. */
  71380. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71381. /**
  71382. * Creates a new CubeTextureAssetTask
  71383. * @param name defines the name of the task
  71384. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71385. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71386. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71387. * @param files defines the explicit list of files (undefined by default)
  71388. */
  71389. constructor(
  71390. /**
  71391. * Defines the name of the task
  71392. */
  71393. name: string,
  71394. /**
  71395. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71396. */
  71397. url: string,
  71398. /**
  71399. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71400. */
  71401. extensions?: string[] | undefined,
  71402. /**
  71403. * Defines if mipmaps should not be generated (default is false)
  71404. */
  71405. noMipmap?: boolean | undefined,
  71406. /**
  71407. * Defines the explicit list of files (undefined by default)
  71408. */
  71409. files?: string[] | undefined);
  71410. /**
  71411. * Execute the current task
  71412. * @param scene defines the scene where you want your assets to be loaded
  71413. * @param onSuccess is a callback called when the task is successfully executed
  71414. * @param onError is a callback called if an error occurs
  71415. */
  71416. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71417. }
  71418. /**
  71419. * Define a task used by AssetsManager to load HDR cube textures
  71420. */
  71421. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71422. /**
  71423. * Defines the name of the task
  71424. */
  71425. name: string;
  71426. /**
  71427. * Defines the location of the file to load
  71428. */
  71429. url: string;
  71430. /**
  71431. * Defines the desired size (the more it increases the longer the generation will be)
  71432. */
  71433. size: number;
  71434. /**
  71435. * Defines if mipmaps should not be generated (default is false)
  71436. */
  71437. noMipmap: boolean;
  71438. /**
  71439. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71440. */
  71441. generateHarmonics: boolean;
  71442. /**
  71443. * 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)
  71444. */
  71445. gammaSpace: boolean;
  71446. /**
  71447. * Internal Use Only
  71448. */
  71449. reserved: boolean;
  71450. /**
  71451. * Gets the loaded texture
  71452. */
  71453. texture: HDRCubeTexture;
  71454. /**
  71455. * Callback called when the task is successful
  71456. */
  71457. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71458. /**
  71459. * Callback called when the task is successful
  71460. */
  71461. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71462. /**
  71463. * Creates a new HDRCubeTextureAssetTask object
  71464. * @param name defines the name of the task
  71465. * @param url defines the location of the file to load
  71466. * @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.
  71467. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71468. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71469. * @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)
  71470. * @param reserved Internal use only
  71471. */
  71472. constructor(
  71473. /**
  71474. * Defines the name of the task
  71475. */
  71476. name: string,
  71477. /**
  71478. * Defines the location of the file to load
  71479. */
  71480. url: string,
  71481. /**
  71482. * Defines the desired size (the more it increases the longer the generation will be)
  71483. */
  71484. size: number,
  71485. /**
  71486. * Defines if mipmaps should not be generated (default is false)
  71487. */
  71488. noMipmap?: boolean,
  71489. /**
  71490. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71491. */
  71492. generateHarmonics?: boolean,
  71493. /**
  71494. * 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)
  71495. */
  71496. gammaSpace?: boolean,
  71497. /**
  71498. * Internal Use Only
  71499. */
  71500. reserved?: boolean);
  71501. /**
  71502. * Execute the current task
  71503. * @param scene defines the scene where you want your assets to be loaded
  71504. * @param onSuccess is a callback called when the task is successfully executed
  71505. * @param onError is a callback called if an error occurs
  71506. */
  71507. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71508. }
  71509. /**
  71510. * Define a task used by AssetsManager to load Equirectangular cube textures
  71511. */
  71512. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71513. /**
  71514. * Defines the name of the task
  71515. */
  71516. name: string;
  71517. /**
  71518. * Defines the location of the file to load
  71519. */
  71520. url: string;
  71521. /**
  71522. * Defines the desired size (the more it increases the longer the generation will be)
  71523. */
  71524. size: number;
  71525. /**
  71526. * Defines if mipmaps should not be generated (default is false)
  71527. */
  71528. noMipmap: boolean;
  71529. /**
  71530. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71531. * but the standard material would require them in Gamma space) (default is true)
  71532. */
  71533. gammaSpace: boolean;
  71534. /**
  71535. * Gets the loaded texture
  71536. */
  71537. texture: EquiRectangularCubeTexture;
  71538. /**
  71539. * Callback called when the task is successful
  71540. */
  71541. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71542. /**
  71543. * Callback called when the task is successful
  71544. */
  71545. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71546. /**
  71547. * Creates a new EquiRectangularCubeTextureAssetTask object
  71548. * @param name defines the name of the task
  71549. * @param url defines the location of the file to load
  71550. * @param size defines the desired size (the more it increases the longer the generation will be)
  71551. * If the size is omitted this implies you are using a preprocessed cubemap.
  71552. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71553. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71554. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71555. * (default is true)
  71556. */
  71557. constructor(
  71558. /**
  71559. * Defines the name of the task
  71560. */
  71561. name: string,
  71562. /**
  71563. * Defines the location of the file to load
  71564. */
  71565. url: string,
  71566. /**
  71567. * Defines the desired size (the more it increases the longer the generation will be)
  71568. */
  71569. size: number,
  71570. /**
  71571. * Defines if mipmaps should not be generated (default is false)
  71572. */
  71573. noMipmap?: boolean,
  71574. /**
  71575. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71576. * but the standard material would require them in Gamma space) (default is true)
  71577. */
  71578. gammaSpace?: boolean);
  71579. /**
  71580. * Execute the current task
  71581. * @param scene defines the scene where you want your assets to be loaded
  71582. * @param onSuccess is a callback called when the task is successfully executed
  71583. * @param onError is a callback called if an error occurs
  71584. */
  71585. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71586. }
  71587. /**
  71588. * This class can be used to easily import assets into a scene
  71589. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71590. */
  71591. export class AssetsManager {
  71592. private _scene;
  71593. private _isLoading;
  71594. protected _tasks: AbstractAssetTask[];
  71595. protected _waitingTasksCount: number;
  71596. protected _totalTasksCount: number;
  71597. /**
  71598. * Callback called when all tasks are processed
  71599. */
  71600. onFinish: (tasks: AbstractAssetTask[]) => void;
  71601. /**
  71602. * Callback called when a task is successful
  71603. */
  71604. onTaskSuccess: (task: AbstractAssetTask) => void;
  71605. /**
  71606. * Callback called when a task had an error
  71607. */
  71608. onTaskError: (task: AbstractAssetTask) => void;
  71609. /**
  71610. * Callback called when a task is done (whatever the result is)
  71611. */
  71612. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71613. /**
  71614. * Observable called when all tasks are processed
  71615. */
  71616. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71617. /**
  71618. * Observable called when a task had an error
  71619. */
  71620. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71621. /**
  71622. * Observable called when all tasks were executed
  71623. */
  71624. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71625. /**
  71626. * Observable called when a task is done (whatever the result is)
  71627. */
  71628. onProgressObservable: Observable<IAssetsProgressEvent>;
  71629. /**
  71630. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71631. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71632. */
  71633. useDefaultLoadingScreen: boolean;
  71634. /**
  71635. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71636. * when all assets have been downloaded.
  71637. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71638. */
  71639. autoHideLoadingUI: boolean;
  71640. /**
  71641. * Creates a new AssetsManager
  71642. * @param scene defines the scene to work on
  71643. */
  71644. constructor(scene: Scene);
  71645. /**
  71646. * Add a MeshAssetTask to the list of active tasks
  71647. * @param taskName defines the name of the new task
  71648. * @param meshesNames defines the name of meshes to load
  71649. * @param rootUrl defines the root url to use to locate files
  71650. * @param sceneFilename defines the filename of the scene file
  71651. * @returns a new MeshAssetTask object
  71652. */
  71653. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71654. /**
  71655. * Add a TextFileAssetTask to the list of active tasks
  71656. * @param taskName defines the name of the new task
  71657. * @param url defines the url of the file to load
  71658. * @returns a new TextFileAssetTask object
  71659. */
  71660. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71661. /**
  71662. * Add a BinaryFileAssetTask to the list of active tasks
  71663. * @param taskName defines the name of the new task
  71664. * @param url defines the url of the file to load
  71665. * @returns a new BinaryFileAssetTask object
  71666. */
  71667. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71668. /**
  71669. * Add a ImageAssetTask to the list of active tasks
  71670. * @param taskName defines the name of the new task
  71671. * @param url defines the url of the file to load
  71672. * @returns a new ImageAssetTask object
  71673. */
  71674. addImageTask(taskName: string, url: string): ImageAssetTask;
  71675. /**
  71676. * Add a TextureAssetTask to the list of active tasks
  71677. * @param taskName defines the name of the new task
  71678. * @param url defines the url of the file to load
  71679. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71680. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71681. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71682. * @returns a new TextureAssetTask object
  71683. */
  71684. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71685. /**
  71686. * Add a CubeTextureAssetTask to the list of active tasks
  71687. * @param taskName defines the name of the new task
  71688. * @param url defines the url of the file to load
  71689. * @param extensions defines the extension to use to load the cube map (can be null)
  71690. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71691. * @param files defines the list of files to load (can be null)
  71692. * @returns a new CubeTextureAssetTask object
  71693. */
  71694. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71695. /**
  71696. *
  71697. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71698. * @param taskName defines the name of the new task
  71699. * @param url defines the url of the file to load
  71700. * @param size defines the size you want for the cubemap (can be null)
  71701. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71702. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71703. * @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)
  71704. * @param reserved Internal use only
  71705. * @returns a new HDRCubeTextureAssetTask object
  71706. */
  71707. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71708. /**
  71709. *
  71710. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71711. * @param taskName defines the name of the new task
  71712. * @param url defines the url of the file to load
  71713. * @param size defines the size you want for the cubemap (can be null)
  71714. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71715. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71716. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71717. * @returns a new EquiRectangularCubeTextureAssetTask object
  71718. */
  71719. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71720. /**
  71721. * Remove a task from the assets manager.
  71722. * @param task the task to remove
  71723. */
  71724. removeTask(task: AbstractAssetTask): void;
  71725. private _decreaseWaitingTasksCount;
  71726. private _runTask;
  71727. /**
  71728. * Reset the AssetsManager and remove all tasks
  71729. * @return the current instance of the AssetsManager
  71730. */
  71731. reset(): AssetsManager;
  71732. /**
  71733. * Start the loading process
  71734. * @return the current instance of the AssetsManager
  71735. */
  71736. load(): AssetsManager;
  71737. /**
  71738. * Start the loading process as an async operation
  71739. * @return a promise returning the list of failed tasks
  71740. */
  71741. loadAsync(): Promise<void>;
  71742. }
  71743. }
  71744. declare module BABYLON {
  71745. /**
  71746. * Wrapper class for promise with external resolve and reject.
  71747. */
  71748. export class Deferred<T> {
  71749. /**
  71750. * The promise associated with this deferred object.
  71751. */
  71752. readonly promise: Promise<T>;
  71753. private _resolve;
  71754. private _reject;
  71755. /**
  71756. * The resolve method of the promise associated with this deferred object.
  71757. */
  71758. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71759. /**
  71760. * The reject method of the promise associated with this deferred object.
  71761. */
  71762. get reject(): (reason?: any) => void;
  71763. /**
  71764. * Constructor for this deferred object.
  71765. */
  71766. constructor();
  71767. }
  71768. }
  71769. declare module BABYLON {
  71770. /**
  71771. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71772. */
  71773. export class MeshExploder {
  71774. private _centerMesh;
  71775. private _meshes;
  71776. private _meshesOrigins;
  71777. private _toCenterVectors;
  71778. private _scaledDirection;
  71779. private _newPosition;
  71780. private _centerPosition;
  71781. /**
  71782. * Explodes meshes from a center mesh.
  71783. * @param meshes The meshes to explode.
  71784. * @param centerMesh The mesh to be center of explosion.
  71785. */
  71786. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71787. private _setCenterMesh;
  71788. /**
  71789. * Get class name
  71790. * @returns "MeshExploder"
  71791. */
  71792. getClassName(): string;
  71793. /**
  71794. * "Exploded meshes"
  71795. * @returns Array of meshes with the centerMesh at index 0.
  71796. */
  71797. getMeshes(): Array<Mesh>;
  71798. /**
  71799. * Explodes meshes giving a specific direction
  71800. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71801. */
  71802. explode(direction?: number): void;
  71803. }
  71804. }
  71805. declare module BABYLON {
  71806. /**
  71807. * Class used to help managing file picking and drag'n'drop
  71808. */
  71809. export class FilesInput {
  71810. /**
  71811. * List of files ready to be loaded
  71812. */
  71813. static get FilesToLoad(): {
  71814. [key: string]: File;
  71815. };
  71816. /**
  71817. * Callback called when a file is processed
  71818. */
  71819. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71820. private _engine;
  71821. private _currentScene;
  71822. private _sceneLoadedCallback;
  71823. private _progressCallback;
  71824. private _additionalRenderLoopLogicCallback;
  71825. private _textureLoadingCallback;
  71826. private _startingProcessingFilesCallback;
  71827. private _onReloadCallback;
  71828. private _errorCallback;
  71829. private _elementToMonitor;
  71830. private _sceneFileToLoad;
  71831. private _filesToLoad;
  71832. /**
  71833. * Creates a new FilesInput
  71834. * @param engine defines the rendering engine
  71835. * @param scene defines the hosting scene
  71836. * @param sceneLoadedCallback callback called when scene is loaded
  71837. * @param progressCallback callback called to track progress
  71838. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71839. * @param textureLoadingCallback callback called when a texture is loading
  71840. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71841. * @param onReloadCallback callback called when a reload is requested
  71842. * @param errorCallback callback call if an error occurs
  71843. */
  71844. 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);
  71845. private _dragEnterHandler;
  71846. private _dragOverHandler;
  71847. private _dropHandler;
  71848. /**
  71849. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71850. * @param elementToMonitor defines the DOM element to track
  71851. */
  71852. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71853. /**
  71854. * Release all associated resources
  71855. */
  71856. dispose(): void;
  71857. private renderFunction;
  71858. private drag;
  71859. private drop;
  71860. private _traverseFolder;
  71861. private _processFiles;
  71862. /**
  71863. * Load files from a drop event
  71864. * @param event defines the drop event to use as source
  71865. */
  71866. loadFiles(event: any): void;
  71867. private _processReload;
  71868. /**
  71869. * Reload the current scene from the loaded files
  71870. */
  71871. reload(): void;
  71872. }
  71873. }
  71874. declare module BABYLON {
  71875. /**
  71876. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71878. */
  71879. export class SceneOptimization {
  71880. /**
  71881. * Defines the priority of this optimization (0 by default which means first in the list)
  71882. */
  71883. priority: number;
  71884. /**
  71885. * Gets a string describing the action executed by the current optimization
  71886. * @returns description string
  71887. */
  71888. getDescription(): string;
  71889. /**
  71890. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71891. * @param scene defines the current scene where to apply this optimization
  71892. * @param optimizer defines the current optimizer
  71893. * @returns true if everything that can be done was applied
  71894. */
  71895. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71896. /**
  71897. * Creates the SceneOptimization object
  71898. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71899. * @param desc defines the description associated with the optimization
  71900. */
  71901. constructor(
  71902. /**
  71903. * Defines the priority of this optimization (0 by default which means first in the list)
  71904. */
  71905. priority?: number);
  71906. }
  71907. /**
  71908. * Defines an optimization used to reduce the size of render target textures
  71909. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71910. */
  71911. export class TextureOptimization extends SceneOptimization {
  71912. /**
  71913. * Defines the priority of this optimization (0 by default which means first in the list)
  71914. */
  71915. priority: number;
  71916. /**
  71917. * 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
  71918. */
  71919. maximumSize: number;
  71920. /**
  71921. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71922. */
  71923. step: number;
  71924. /**
  71925. * Gets a string describing the action executed by the current optimization
  71926. * @returns description string
  71927. */
  71928. getDescription(): string;
  71929. /**
  71930. * Creates the TextureOptimization object
  71931. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71932. * @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
  71933. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71934. */
  71935. constructor(
  71936. /**
  71937. * Defines the priority of this optimization (0 by default which means first in the list)
  71938. */
  71939. priority?: number,
  71940. /**
  71941. * 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
  71942. */
  71943. maximumSize?: number,
  71944. /**
  71945. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71946. */
  71947. step?: number);
  71948. /**
  71949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71950. * @param scene defines the current scene where to apply this optimization
  71951. * @param optimizer defines the current optimizer
  71952. * @returns true if everything that can be done was applied
  71953. */
  71954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71955. }
  71956. /**
  71957. * Defines an optimization used to increase or decrease the rendering resolution
  71958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71959. */
  71960. export class HardwareScalingOptimization extends SceneOptimization {
  71961. /**
  71962. * Defines the priority of this optimization (0 by default which means first in the list)
  71963. */
  71964. priority: number;
  71965. /**
  71966. * Defines the maximum scale to use (2 by default)
  71967. */
  71968. maximumScale: number;
  71969. /**
  71970. * Defines the step to use between two passes (0.5 by default)
  71971. */
  71972. step: number;
  71973. private _currentScale;
  71974. private _directionOffset;
  71975. /**
  71976. * Gets a string describing the action executed by the current optimization
  71977. * @return description string
  71978. */
  71979. getDescription(): string;
  71980. /**
  71981. * Creates the HardwareScalingOptimization object
  71982. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71983. * @param maximumScale defines the maximum scale to use (2 by default)
  71984. * @param step defines the step to use between two passes (0.5 by default)
  71985. */
  71986. constructor(
  71987. /**
  71988. * Defines the priority of this optimization (0 by default which means first in the list)
  71989. */
  71990. priority?: number,
  71991. /**
  71992. * Defines the maximum scale to use (2 by default)
  71993. */
  71994. maximumScale?: number,
  71995. /**
  71996. * Defines the step to use between two passes (0.5 by default)
  71997. */
  71998. step?: number);
  71999. /**
  72000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72001. * @param scene defines the current scene where to apply this optimization
  72002. * @param optimizer defines the current optimizer
  72003. * @returns true if everything that can be done was applied
  72004. */
  72005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72006. }
  72007. /**
  72008. * Defines an optimization used to remove shadows
  72009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72010. */
  72011. export class ShadowsOptimization extends SceneOptimization {
  72012. /**
  72013. * Gets a string describing the action executed by the current optimization
  72014. * @return description string
  72015. */
  72016. getDescription(): string;
  72017. /**
  72018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72019. * @param scene defines the current scene where to apply this optimization
  72020. * @param optimizer defines the current optimizer
  72021. * @returns true if everything that can be done was applied
  72022. */
  72023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72024. }
  72025. /**
  72026. * Defines an optimization used to turn post-processes off
  72027. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72028. */
  72029. export class PostProcessesOptimization extends SceneOptimization {
  72030. /**
  72031. * Gets a string describing the action executed by the current optimization
  72032. * @return description string
  72033. */
  72034. getDescription(): string;
  72035. /**
  72036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72037. * @param scene defines the current scene where to apply this optimization
  72038. * @param optimizer defines the current optimizer
  72039. * @returns true if everything that can be done was applied
  72040. */
  72041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72042. }
  72043. /**
  72044. * Defines an optimization used to turn lens flares off
  72045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72046. */
  72047. export class LensFlaresOptimization extends SceneOptimization {
  72048. /**
  72049. * Gets a string describing the action executed by the current optimization
  72050. * @return description string
  72051. */
  72052. getDescription(): string;
  72053. /**
  72054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72055. * @param scene defines the current scene where to apply this optimization
  72056. * @param optimizer defines the current optimizer
  72057. * @returns true if everything that can be done was applied
  72058. */
  72059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72060. }
  72061. /**
  72062. * Defines an optimization based on user defined callback.
  72063. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72064. */
  72065. export class CustomOptimization extends SceneOptimization {
  72066. /**
  72067. * Callback called to apply the custom optimization.
  72068. */
  72069. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72070. /**
  72071. * Callback called to get custom description
  72072. */
  72073. onGetDescription: () => string;
  72074. /**
  72075. * Gets a string describing the action executed by the current optimization
  72076. * @returns description string
  72077. */
  72078. getDescription(): string;
  72079. /**
  72080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72081. * @param scene defines the current scene where to apply this optimization
  72082. * @param optimizer defines the current optimizer
  72083. * @returns true if everything that can be done was applied
  72084. */
  72085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72086. }
  72087. /**
  72088. * Defines an optimization used to turn particles off
  72089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72090. */
  72091. export class ParticlesOptimization extends SceneOptimization {
  72092. /**
  72093. * Gets a string describing the action executed by the current optimization
  72094. * @return description string
  72095. */
  72096. getDescription(): string;
  72097. /**
  72098. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72099. * @param scene defines the current scene where to apply this optimization
  72100. * @param optimizer defines the current optimizer
  72101. * @returns true if everything that can be done was applied
  72102. */
  72103. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72104. }
  72105. /**
  72106. * Defines an optimization used to turn render targets off
  72107. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72108. */
  72109. export class RenderTargetsOptimization extends SceneOptimization {
  72110. /**
  72111. * Gets a string describing the action executed by the current optimization
  72112. * @return description string
  72113. */
  72114. getDescription(): string;
  72115. /**
  72116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72117. * @param scene defines the current scene where to apply this optimization
  72118. * @param optimizer defines the current optimizer
  72119. * @returns true if everything that can be done was applied
  72120. */
  72121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72122. }
  72123. /**
  72124. * Defines an optimization used to merge meshes with compatible materials
  72125. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72126. */
  72127. export class MergeMeshesOptimization extends SceneOptimization {
  72128. private static _UpdateSelectionTree;
  72129. /**
  72130. * Gets or sets a boolean which defines if optimization octree has to be updated
  72131. */
  72132. static get UpdateSelectionTree(): boolean;
  72133. /**
  72134. * Gets or sets a boolean which defines if optimization octree has to be updated
  72135. */
  72136. static set UpdateSelectionTree(value: boolean);
  72137. /**
  72138. * Gets a string describing the action executed by the current optimization
  72139. * @return description string
  72140. */
  72141. getDescription(): string;
  72142. private _canBeMerged;
  72143. /**
  72144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72145. * @param scene defines the current scene where to apply this optimization
  72146. * @param optimizer defines the current optimizer
  72147. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72148. * @returns true if everything that can be done was applied
  72149. */
  72150. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72151. }
  72152. /**
  72153. * Defines a list of options used by SceneOptimizer
  72154. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72155. */
  72156. export class SceneOptimizerOptions {
  72157. /**
  72158. * Defines the target frame rate to reach (60 by default)
  72159. */
  72160. targetFrameRate: number;
  72161. /**
  72162. * Defines the interval between two checkes (2000ms by default)
  72163. */
  72164. trackerDuration: number;
  72165. /**
  72166. * Gets the list of optimizations to apply
  72167. */
  72168. optimizations: SceneOptimization[];
  72169. /**
  72170. * Creates a new list of options used by SceneOptimizer
  72171. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72172. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72173. */
  72174. constructor(
  72175. /**
  72176. * Defines the target frame rate to reach (60 by default)
  72177. */
  72178. targetFrameRate?: number,
  72179. /**
  72180. * Defines the interval between two checkes (2000ms by default)
  72181. */
  72182. trackerDuration?: number);
  72183. /**
  72184. * Add a new optimization
  72185. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72186. * @returns the current SceneOptimizerOptions
  72187. */
  72188. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72189. /**
  72190. * Add a new custom optimization
  72191. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72192. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72193. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72194. * @returns the current SceneOptimizerOptions
  72195. */
  72196. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72197. /**
  72198. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72199. * @param targetFrameRate defines the target frame rate (60 by default)
  72200. * @returns a SceneOptimizerOptions object
  72201. */
  72202. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72203. /**
  72204. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72205. * @param targetFrameRate defines the target frame rate (60 by default)
  72206. * @returns a SceneOptimizerOptions object
  72207. */
  72208. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72209. /**
  72210. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72211. * @param targetFrameRate defines the target frame rate (60 by default)
  72212. * @returns a SceneOptimizerOptions object
  72213. */
  72214. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72215. }
  72216. /**
  72217. * Class used to run optimizations in order to reach a target frame rate
  72218. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72219. */
  72220. export class SceneOptimizer implements IDisposable {
  72221. private _isRunning;
  72222. private _options;
  72223. private _scene;
  72224. private _currentPriorityLevel;
  72225. private _targetFrameRate;
  72226. private _trackerDuration;
  72227. private _currentFrameRate;
  72228. private _sceneDisposeObserver;
  72229. private _improvementMode;
  72230. /**
  72231. * Defines an observable called when the optimizer reaches the target frame rate
  72232. */
  72233. onSuccessObservable: Observable<SceneOptimizer>;
  72234. /**
  72235. * Defines an observable called when the optimizer enables an optimization
  72236. */
  72237. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72238. /**
  72239. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72240. */
  72241. onFailureObservable: Observable<SceneOptimizer>;
  72242. /**
  72243. * Gets a boolean indicating if the optimizer is in improvement mode
  72244. */
  72245. get isInImprovementMode(): boolean;
  72246. /**
  72247. * Gets the current priority level (0 at start)
  72248. */
  72249. get currentPriorityLevel(): number;
  72250. /**
  72251. * Gets the current frame rate checked by the SceneOptimizer
  72252. */
  72253. get currentFrameRate(): number;
  72254. /**
  72255. * Gets or sets the current target frame rate (60 by default)
  72256. */
  72257. get targetFrameRate(): number;
  72258. /**
  72259. * Gets or sets the current target frame rate (60 by default)
  72260. */
  72261. set targetFrameRate(value: number);
  72262. /**
  72263. * Gets or sets the current interval between two checks (every 2000ms by default)
  72264. */
  72265. get trackerDuration(): number;
  72266. /**
  72267. * Gets or sets the current interval between two checks (every 2000ms by default)
  72268. */
  72269. set trackerDuration(value: number);
  72270. /**
  72271. * Gets the list of active optimizations
  72272. */
  72273. get optimizations(): SceneOptimization[];
  72274. /**
  72275. * Creates a new SceneOptimizer
  72276. * @param scene defines the scene to work on
  72277. * @param options defines the options to use with the SceneOptimizer
  72278. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72279. * @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)
  72280. */
  72281. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72282. /**
  72283. * Stops the current optimizer
  72284. */
  72285. stop(): void;
  72286. /**
  72287. * Reset the optimizer to initial step (current priority level = 0)
  72288. */
  72289. reset(): void;
  72290. /**
  72291. * Start the optimizer. By default it will try to reach a specific framerate
  72292. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72293. */
  72294. start(): void;
  72295. private _checkCurrentState;
  72296. /**
  72297. * Release all resources
  72298. */
  72299. dispose(): void;
  72300. /**
  72301. * Helper function to create a SceneOptimizer with one single line of code
  72302. * @param scene defines the scene to work on
  72303. * @param options defines the options to use with the SceneOptimizer
  72304. * @param onSuccess defines a callback to call on success
  72305. * @param onFailure defines a callback to call on failure
  72306. * @returns the new SceneOptimizer object
  72307. */
  72308. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72309. }
  72310. }
  72311. declare module BABYLON {
  72312. /**
  72313. * Class used to serialize a scene into a string
  72314. */
  72315. export class SceneSerializer {
  72316. /**
  72317. * Clear cache used by a previous serialization
  72318. */
  72319. static ClearCache(): void;
  72320. /**
  72321. * Serialize a scene into a JSON compatible object
  72322. * @param scene defines the scene to serialize
  72323. * @returns a JSON compatible object
  72324. */
  72325. static Serialize(scene: Scene): any;
  72326. /**
  72327. * Serialize a mesh into a JSON compatible object
  72328. * @param toSerialize defines the mesh to serialize
  72329. * @param withParents defines if parents must be serialized as well
  72330. * @param withChildren defines if children must be serialized as well
  72331. * @returns a JSON compatible object
  72332. */
  72333. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72334. }
  72335. }
  72336. declare module BABYLON {
  72337. /**
  72338. * Class used to host texture specific utilities
  72339. */
  72340. export class TextureTools {
  72341. /**
  72342. * Uses the GPU to create a copy texture rescaled at a given size
  72343. * @param texture Texture to copy from
  72344. * @param width defines the desired width
  72345. * @param height defines the desired height
  72346. * @param useBilinearMode defines if bilinear mode has to be used
  72347. * @return the generated texture
  72348. */
  72349. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72350. }
  72351. }
  72352. declare module BABYLON {
  72353. /**
  72354. * This represents the different options available for the video capture.
  72355. */
  72356. export interface VideoRecorderOptions {
  72357. /** Defines the mime type of the video. */
  72358. mimeType: string;
  72359. /** Defines the FPS the video should be recorded at. */
  72360. fps: number;
  72361. /** Defines the chunk size for the recording data. */
  72362. recordChunckSize: number;
  72363. /** The audio tracks to attach to the recording. */
  72364. audioTracks?: MediaStreamTrack[];
  72365. }
  72366. /**
  72367. * This can help with recording videos from BabylonJS.
  72368. * This is based on the available WebRTC functionalities of the browser.
  72369. *
  72370. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72371. */
  72372. export class VideoRecorder {
  72373. private static readonly _defaultOptions;
  72374. /**
  72375. * Returns whether or not the VideoRecorder is available in your browser.
  72376. * @param engine Defines the Babylon Engine.
  72377. * @returns true if supported otherwise false.
  72378. */
  72379. static IsSupported(engine: Engine): boolean;
  72380. private readonly _options;
  72381. private _canvas;
  72382. private _mediaRecorder;
  72383. private _recordedChunks;
  72384. private _fileName;
  72385. private _resolve;
  72386. private _reject;
  72387. /**
  72388. * True when a recording is already in progress.
  72389. */
  72390. get isRecording(): boolean;
  72391. /**
  72392. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72393. * @param engine Defines the BabylonJS Engine you wish to record.
  72394. * @param options Defines options that can be used to customize the capture.
  72395. */
  72396. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72397. /**
  72398. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72399. */
  72400. stopRecording(): void;
  72401. /**
  72402. * Starts recording the canvas for a max duration specified in parameters.
  72403. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72404. * If null no automatic download will start and you can rely on the promise to get the data back.
  72405. * @param maxDuration Defines the maximum recording time in seconds.
  72406. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72407. * @return A promise callback at the end of the recording with the video data in Blob.
  72408. */
  72409. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72410. /**
  72411. * Releases internal resources used during the recording.
  72412. */
  72413. dispose(): void;
  72414. private _handleDataAvailable;
  72415. private _handleError;
  72416. private _handleStop;
  72417. }
  72418. }
  72419. declare module BABYLON {
  72420. /**
  72421. * Class containing a set of static utilities functions for screenshots
  72422. */
  72423. export class ScreenshotTools {
  72424. /**
  72425. * Captures a screenshot of the current rendering
  72426. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72427. * @param engine defines the rendering engine
  72428. * @param camera defines the source camera
  72429. * @param size This parameter can be set to a single number or to an object with the
  72430. * following (optional) properties: precision, width, height. If a single number is passed,
  72431. * it will be used for both width and height. If an object is passed, the screenshot size
  72432. * will be derived from the parameters. The precision property is a multiplier allowing
  72433. * rendering at a higher or lower resolution
  72434. * @param successCallback defines the callback receives a single parameter which contains the
  72435. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72436. * src parameter of an <img> to display it
  72437. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72438. * Check your browser for supported MIME types
  72439. */
  72440. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72441. /**
  72442. * Captures a screenshot of the current rendering
  72443. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72444. * @param engine defines the rendering engine
  72445. * @param camera defines the source camera
  72446. * @param size This parameter can be set to a single number or to an object with the
  72447. * following (optional) properties: precision, width, height. If a single number is passed,
  72448. * it will be used for both width and height. If an object is passed, the screenshot size
  72449. * will be derived from the parameters. The precision property is a multiplier allowing
  72450. * rendering at a higher or lower resolution
  72451. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72452. * Check your browser for supported MIME types
  72453. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72454. * to the src parameter of an <img> to display it
  72455. */
  72456. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72457. /**
  72458. * Generates an image screenshot from the specified camera.
  72459. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72460. * @param engine The engine to use for rendering
  72461. * @param camera The camera to use for rendering
  72462. * @param size This parameter can be set to a single number or to an object with the
  72463. * following (optional) properties: precision, width, height. If a single number is passed,
  72464. * it will be used for both width and height. If an object is passed, the screenshot size
  72465. * will be derived from the parameters. The precision property is a multiplier allowing
  72466. * rendering at a higher or lower resolution
  72467. * @param successCallback The callback receives a single parameter which contains the
  72468. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72469. * src parameter of an <img> to display it
  72470. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72471. * Check your browser for supported MIME types
  72472. * @param samples Texture samples (default: 1)
  72473. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72474. * @param fileName A name for for the downloaded file.
  72475. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72476. */
  72477. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72478. /**
  72479. * Generates an image screenshot from the specified camera.
  72480. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72481. * @param engine The engine to use for rendering
  72482. * @param camera The camera to use for rendering
  72483. * @param size This parameter can be set to a single number or to an object with the
  72484. * following (optional) properties: precision, width, height. If a single number is passed,
  72485. * it will be used for both width and height. If an object is passed, the screenshot size
  72486. * will be derived from the parameters. The precision property is a multiplier allowing
  72487. * rendering at a higher or lower resolution
  72488. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72489. * Check your browser for supported MIME types
  72490. * @param samples Texture samples (default: 1)
  72491. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72492. * @param fileName A name for for the downloaded file.
  72493. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72494. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72495. * to the src parameter of an <img> to display it
  72496. */
  72497. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72498. /**
  72499. * Gets height and width for screenshot size
  72500. * @private
  72501. */
  72502. private static _getScreenshotSize;
  72503. }
  72504. }
  72505. declare module BABYLON {
  72506. /**
  72507. * Interface for a data buffer
  72508. */
  72509. export interface IDataBuffer {
  72510. /**
  72511. * Reads bytes from the data buffer.
  72512. * @param byteOffset The byte offset to read
  72513. * @param byteLength The byte length to read
  72514. * @returns A promise that resolves when the bytes are read
  72515. */
  72516. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72517. /**
  72518. * The byte length of the buffer.
  72519. */
  72520. readonly byteLength: number;
  72521. }
  72522. /**
  72523. * Utility class for reading from a data buffer
  72524. */
  72525. export class DataReader {
  72526. /**
  72527. * The data buffer associated with this data reader.
  72528. */
  72529. readonly buffer: IDataBuffer;
  72530. /**
  72531. * The current byte offset from the beginning of the data buffer.
  72532. */
  72533. byteOffset: number;
  72534. private _dataView;
  72535. private _dataByteOffset;
  72536. /**
  72537. * Constructor
  72538. * @param buffer The buffer to read
  72539. */
  72540. constructor(buffer: IDataBuffer);
  72541. /**
  72542. * Loads the given byte length.
  72543. * @param byteLength The byte length to load
  72544. * @returns A promise that resolves when the load is complete
  72545. */
  72546. loadAsync(byteLength: number): Promise<void>;
  72547. /**
  72548. * Read a unsigned 32-bit integer from the currently loaded data range.
  72549. * @returns The 32-bit integer read
  72550. */
  72551. readUint32(): number;
  72552. /**
  72553. * Read a byte array from the currently loaded data range.
  72554. * @param byteLength The byte length to read
  72555. * @returns The byte array read
  72556. */
  72557. readUint8Array(byteLength: number): Uint8Array;
  72558. /**
  72559. * Read a string from the currently loaded data range.
  72560. * @param byteLength The byte length to read
  72561. * @returns The string read
  72562. */
  72563. readString(byteLength: number): string;
  72564. /**
  72565. * Skips the given byte length the currently loaded data range.
  72566. * @param byteLength The byte length to skip
  72567. */
  72568. skipBytes(byteLength: number): void;
  72569. }
  72570. }
  72571. declare module BABYLON {
  72572. /**
  72573. * Class for storing data to local storage if available or in-memory storage otherwise
  72574. */
  72575. export class DataStorage {
  72576. private static _Storage;
  72577. private static _GetStorage;
  72578. /**
  72579. * Reads a string from the data storage
  72580. * @param key The key to read
  72581. * @param defaultValue The value if the key doesn't exist
  72582. * @returns The string value
  72583. */
  72584. static ReadString(key: string, defaultValue: string): string;
  72585. /**
  72586. * Writes a string to the data storage
  72587. * @param key The key to write
  72588. * @param value The value to write
  72589. */
  72590. static WriteString(key: string, value: string): void;
  72591. /**
  72592. * Reads a boolean from the data storage
  72593. * @param key The key to read
  72594. * @param defaultValue The value if the key doesn't exist
  72595. * @returns The boolean value
  72596. */
  72597. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  72598. /**
  72599. * Writes a boolean to the data storage
  72600. * @param key The key to write
  72601. * @param value The value to write
  72602. */
  72603. static WriteBoolean(key: string, value: boolean): void;
  72604. /**
  72605. * Reads a number from the data storage
  72606. * @param key The key to read
  72607. * @param defaultValue The value if the key doesn't exist
  72608. * @returns The number value
  72609. */
  72610. static ReadNumber(key: string, defaultValue: number): number;
  72611. /**
  72612. * Writes a number to the data storage
  72613. * @param key The key to write
  72614. * @param value The value to write
  72615. */
  72616. static WriteNumber(key: string, value: number): void;
  72617. }
  72618. }
  72619. declare module BABYLON {
  72620. /**
  72621. * An interface for all Hit test features
  72622. */
  72623. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  72624. /**
  72625. * Triggered when new babylon (transformed) hit test results are available
  72626. */
  72627. onHitTestResultObservable: Observable<T[]>;
  72628. }
  72629. /**
  72630. * Options used for hit testing
  72631. */
  72632. export interface IWebXRLegacyHitTestOptions {
  72633. /**
  72634. * Only test when user interacted with the scene. Default - hit test every frame
  72635. */
  72636. testOnPointerDownOnly?: boolean;
  72637. /**
  72638. * The node to use to transform the local results to world coordinates
  72639. */
  72640. worldParentNode?: TransformNode;
  72641. }
  72642. /**
  72643. * Interface defining the babylon result of raycasting/hit-test
  72644. */
  72645. export interface IWebXRLegacyHitResult {
  72646. /**
  72647. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72648. */
  72649. transformationMatrix: Matrix;
  72650. /**
  72651. * The native hit test result
  72652. */
  72653. xrHitResult: XRHitResult | XRHitTestResult;
  72654. }
  72655. /**
  72656. * The currently-working hit-test module.
  72657. * Hit test (or Ray-casting) is used to interact with the real world.
  72658. * For further information read here - https://github.com/immersive-web/hit-test
  72659. */
  72660. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  72661. /**
  72662. * options to use when constructing this feature
  72663. */
  72664. readonly options: IWebXRLegacyHitTestOptions;
  72665. private _direction;
  72666. private _mat;
  72667. private _onSelectEnabled;
  72668. private _origin;
  72669. /**
  72670. * The module's name
  72671. */
  72672. static readonly Name: string;
  72673. /**
  72674. * The (Babylon) version of this module.
  72675. * This is an integer representing the implementation version.
  72676. * This number does not correspond to the WebXR specs version
  72677. */
  72678. static readonly Version: number;
  72679. /**
  72680. * Populated with the last native XR Hit Results
  72681. */
  72682. lastNativeXRHitResults: XRHitResult[];
  72683. /**
  72684. * Triggered when new babylon (transformed) hit test results are available
  72685. */
  72686. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  72687. /**
  72688. * Creates a new instance of the (legacy version) hit test feature
  72689. * @param _xrSessionManager an instance of WebXRSessionManager
  72690. * @param options options to use when constructing this feature
  72691. */
  72692. constructor(_xrSessionManager: WebXRSessionManager,
  72693. /**
  72694. * options to use when constructing this feature
  72695. */
  72696. options?: IWebXRLegacyHitTestOptions);
  72697. /**
  72698. * execute a hit test with an XR Ray
  72699. *
  72700. * @param xrSession a native xrSession that will execute this hit test
  72701. * @param xrRay the ray (position and direction) to use for ray-casting
  72702. * @param referenceSpace native XR reference space to use for the hit-test
  72703. * @param filter filter function that will filter the results
  72704. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72705. */
  72706. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72707. /**
  72708. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72709. * @param event the (select) event to use to select with
  72710. * @param referenceSpace the reference space to use for this hit test
  72711. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72712. */
  72713. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72714. /**
  72715. * attach this feature
  72716. * Will usually be called by the features manager
  72717. *
  72718. * @returns true if successful.
  72719. */
  72720. attach(): boolean;
  72721. /**
  72722. * detach this feature.
  72723. * Will usually be called by the features manager
  72724. *
  72725. * @returns true if successful.
  72726. */
  72727. detach(): boolean;
  72728. /**
  72729. * Dispose this feature and all of the resources attached
  72730. */
  72731. dispose(): void;
  72732. protected _onXRFrame(frame: XRFrame): void;
  72733. private _onHitTestResults;
  72734. private _onSelect;
  72735. }
  72736. }
  72737. declare module BABYLON {
  72738. /**
  72739. * Options used for hit testing (version 2)
  72740. */
  72741. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  72742. /**
  72743. * Do not create a permanent hit test. Will usually be used when only
  72744. * transient inputs are needed.
  72745. */
  72746. disablePermanentHitTest?: boolean;
  72747. /**
  72748. * Enable transient (for example touch-based) hit test inspections
  72749. */
  72750. enableTransientHitTest?: boolean;
  72751. /**
  72752. * Offset ray for the permanent hit test
  72753. */
  72754. offsetRay?: Vector3;
  72755. /**
  72756. * Offset ray for the transient hit test
  72757. */
  72758. transientOffsetRay?: Vector3;
  72759. /**
  72760. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  72761. */
  72762. useReferenceSpace?: boolean;
  72763. }
  72764. /**
  72765. * Interface defining the babylon result of hit-test
  72766. */
  72767. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  72768. /**
  72769. * The input source that generated this hit test (if transient)
  72770. */
  72771. inputSource?: XRInputSource;
  72772. /**
  72773. * Is this a transient hit test
  72774. */
  72775. isTransient?: boolean;
  72776. /**
  72777. * Position of the hit test result
  72778. */
  72779. position: Vector3;
  72780. /**
  72781. * Rotation of the hit test result
  72782. */
  72783. rotationQuaternion: Quaternion;
  72784. /**
  72785. * The native hit test result
  72786. */
  72787. xrHitResult: XRHitTestResult;
  72788. }
  72789. /**
  72790. * The currently-working hit-test module.
  72791. * Hit test (or Ray-casting) is used to interact with the real world.
  72792. * For further information read here - https://github.com/immersive-web/hit-test
  72793. *
  72794. * Tested on chrome (mobile) 80.
  72795. */
  72796. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  72797. /**
  72798. * options to use when constructing this feature
  72799. */
  72800. readonly options: IWebXRHitTestOptions;
  72801. private _tmpMat;
  72802. private _tmpPos;
  72803. private _tmpQuat;
  72804. private _transientXrHitTestSource;
  72805. private _xrHitTestSource;
  72806. private initHitTestSource;
  72807. /**
  72808. * The module's name
  72809. */
  72810. static readonly Name: string;
  72811. /**
  72812. * The (Babylon) version of this module.
  72813. * This is an integer representing the implementation version.
  72814. * This number does not correspond to the WebXR specs version
  72815. */
  72816. static readonly Version: number;
  72817. /**
  72818. * When set to true, each hit test will have its own position/rotation objects
  72819. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  72820. * the developers will clone them or copy them as they see fit.
  72821. */
  72822. autoCloneTransformation: boolean;
  72823. /**
  72824. * Triggered when new babylon (transformed) hit test results are available
  72825. */
  72826. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72827. /**
  72828. * Use this to temporarily pause hit test checks.
  72829. */
  72830. paused: boolean;
  72831. /**
  72832. * Creates a new instance of the hit test feature
  72833. * @param _xrSessionManager an instance of WebXRSessionManager
  72834. * @param options options to use when constructing this feature
  72835. */
  72836. constructor(_xrSessionManager: WebXRSessionManager,
  72837. /**
  72838. * options to use when constructing this feature
  72839. */
  72840. options?: IWebXRHitTestOptions);
  72841. /**
  72842. * attach this feature
  72843. * Will usually be called by the features manager
  72844. *
  72845. * @returns true if successful.
  72846. */
  72847. attach(): boolean;
  72848. /**
  72849. * detach this feature.
  72850. * Will usually be called by the features manager
  72851. *
  72852. * @returns true if successful.
  72853. */
  72854. detach(): boolean;
  72855. /**
  72856. * Dispose this feature and all of the resources attached
  72857. */
  72858. dispose(): void;
  72859. protected _onXRFrame(frame: XRFrame): void;
  72860. private _processWebXRHitTestResult;
  72861. }
  72862. }
  72863. declare module BABYLON {
  72864. /**
  72865. * Configuration options of the anchor system
  72866. */
  72867. export interface IWebXRAnchorSystemOptions {
  72868. /**
  72869. * a node that will be used to convert local to world coordinates
  72870. */
  72871. worldParentNode?: TransformNode;
  72872. /**
  72873. * If set to true a reference of the created anchors will be kept until the next session starts
  72874. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  72875. */
  72876. doNotRemoveAnchorsOnSessionEnded?: boolean;
  72877. }
  72878. /**
  72879. * A babylon container for an XR Anchor
  72880. */
  72881. export interface IWebXRAnchor {
  72882. /**
  72883. * A babylon-assigned ID for this anchor
  72884. */
  72885. id: number;
  72886. /**
  72887. * Transformation matrix to apply to an object attached to this anchor
  72888. */
  72889. transformationMatrix: Matrix;
  72890. /**
  72891. * The native anchor object
  72892. */
  72893. xrAnchor: XRAnchor;
  72894. /**
  72895. * if defined, this object will be constantly updated by the anchor's position and rotation
  72896. */
  72897. attachedNode?: TransformNode;
  72898. }
  72899. /**
  72900. * An implementation of the anchor system for WebXR.
  72901. * For further information see https://github.com/immersive-web/anchors/
  72902. */
  72903. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72904. private _options;
  72905. private _lastFrameDetected;
  72906. private _trackedAnchors;
  72907. private _referenceSpaceForFrameAnchors;
  72908. private _futureAnchors;
  72909. /**
  72910. * The module's name
  72911. */
  72912. static readonly Name: string;
  72913. /**
  72914. * The (Babylon) version of this module.
  72915. * This is an integer representing the implementation version.
  72916. * This number does not correspond to the WebXR specs version
  72917. */
  72918. static readonly Version: number;
  72919. /**
  72920. * Observers registered here will be executed when a new anchor was added to the session
  72921. */
  72922. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72923. /**
  72924. * Observers registered here will be executed when an anchor was removed from the session
  72925. */
  72926. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72927. /**
  72928. * Observers registered here will be executed when an existing anchor updates
  72929. * This can execute N times every frame
  72930. */
  72931. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72932. /**
  72933. * Set the reference space to use for anchor creation, when not using a hit test.
  72934. * Will default to the session's reference space if not defined
  72935. */
  72936. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  72937. /**
  72938. * constructs a new anchor system
  72939. * @param _xrSessionManager an instance of WebXRSessionManager
  72940. * @param _options configuration object for this feature
  72941. */
  72942. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72943. private _tmpVector;
  72944. private _tmpQuaternion;
  72945. private _populateTmpTransformation;
  72946. /**
  72947. * Create a new anchor point using a hit test result at a specific point in the scene
  72948. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72949. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72950. *
  72951. * @param hitTestResult The hit test result to use for this anchor creation
  72952. * @param position an optional position offset for this anchor
  72953. * @param rotationQuaternion an optional rotation offset for this anchor
  72954. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72955. */
  72956. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  72957. /**
  72958. * Add a new anchor at a specific position and rotation
  72959. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  72960. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  72961. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  72962. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  72963. *
  72964. * @param position the position in which to add an anchor
  72965. * @param rotationQuaternion an optional rotation for the anchor transformation
  72966. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  72967. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  72968. */
  72969. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  72970. /**
  72971. * detach this feature.
  72972. * Will usually be called by the features manager
  72973. *
  72974. * @returns true if successful.
  72975. */
  72976. detach(): boolean;
  72977. /**
  72978. * Dispose this feature and all of the resources attached
  72979. */
  72980. dispose(): void;
  72981. protected _onXRFrame(frame: XRFrame): void;
  72982. /**
  72983. * avoiding using Array.find for global support.
  72984. * @param xrAnchor the plane to find in the array
  72985. */
  72986. private _findIndexInAnchorArray;
  72987. private _updateAnchorWithXRFrame;
  72988. private _createAnchorAtTransformation;
  72989. }
  72990. }
  72991. declare module BABYLON {
  72992. /**
  72993. * Options used in the plane detector module
  72994. */
  72995. export interface IWebXRPlaneDetectorOptions {
  72996. /**
  72997. * The node to use to transform the local results to world coordinates
  72998. */
  72999. worldParentNode?: TransformNode;
  73000. /**
  73001. * If set to true a reference of the created planes will be kept until the next session starts
  73002. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73003. */
  73004. doNotRemovePlanesOnSessionEnded?: boolean;
  73005. }
  73006. /**
  73007. * A babylon interface for a WebXR plane.
  73008. * A Plane is actually a polygon, built from N points in space
  73009. *
  73010. * Supported in chrome 79, not supported in canary 81 ATM
  73011. */
  73012. export interface IWebXRPlane {
  73013. /**
  73014. * a babylon-assigned ID for this polygon
  73015. */
  73016. id: number;
  73017. /**
  73018. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73019. */
  73020. polygonDefinition: Array<Vector3>;
  73021. /**
  73022. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73023. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73024. */
  73025. transformationMatrix: Matrix;
  73026. /**
  73027. * the native xr-plane object
  73028. */
  73029. xrPlane: XRPlane;
  73030. }
  73031. /**
  73032. * The plane detector is used to detect planes in the real world when in AR
  73033. * For more information see https://github.com/immersive-web/real-world-geometry/
  73034. */
  73035. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73036. private _options;
  73037. private _detectedPlanes;
  73038. private _enabled;
  73039. private _lastFrameDetected;
  73040. /**
  73041. * The module's name
  73042. */
  73043. static readonly Name: string;
  73044. /**
  73045. * The (Babylon) version of this module.
  73046. * This is an integer representing the implementation version.
  73047. * This number does not correspond to the WebXR specs version
  73048. */
  73049. static readonly Version: number;
  73050. /**
  73051. * Observers registered here will be executed when a new plane was added to the session
  73052. */
  73053. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73054. /**
  73055. * Observers registered here will be executed when a plane is no longer detected in the session
  73056. */
  73057. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73058. /**
  73059. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73060. * This can execute N times every frame
  73061. */
  73062. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73063. /**
  73064. * construct a new Plane Detector
  73065. * @param _xrSessionManager an instance of xr Session manager
  73066. * @param _options configuration to use when constructing this feature
  73067. */
  73068. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73069. /**
  73070. * detach this feature.
  73071. * Will usually be called by the features manager
  73072. *
  73073. * @returns true if successful.
  73074. */
  73075. detach(): boolean;
  73076. /**
  73077. * Dispose this feature and all of the resources attached
  73078. */
  73079. dispose(): void;
  73080. protected _onXRFrame(frame: XRFrame): void;
  73081. private _init;
  73082. private _updatePlaneWithXRPlane;
  73083. /**
  73084. * avoiding using Array.find for global support.
  73085. * @param xrPlane the plane to find in the array
  73086. */
  73087. private findIndexInPlaneArray;
  73088. }
  73089. }
  73090. declare module BABYLON {
  73091. /**
  73092. * Options interface for the background remover plugin
  73093. */
  73094. export interface IWebXRBackgroundRemoverOptions {
  73095. /**
  73096. * Further background meshes to disable when entering AR
  73097. */
  73098. backgroundMeshes?: AbstractMesh[];
  73099. /**
  73100. * flags to configure the removal of the environment helper.
  73101. * If not set, the entire background will be removed. If set, flags should be set as well.
  73102. */
  73103. environmentHelperRemovalFlags?: {
  73104. /**
  73105. * Should the skybox be removed (default false)
  73106. */
  73107. skyBox?: boolean;
  73108. /**
  73109. * Should the ground be removed (default false)
  73110. */
  73111. ground?: boolean;
  73112. };
  73113. /**
  73114. * don't disable the environment helper
  73115. */
  73116. ignoreEnvironmentHelper?: boolean;
  73117. }
  73118. /**
  73119. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73120. */
  73121. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73122. /**
  73123. * read-only options to be used in this module
  73124. */
  73125. readonly options: IWebXRBackgroundRemoverOptions;
  73126. /**
  73127. * The module's name
  73128. */
  73129. static readonly Name: string;
  73130. /**
  73131. * The (Babylon) version of this module.
  73132. * This is an integer representing the implementation version.
  73133. * This number does not correspond to the WebXR specs version
  73134. */
  73135. static readonly Version: number;
  73136. /**
  73137. * registered observers will be triggered when the background state changes
  73138. */
  73139. onBackgroundStateChangedObservable: Observable<boolean>;
  73140. /**
  73141. * constructs a new background remover module
  73142. * @param _xrSessionManager the session manager for this module
  73143. * @param options read-only options to be used in this module
  73144. */
  73145. constructor(_xrSessionManager: WebXRSessionManager,
  73146. /**
  73147. * read-only options to be used in this module
  73148. */
  73149. options?: IWebXRBackgroundRemoverOptions);
  73150. /**
  73151. * attach this feature
  73152. * Will usually be called by the features manager
  73153. *
  73154. * @returns true if successful.
  73155. */
  73156. attach(): boolean;
  73157. /**
  73158. * detach this feature.
  73159. * Will usually be called by the features manager
  73160. *
  73161. * @returns true if successful.
  73162. */
  73163. detach(): boolean;
  73164. /**
  73165. * Dispose this feature and all of the resources attached
  73166. */
  73167. dispose(): void;
  73168. protected _onXRFrame(_xrFrame: XRFrame): void;
  73169. private _setBackgroundState;
  73170. }
  73171. }
  73172. declare module BABYLON {
  73173. /**
  73174. * Options for the controller physics feature
  73175. */
  73176. export class IWebXRControllerPhysicsOptions {
  73177. /**
  73178. * Should the headset get its own impostor
  73179. */
  73180. enableHeadsetImpostor?: boolean;
  73181. /**
  73182. * Optional parameters for the headset impostor
  73183. */
  73184. headsetImpostorParams?: {
  73185. /**
  73186. * The type of impostor to create. Default is sphere
  73187. */
  73188. impostorType: number;
  73189. /**
  73190. * the size of the impostor. Defaults to 10cm
  73191. */
  73192. impostorSize?: number | {
  73193. width: number;
  73194. height: number;
  73195. depth: number;
  73196. };
  73197. /**
  73198. * Friction definitions
  73199. */
  73200. friction?: number;
  73201. /**
  73202. * Restitution
  73203. */
  73204. restitution?: number;
  73205. };
  73206. /**
  73207. * The physics properties of the future impostors
  73208. */
  73209. physicsProperties?: {
  73210. /**
  73211. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73212. * Note that this requires a physics engine that supports mesh impostors!
  73213. */
  73214. useControllerMesh?: boolean;
  73215. /**
  73216. * The type of impostor to create. Default is sphere
  73217. */
  73218. impostorType?: number;
  73219. /**
  73220. * the size of the impostor. Defaults to 10cm
  73221. */
  73222. impostorSize?: number | {
  73223. width: number;
  73224. height: number;
  73225. depth: number;
  73226. };
  73227. /**
  73228. * Friction definitions
  73229. */
  73230. friction?: number;
  73231. /**
  73232. * Restitution
  73233. */
  73234. restitution?: number;
  73235. };
  73236. /**
  73237. * the xr input to use with this pointer selection
  73238. */
  73239. xrInput: WebXRInput;
  73240. }
  73241. /**
  73242. * Add physics impostor to your webxr controllers,
  73243. * including naive calculation of their linear and angular velocity
  73244. */
  73245. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73246. private readonly _options;
  73247. private _attachController;
  73248. private _controllers;
  73249. private _debugMode;
  73250. private _delta;
  73251. private _headsetImpostor?;
  73252. private _headsetMesh?;
  73253. private _lastTimestamp;
  73254. private _tmpQuaternion;
  73255. private _tmpVector;
  73256. /**
  73257. * The module's name
  73258. */
  73259. static readonly Name: string;
  73260. /**
  73261. * The (Babylon) version of this module.
  73262. * This is an integer representing the implementation version.
  73263. * This number does not correspond to the webxr specs version
  73264. */
  73265. static readonly Version: number;
  73266. /**
  73267. * Construct a new Controller Physics Feature
  73268. * @param _xrSessionManager the corresponding xr session manager
  73269. * @param _options options to create this feature with
  73270. */
  73271. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73272. /**
  73273. * @hidden
  73274. * enable debugging - will show console outputs and the impostor mesh
  73275. */
  73276. _enablePhysicsDebug(): void;
  73277. /**
  73278. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73279. * @param xrController the controller to add
  73280. */
  73281. addController(xrController: WebXRInputSource): void;
  73282. /**
  73283. * attach this feature
  73284. * Will usually be called by the features manager
  73285. *
  73286. * @returns true if successful.
  73287. */
  73288. attach(): boolean;
  73289. /**
  73290. * detach this feature.
  73291. * Will usually be called by the features manager
  73292. *
  73293. * @returns true if successful.
  73294. */
  73295. detach(): boolean;
  73296. /**
  73297. * Get the headset impostor, if enabled
  73298. * @returns the impostor
  73299. */
  73300. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73301. /**
  73302. * Get the physics impostor of a specific controller.
  73303. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73304. * @param controller the controller or the controller id of which to get the impostor
  73305. * @returns the impostor or null
  73306. */
  73307. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73308. /**
  73309. * Update the physics properties provided in the constructor
  73310. * @param newProperties the new properties object
  73311. */
  73312. setPhysicsProperties(newProperties: {
  73313. impostorType?: number;
  73314. impostorSize?: number | {
  73315. width: number;
  73316. height: number;
  73317. depth: number;
  73318. };
  73319. friction?: number;
  73320. restitution?: number;
  73321. }): void;
  73322. protected _onXRFrame(_xrFrame: any): void;
  73323. private _detachController;
  73324. }
  73325. }
  73326. declare module BABYLON {
  73327. /**
  73328. * The motion controller class for all microsoft mixed reality controllers
  73329. */
  73330. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73331. protected readonly _mapping: {
  73332. defaultButton: {
  73333. valueNodeName: string;
  73334. unpressedNodeName: string;
  73335. pressedNodeName: string;
  73336. };
  73337. defaultAxis: {
  73338. valueNodeName: string;
  73339. minNodeName: string;
  73340. maxNodeName: string;
  73341. };
  73342. buttons: {
  73343. "xr-standard-trigger": {
  73344. rootNodeName: string;
  73345. componentProperty: string;
  73346. states: string[];
  73347. };
  73348. "xr-standard-squeeze": {
  73349. rootNodeName: string;
  73350. componentProperty: string;
  73351. states: string[];
  73352. };
  73353. "xr-standard-touchpad": {
  73354. rootNodeName: string;
  73355. labelAnchorNodeName: string;
  73356. touchPointNodeName: string;
  73357. };
  73358. "xr-standard-thumbstick": {
  73359. rootNodeName: string;
  73360. componentProperty: string;
  73361. states: string[];
  73362. };
  73363. };
  73364. axes: {
  73365. "xr-standard-touchpad": {
  73366. "x-axis": {
  73367. rootNodeName: string;
  73368. };
  73369. "y-axis": {
  73370. rootNodeName: string;
  73371. };
  73372. };
  73373. "xr-standard-thumbstick": {
  73374. "x-axis": {
  73375. rootNodeName: string;
  73376. };
  73377. "y-axis": {
  73378. rootNodeName: string;
  73379. };
  73380. };
  73381. };
  73382. };
  73383. /**
  73384. * The base url used to load the left and right controller models
  73385. */
  73386. static MODEL_BASE_URL: string;
  73387. /**
  73388. * The name of the left controller model file
  73389. */
  73390. static MODEL_LEFT_FILENAME: string;
  73391. /**
  73392. * The name of the right controller model file
  73393. */
  73394. static MODEL_RIGHT_FILENAME: string;
  73395. profileId: string;
  73396. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73397. protected _getFilenameAndPath(): {
  73398. filename: string;
  73399. path: string;
  73400. };
  73401. protected _getModelLoadingConstraints(): boolean;
  73402. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73403. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73404. protected _updateModel(): void;
  73405. }
  73406. }
  73407. declare module BABYLON {
  73408. /**
  73409. * The motion controller class for oculus touch (quest, rift).
  73410. * This class supports legacy mapping as well the standard xr mapping
  73411. */
  73412. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73413. private _forceLegacyControllers;
  73414. private _modelRootNode;
  73415. /**
  73416. * The base url used to load the left and right controller models
  73417. */
  73418. static MODEL_BASE_URL: string;
  73419. /**
  73420. * The name of the left controller model file
  73421. */
  73422. static MODEL_LEFT_FILENAME: string;
  73423. /**
  73424. * The name of the right controller model file
  73425. */
  73426. static MODEL_RIGHT_FILENAME: string;
  73427. /**
  73428. * Base Url for the Quest controller model.
  73429. */
  73430. static QUEST_MODEL_BASE_URL: string;
  73431. profileId: string;
  73432. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73433. protected _getFilenameAndPath(): {
  73434. filename: string;
  73435. path: string;
  73436. };
  73437. protected _getModelLoadingConstraints(): boolean;
  73438. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73439. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73440. protected _updateModel(): void;
  73441. /**
  73442. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73443. * between the touch and touch 2.
  73444. */
  73445. private _isQuest;
  73446. }
  73447. }
  73448. declare module BABYLON {
  73449. /**
  73450. * The motion controller class for the standard HTC-Vive controllers
  73451. */
  73452. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73453. private _modelRootNode;
  73454. /**
  73455. * The base url used to load the left and right controller models
  73456. */
  73457. static MODEL_BASE_URL: string;
  73458. /**
  73459. * File name for the controller model.
  73460. */
  73461. static MODEL_FILENAME: string;
  73462. profileId: string;
  73463. /**
  73464. * Create a new Vive motion controller object
  73465. * @param scene the scene to use to create this controller
  73466. * @param gamepadObject the corresponding gamepad object
  73467. * @param handedness the handedness of the controller
  73468. */
  73469. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73470. protected _getFilenameAndPath(): {
  73471. filename: string;
  73472. path: string;
  73473. };
  73474. protected _getModelLoadingConstraints(): boolean;
  73475. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73476. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73477. protected _updateModel(): void;
  73478. }
  73479. }
  73480. declare module BABYLON {
  73481. /**
  73482. * A cursor which tracks a point on a path
  73483. */
  73484. export class PathCursor {
  73485. private path;
  73486. /**
  73487. * Stores path cursor callbacks for when an onchange event is triggered
  73488. */
  73489. private _onchange;
  73490. /**
  73491. * The value of the path cursor
  73492. */
  73493. value: number;
  73494. /**
  73495. * The animation array of the path cursor
  73496. */
  73497. animations: Animation[];
  73498. /**
  73499. * Initializes the path cursor
  73500. * @param path The path to track
  73501. */
  73502. constructor(path: Path2);
  73503. /**
  73504. * Gets the cursor point on the path
  73505. * @returns A point on the path cursor at the cursor location
  73506. */
  73507. getPoint(): Vector3;
  73508. /**
  73509. * Moves the cursor ahead by the step amount
  73510. * @param step The amount to move the cursor forward
  73511. * @returns This path cursor
  73512. */
  73513. moveAhead(step?: number): PathCursor;
  73514. /**
  73515. * Moves the cursor behind by the step amount
  73516. * @param step The amount to move the cursor back
  73517. * @returns This path cursor
  73518. */
  73519. moveBack(step?: number): PathCursor;
  73520. /**
  73521. * Moves the cursor by the step amount
  73522. * If the step amount is greater than one, an exception is thrown
  73523. * @param step The amount to move the cursor
  73524. * @returns This path cursor
  73525. */
  73526. move(step: number): PathCursor;
  73527. /**
  73528. * Ensures that the value is limited between zero and one
  73529. * @returns This path cursor
  73530. */
  73531. private ensureLimits;
  73532. /**
  73533. * Runs onchange callbacks on change (used by the animation engine)
  73534. * @returns This path cursor
  73535. */
  73536. private raiseOnChange;
  73537. /**
  73538. * Executes a function on change
  73539. * @param f A path cursor onchange callback
  73540. * @returns This path cursor
  73541. */
  73542. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73543. }
  73544. }
  73545. declare module BABYLON {
  73546. /** @hidden */
  73547. export var blurPixelShader: {
  73548. name: string;
  73549. shader: string;
  73550. };
  73551. }
  73552. declare module BABYLON {
  73553. /** @hidden */
  73554. export var pointCloudVertexDeclaration: {
  73555. name: string;
  73556. shader: string;
  73557. };
  73558. }
  73559. // Mixins
  73560. interface Window {
  73561. mozIndexedDB: IDBFactory;
  73562. webkitIndexedDB: IDBFactory;
  73563. msIndexedDB: IDBFactory;
  73564. webkitURL: typeof URL;
  73565. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  73566. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  73567. WebGLRenderingContext: WebGLRenderingContext;
  73568. MSGesture: MSGesture;
  73569. CANNON: any;
  73570. AudioContext: AudioContext;
  73571. webkitAudioContext: AudioContext;
  73572. PointerEvent: any;
  73573. Math: Math;
  73574. Uint8Array: Uint8ArrayConstructor;
  73575. Float32Array: Float32ArrayConstructor;
  73576. mozURL: typeof URL;
  73577. msURL: typeof URL;
  73578. VRFrameData: any; // WebVR, from specs 1.1
  73579. DracoDecoderModule: any;
  73580. setImmediate(handler: (...args: any[]) => void): number;
  73581. }
  73582. interface HTMLCanvasElement {
  73583. requestPointerLock(): void;
  73584. msRequestPointerLock?(): void;
  73585. mozRequestPointerLock?(): void;
  73586. webkitRequestPointerLock?(): void;
  73587. /** Track wether a record is in progress */
  73588. isRecording: boolean;
  73589. /** Capture Stream method defined by some browsers */
  73590. captureStream(fps?: number): MediaStream;
  73591. }
  73592. interface CanvasRenderingContext2D {
  73593. msImageSmoothingEnabled: boolean;
  73594. }
  73595. interface MouseEvent {
  73596. mozMovementX: number;
  73597. mozMovementY: number;
  73598. webkitMovementX: number;
  73599. webkitMovementY: number;
  73600. msMovementX: number;
  73601. msMovementY: number;
  73602. }
  73603. interface Navigator {
  73604. mozGetVRDevices: (any: any) => any;
  73605. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73606. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73607. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  73608. webkitGetGamepads(): Gamepad[];
  73609. msGetGamepads(): Gamepad[];
  73610. webkitGamepads(): Gamepad[];
  73611. }
  73612. interface HTMLVideoElement {
  73613. mozSrcObject: any;
  73614. }
  73615. interface Math {
  73616. fround(x: number): number;
  73617. imul(a: number, b: number): number;
  73618. }
  73619. interface WebGLRenderingContext {
  73620. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  73621. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  73622. vertexAttribDivisor(index: number, divisor: number): void;
  73623. createVertexArray(): any;
  73624. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  73625. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  73626. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  73627. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  73628. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  73629. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  73630. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  73631. // Queries
  73632. createQuery(): WebGLQuery;
  73633. deleteQuery(query: WebGLQuery): void;
  73634. beginQuery(target: number, query: WebGLQuery): void;
  73635. endQuery(target: number): void;
  73636. getQueryParameter(query: WebGLQuery, pname: number): any;
  73637. getQuery(target: number, pname: number): any;
  73638. MAX_SAMPLES: number;
  73639. RGBA8: number;
  73640. READ_FRAMEBUFFER: number;
  73641. DRAW_FRAMEBUFFER: number;
  73642. UNIFORM_BUFFER: number;
  73643. HALF_FLOAT_OES: number;
  73644. RGBA16F: number;
  73645. RGBA32F: number;
  73646. R32F: number;
  73647. RG32F: number;
  73648. RGB32F: number;
  73649. R16F: number;
  73650. RG16F: number;
  73651. RGB16F: number;
  73652. RED: number;
  73653. RG: number;
  73654. R8: number;
  73655. RG8: number;
  73656. UNSIGNED_INT_24_8: number;
  73657. DEPTH24_STENCIL8: number;
  73658. MIN: number;
  73659. MAX: number;
  73660. /* Multiple Render Targets */
  73661. drawBuffers(buffers: number[]): void;
  73662. readBuffer(src: number): void;
  73663. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  73664. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  73665. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  73666. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  73667. // Occlusion Query
  73668. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  73669. ANY_SAMPLES_PASSED: number;
  73670. QUERY_RESULT_AVAILABLE: number;
  73671. QUERY_RESULT: number;
  73672. }
  73673. interface WebGLProgram {
  73674. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  73675. }
  73676. interface EXT_disjoint_timer_query {
  73677. QUERY_COUNTER_BITS_EXT: number;
  73678. TIME_ELAPSED_EXT: number;
  73679. TIMESTAMP_EXT: number;
  73680. GPU_DISJOINT_EXT: number;
  73681. QUERY_RESULT_EXT: number;
  73682. QUERY_RESULT_AVAILABLE_EXT: number;
  73683. queryCounterEXT(query: WebGLQuery, target: number): void;
  73684. createQueryEXT(): WebGLQuery;
  73685. beginQueryEXT(target: number, query: WebGLQuery): void;
  73686. endQueryEXT(target: number): void;
  73687. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  73688. deleteQueryEXT(query: WebGLQuery): void;
  73689. }
  73690. interface WebGLUniformLocation {
  73691. _currentState: any;
  73692. }
  73693. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  73694. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  73695. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  73696. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73697. interface WebGLRenderingContext {
  73698. readonly RASTERIZER_DISCARD: number;
  73699. readonly DEPTH_COMPONENT24: number;
  73700. readonly TEXTURE_3D: number;
  73701. readonly TEXTURE_2D_ARRAY: number;
  73702. readonly TEXTURE_COMPARE_FUNC: number;
  73703. readonly TEXTURE_COMPARE_MODE: number;
  73704. readonly COMPARE_REF_TO_TEXTURE: number;
  73705. readonly TEXTURE_WRAP_R: number;
  73706. readonly HALF_FLOAT: number;
  73707. readonly RGB8: number;
  73708. readonly RED_INTEGER: number;
  73709. readonly RG_INTEGER: number;
  73710. readonly RGB_INTEGER: number;
  73711. readonly RGBA_INTEGER: number;
  73712. readonly R8_SNORM: number;
  73713. readonly RG8_SNORM: number;
  73714. readonly RGB8_SNORM: number;
  73715. readonly RGBA8_SNORM: number;
  73716. readonly R8I: number;
  73717. readonly RG8I: number;
  73718. readonly RGB8I: number;
  73719. readonly RGBA8I: number;
  73720. readonly R8UI: number;
  73721. readonly RG8UI: number;
  73722. readonly RGB8UI: number;
  73723. readonly RGBA8UI: number;
  73724. readonly R16I: number;
  73725. readonly RG16I: number;
  73726. readonly RGB16I: number;
  73727. readonly RGBA16I: number;
  73728. readonly R16UI: number;
  73729. readonly RG16UI: number;
  73730. readonly RGB16UI: number;
  73731. readonly RGBA16UI: number;
  73732. readonly R32I: number;
  73733. readonly RG32I: number;
  73734. readonly RGB32I: number;
  73735. readonly RGBA32I: number;
  73736. readonly R32UI: number;
  73737. readonly RG32UI: number;
  73738. readonly RGB32UI: number;
  73739. readonly RGBA32UI: number;
  73740. readonly RGB10_A2UI: number;
  73741. readonly R11F_G11F_B10F: number;
  73742. readonly RGB9_E5: number;
  73743. readonly RGB10_A2: number;
  73744. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  73745. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  73746. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  73747. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73748. readonly DEPTH_COMPONENT32F: number;
  73749. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  73750. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  73751. 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;
  73752. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  73753. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  73754. readonly TRANSFORM_FEEDBACK: number;
  73755. readonly INTERLEAVED_ATTRIBS: number;
  73756. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  73757. createTransformFeedback(): WebGLTransformFeedback;
  73758. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  73759. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  73760. beginTransformFeedback(primitiveMode: number): void;
  73761. endTransformFeedback(): void;
  73762. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  73763. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73764. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73765. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  73766. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  73767. }
  73768. interface ImageBitmap {
  73769. readonly width: number;
  73770. readonly height: number;
  73771. close(): void;
  73772. }
  73773. interface WebGLQuery extends WebGLObject {
  73774. }
  73775. declare var WebGLQuery: {
  73776. prototype: WebGLQuery;
  73777. new(): WebGLQuery;
  73778. };
  73779. interface WebGLSampler extends WebGLObject {
  73780. }
  73781. declare var WebGLSampler: {
  73782. prototype: WebGLSampler;
  73783. new(): WebGLSampler;
  73784. };
  73785. interface WebGLSync extends WebGLObject {
  73786. }
  73787. declare var WebGLSync: {
  73788. prototype: WebGLSync;
  73789. new(): WebGLSync;
  73790. };
  73791. interface WebGLTransformFeedback extends WebGLObject {
  73792. }
  73793. declare var WebGLTransformFeedback: {
  73794. prototype: WebGLTransformFeedback;
  73795. new(): WebGLTransformFeedback;
  73796. };
  73797. interface WebGLVertexArrayObject extends WebGLObject {
  73798. }
  73799. declare var WebGLVertexArrayObject: {
  73800. prototype: WebGLVertexArrayObject;
  73801. new(): WebGLVertexArrayObject;
  73802. };
  73803. // Type definitions for WebVR API
  73804. // Project: https://w3c.github.io/webvr/
  73805. // Definitions by: six a <https://github.com/lostfictions>
  73806. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  73807. interface VRDisplay extends EventTarget {
  73808. /**
  73809. * Dictionary of capabilities describing the VRDisplay.
  73810. */
  73811. readonly capabilities: VRDisplayCapabilities;
  73812. /**
  73813. * z-depth defining the far plane of the eye view frustum
  73814. * enables mapping of values in the render target depth
  73815. * attachment to scene coordinates. Initially set to 10000.0.
  73816. */
  73817. depthFar: number;
  73818. /**
  73819. * z-depth defining the near plane of the eye view frustum
  73820. * enables mapping of values in the render target depth
  73821. * attachment to scene coordinates. Initially set to 0.01.
  73822. */
  73823. depthNear: number;
  73824. /**
  73825. * An identifier for this distinct VRDisplay. Used as an
  73826. * association point in the Gamepad API.
  73827. */
  73828. readonly displayId: number;
  73829. /**
  73830. * A display name, a user-readable name identifying it.
  73831. */
  73832. readonly displayName: string;
  73833. readonly isConnected: boolean;
  73834. readonly isPresenting: boolean;
  73835. /**
  73836. * If this VRDisplay supports room-scale experiences, the optional
  73837. * stage attribute contains details on the room-scale parameters.
  73838. */
  73839. readonly stageParameters: VRStageParameters | null;
  73840. /**
  73841. * Passing the value returned by `requestAnimationFrame` to
  73842. * `cancelAnimationFrame` will unregister the callback.
  73843. * @param handle Define the hanle of the request to cancel
  73844. */
  73845. cancelAnimationFrame(handle: number): void;
  73846. /**
  73847. * Stops presenting to the VRDisplay.
  73848. * @returns a promise to know when it stopped
  73849. */
  73850. exitPresent(): Promise<void>;
  73851. /**
  73852. * Return the current VREyeParameters for the given eye.
  73853. * @param whichEye Define the eye we want the parameter for
  73854. * @returns the eye parameters
  73855. */
  73856. getEyeParameters(whichEye: string): VREyeParameters;
  73857. /**
  73858. * Populates the passed VRFrameData with the information required to render
  73859. * the current frame.
  73860. * @param frameData Define the data structure to populate
  73861. * @returns true if ok otherwise false
  73862. */
  73863. getFrameData(frameData: VRFrameData): boolean;
  73864. /**
  73865. * Get the layers currently being presented.
  73866. * @returns the list of VR layers
  73867. */
  73868. getLayers(): VRLayer[];
  73869. /**
  73870. * Return a VRPose containing the future predicted pose of the VRDisplay
  73871. * when the current frame will be presented. The value returned will not
  73872. * change until JavaScript has returned control to the browser.
  73873. *
  73874. * The VRPose will contain the position, orientation, velocity,
  73875. * and acceleration of each of these properties.
  73876. * @returns the pose object
  73877. */
  73878. getPose(): VRPose;
  73879. /**
  73880. * Return the current instantaneous pose of the VRDisplay, with no
  73881. * prediction applied.
  73882. * @returns the current instantaneous pose
  73883. */
  73884. getImmediatePose(): VRPose;
  73885. /**
  73886. * The callback passed to `requestAnimationFrame` will be called
  73887. * any time a new frame should be rendered. When the VRDisplay is
  73888. * presenting the callback will be called at the native refresh
  73889. * rate of the HMD. When not presenting this function acts
  73890. * identically to how window.requestAnimationFrame acts. Content should
  73891. * make no assumptions of frame rate or vsync behavior as the HMD runs
  73892. * asynchronously from other displays and at differing refresh rates.
  73893. * @param callback Define the eaction to run next frame
  73894. * @returns the request handle it
  73895. */
  73896. requestAnimationFrame(callback: FrameRequestCallback): number;
  73897. /**
  73898. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  73899. * Repeat calls while already presenting will update the VRLayers being displayed.
  73900. * @param layers Define the list of layer to present
  73901. * @returns a promise to know when the request has been fulfilled
  73902. */
  73903. requestPresent(layers: VRLayer[]): Promise<void>;
  73904. /**
  73905. * Reset the pose for this display, treating its current position and
  73906. * orientation as the "origin/zero" values. VRPose.position,
  73907. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  73908. * updated when calling resetPose(). This should be called in only
  73909. * sitting-space experiences.
  73910. */
  73911. resetPose(): void;
  73912. /**
  73913. * The VRLayer provided to the VRDisplay will be captured and presented
  73914. * in the HMD. Calling this function has the same effect on the source
  73915. * canvas as any other operation that uses its source image, and canvases
  73916. * created without preserveDrawingBuffer set to true will be cleared.
  73917. * @param pose Define the pose to submit
  73918. */
  73919. submitFrame(pose?: VRPose): void;
  73920. }
  73921. declare var VRDisplay: {
  73922. prototype: VRDisplay;
  73923. new(): VRDisplay;
  73924. };
  73925. interface VRLayer {
  73926. leftBounds?: number[] | Float32Array | null;
  73927. rightBounds?: number[] | Float32Array | null;
  73928. source?: HTMLCanvasElement | null;
  73929. }
  73930. interface VRDisplayCapabilities {
  73931. readonly canPresent: boolean;
  73932. readonly hasExternalDisplay: boolean;
  73933. readonly hasOrientation: boolean;
  73934. readonly hasPosition: boolean;
  73935. readonly maxLayers: number;
  73936. }
  73937. interface VREyeParameters {
  73938. /** @deprecated */
  73939. readonly fieldOfView: VRFieldOfView;
  73940. readonly offset: Float32Array;
  73941. readonly renderHeight: number;
  73942. readonly renderWidth: number;
  73943. }
  73944. interface VRFieldOfView {
  73945. readonly downDegrees: number;
  73946. readonly leftDegrees: number;
  73947. readonly rightDegrees: number;
  73948. readonly upDegrees: number;
  73949. }
  73950. interface VRFrameData {
  73951. readonly leftProjectionMatrix: Float32Array;
  73952. readonly leftViewMatrix: Float32Array;
  73953. readonly pose: VRPose;
  73954. readonly rightProjectionMatrix: Float32Array;
  73955. readonly rightViewMatrix: Float32Array;
  73956. readonly timestamp: number;
  73957. }
  73958. interface VRPose {
  73959. readonly angularAcceleration: Float32Array | null;
  73960. readonly angularVelocity: Float32Array | null;
  73961. readonly linearAcceleration: Float32Array | null;
  73962. readonly linearVelocity: Float32Array | null;
  73963. readonly orientation: Float32Array | null;
  73964. readonly position: Float32Array | null;
  73965. readonly timestamp: number;
  73966. }
  73967. interface VRStageParameters {
  73968. sittingToStandingTransform?: Float32Array;
  73969. sizeX?: number;
  73970. sizeY?: number;
  73971. }
  73972. interface Navigator {
  73973. getVRDisplays(): Promise<VRDisplay[]>;
  73974. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  73975. }
  73976. interface Window {
  73977. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  73978. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  73979. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  73980. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73981. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  73982. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  73983. }
  73984. interface Gamepad {
  73985. readonly displayId: number;
  73986. }
  73987. type XRSessionMode =
  73988. | "inline"
  73989. | "immersive-vr"
  73990. | "immersive-ar";
  73991. type XRReferenceSpaceType =
  73992. | "viewer"
  73993. | "local"
  73994. | "local-floor"
  73995. | "bounded-floor"
  73996. | "unbounded";
  73997. type XREnvironmentBlendMode =
  73998. | "opaque"
  73999. | "additive"
  74000. | "alpha-blend";
  74001. type XRVisibilityState =
  74002. | "visible"
  74003. | "visible-blurred"
  74004. | "hidden";
  74005. type XRHandedness =
  74006. | "none"
  74007. | "left"
  74008. | "right";
  74009. type XRTargetRayMode =
  74010. | "gaze"
  74011. | "tracked-pointer"
  74012. | "screen";
  74013. type XREye =
  74014. | "none"
  74015. | "left"
  74016. | "right";
  74017. type XREventType =
  74018. | "devicechange"
  74019. | "visibilitychange"
  74020. | "end"
  74021. | "inputsourceschange"
  74022. | "select"
  74023. | "selectstart"
  74024. | "selectend"
  74025. | "squeeze"
  74026. | "squeezestart"
  74027. | "squeezeend"
  74028. | "reset";
  74029. interface XRSpace extends EventTarget {
  74030. }
  74031. interface XRRenderState {
  74032. depthNear?: number;
  74033. depthFar?: number;
  74034. inlineVerticalFieldOfView?: number;
  74035. baseLayer?: XRWebGLLayer;
  74036. }
  74037. interface XRInputSource {
  74038. handedness: XRHandedness;
  74039. targetRayMode: XRTargetRayMode;
  74040. targetRaySpace: XRSpace;
  74041. gripSpace: XRSpace | undefined;
  74042. gamepad: Gamepad | undefined;
  74043. profiles: Array<string>;
  74044. }
  74045. interface XRSessionInit {
  74046. optionalFeatures?: string[];
  74047. requiredFeatures?: string[];
  74048. }
  74049. interface XRSession {
  74050. addEventListener: Function;
  74051. removeEventListener: Function;
  74052. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74053. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74054. requestAnimationFrame: Function;
  74055. end(): Promise<void>;
  74056. renderState: XRRenderState;
  74057. inputSources: Array<XRInputSource>;
  74058. // hit test
  74059. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74060. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74061. // legacy AR hit test
  74062. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74063. // legacy plane detection
  74064. updateWorldTrackingState(options: {
  74065. planeDetectionState?: { enabled: boolean; }
  74066. }): void;
  74067. }
  74068. interface XRReferenceSpace extends XRSpace {
  74069. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74070. onreset: any;
  74071. }
  74072. type XRPlaneSet = Set<XRPlane>;
  74073. type XRAnchorSet = Set<XRAnchor>;
  74074. interface XRFrame {
  74075. session: XRSession;
  74076. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74077. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74078. // AR
  74079. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74080. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74081. // Anchors
  74082. trackedAnchors?: XRAnchorSet;
  74083. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74084. // Planes
  74085. worldInformation: {
  74086. detectedPlanes?: XRPlaneSet;
  74087. };
  74088. }
  74089. interface XRViewerPose extends XRPose {
  74090. views: Array<XRView>;
  74091. }
  74092. interface XRPose {
  74093. transform: XRRigidTransform;
  74094. emulatedPosition: boolean;
  74095. }
  74096. interface XRWebGLLayerOptions {
  74097. antialias?: boolean;
  74098. depth?: boolean;
  74099. stencil?: boolean;
  74100. alpha?: boolean;
  74101. multiview?: boolean;
  74102. framebufferScaleFactor?: number;
  74103. }
  74104. declare var XRWebGLLayer: {
  74105. prototype: XRWebGLLayer;
  74106. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74107. };
  74108. interface XRWebGLLayer {
  74109. framebuffer: WebGLFramebuffer;
  74110. framebufferWidth: number;
  74111. framebufferHeight: number;
  74112. getViewport: Function;
  74113. }
  74114. declare class XRRigidTransform {
  74115. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74116. position: DOMPointReadOnly;
  74117. orientation: DOMPointReadOnly;
  74118. matrix: Float32Array;
  74119. inverse: XRRigidTransform;
  74120. }
  74121. interface XRView {
  74122. eye: XREye;
  74123. projectionMatrix: Float32Array;
  74124. transform: XRRigidTransform;
  74125. }
  74126. interface XRInputSourceChangeEvent {
  74127. session: XRSession;
  74128. removed: Array<XRInputSource>;
  74129. added: Array<XRInputSource>;
  74130. }
  74131. interface XRInputSourceEvent extends Event {
  74132. readonly frame: XRFrame;
  74133. readonly inputSource: XRInputSource;
  74134. }
  74135. // Experimental(er) features
  74136. declare class XRRay {
  74137. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74138. origin: DOMPointReadOnly;
  74139. direction: DOMPointReadOnly;
  74140. matrix: Float32Array;
  74141. }
  74142. declare enum XRHitTestTrackableType {
  74143. "point",
  74144. "plane"
  74145. }
  74146. interface XRHitResult {
  74147. hitMatrix: Float32Array;
  74148. }
  74149. interface XRTransientInputHitTestResult {
  74150. readonly inputSource: XRInputSource;
  74151. readonly results: Array<XRHitTestResult>;
  74152. }
  74153. interface XRHitTestResult {
  74154. getPose(baseSpace: XRSpace): XRPose | undefined;
  74155. // When anchor system is enabled
  74156. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74157. }
  74158. interface XRHitTestSource {
  74159. cancel(): void;
  74160. }
  74161. interface XRTransientInputHitTestSource {
  74162. cancel(): void;
  74163. }
  74164. interface XRHitTestOptionsInit {
  74165. space: XRSpace;
  74166. entityTypes?: Array<XRHitTestTrackableType>;
  74167. offsetRay?: XRRay;
  74168. }
  74169. interface XRTransientInputHitTestOptionsInit {
  74170. profile: string;
  74171. entityTypes?: Array<XRHitTestTrackableType>;
  74172. offsetRay?: XRRay;
  74173. }
  74174. interface XRAnchor {
  74175. anchorSpace: XRSpace;
  74176. delete(): void;
  74177. }
  74178. interface XRPlane {
  74179. orientation: "Horizontal" | "Vertical";
  74180. planeSpace: XRSpace;
  74181. polygon: Array<DOMPointReadOnly>;
  74182. lastChangedTime: number;
  74183. }
  74184. /**
  74185. * @ignore
  74186. */
  74187. declare module BABYLON.GLTF2.Exporter {
  74188. }
  74189. /**
  74190. * @ignore
  74191. */
  74192. declare module BABYLON.GLTF1 {
  74193. }
  74194. declare module BABYLON.GUI {
  74195. /**
  74196. * Class used to specific a value and its associated unit
  74197. */
  74198. export class ValueAndUnit {
  74199. /** defines the unit to store */
  74200. unit: number;
  74201. /** defines a boolean indicating if the value can be negative */
  74202. negativeValueAllowed: boolean;
  74203. private _value;
  74204. private _originalUnit;
  74205. /**
  74206. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74207. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74208. */
  74209. ignoreAdaptiveScaling: boolean;
  74210. /**
  74211. * Creates a new ValueAndUnit
  74212. * @param value defines the value to store
  74213. * @param unit defines the unit to store
  74214. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74215. */
  74216. constructor(value: number,
  74217. /** defines the unit to store */
  74218. unit?: number,
  74219. /** defines a boolean indicating if the value can be negative */
  74220. negativeValueAllowed?: boolean);
  74221. /** Gets a boolean indicating if the value is a percentage */
  74222. get isPercentage(): boolean;
  74223. /** Gets a boolean indicating if the value is store as pixel */
  74224. get isPixel(): boolean;
  74225. /** Gets direct internal value */
  74226. get internalValue(): number;
  74227. /**
  74228. * Gets value as pixel
  74229. * @param host defines the root host
  74230. * @param refValue defines the reference value for percentages
  74231. * @returns the value as pixel
  74232. */
  74233. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74234. /**
  74235. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74236. * @param value defines the value to store
  74237. * @param unit defines the unit to store
  74238. * @returns the current ValueAndUnit
  74239. */
  74240. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74241. /**
  74242. * Gets the value accordingly to its unit
  74243. * @param host defines the root host
  74244. * @returns the value
  74245. */
  74246. getValue(host: AdvancedDynamicTexture): number;
  74247. /**
  74248. * Gets a string representation of the value
  74249. * @param host defines the root host
  74250. * @param decimals defines an optional number of decimals to display
  74251. * @returns a string
  74252. */
  74253. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74254. /**
  74255. * Store a value parsed from a string
  74256. * @param source defines the source string
  74257. * @returns true if the value was successfully parsed
  74258. */
  74259. fromString(source: string | number): boolean;
  74260. private static _Regex;
  74261. private static _UNITMODE_PERCENTAGE;
  74262. private static _UNITMODE_PIXEL;
  74263. /** UNITMODE_PERCENTAGE */
  74264. static get UNITMODE_PERCENTAGE(): number;
  74265. /** UNITMODE_PIXEL */
  74266. static get UNITMODE_PIXEL(): number;
  74267. }
  74268. }
  74269. declare module BABYLON.GUI {
  74270. /**
  74271. * Define a style used by control to automatically setup properties based on a template.
  74272. * Only support font related properties so far
  74273. */
  74274. export class Style implements BABYLON.IDisposable {
  74275. private _fontFamily;
  74276. private _fontStyle;
  74277. private _fontWeight;
  74278. /** @hidden */
  74279. _host: AdvancedDynamicTexture;
  74280. /** @hidden */
  74281. _fontSize: ValueAndUnit;
  74282. /**
  74283. * BABYLON.Observable raised when the style values are changed
  74284. */
  74285. onChangedObservable: BABYLON.Observable<Style>;
  74286. /**
  74287. * Creates a new style object
  74288. * @param host defines the AdvancedDynamicTexture which hosts this style
  74289. */
  74290. constructor(host: AdvancedDynamicTexture);
  74291. /**
  74292. * Gets or sets the font size
  74293. */
  74294. get fontSize(): string | number;
  74295. set fontSize(value: string | number);
  74296. /**
  74297. * Gets or sets the font family
  74298. */
  74299. get fontFamily(): string;
  74300. set fontFamily(value: string);
  74301. /**
  74302. * Gets or sets the font style
  74303. */
  74304. get fontStyle(): string;
  74305. set fontStyle(value: string);
  74306. /** Gets or sets font weight */
  74307. get fontWeight(): string;
  74308. set fontWeight(value: string);
  74309. /** Dispose all associated resources */
  74310. dispose(): void;
  74311. }
  74312. }
  74313. declare module BABYLON.GUI {
  74314. /**
  74315. * Class used to transport BABYLON.Vector2 information for pointer events
  74316. */
  74317. export class Vector2WithInfo extends BABYLON.Vector2 {
  74318. /** defines the current mouse button index */
  74319. buttonIndex: number;
  74320. /**
  74321. * Creates a new Vector2WithInfo
  74322. * @param source defines the vector2 data to transport
  74323. * @param buttonIndex defines the current mouse button index
  74324. */
  74325. constructor(source: BABYLON.Vector2,
  74326. /** defines the current mouse button index */
  74327. buttonIndex?: number);
  74328. }
  74329. /** Class used to provide 2D matrix features */
  74330. export class Matrix2D {
  74331. /** Gets the internal array of 6 floats used to store matrix data */
  74332. m: Float32Array;
  74333. /**
  74334. * Creates a new matrix
  74335. * @param m00 defines value for (0, 0)
  74336. * @param m01 defines value for (0, 1)
  74337. * @param m10 defines value for (1, 0)
  74338. * @param m11 defines value for (1, 1)
  74339. * @param m20 defines value for (2, 0)
  74340. * @param m21 defines value for (2, 1)
  74341. */
  74342. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74343. /**
  74344. * Fills the matrix from direct values
  74345. * @param m00 defines value for (0, 0)
  74346. * @param m01 defines value for (0, 1)
  74347. * @param m10 defines value for (1, 0)
  74348. * @param m11 defines value for (1, 1)
  74349. * @param m20 defines value for (2, 0)
  74350. * @param m21 defines value for (2, 1)
  74351. * @returns the current modified matrix
  74352. */
  74353. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74354. /**
  74355. * Gets matrix determinant
  74356. * @returns the determinant
  74357. */
  74358. determinant(): number;
  74359. /**
  74360. * Inverses the matrix and stores it in a target matrix
  74361. * @param result defines the target matrix
  74362. * @returns the current matrix
  74363. */
  74364. invertToRef(result: Matrix2D): Matrix2D;
  74365. /**
  74366. * Multiplies the current matrix with another one
  74367. * @param other defines the second operand
  74368. * @param result defines the target matrix
  74369. * @returns the current matrix
  74370. */
  74371. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74372. /**
  74373. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74374. * @param x defines the x coordinate to transform
  74375. * @param y defines the x coordinate to transform
  74376. * @param result defines the target vector2
  74377. * @returns the current matrix
  74378. */
  74379. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74380. /**
  74381. * Creates an identity matrix
  74382. * @returns a new matrix
  74383. */
  74384. static Identity(): Matrix2D;
  74385. /**
  74386. * Creates a translation matrix and stores it in a target matrix
  74387. * @param x defines the x coordinate of the translation
  74388. * @param y defines the y coordinate of the translation
  74389. * @param result defines the target matrix
  74390. */
  74391. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74392. /**
  74393. * Creates a scaling matrix and stores it in a target matrix
  74394. * @param x defines the x coordinate of the scaling
  74395. * @param y defines the y coordinate of the scaling
  74396. * @param result defines the target matrix
  74397. */
  74398. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74399. /**
  74400. * Creates a rotation matrix and stores it in a target matrix
  74401. * @param angle defines the rotation angle
  74402. * @param result defines the target matrix
  74403. */
  74404. static RotationToRef(angle: number, result: Matrix2D): void;
  74405. private static _TempPreTranslationMatrix;
  74406. private static _TempPostTranslationMatrix;
  74407. private static _TempRotationMatrix;
  74408. private static _TempScalingMatrix;
  74409. private static _TempCompose0;
  74410. private static _TempCompose1;
  74411. private static _TempCompose2;
  74412. /**
  74413. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  74414. * @param tx defines the x coordinate of the translation
  74415. * @param ty defines the y coordinate of the translation
  74416. * @param angle defines the rotation angle
  74417. * @param scaleX defines the x coordinate of the scaling
  74418. * @param scaleY defines the y coordinate of the scaling
  74419. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  74420. * @param result defines the target matrix
  74421. */
  74422. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  74423. }
  74424. }
  74425. declare module BABYLON.GUI {
  74426. /**
  74427. * Class used to store 2D control sizes
  74428. */
  74429. export class Measure {
  74430. /** defines left coordinate */
  74431. left: number;
  74432. /** defines top coordinate */
  74433. top: number;
  74434. /** defines width dimension */
  74435. width: number;
  74436. /** defines height dimension */
  74437. height: number;
  74438. /**
  74439. * Creates a new measure
  74440. * @param left defines left coordinate
  74441. * @param top defines top coordinate
  74442. * @param width defines width dimension
  74443. * @param height defines height dimension
  74444. */
  74445. constructor(
  74446. /** defines left coordinate */
  74447. left: number,
  74448. /** defines top coordinate */
  74449. top: number,
  74450. /** defines width dimension */
  74451. width: number,
  74452. /** defines height dimension */
  74453. height: number);
  74454. /**
  74455. * Copy from another measure
  74456. * @param other defines the other measure to copy from
  74457. */
  74458. copyFrom(other: Measure): void;
  74459. /**
  74460. * Copy from a group of 4 floats
  74461. * @param left defines left coordinate
  74462. * @param top defines top coordinate
  74463. * @param width defines width dimension
  74464. * @param height defines height dimension
  74465. */
  74466. copyFromFloats(left: number, top: number, width: number, height: number): void;
  74467. /**
  74468. * Computes the axis aligned bounding box measure for two given measures
  74469. * @param a Input measure
  74470. * @param b Input measure
  74471. * @param result the resulting bounding measure
  74472. */
  74473. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  74474. /**
  74475. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  74476. * @param transform the matrix to transform the measure before computing the AABB
  74477. * @param result the resulting AABB
  74478. */
  74479. transformToRef(transform: Matrix2D, result: Measure): void;
  74480. /**
  74481. * Check equality between this measure and another one
  74482. * @param other defines the other measures
  74483. * @returns true if both measures are equals
  74484. */
  74485. isEqualsTo(other: Measure): boolean;
  74486. /**
  74487. * Creates an empty measure
  74488. * @returns a new measure
  74489. */
  74490. static Empty(): Measure;
  74491. }
  74492. }
  74493. declare module BABYLON.GUI {
  74494. /**
  74495. * Interface used to define a control that can receive focus
  74496. */
  74497. export interface IFocusableControl {
  74498. /**
  74499. * Function called when the control receives the focus
  74500. */
  74501. onFocus(): void;
  74502. /**
  74503. * Function called when the control loses the focus
  74504. */
  74505. onBlur(): void;
  74506. /**
  74507. * Function called to let the control handle keyboard events
  74508. * @param evt defines the current keyboard event
  74509. */
  74510. processKeyboard(evt: KeyboardEvent): void;
  74511. /**
  74512. * Function called to get the list of controls that should not steal the focus from this control
  74513. * @returns an array of controls
  74514. */
  74515. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74516. }
  74517. /**
  74518. * Class used to create texture to support 2D GUI elements
  74519. * @see http://doc.babylonjs.com/how_to/gui
  74520. */
  74521. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  74522. private _isDirty;
  74523. private _renderObserver;
  74524. private _resizeObserver;
  74525. private _preKeyboardObserver;
  74526. private _pointerMoveObserver;
  74527. private _pointerObserver;
  74528. private _canvasPointerOutObserver;
  74529. private _background;
  74530. /** @hidden */
  74531. _rootContainer: Container;
  74532. /** @hidden */
  74533. _lastPickedControl: Control;
  74534. /** @hidden */
  74535. _lastControlOver: {
  74536. [pointerId: number]: Control;
  74537. };
  74538. /** @hidden */
  74539. _lastControlDown: {
  74540. [pointerId: number]: Control;
  74541. };
  74542. /** @hidden */
  74543. _capturingControl: {
  74544. [pointerId: number]: Control;
  74545. };
  74546. /** @hidden */
  74547. _shouldBlockPointer: boolean;
  74548. /** @hidden */
  74549. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  74550. /** @hidden */
  74551. _linkedControls: Control[];
  74552. private _isFullscreen;
  74553. private _fullscreenViewport;
  74554. private _idealWidth;
  74555. private _idealHeight;
  74556. private _useSmallestIdeal;
  74557. private _renderAtIdealSize;
  74558. private _focusedControl;
  74559. private _blockNextFocusCheck;
  74560. private _renderScale;
  74561. private _rootElement;
  74562. private _cursorChanged;
  74563. private _defaultMousePointerId;
  74564. /** @hidden */
  74565. _numLayoutCalls: number;
  74566. /** Gets the number of layout calls made the last time the ADT has been rendered */
  74567. get numLayoutCalls(): number;
  74568. /** @hidden */
  74569. _numRenderCalls: number;
  74570. /** Gets the number of render calls made the last time the ADT has been rendered */
  74571. get numRenderCalls(): number;
  74572. /**
  74573. * Define type to string to ensure compatibility across browsers
  74574. * Safari doesn't support DataTransfer constructor
  74575. */
  74576. private _clipboardData;
  74577. /**
  74578. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  74579. */
  74580. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  74581. /**
  74582. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  74583. */
  74584. onControlPickedObservable: BABYLON.Observable<Control>;
  74585. /**
  74586. * BABYLON.Observable event triggered before layout is evaluated
  74587. */
  74588. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74589. /**
  74590. * BABYLON.Observable event triggered after the layout was evaluated
  74591. */
  74592. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74593. /**
  74594. * BABYLON.Observable event triggered before the texture is rendered
  74595. */
  74596. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74597. /**
  74598. * BABYLON.Observable event triggered after the texture was rendered
  74599. */
  74600. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  74601. /**
  74602. * Gets or sets a boolean defining if alpha is stored as premultiplied
  74603. */
  74604. premulAlpha: boolean;
  74605. /**
  74606. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  74607. * Useful when you want more antialiasing
  74608. */
  74609. get renderScale(): number;
  74610. set renderScale(value: number);
  74611. /** Gets or sets the background color */
  74612. get background(): string;
  74613. set background(value: string);
  74614. /**
  74615. * Gets or sets the ideal width used to design controls.
  74616. * The GUI will then rescale everything accordingly
  74617. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74618. */
  74619. get idealWidth(): number;
  74620. set idealWidth(value: number);
  74621. /**
  74622. * Gets or sets the ideal height used to design controls.
  74623. * The GUI will then rescale everything accordingly
  74624. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74625. */
  74626. get idealHeight(): number;
  74627. set idealHeight(value: number);
  74628. /**
  74629. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  74630. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74631. */
  74632. get useSmallestIdeal(): boolean;
  74633. set useSmallestIdeal(value: boolean);
  74634. /**
  74635. * Gets or sets a boolean indicating if adaptive scaling must be used
  74636. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74637. */
  74638. get renderAtIdealSize(): boolean;
  74639. set renderAtIdealSize(value: boolean);
  74640. /**
  74641. * Gets the ratio used when in "ideal mode"
  74642. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74643. * */
  74644. get idealRatio(): number;
  74645. /**
  74646. * Gets the underlying layer used to render the texture when in fullscreen mode
  74647. */
  74648. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  74649. /**
  74650. * Gets the root container control
  74651. */
  74652. get rootContainer(): Container;
  74653. /**
  74654. * Returns an array containing the root container.
  74655. * This is mostly used to let the Inspector introspects the ADT
  74656. * @returns an array containing the rootContainer
  74657. */
  74658. getChildren(): Array<Container>;
  74659. /**
  74660. * Will return all controls that are inside this texture
  74661. * @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
  74662. * @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
  74663. * @return all child controls
  74664. */
  74665. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  74666. /**
  74667. * Gets or sets the current focused control
  74668. */
  74669. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  74670. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  74671. /**
  74672. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  74673. */
  74674. get isForeground(): boolean;
  74675. set isForeground(value: boolean);
  74676. /**
  74677. * Gets or set information about clipboardData
  74678. */
  74679. get clipboardData(): string;
  74680. set clipboardData(value: string);
  74681. /**
  74682. * Creates a new AdvancedDynamicTexture
  74683. * @param name defines the name of the texture
  74684. * @param width defines the width of the texture
  74685. * @param height defines the height of the texture
  74686. * @param scene defines the hosting scene
  74687. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  74688. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  74689. */
  74690. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  74691. /**
  74692. * Get the current class name of the texture useful for serialization or dynamic coding.
  74693. * @returns "AdvancedDynamicTexture"
  74694. */
  74695. getClassName(): string;
  74696. /**
  74697. * Function used to execute a function on all controls
  74698. * @param func defines the function to execute
  74699. * @param container defines the container where controls belong. If null the root container will be used
  74700. */
  74701. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  74702. private _useInvalidateRectOptimization;
  74703. /**
  74704. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  74705. */
  74706. get useInvalidateRectOptimization(): boolean;
  74707. set useInvalidateRectOptimization(value: boolean);
  74708. private _invalidatedRectangle;
  74709. /**
  74710. * Invalidates a rectangle area on the gui texture
  74711. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  74712. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  74713. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  74714. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  74715. */
  74716. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  74717. /**
  74718. * Marks the texture as dirty forcing a complete update
  74719. */
  74720. markAsDirty(): void;
  74721. /**
  74722. * Helper function used to create a new style
  74723. * @returns a new style
  74724. * @see http://doc.babylonjs.com/how_to/gui#styles
  74725. */
  74726. createStyle(): Style;
  74727. /**
  74728. * Adds a new control to the root container
  74729. * @param control defines the control to add
  74730. * @returns the current texture
  74731. */
  74732. addControl(control: Control): AdvancedDynamicTexture;
  74733. /**
  74734. * Removes a control from the root container
  74735. * @param control defines the control to remove
  74736. * @returns the current texture
  74737. */
  74738. removeControl(control: Control): AdvancedDynamicTexture;
  74739. /**
  74740. * Release all resources
  74741. */
  74742. dispose(): void;
  74743. private _onResize;
  74744. /** @hidden */
  74745. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  74746. /**
  74747. * Get screen coordinates for a vector3
  74748. * @param position defines the position to project
  74749. * @param worldMatrix defines the world matrix to use
  74750. * @returns the projected position
  74751. */
  74752. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  74753. private _checkUpdate;
  74754. private _clearMeasure;
  74755. private _render;
  74756. /** @hidden */
  74757. _changeCursor(cursor: string): void;
  74758. /** @hidden */
  74759. _registerLastControlDown(control: Control, pointerId: number): void;
  74760. private _doPicking;
  74761. /** @hidden */
  74762. _cleanControlAfterRemovalFromList(list: {
  74763. [pointerId: number]: Control;
  74764. }, control: Control): void;
  74765. /** @hidden */
  74766. _cleanControlAfterRemoval(control: Control): void;
  74767. /** Attach to all scene events required to support pointer events */
  74768. attach(): void;
  74769. /** @hidden */
  74770. private onClipboardCopy;
  74771. /** @hidden */
  74772. private onClipboardCut;
  74773. /** @hidden */
  74774. private onClipboardPaste;
  74775. /**
  74776. * Register the clipboard Events onto the canvas
  74777. */
  74778. registerClipboardEvents(): void;
  74779. /**
  74780. * Unregister the clipboard Events from the canvas
  74781. */
  74782. unRegisterClipboardEvents(): void;
  74783. /**
  74784. * Connect the texture to a hosting mesh to enable interactions
  74785. * @param mesh defines the mesh to attach to
  74786. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  74787. */
  74788. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  74789. /**
  74790. * Move the focus to a specific control
  74791. * @param control defines the control which will receive the focus
  74792. */
  74793. moveFocusToControl(control: IFocusableControl): void;
  74794. private _manageFocus;
  74795. private _attachToOnPointerOut;
  74796. /**
  74797. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  74798. * @param mesh defines the mesh which will receive the texture
  74799. * @param width defines the texture width (1024 by default)
  74800. * @param height defines the texture height (1024 by default)
  74801. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  74802. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  74803. * @returns a new AdvancedDynamicTexture
  74804. */
  74805. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  74806. /**
  74807. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  74808. * In this mode the texture will rely on a layer for its rendering.
  74809. * This allows it to be treated like any other layer.
  74810. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  74811. * LayerMask is set through advancedTexture.layer.layerMask
  74812. * @param name defines name for the texture
  74813. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  74814. * @param scene defines the hsoting scene
  74815. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  74816. * @returns a new AdvancedDynamicTexture
  74817. */
  74818. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  74819. }
  74820. }
  74821. declare module BABYLON.GUI {
  74822. /**
  74823. * Root class used for all 2D controls
  74824. * @see http://doc.babylonjs.com/how_to/gui#controls
  74825. */
  74826. export class Control {
  74827. /** defines the name of the control */
  74828. name?: string | undefined;
  74829. /**
  74830. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  74831. */
  74832. static AllowAlphaInheritance: boolean;
  74833. private _alpha;
  74834. private _alphaSet;
  74835. private _zIndex;
  74836. /** @hidden */
  74837. _host: AdvancedDynamicTexture;
  74838. /** Gets or sets the control parent */
  74839. parent: BABYLON.Nullable<Container>;
  74840. /** @hidden */
  74841. _currentMeasure: Measure;
  74842. private _fontFamily;
  74843. private _fontStyle;
  74844. private _fontWeight;
  74845. private _fontSize;
  74846. private _font;
  74847. /** @hidden */
  74848. _width: ValueAndUnit;
  74849. /** @hidden */
  74850. _height: ValueAndUnit;
  74851. /** @hidden */
  74852. protected _fontOffset: {
  74853. ascent: number;
  74854. height: number;
  74855. descent: number;
  74856. };
  74857. private _color;
  74858. private _style;
  74859. private _styleObserver;
  74860. /** @hidden */
  74861. protected _horizontalAlignment: number;
  74862. /** @hidden */
  74863. protected _verticalAlignment: number;
  74864. /** @hidden */
  74865. protected _isDirty: boolean;
  74866. /** @hidden */
  74867. protected _wasDirty: boolean;
  74868. /** @hidden */
  74869. _tempParentMeasure: Measure;
  74870. /** @hidden */
  74871. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  74872. /** @hidden */
  74873. protected _cachedParentMeasure: Measure;
  74874. private _paddingLeft;
  74875. private _paddingRight;
  74876. private _paddingTop;
  74877. private _paddingBottom;
  74878. /** @hidden */
  74879. _left: ValueAndUnit;
  74880. /** @hidden */
  74881. _top: ValueAndUnit;
  74882. private _scaleX;
  74883. private _scaleY;
  74884. private _rotation;
  74885. private _transformCenterX;
  74886. private _transformCenterY;
  74887. /** @hidden */
  74888. _transformMatrix: Matrix2D;
  74889. /** @hidden */
  74890. protected _invertTransformMatrix: Matrix2D;
  74891. /** @hidden */
  74892. protected _transformedPosition: BABYLON.Vector2;
  74893. private _isMatrixDirty;
  74894. private _cachedOffsetX;
  74895. private _cachedOffsetY;
  74896. private _isVisible;
  74897. private _isHighlighted;
  74898. /** @hidden */
  74899. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  74900. private _fontSet;
  74901. private _dummyVector2;
  74902. private _downCount;
  74903. private _enterCount;
  74904. private _doNotRender;
  74905. private _downPointerIds;
  74906. protected _isEnabled: boolean;
  74907. protected _disabledColor: string;
  74908. protected _disabledColorItem: string;
  74909. /** @hidden */
  74910. protected _rebuildLayout: boolean;
  74911. /** @hidden */
  74912. _customData: any;
  74913. /** @hidden */
  74914. _isClipped: boolean;
  74915. /** @hidden */
  74916. _automaticSize: boolean;
  74917. /** @hidden */
  74918. _tag: any;
  74919. /**
  74920. * 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
  74921. */
  74922. uniqueId: number;
  74923. /**
  74924. * Gets or sets an object used to store user defined information for the node
  74925. */
  74926. metadata: any;
  74927. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  74928. isHitTestVisible: boolean;
  74929. /** Gets or sets a boolean indicating if the control can block pointer events */
  74930. isPointerBlocker: boolean;
  74931. /** Gets or sets a boolean indicating if the control can be focusable */
  74932. isFocusInvisible: boolean;
  74933. /**
  74934. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  74935. * 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
  74936. */
  74937. clipChildren: boolean;
  74938. /**
  74939. * Gets or sets a boolean indicating that control content must be clipped
  74940. * 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
  74941. */
  74942. clipContent: boolean;
  74943. /**
  74944. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  74945. */
  74946. useBitmapCache: boolean;
  74947. private _cacheData;
  74948. private _shadowOffsetX;
  74949. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  74950. get shadowOffsetX(): number;
  74951. set shadowOffsetX(value: number);
  74952. private _shadowOffsetY;
  74953. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  74954. get shadowOffsetY(): number;
  74955. set shadowOffsetY(value: number);
  74956. private _shadowBlur;
  74957. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  74958. get shadowBlur(): number;
  74959. set shadowBlur(value: number);
  74960. private _shadowColor;
  74961. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  74962. get shadowColor(): string;
  74963. set shadowColor(value: string);
  74964. /** Gets or sets the cursor to use when the control is hovered */
  74965. hoverCursor: string;
  74966. /** @hidden */
  74967. protected _linkOffsetX: ValueAndUnit;
  74968. /** @hidden */
  74969. protected _linkOffsetY: ValueAndUnit;
  74970. /** Gets the control type name */
  74971. get typeName(): string;
  74972. /**
  74973. * Get the current class name of the control.
  74974. * @returns current class name
  74975. */
  74976. getClassName(): string;
  74977. /**
  74978. * An event triggered when pointer wheel is scrolled
  74979. */
  74980. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  74981. /**
  74982. * An event triggered when the pointer move over the control.
  74983. */
  74984. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  74985. /**
  74986. * An event triggered when the pointer move out of the control.
  74987. */
  74988. onPointerOutObservable: BABYLON.Observable<Control>;
  74989. /**
  74990. * An event triggered when the pointer taps the control
  74991. */
  74992. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  74993. /**
  74994. * An event triggered when pointer up
  74995. */
  74996. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  74997. /**
  74998. * An event triggered when a control is clicked on
  74999. */
  75000. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75001. /**
  75002. * An event triggered when pointer enters the control
  75003. */
  75004. onPointerEnterObservable: BABYLON.Observable<Control>;
  75005. /**
  75006. * An event triggered when the control is marked as dirty
  75007. */
  75008. onDirtyObservable: BABYLON.Observable<Control>;
  75009. /**
  75010. * An event triggered before drawing the control
  75011. */
  75012. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75013. /**
  75014. * An event triggered after the control was drawn
  75015. */
  75016. onAfterDrawObservable: BABYLON.Observable<Control>;
  75017. /**
  75018. * An event triggered when the control has been disposed
  75019. */
  75020. onDisposeObservable: BABYLON.Observable<Control>;
  75021. /**
  75022. * Get the hosting AdvancedDynamicTexture
  75023. */
  75024. get host(): AdvancedDynamicTexture;
  75025. /** Gets or set information about font offsets (used to render and align text) */
  75026. get fontOffset(): {
  75027. ascent: number;
  75028. height: number;
  75029. descent: number;
  75030. };
  75031. set fontOffset(offset: {
  75032. ascent: number;
  75033. height: number;
  75034. descent: number;
  75035. });
  75036. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75037. get alpha(): number;
  75038. set alpha(value: number);
  75039. /**
  75040. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75041. */
  75042. get isHighlighted(): boolean;
  75043. set isHighlighted(value: boolean);
  75044. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75045. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75046. */
  75047. get scaleX(): number;
  75048. set scaleX(value: number);
  75049. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75050. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75051. */
  75052. get scaleY(): number;
  75053. set scaleY(value: number);
  75054. /** Gets or sets the rotation angle (0 by default)
  75055. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75056. */
  75057. get rotation(): number;
  75058. set rotation(value: number);
  75059. /** Gets or sets the transformation center on Y axis (0 by default)
  75060. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75061. */
  75062. get transformCenterY(): number;
  75063. set transformCenterY(value: number);
  75064. /** Gets or sets the transformation center on X axis (0 by default)
  75065. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75066. */
  75067. get transformCenterX(): number;
  75068. set transformCenterX(value: number);
  75069. /**
  75070. * Gets or sets the horizontal alignment
  75071. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75072. */
  75073. get horizontalAlignment(): number;
  75074. set horizontalAlignment(value: number);
  75075. /**
  75076. * Gets or sets the vertical alignment
  75077. * @see http://doc.babylonjs.com/how_to/gui#alignments
  75078. */
  75079. get verticalAlignment(): number;
  75080. set verticalAlignment(value: number);
  75081. /**
  75082. * Gets or sets control width
  75083. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75084. */
  75085. get width(): string | number;
  75086. set width(value: string | number);
  75087. /**
  75088. * Gets or sets the control width in pixel
  75089. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75090. */
  75091. get widthInPixels(): number;
  75092. set widthInPixels(value: number);
  75093. /**
  75094. * Gets or sets control height
  75095. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75096. */
  75097. get height(): string | number;
  75098. set height(value: string | number);
  75099. /**
  75100. * Gets or sets control height in pixel
  75101. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75102. */
  75103. get heightInPixels(): number;
  75104. set heightInPixels(value: number);
  75105. /** Gets or set font family */
  75106. get fontFamily(): string;
  75107. set fontFamily(value: string);
  75108. /** Gets or sets font style */
  75109. get fontStyle(): string;
  75110. set fontStyle(value: string);
  75111. /** Gets or sets font weight */
  75112. get fontWeight(): string;
  75113. set fontWeight(value: string);
  75114. /**
  75115. * Gets or sets style
  75116. * @see http://doc.babylonjs.com/how_to/gui#styles
  75117. */
  75118. get style(): BABYLON.Nullable<Style>;
  75119. set style(value: BABYLON.Nullable<Style>);
  75120. /** @hidden */
  75121. get _isFontSizeInPercentage(): boolean;
  75122. /** Gets or sets font size in pixels */
  75123. get fontSizeInPixels(): number;
  75124. set fontSizeInPixels(value: number);
  75125. /** Gets or sets font size */
  75126. get fontSize(): string | number;
  75127. set fontSize(value: string | number);
  75128. /** Gets or sets foreground color */
  75129. get color(): string;
  75130. set color(value: string);
  75131. /** Gets or sets z index which is used to reorder controls on the z axis */
  75132. get zIndex(): number;
  75133. set zIndex(value: number);
  75134. /** Gets or sets a boolean indicating if the control can be rendered */
  75135. get notRenderable(): boolean;
  75136. set notRenderable(value: boolean);
  75137. /** Gets or sets a boolean indicating if the control is visible */
  75138. get isVisible(): boolean;
  75139. set isVisible(value: boolean);
  75140. /** Gets a boolean indicating that the control needs to update its rendering */
  75141. get isDirty(): boolean;
  75142. /**
  75143. * Gets the current linked mesh (or null if none)
  75144. */
  75145. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75146. /**
  75147. * Gets or sets a value indicating the padding to use on the left of the control
  75148. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75149. */
  75150. get paddingLeft(): string | number;
  75151. set paddingLeft(value: string | number);
  75152. /**
  75153. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75154. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75155. */
  75156. get paddingLeftInPixels(): number;
  75157. set paddingLeftInPixels(value: number);
  75158. /**
  75159. * Gets or sets a value indicating the padding to use on the right of the control
  75160. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75161. */
  75162. get paddingRight(): string | number;
  75163. set paddingRight(value: string | number);
  75164. /**
  75165. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75166. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75167. */
  75168. get paddingRightInPixels(): number;
  75169. set paddingRightInPixels(value: number);
  75170. /**
  75171. * Gets or sets a value indicating the padding to use on the top of the control
  75172. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75173. */
  75174. get paddingTop(): string | number;
  75175. set paddingTop(value: string | number);
  75176. /**
  75177. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75178. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75179. */
  75180. get paddingTopInPixels(): number;
  75181. set paddingTopInPixels(value: number);
  75182. /**
  75183. * Gets or sets a value indicating the padding to use on the bottom of the control
  75184. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75185. */
  75186. get paddingBottom(): string | number;
  75187. set paddingBottom(value: string | number);
  75188. /**
  75189. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75190. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75191. */
  75192. get paddingBottomInPixels(): number;
  75193. set paddingBottomInPixels(value: number);
  75194. /**
  75195. * Gets or sets a value indicating the left coordinate of the control
  75196. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75197. */
  75198. get left(): string | number;
  75199. set left(value: string | number);
  75200. /**
  75201. * Gets or sets a value indicating the left coordinate in pixels of the control
  75202. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75203. */
  75204. get leftInPixels(): number;
  75205. set leftInPixels(value: number);
  75206. /**
  75207. * Gets or sets a value indicating the top coordinate of the control
  75208. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75209. */
  75210. get top(): string | number;
  75211. set top(value: string | number);
  75212. /**
  75213. * Gets or sets a value indicating the top coordinate in pixels of the control
  75214. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  75215. */
  75216. get topInPixels(): number;
  75217. set topInPixels(value: number);
  75218. /**
  75219. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75220. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75221. */
  75222. get linkOffsetX(): string | number;
  75223. set linkOffsetX(value: string | number);
  75224. /**
  75225. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75226. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75227. */
  75228. get linkOffsetXInPixels(): number;
  75229. set linkOffsetXInPixels(value: number);
  75230. /**
  75231. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75232. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75233. */
  75234. get linkOffsetY(): string | number;
  75235. set linkOffsetY(value: string | number);
  75236. /**
  75237. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75238. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75239. */
  75240. get linkOffsetYInPixels(): number;
  75241. set linkOffsetYInPixels(value: number);
  75242. /** Gets the center coordinate on X axis */
  75243. get centerX(): number;
  75244. /** Gets the center coordinate on Y axis */
  75245. get centerY(): number;
  75246. /** Gets or sets if control is Enabled*/
  75247. get isEnabled(): boolean;
  75248. set isEnabled(value: boolean);
  75249. /** Gets or sets background color of control if it's disabled*/
  75250. get disabledColor(): string;
  75251. set disabledColor(value: string);
  75252. /** Gets or sets front color of control if it's disabled*/
  75253. get disabledColorItem(): string;
  75254. set disabledColorItem(value: string);
  75255. /**
  75256. * Creates a new control
  75257. * @param name defines the name of the control
  75258. */
  75259. constructor(
  75260. /** defines the name of the control */
  75261. name?: string | undefined);
  75262. /** @hidden */
  75263. protected _getTypeName(): string;
  75264. /**
  75265. * Gets the first ascendant in the hierarchy of the given type
  75266. * @param className defines the required type
  75267. * @returns the ascendant or null if not found
  75268. */
  75269. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75270. /** @hidden */
  75271. _resetFontCache(): void;
  75272. /**
  75273. * Determines if a container is an ascendant of the current control
  75274. * @param container defines the container to look for
  75275. * @returns true if the container is one of the ascendant of the control
  75276. */
  75277. isAscendant(container: Control): boolean;
  75278. /**
  75279. * Gets coordinates in local control space
  75280. * @param globalCoordinates defines the coordinates to transform
  75281. * @returns the new coordinates in local space
  75282. */
  75283. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75284. /**
  75285. * Gets coordinates in local control space
  75286. * @param globalCoordinates defines the coordinates to transform
  75287. * @param result defines the target vector2 where to store the result
  75288. * @returns the current control
  75289. */
  75290. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75291. /**
  75292. * Gets coordinates in parent local control space
  75293. * @param globalCoordinates defines the coordinates to transform
  75294. * @returns the new coordinates in parent local space
  75295. */
  75296. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75297. /**
  75298. * Move the current control to a vector3 position projected onto the screen.
  75299. * @param position defines the target position
  75300. * @param scene defines the hosting scene
  75301. */
  75302. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75303. /**
  75304. * Will store all controls that have this control as ascendant in a given array
  75305. * @param results defines the array where to store the descendants
  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. */
  75309. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75310. /**
  75311. * Will return all controls that have this control as ascendant
  75312. * @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
  75313. * @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
  75314. * @return all child controls
  75315. */
  75316. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75317. /**
  75318. * Link current control with a target mesh
  75319. * @param mesh defines the mesh to link with
  75320. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  75321. */
  75322. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75323. /** @hidden */
  75324. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75325. /** @hidden */
  75326. _offsetLeft(offset: number): void;
  75327. /** @hidden */
  75328. _offsetTop(offset: number): void;
  75329. /** @hidden */
  75330. _markMatrixAsDirty(): void;
  75331. /** @hidden */
  75332. _flagDescendantsAsMatrixDirty(): void;
  75333. /** @hidden */
  75334. _intersectsRect(rect: Measure): boolean;
  75335. /** @hidden */
  75336. protected invalidateRect(): void;
  75337. /** @hidden */
  75338. _markAsDirty(force?: boolean): void;
  75339. /** @hidden */
  75340. _markAllAsDirty(): void;
  75341. /** @hidden */
  75342. _link(host: AdvancedDynamicTexture): void;
  75343. /** @hidden */
  75344. protected _transform(context?: CanvasRenderingContext2D): void;
  75345. /** @hidden */
  75346. _renderHighlight(context: CanvasRenderingContext2D): void;
  75347. /** @hidden */
  75348. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75349. /** @hidden */
  75350. protected _applyStates(context: CanvasRenderingContext2D): void;
  75351. /** @hidden */
  75352. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75353. /** @hidden */
  75354. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75355. protected _evaluateClippingState(parentMeasure: Measure): void;
  75356. /** @hidden */
  75357. _measure(): void;
  75358. /** @hidden */
  75359. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75360. /** @hidden */
  75361. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75362. /** @hidden */
  75363. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75364. /** @hidden */
  75365. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75366. private static _ClipMeasure;
  75367. private _tmpMeasureA;
  75368. private _clip;
  75369. /** @hidden */
  75370. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75371. /** @hidden */
  75372. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75373. /**
  75374. * Tests if a given coordinates belong to the current control
  75375. * @param x defines x coordinate to test
  75376. * @param y defines y coordinate to test
  75377. * @returns true if the coordinates are inside the control
  75378. */
  75379. contains(x: number, y: number): boolean;
  75380. /** @hidden */
  75381. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75382. /** @hidden */
  75383. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75384. /** @hidden */
  75385. _onPointerEnter(target: Control): boolean;
  75386. /** @hidden */
  75387. _onPointerOut(target: Control, force?: boolean): void;
  75388. /** @hidden */
  75389. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75390. /** @hidden */
  75391. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75392. /** @hidden */
  75393. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75394. /** @hidden */
  75395. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75396. /** @hidden */
  75397. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75398. private _prepareFont;
  75399. /** Releases associated resources */
  75400. dispose(): void;
  75401. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75402. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75403. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75404. private static _VERTICAL_ALIGNMENT_TOP;
  75405. private static _VERTICAL_ALIGNMENT_BOTTOM;
  75406. private static _VERTICAL_ALIGNMENT_CENTER;
  75407. /** HORIZONTAL_ALIGNMENT_LEFT */
  75408. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  75409. /** HORIZONTAL_ALIGNMENT_RIGHT */
  75410. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  75411. /** HORIZONTAL_ALIGNMENT_CENTER */
  75412. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  75413. /** VERTICAL_ALIGNMENT_TOP */
  75414. static get VERTICAL_ALIGNMENT_TOP(): number;
  75415. /** VERTICAL_ALIGNMENT_BOTTOM */
  75416. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  75417. /** VERTICAL_ALIGNMENT_CENTER */
  75418. static get VERTICAL_ALIGNMENT_CENTER(): number;
  75419. private static _FontHeightSizes;
  75420. /** @hidden */
  75421. static _GetFontOffset(font: string): {
  75422. ascent: number;
  75423. height: number;
  75424. descent: number;
  75425. };
  75426. /**
  75427. * Creates a stack panel that can be used to render headers
  75428. * @param control defines the control to associate with the header
  75429. * @param text defines the text of the header
  75430. * @param size defines the size of the header
  75431. * @param options defines options used to configure the header
  75432. * @returns a new StackPanel
  75433. * @ignore
  75434. * @hidden
  75435. */
  75436. static AddHeader: (control: Control, text: string, size: string | number, options: {
  75437. isHorizontal: boolean;
  75438. controlFirst: boolean;
  75439. }) => any;
  75440. /** @hidden */
  75441. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  75442. }
  75443. }
  75444. declare module BABYLON.GUI {
  75445. /**
  75446. * Root class for 2D containers
  75447. * @see http://doc.babylonjs.com/how_to/gui#containers
  75448. */
  75449. export class Container extends Control {
  75450. name?: string | undefined;
  75451. /** @hidden */
  75452. _children: Control[];
  75453. /** @hidden */
  75454. protected _measureForChildren: Measure;
  75455. /** @hidden */
  75456. protected _background: string;
  75457. /** @hidden */
  75458. protected _adaptWidthToChildren: boolean;
  75459. /** @hidden */
  75460. protected _adaptHeightToChildren: boolean;
  75461. /**
  75462. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  75463. */
  75464. logLayoutCycleErrors: boolean;
  75465. /**
  75466. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  75467. */
  75468. maxLayoutCycle: number;
  75469. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  75470. get adaptHeightToChildren(): boolean;
  75471. set adaptHeightToChildren(value: boolean);
  75472. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  75473. get adaptWidthToChildren(): boolean;
  75474. set adaptWidthToChildren(value: boolean);
  75475. /** Gets or sets background color */
  75476. get background(): string;
  75477. set background(value: string);
  75478. /** Gets the list of children */
  75479. get children(): Control[];
  75480. /**
  75481. * Creates a new Container
  75482. * @param name defines the name of the container
  75483. */
  75484. constructor(name?: string | undefined);
  75485. protected _getTypeName(): string;
  75486. _flagDescendantsAsMatrixDirty(): void;
  75487. /**
  75488. * Gets a child using its name
  75489. * @param name defines the child name to look for
  75490. * @returns the child control if found
  75491. */
  75492. getChildByName(name: string): BABYLON.Nullable<Control>;
  75493. /**
  75494. * Gets a child using its type and its name
  75495. * @param name defines the child name to look for
  75496. * @param type defines the child type to look for
  75497. * @returns the child control if found
  75498. */
  75499. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  75500. /**
  75501. * Search for a specific control in children
  75502. * @param control defines the control to look for
  75503. * @returns true if the control is in child list
  75504. */
  75505. containsControl(control: Control): boolean;
  75506. /**
  75507. * Adds a new control to the current container
  75508. * @param control defines the control to add
  75509. * @returns the current container
  75510. */
  75511. addControl(control: BABYLON.Nullable<Control>): Container;
  75512. /**
  75513. * Removes all controls from the current container
  75514. * @returns the current container
  75515. */
  75516. clearControls(): Container;
  75517. /**
  75518. * Removes a control from the current container
  75519. * @param control defines the control to remove
  75520. * @returns the current container
  75521. */
  75522. removeControl(control: Control): Container;
  75523. /** @hidden */
  75524. _reOrderControl(control: Control): void;
  75525. /** @hidden */
  75526. _offsetLeft(offset: number): void;
  75527. /** @hidden */
  75528. _offsetTop(offset: number): void;
  75529. /** @hidden */
  75530. _markAllAsDirty(): void;
  75531. /** @hidden */
  75532. protected _localDraw(context: CanvasRenderingContext2D): void;
  75533. /** @hidden */
  75534. _link(host: AdvancedDynamicTexture): void;
  75535. /** @hidden */
  75536. protected _beforeLayout(): void;
  75537. /** @hidden */
  75538. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75539. /** @hidden */
  75540. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75541. protected _postMeasure(): void;
  75542. /** @hidden */
  75543. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75544. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75545. /** @hidden */
  75546. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75547. /** @hidden */
  75548. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75549. /** Releases associated resources */
  75550. dispose(): void;
  75551. }
  75552. }
  75553. declare module BABYLON.GUI {
  75554. /** Class used to create rectangle container */
  75555. export class Rectangle extends Container {
  75556. name?: string | undefined;
  75557. private _thickness;
  75558. private _cornerRadius;
  75559. /** Gets or sets border thickness */
  75560. get thickness(): number;
  75561. set thickness(value: number);
  75562. /** Gets or sets the corner radius angle */
  75563. get cornerRadius(): number;
  75564. set cornerRadius(value: number);
  75565. /**
  75566. * Creates a new Rectangle
  75567. * @param name defines the control name
  75568. */
  75569. constructor(name?: string | undefined);
  75570. protected _getTypeName(): string;
  75571. protected _localDraw(context: CanvasRenderingContext2D): void;
  75572. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75573. private _drawRoundedRect;
  75574. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75575. }
  75576. }
  75577. declare module BABYLON.GUI {
  75578. /**
  75579. * Enum that determines the text-wrapping mode to use.
  75580. */
  75581. export enum TextWrapping {
  75582. /**
  75583. * Clip the text when it's larger than Control.width; this is the default mode.
  75584. */
  75585. Clip = 0,
  75586. /**
  75587. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  75588. */
  75589. WordWrap = 1,
  75590. /**
  75591. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  75592. */
  75593. Ellipsis = 2
  75594. }
  75595. /**
  75596. * Class used to create text block control
  75597. */
  75598. export class TextBlock extends Control {
  75599. /**
  75600. * Defines the name of the control
  75601. */
  75602. name?: string | undefined;
  75603. private _text;
  75604. private _textWrapping;
  75605. private _textHorizontalAlignment;
  75606. private _textVerticalAlignment;
  75607. private _lines;
  75608. private _resizeToFit;
  75609. private _lineSpacing;
  75610. private _outlineWidth;
  75611. private _outlineColor;
  75612. /**
  75613. * An event triggered after the text is changed
  75614. */
  75615. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  75616. /**
  75617. * An event triggered after the text was broken up into lines
  75618. */
  75619. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  75620. /**
  75621. * Function used to split a string into words. By default, a string is split at each space character found
  75622. */
  75623. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  75624. /**
  75625. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  75626. */
  75627. get lines(): any[];
  75628. /**
  75629. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75630. */
  75631. get resizeToFit(): boolean;
  75632. /**
  75633. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  75634. */
  75635. set resizeToFit(value: boolean);
  75636. /**
  75637. * Gets or sets a boolean indicating if text must be wrapped
  75638. */
  75639. get textWrapping(): TextWrapping | boolean;
  75640. /**
  75641. * Gets or sets a boolean indicating if text must be wrapped
  75642. */
  75643. set textWrapping(value: TextWrapping | boolean);
  75644. /**
  75645. * Gets or sets text to display
  75646. */
  75647. get text(): string;
  75648. /**
  75649. * Gets or sets text to display
  75650. */
  75651. set text(value: string);
  75652. /**
  75653. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75654. */
  75655. get textHorizontalAlignment(): number;
  75656. /**
  75657. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  75658. */
  75659. set textHorizontalAlignment(value: number);
  75660. /**
  75661. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75662. */
  75663. get textVerticalAlignment(): number;
  75664. /**
  75665. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  75666. */
  75667. set textVerticalAlignment(value: number);
  75668. /**
  75669. * Gets or sets line spacing value
  75670. */
  75671. set lineSpacing(value: string | number);
  75672. /**
  75673. * Gets or sets line spacing value
  75674. */
  75675. get lineSpacing(): string | number;
  75676. /**
  75677. * Gets or sets outlineWidth of the text to display
  75678. */
  75679. get outlineWidth(): number;
  75680. /**
  75681. * Gets or sets outlineWidth of the text to display
  75682. */
  75683. set outlineWidth(value: number);
  75684. /**
  75685. * Gets or sets outlineColor of the text to display
  75686. */
  75687. get outlineColor(): string;
  75688. /**
  75689. * Gets or sets outlineColor of the text to display
  75690. */
  75691. set outlineColor(value: string);
  75692. /**
  75693. * Creates a new TextBlock object
  75694. * @param name defines the name of the control
  75695. * @param text defines the text to display (emptry string by default)
  75696. */
  75697. constructor(
  75698. /**
  75699. * Defines the name of the control
  75700. */
  75701. name?: string | undefined, text?: string);
  75702. protected _getTypeName(): string;
  75703. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75704. private _drawText;
  75705. /** @hidden */
  75706. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75707. protected _applyStates(context: CanvasRenderingContext2D): void;
  75708. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  75709. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  75710. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  75711. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  75712. protected _renderLines(context: CanvasRenderingContext2D): void;
  75713. /**
  75714. * Given a width constraint applied on the text block, find the expected height
  75715. * @returns expected height
  75716. */
  75717. computeExpectedHeight(): number;
  75718. dispose(): void;
  75719. }
  75720. }
  75721. declare module BABYLON.GUI {
  75722. /**
  75723. * Class used to create 2D images
  75724. */
  75725. export class Image extends Control {
  75726. name?: string | undefined;
  75727. private _workingCanvas;
  75728. private _domImage;
  75729. private _imageWidth;
  75730. private _imageHeight;
  75731. private _loaded;
  75732. private _stretch;
  75733. private _source;
  75734. private _autoScale;
  75735. private _sourceLeft;
  75736. private _sourceTop;
  75737. private _sourceWidth;
  75738. private _sourceHeight;
  75739. private _svgAttributesComputationCompleted;
  75740. private _isSVG;
  75741. private _cellWidth;
  75742. private _cellHeight;
  75743. private _cellId;
  75744. private _populateNinePatchSlicesFromImage;
  75745. private _sliceLeft;
  75746. private _sliceRight;
  75747. private _sliceTop;
  75748. private _sliceBottom;
  75749. private _detectPointerOnOpaqueOnly;
  75750. /**
  75751. * BABYLON.Observable notified when the content is loaded
  75752. */
  75753. onImageLoadedObservable: BABYLON.Observable<Image>;
  75754. /**
  75755. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  75756. */
  75757. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  75758. /**
  75759. * Gets a boolean indicating that the content is loaded
  75760. */
  75761. get isLoaded(): boolean;
  75762. /**
  75763. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  75764. */
  75765. get populateNinePatchSlicesFromImage(): boolean;
  75766. set populateNinePatchSlicesFromImage(value: boolean);
  75767. /**
  75768. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  75769. * Beware using this as this will comsume more memory as the image has to be stored twice
  75770. */
  75771. get detectPointerOnOpaqueOnly(): boolean;
  75772. set detectPointerOnOpaqueOnly(value: boolean);
  75773. /**
  75774. * Gets or sets the left value for slicing (9-patch)
  75775. */
  75776. get sliceLeft(): number;
  75777. set sliceLeft(value: number);
  75778. /**
  75779. * Gets or sets the right value for slicing (9-patch)
  75780. */
  75781. get sliceRight(): number;
  75782. set sliceRight(value: number);
  75783. /**
  75784. * Gets or sets the top value for slicing (9-patch)
  75785. */
  75786. get sliceTop(): number;
  75787. set sliceTop(value: number);
  75788. /**
  75789. * Gets or sets the bottom value for slicing (9-patch)
  75790. */
  75791. get sliceBottom(): number;
  75792. set sliceBottom(value: number);
  75793. /**
  75794. * Gets or sets the left coordinate in the source image
  75795. */
  75796. get sourceLeft(): number;
  75797. set sourceLeft(value: number);
  75798. /**
  75799. * Gets or sets the top coordinate in the source image
  75800. */
  75801. get sourceTop(): number;
  75802. set sourceTop(value: number);
  75803. /**
  75804. * Gets or sets the width to capture in the source image
  75805. */
  75806. get sourceWidth(): number;
  75807. set sourceWidth(value: number);
  75808. /**
  75809. * Gets or sets the height to capture in the source image
  75810. */
  75811. get sourceHeight(): number;
  75812. set sourceHeight(value: number);
  75813. /** Indicates if the format of the image is SVG */
  75814. get isSVG(): boolean;
  75815. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  75816. get svgAttributesComputationCompleted(): boolean;
  75817. /**
  75818. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  75819. * @see http://doc.babylonjs.com/how_to/gui#image
  75820. */
  75821. get autoScale(): boolean;
  75822. set autoScale(value: boolean);
  75823. /** Gets or sets the streching mode used by the image */
  75824. get stretch(): number;
  75825. set stretch(value: number);
  75826. /** @hidden */
  75827. _rotate90(n: number, preserveProperties?: boolean): Image;
  75828. private _handleRotationForSVGImage;
  75829. private _rotate90SourceProperties;
  75830. /**
  75831. * Gets or sets the internal DOM image used to render the control
  75832. */
  75833. set domImage(value: HTMLImageElement);
  75834. get domImage(): HTMLImageElement;
  75835. private _onImageLoaded;
  75836. private _extractNinePatchSliceDataFromImage;
  75837. /**
  75838. * Gets or sets image source url
  75839. */
  75840. set source(value: BABYLON.Nullable<string>);
  75841. /**
  75842. * Checks for svg document with icon id present
  75843. */
  75844. private _svgCheck;
  75845. /**
  75846. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  75847. * given external svg file and icon id
  75848. */
  75849. private _getSVGAttribs;
  75850. /**
  75851. * Gets or sets the cell width to use when animation sheet is enabled
  75852. * @see http://doc.babylonjs.com/how_to/gui#image
  75853. */
  75854. get cellWidth(): number;
  75855. set cellWidth(value: number);
  75856. /**
  75857. * Gets or sets the cell height to use when animation sheet is enabled
  75858. * @see http://doc.babylonjs.com/how_to/gui#image
  75859. */
  75860. get cellHeight(): number;
  75861. set cellHeight(value: number);
  75862. /**
  75863. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  75864. * @see http://doc.babylonjs.com/how_to/gui#image
  75865. */
  75866. get cellId(): number;
  75867. set cellId(value: number);
  75868. /**
  75869. * Creates a new Image
  75870. * @param name defines the control name
  75871. * @param url defines the image url
  75872. */
  75873. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  75874. /**
  75875. * Tests if a given coordinates belong to the current control
  75876. * @param x defines x coordinate to test
  75877. * @param y defines y coordinate to test
  75878. * @returns true if the coordinates are inside the control
  75879. */
  75880. contains(x: number, y: number): boolean;
  75881. protected _getTypeName(): string;
  75882. /** Force the control to synchronize with its content */
  75883. synchronizeSizeWithContent(): void;
  75884. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75885. private _prepareWorkingCanvasForOpaqueDetection;
  75886. private _drawImage;
  75887. _draw(context: CanvasRenderingContext2D): void;
  75888. private _renderCornerPatch;
  75889. private _renderNinePatch;
  75890. dispose(): void;
  75891. /** STRETCH_NONE */
  75892. static readonly STRETCH_NONE: number;
  75893. /** STRETCH_FILL */
  75894. static readonly STRETCH_FILL: number;
  75895. /** STRETCH_UNIFORM */
  75896. static readonly STRETCH_UNIFORM: number;
  75897. /** STRETCH_EXTEND */
  75898. static readonly STRETCH_EXTEND: number;
  75899. /** NINE_PATCH */
  75900. static readonly STRETCH_NINE_PATCH: number;
  75901. }
  75902. }
  75903. declare module BABYLON.GUI {
  75904. /**
  75905. * Class used to create 2D buttons
  75906. */
  75907. export class Button extends Rectangle {
  75908. name?: string | undefined;
  75909. /**
  75910. * Function called to generate a pointer enter animation
  75911. */
  75912. pointerEnterAnimation: () => void;
  75913. /**
  75914. * Function called to generate a pointer out animation
  75915. */
  75916. pointerOutAnimation: () => void;
  75917. /**
  75918. * Function called to generate a pointer down animation
  75919. */
  75920. pointerDownAnimation: () => void;
  75921. /**
  75922. * Function called to generate a pointer up animation
  75923. */
  75924. pointerUpAnimation: () => void;
  75925. /**
  75926. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  75927. */
  75928. delegatePickingToChildren: boolean;
  75929. private _image;
  75930. /**
  75931. * Returns the image part of the button (if any)
  75932. */
  75933. get image(): BABYLON.Nullable<Image>;
  75934. private _textBlock;
  75935. /**
  75936. * Returns the image part of the button (if any)
  75937. */
  75938. get textBlock(): BABYLON.Nullable<TextBlock>;
  75939. /**
  75940. * Creates a new Button
  75941. * @param name defines the name of the button
  75942. */
  75943. constructor(name?: string | undefined);
  75944. protected _getTypeName(): string;
  75945. /** @hidden */
  75946. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75947. /** @hidden */
  75948. _onPointerEnter(target: Control): boolean;
  75949. /** @hidden */
  75950. _onPointerOut(target: Control, force?: boolean): void;
  75951. /** @hidden */
  75952. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75953. /** @hidden */
  75954. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75955. /**
  75956. * Creates a new button made with an image and a text
  75957. * @param name defines the name of the button
  75958. * @param text defines the text of the button
  75959. * @param imageUrl defines the url of the image
  75960. * @returns a new Button
  75961. */
  75962. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  75963. /**
  75964. * Creates a new button made with an image
  75965. * @param name defines the name of the button
  75966. * @param imageUrl defines the url of the image
  75967. * @returns a new Button
  75968. */
  75969. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  75970. /**
  75971. * Creates a new button made with a text
  75972. * @param name defines the name of the button
  75973. * @param text defines the text of the button
  75974. * @returns a new Button
  75975. */
  75976. static CreateSimpleButton(name: string, text: string): Button;
  75977. /**
  75978. * Creates a new button made with an image and a centered text
  75979. * @param name defines the name of the button
  75980. * @param text defines the text of the button
  75981. * @param imageUrl defines the url of the image
  75982. * @returns a new Button
  75983. */
  75984. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  75985. }
  75986. }
  75987. declare module BABYLON.GUI {
  75988. /**
  75989. * Class used to create a 2D stack panel container
  75990. */
  75991. export class StackPanel extends Container {
  75992. name?: string | undefined;
  75993. private _isVertical;
  75994. private _manualWidth;
  75995. private _manualHeight;
  75996. private _doNotTrackManualChanges;
  75997. /**
  75998. * Gets or sets a boolean indicating that layou warnings should be ignored
  75999. */
  76000. ignoreLayoutWarnings: boolean;
  76001. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76002. get isVertical(): boolean;
  76003. set isVertical(value: boolean);
  76004. /**
  76005. * Gets or sets panel width.
  76006. * This value should not be set when in horizontal mode as it will be computed automatically
  76007. */
  76008. set width(value: string | number);
  76009. get width(): string | number;
  76010. /**
  76011. * Gets or sets panel height.
  76012. * This value should not be set when in vertical mode as it will be computed automatically
  76013. */
  76014. set height(value: string | number);
  76015. get height(): string | number;
  76016. /**
  76017. * Creates a new StackPanel
  76018. * @param name defines control name
  76019. */
  76020. constructor(name?: string | undefined);
  76021. protected _getTypeName(): string;
  76022. /** @hidden */
  76023. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76024. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76025. protected _postMeasure(): void;
  76026. }
  76027. }
  76028. declare module BABYLON.GUI {
  76029. /**
  76030. * Class used to represent a 2D checkbox
  76031. */
  76032. export class Checkbox extends Control {
  76033. name?: string | undefined;
  76034. private _isChecked;
  76035. private _background;
  76036. private _checkSizeRatio;
  76037. private _thickness;
  76038. /** Gets or sets border thickness */
  76039. get thickness(): number;
  76040. set thickness(value: number);
  76041. /**
  76042. * BABYLON.Observable raised when isChecked property changes
  76043. */
  76044. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76045. /** Gets or sets a value indicating the ratio between overall size and check size */
  76046. get checkSizeRatio(): number;
  76047. set checkSizeRatio(value: number);
  76048. /** Gets or sets background color */
  76049. get background(): string;
  76050. set background(value: string);
  76051. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76052. get isChecked(): boolean;
  76053. set isChecked(value: boolean);
  76054. /**
  76055. * Creates a new CheckBox
  76056. * @param name defines the control name
  76057. */
  76058. constructor(name?: string | undefined);
  76059. protected _getTypeName(): string;
  76060. /** @hidden */
  76061. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76062. /** @hidden */
  76063. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76064. /**
  76065. * Utility function to easily create a checkbox with a header
  76066. * @param title defines the label to use for the header
  76067. * @param onValueChanged defines the callback to call when value changes
  76068. * @returns a StackPanel containing the checkbox and a textBlock
  76069. */
  76070. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76071. }
  76072. }
  76073. declare module BABYLON.GUI {
  76074. /**
  76075. * Class used to store key control properties
  76076. */
  76077. export class KeyPropertySet {
  76078. /** Width */
  76079. width?: string;
  76080. /** Height */
  76081. height?: string;
  76082. /** Left padding */
  76083. paddingLeft?: string;
  76084. /** Right padding */
  76085. paddingRight?: string;
  76086. /** Top padding */
  76087. paddingTop?: string;
  76088. /** Bottom padding */
  76089. paddingBottom?: string;
  76090. /** Foreground color */
  76091. color?: string;
  76092. /** Background color */
  76093. background?: string;
  76094. }
  76095. /**
  76096. * Class used to create virtual keyboard
  76097. */
  76098. export class VirtualKeyboard extends StackPanel {
  76099. /** BABYLON.Observable raised when a key is pressed */
  76100. onKeyPressObservable: BABYLON.Observable<string>;
  76101. /** Gets or sets default key button width */
  76102. defaultButtonWidth: string;
  76103. /** Gets or sets default key button height */
  76104. defaultButtonHeight: string;
  76105. /** Gets or sets default key button left padding */
  76106. defaultButtonPaddingLeft: string;
  76107. /** Gets or sets default key button right padding */
  76108. defaultButtonPaddingRight: string;
  76109. /** Gets or sets default key button top padding */
  76110. defaultButtonPaddingTop: string;
  76111. /** Gets or sets default key button bottom padding */
  76112. defaultButtonPaddingBottom: string;
  76113. /** Gets or sets default key button foreground color */
  76114. defaultButtonColor: string;
  76115. /** Gets or sets default key button background color */
  76116. defaultButtonBackground: string;
  76117. /** Gets or sets shift button foreground color */
  76118. shiftButtonColor: string;
  76119. /** Gets or sets shift button thickness*/
  76120. selectedShiftThickness: number;
  76121. /** Gets shift key state */
  76122. shiftState: number;
  76123. protected _getTypeName(): string;
  76124. private _createKey;
  76125. /**
  76126. * Adds a new row of keys
  76127. * @param keys defines the list of keys to add
  76128. * @param propertySets defines the associated property sets
  76129. */
  76130. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76131. /**
  76132. * Set the shift key to a specific state
  76133. * @param shiftState defines the new shift state
  76134. */
  76135. applyShiftState(shiftState: number): void;
  76136. private _currentlyConnectedInputText;
  76137. private _connectedInputTexts;
  76138. private _onKeyPressObserver;
  76139. /** Gets the input text control currently attached to the keyboard */
  76140. get connectedInputText(): BABYLON.Nullable<InputText>;
  76141. /**
  76142. * Connects the keyboard with an input text control
  76143. *
  76144. * @param input defines the target control
  76145. */
  76146. connect(input: InputText): void;
  76147. /**
  76148. * Disconnects the keyboard from connected InputText controls
  76149. *
  76150. * @param input optionally defines a target control, otherwise all are disconnected
  76151. */
  76152. disconnect(input?: InputText): void;
  76153. private _removeConnectedInputObservables;
  76154. /**
  76155. * Release all resources
  76156. */
  76157. dispose(): void;
  76158. /**
  76159. * Creates a new keyboard using a default layout
  76160. *
  76161. * @param name defines control name
  76162. * @returns a new VirtualKeyboard
  76163. */
  76164. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76165. }
  76166. }
  76167. declare module BABYLON.GUI {
  76168. /**
  76169. * Class used to create input text control
  76170. */
  76171. export class InputText extends Control implements IFocusableControl {
  76172. name?: string | undefined;
  76173. private _text;
  76174. private _placeholderText;
  76175. private _background;
  76176. private _focusedBackground;
  76177. private _focusedColor;
  76178. private _placeholderColor;
  76179. private _thickness;
  76180. private _margin;
  76181. private _autoStretchWidth;
  76182. private _maxWidth;
  76183. private _isFocused;
  76184. private _blinkTimeout;
  76185. private _blinkIsEven;
  76186. private _cursorOffset;
  76187. private _scrollLeft;
  76188. private _textWidth;
  76189. private _clickedCoordinate;
  76190. private _deadKey;
  76191. private _addKey;
  76192. private _currentKey;
  76193. private _isTextHighlightOn;
  76194. private _textHighlightColor;
  76195. private _highligherOpacity;
  76196. private _highlightedText;
  76197. private _startHighlightIndex;
  76198. private _endHighlightIndex;
  76199. private _cursorIndex;
  76200. private _onFocusSelectAll;
  76201. private _isPointerDown;
  76202. private _onClipboardObserver;
  76203. private _onPointerDblTapObserver;
  76204. /** @hidden */
  76205. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76206. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76207. promptMessage: string;
  76208. /** Force disable prompt on mobile device */
  76209. disableMobilePrompt: boolean;
  76210. /** BABYLON.Observable raised when the text changes */
  76211. onTextChangedObservable: BABYLON.Observable<InputText>;
  76212. /** BABYLON.Observable raised just before an entered character is to be added */
  76213. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76214. /** BABYLON.Observable raised when the control gets the focus */
  76215. onFocusObservable: BABYLON.Observable<InputText>;
  76216. /** BABYLON.Observable raised when the control loses the focus */
  76217. onBlurObservable: BABYLON.Observable<InputText>;
  76218. /**Observable raised when the text is highlighted */
  76219. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76220. /**Observable raised when copy event is triggered */
  76221. onTextCopyObservable: BABYLON.Observable<InputText>;
  76222. /** BABYLON.Observable raised when cut event is triggered */
  76223. onTextCutObservable: BABYLON.Observable<InputText>;
  76224. /** BABYLON.Observable raised when paste event is triggered */
  76225. onTextPasteObservable: BABYLON.Observable<InputText>;
  76226. /** BABYLON.Observable raised when a key event was processed */
  76227. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76228. /** Gets or sets the maximum width allowed by the control */
  76229. get maxWidth(): string | number;
  76230. /** Gets the maximum width allowed by the control in pixels */
  76231. get maxWidthInPixels(): number;
  76232. set maxWidth(value: string | number);
  76233. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76234. get highligherOpacity(): number;
  76235. set highligherOpacity(value: number);
  76236. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76237. get onFocusSelectAll(): boolean;
  76238. set onFocusSelectAll(value: boolean);
  76239. /** Gets or sets the text hightlight color */
  76240. get textHighlightColor(): string;
  76241. set textHighlightColor(value: string);
  76242. /** Gets or sets control margin */
  76243. get margin(): string;
  76244. /** Gets control margin in pixels */
  76245. get marginInPixels(): number;
  76246. set margin(value: string);
  76247. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76248. get autoStretchWidth(): boolean;
  76249. set autoStretchWidth(value: boolean);
  76250. /** Gets or sets border thickness */
  76251. get thickness(): number;
  76252. set thickness(value: number);
  76253. /** Gets or sets the background color when focused */
  76254. get focusedBackground(): string;
  76255. set focusedBackground(value: string);
  76256. /** Gets or sets the background color when focused */
  76257. get focusedColor(): string;
  76258. set focusedColor(value: string);
  76259. /** Gets or sets the background color */
  76260. get background(): string;
  76261. set background(value: string);
  76262. /** Gets or sets the placeholder color */
  76263. get placeholderColor(): string;
  76264. set placeholderColor(value: string);
  76265. /** Gets or sets the text displayed when the control is empty */
  76266. get placeholderText(): string;
  76267. set placeholderText(value: string);
  76268. /** Gets or sets the dead key flag */
  76269. get deadKey(): boolean;
  76270. set deadKey(flag: boolean);
  76271. /** Gets or sets the highlight text */
  76272. get highlightedText(): string;
  76273. set highlightedText(text: string);
  76274. /** Gets or sets if the current key should be added */
  76275. get addKey(): boolean;
  76276. set addKey(flag: boolean);
  76277. /** Gets or sets the value of the current key being entered */
  76278. get currentKey(): string;
  76279. set currentKey(key: string);
  76280. /** Gets or sets the text displayed in the control */
  76281. get text(): string;
  76282. set text(value: string);
  76283. /** Gets or sets control width */
  76284. get width(): string | number;
  76285. set width(value: string | number);
  76286. /**
  76287. * Creates a new InputText
  76288. * @param name defines the control name
  76289. * @param text defines the text of the control
  76290. */
  76291. constructor(name?: string | undefined, text?: string);
  76292. /** @hidden */
  76293. onBlur(): void;
  76294. /** @hidden */
  76295. onFocus(): void;
  76296. protected _getTypeName(): string;
  76297. /**
  76298. * Function called to get the list of controls that should not steal the focus from this control
  76299. * @returns an array of controls
  76300. */
  76301. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76302. /** @hidden */
  76303. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76304. /** @hidden */
  76305. private _updateValueFromCursorIndex;
  76306. /** @hidden */
  76307. private _processDblClick;
  76308. /** @hidden */
  76309. private _selectAllText;
  76310. /**
  76311. * Handles the keyboard event
  76312. * @param evt Defines the KeyboardEvent
  76313. */
  76314. processKeyboard(evt: KeyboardEvent): void;
  76315. /** @hidden */
  76316. private _onCopyText;
  76317. /** @hidden */
  76318. private _onCutText;
  76319. /** @hidden */
  76320. private _onPasteText;
  76321. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76322. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76323. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76324. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76325. protected _beforeRenderText(text: string): string;
  76326. dispose(): void;
  76327. }
  76328. }
  76329. declare module BABYLON.GUI {
  76330. /**
  76331. * Class used to create a 2D grid container
  76332. */
  76333. export class Grid extends Container {
  76334. name?: string | undefined;
  76335. private _rowDefinitions;
  76336. private _columnDefinitions;
  76337. private _cells;
  76338. private _childControls;
  76339. /**
  76340. * Gets the number of columns
  76341. */
  76342. get columnCount(): number;
  76343. /**
  76344. * Gets the number of rows
  76345. */
  76346. get rowCount(): number;
  76347. /** Gets the list of children */
  76348. get children(): Control[];
  76349. /** Gets the list of cells (e.g. the containers) */
  76350. get cells(): {
  76351. [key: string]: Container;
  76352. };
  76353. /**
  76354. * Gets the definition of a specific row
  76355. * @param index defines the index of the row
  76356. * @returns the row definition
  76357. */
  76358. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76359. /**
  76360. * Gets the definition of a specific column
  76361. * @param index defines the index of the column
  76362. * @returns the column definition
  76363. */
  76364. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76365. /**
  76366. * Adds a new row to the grid
  76367. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76368. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76369. * @returns the current grid
  76370. */
  76371. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76372. /**
  76373. * Adds a new column to the grid
  76374. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76375. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76376. * @returns the current grid
  76377. */
  76378. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76379. /**
  76380. * Update a row definition
  76381. * @param index defines the index of the row to update
  76382. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76383. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76384. * @returns the current grid
  76385. */
  76386. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76387. /**
  76388. * Update a column definition
  76389. * @param index defines the index of the column to update
  76390. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76391. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76392. * @returns the current grid
  76393. */
  76394. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76395. /**
  76396. * Gets the list of children stored in a specific cell
  76397. * @param row defines the row to check
  76398. * @param column defines the column to check
  76399. * @returns the list of controls
  76400. */
  76401. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76402. /**
  76403. * Gets a string representing the child cell info (row x column)
  76404. * @param child defines the control to get info from
  76405. * @returns a string containing the child cell info (row x column)
  76406. */
  76407. getChildCellInfo(child: Control): string;
  76408. private _removeCell;
  76409. private _offsetCell;
  76410. /**
  76411. * Remove a column definition at specified index
  76412. * @param index defines the index of the column to remove
  76413. * @returns the current grid
  76414. */
  76415. removeColumnDefinition(index: number): Grid;
  76416. /**
  76417. * Remove a row definition at specified index
  76418. * @param index defines the index of the row to remove
  76419. * @returns the current grid
  76420. */
  76421. removeRowDefinition(index: number): Grid;
  76422. /**
  76423. * Adds a new control to the current grid
  76424. * @param control defines the control to add
  76425. * @param row defines the row where to add the control (0 by default)
  76426. * @param column defines the column where to add the control (0 by default)
  76427. * @returns the current grid
  76428. */
  76429. addControl(control: Control, row?: number, column?: number): Grid;
  76430. /**
  76431. * Removes a control from the current container
  76432. * @param control defines the control to remove
  76433. * @returns the current container
  76434. */
  76435. removeControl(control: Control): Container;
  76436. /**
  76437. * Creates a new Grid
  76438. * @param name defines control name
  76439. */
  76440. constructor(name?: string | undefined);
  76441. protected _getTypeName(): string;
  76442. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  76443. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76444. _flagDescendantsAsMatrixDirty(): void;
  76445. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76446. /** Releases associated resources */
  76447. dispose(): void;
  76448. }
  76449. }
  76450. declare module BABYLON.GUI {
  76451. /** Class used to create color pickers */
  76452. export class ColorPicker extends Control {
  76453. name?: string | undefined;
  76454. private static _Epsilon;
  76455. private _colorWheelCanvas;
  76456. private _value;
  76457. private _tmpColor;
  76458. private _pointerStartedOnSquare;
  76459. private _pointerStartedOnWheel;
  76460. private _squareLeft;
  76461. private _squareTop;
  76462. private _squareSize;
  76463. private _h;
  76464. private _s;
  76465. private _v;
  76466. private _lastPointerDownID;
  76467. /**
  76468. * BABYLON.Observable raised when the value changes
  76469. */
  76470. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  76471. /** Gets or sets the color of the color picker */
  76472. get value(): BABYLON.Color3;
  76473. set value(value: BABYLON.Color3);
  76474. /**
  76475. * Gets or sets control width
  76476. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76477. */
  76478. get width(): string | number;
  76479. set width(value: string | number);
  76480. /**
  76481. * Gets or sets control height
  76482. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  76483. */
  76484. get height(): string | number;
  76485. /** Gets or sets control height */
  76486. set height(value: string | number);
  76487. /** Gets or sets control size */
  76488. get size(): string | number;
  76489. set size(value: string | number);
  76490. /**
  76491. * Creates a new ColorPicker
  76492. * @param name defines the control name
  76493. */
  76494. constructor(name?: string | undefined);
  76495. protected _getTypeName(): string;
  76496. /** @hidden */
  76497. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76498. private _updateSquareProps;
  76499. private _drawGradientSquare;
  76500. private _drawCircle;
  76501. private _createColorWheelCanvas;
  76502. /** @hidden */
  76503. _draw(context: CanvasRenderingContext2D): void;
  76504. private _pointerIsDown;
  76505. private _updateValueFromPointer;
  76506. private _isPointOnSquare;
  76507. private _isPointOnWheel;
  76508. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76509. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76510. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76511. /**
  76512. * This function expands the color picker by creating a color picker dialog with manual
  76513. * color value input and the ability to save colors into an array to be used later in
  76514. * subsequent launches of the dialogue.
  76515. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  76516. * @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.
  76517. * @returns picked color as a hex string and the saved colors array as hex strings.
  76518. */
  76519. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  76520. pickerWidth?: string;
  76521. pickerHeight?: string;
  76522. headerHeight?: string;
  76523. lastColor?: string;
  76524. swatchLimit?: number;
  76525. numSwatchesPerLine?: number;
  76526. savedColors?: Array<string>;
  76527. }): Promise<{
  76528. savedColors?: string[];
  76529. pickedColor: string;
  76530. }>;
  76531. }
  76532. }
  76533. declare module BABYLON.GUI {
  76534. /** Class used to create 2D ellipse containers */
  76535. export class Ellipse extends Container {
  76536. name?: string | undefined;
  76537. private _thickness;
  76538. /** Gets or sets border thickness */
  76539. get thickness(): number;
  76540. set thickness(value: number);
  76541. /**
  76542. * Creates a new Ellipse
  76543. * @param name defines the control name
  76544. */
  76545. constructor(name?: string | undefined);
  76546. protected _getTypeName(): string;
  76547. protected _localDraw(context: CanvasRenderingContext2D): void;
  76548. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76549. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76550. }
  76551. }
  76552. declare module BABYLON.GUI {
  76553. /**
  76554. * Class used to create a password control
  76555. */
  76556. export class InputPassword extends InputText {
  76557. protected _beforeRenderText(text: string): string;
  76558. }
  76559. }
  76560. declare module BABYLON.GUI {
  76561. /** Class used to render 2D lines */
  76562. export class Line extends Control {
  76563. name?: string | undefined;
  76564. private _lineWidth;
  76565. private _x1;
  76566. private _y1;
  76567. private _x2;
  76568. private _y2;
  76569. private _dash;
  76570. private _connectedControl;
  76571. private _connectedControlDirtyObserver;
  76572. /** Gets or sets the dash pattern */
  76573. get dash(): Array<number>;
  76574. set dash(value: Array<number>);
  76575. /** Gets or sets the control connected with the line end */
  76576. get connectedControl(): Control;
  76577. set connectedControl(value: Control);
  76578. /** Gets or sets start coordinates on X axis */
  76579. get x1(): string | number;
  76580. set x1(value: string | number);
  76581. /** Gets or sets start coordinates on Y axis */
  76582. get y1(): string | number;
  76583. set y1(value: string | number);
  76584. /** Gets or sets end coordinates on X axis */
  76585. get x2(): string | number;
  76586. set x2(value: string | number);
  76587. /** Gets or sets end coordinates on Y axis */
  76588. get y2(): string | number;
  76589. set y2(value: string | number);
  76590. /** Gets or sets line width */
  76591. get lineWidth(): number;
  76592. set lineWidth(value: number);
  76593. /** Gets or sets horizontal alignment */
  76594. set horizontalAlignment(value: number);
  76595. /** Gets or sets vertical alignment */
  76596. set verticalAlignment(value: number);
  76597. private get _effectiveX2();
  76598. private get _effectiveY2();
  76599. /**
  76600. * Creates a new Line
  76601. * @param name defines the control name
  76602. */
  76603. constructor(name?: string | undefined);
  76604. protected _getTypeName(): string;
  76605. _draw(context: CanvasRenderingContext2D): void;
  76606. _measure(): void;
  76607. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76608. /**
  76609. * Move one end of the line given 3D cartesian coordinates.
  76610. * @param position Targeted world position
  76611. * @param scene BABYLON.Scene
  76612. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76613. */
  76614. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  76615. /**
  76616. * Move one end of the line to a position in screen absolute space.
  76617. * @param projectedPosition Position in screen absolute space (X, Y)
  76618. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  76619. */
  76620. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  76621. }
  76622. }
  76623. declare module BABYLON.GUI {
  76624. /**
  76625. * Class used to store a point for a MultiLine object.
  76626. * The point can be pure 2D coordinates, a mesh or a control
  76627. */
  76628. export class MultiLinePoint {
  76629. private _multiLine;
  76630. private _x;
  76631. private _y;
  76632. private _control;
  76633. private _mesh;
  76634. private _controlObserver;
  76635. private _meshObserver;
  76636. /** @hidden */
  76637. _point: BABYLON.Vector2;
  76638. /**
  76639. * Creates a new MultiLinePoint
  76640. * @param multiLine defines the source MultiLine object
  76641. */
  76642. constructor(multiLine: MultiLine);
  76643. /** Gets or sets x coordinate */
  76644. get x(): string | number;
  76645. set x(value: string | number);
  76646. /** Gets or sets y coordinate */
  76647. get y(): string | number;
  76648. set y(value: string | number);
  76649. /** Gets or sets the control associated with this point */
  76650. get control(): BABYLON.Nullable<Control>;
  76651. set control(value: BABYLON.Nullable<Control>);
  76652. /** Gets or sets the mesh associated with this point */
  76653. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76654. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  76655. /** Resets links */
  76656. resetLinks(): void;
  76657. /**
  76658. * Gets a translation vector
  76659. * @returns the translation vector
  76660. */
  76661. translate(): BABYLON.Vector2;
  76662. private _translatePoint;
  76663. /** Release associated resources */
  76664. dispose(): void;
  76665. }
  76666. }
  76667. declare module BABYLON.GUI {
  76668. /**
  76669. * Class used to create multi line control
  76670. */
  76671. export class MultiLine extends Control {
  76672. name?: string | undefined;
  76673. private _lineWidth;
  76674. private _dash;
  76675. private _points;
  76676. private _minX;
  76677. private _minY;
  76678. private _maxX;
  76679. private _maxY;
  76680. /**
  76681. * Creates a new MultiLine
  76682. * @param name defines the control name
  76683. */
  76684. constructor(name?: string | undefined);
  76685. /** Gets or sets dash pattern */
  76686. get dash(): Array<number>;
  76687. set dash(value: Array<number>);
  76688. /**
  76689. * Gets point stored at specified index
  76690. * @param index defines the index to look for
  76691. * @returns the requested point if found
  76692. */
  76693. getAt(index: number): MultiLinePoint;
  76694. /** Function called when a point is updated */
  76695. onPointUpdate: () => void;
  76696. /**
  76697. * Adds new points to the point collection
  76698. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  76699. * @returns the list of created MultiLinePoint
  76700. */
  76701. add(...items: (AbstractMesh | Control | {
  76702. x: string | number;
  76703. y: string | number;
  76704. })[]): MultiLinePoint[];
  76705. /**
  76706. * Adds a new point to the point collection
  76707. * @param item defines the item (mesh, control or 2d coordiantes) to add
  76708. * @returns the created MultiLinePoint
  76709. */
  76710. push(item?: (AbstractMesh | Control | {
  76711. x: string | number;
  76712. y: string | number;
  76713. })): MultiLinePoint;
  76714. /**
  76715. * Remove a specific value or point from the active point collection
  76716. * @param value defines the value or point to remove
  76717. */
  76718. remove(value: number | MultiLinePoint): void;
  76719. /**
  76720. * Resets this object to initial state (no point)
  76721. */
  76722. reset(): void;
  76723. /**
  76724. * Resets all links
  76725. */
  76726. resetLinks(): void;
  76727. /** Gets or sets line width */
  76728. get lineWidth(): number;
  76729. set lineWidth(value: number);
  76730. set horizontalAlignment(value: number);
  76731. set verticalAlignment(value: number);
  76732. protected _getTypeName(): string;
  76733. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76734. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76735. _measure(): void;
  76736. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76737. dispose(): void;
  76738. }
  76739. }
  76740. declare module BABYLON.GUI {
  76741. /**
  76742. * Class used to create radio button controls
  76743. */
  76744. export class RadioButton extends Control {
  76745. name?: string | undefined;
  76746. private _isChecked;
  76747. private _background;
  76748. private _checkSizeRatio;
  76749. private _thickness;
  76750. /** Gets or sets border thickness */
  76751. get thickness(): number;
  76752. set thickness(value: number);
  76753. /** Gets or sets group name */
  76754. group: string;
  76755. /** BABYLON.Observable raised when isChecked is changed */
  76756. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76757. /** Gets or sets a value indicating the ratio between overall size and check size */
  76758. get checkSizeRatio(): number;
  76759. set checkSizeRatio(value: number);
  76760. /** Gets or sets background color */
  76761. get background(): string;
  76762. set background(value: string);
  76763. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76764. get isChecked(): boolean;
  76765. set isChecked(value: boolean);
  76766. /**
  76767. * Creates a new RadioButton
  76768. * @param name defines the control name
  76769. */
  76770. constructor(name?: string | undefined);
  76771. protected _getTypeName(): string;
  76772. _draw(context: CanvasRenderingContext2D): void;
  76773. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76774. /**
  76775. * Utility function to easily create a radio button with a header
  76776. * @param title defines the label to use for the header
  76777. * @param group defines the group to use for the radio button
  76778. * @param isChecked defines the initial state of the radio button
  76779. * @param onValueChanged defines the callback to call when value changes
  76780. * @returns a StackPanel containing the radio button and a textBlock
  76781. */
  76782. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  76783. }
  76784. }
  76785. declare module BABYLON.GUI {
  76786. /**
  76787. * Class used to create slider controls
  76788. */
  76789. export class BaseSlider extends Control {
  76790. name?: string | undefined;
  76791. protected _thumbWidth: ValueAndUnit;
  76792. private _minimum;
  76793. private _maximum;
  76794. private _value;
  76795. private _isVertical;
  76796. protected _barOffset: ValueAndUnit;
  76797. private _isThumbClamped;
  76798. protected _displayThumb: boolean;
  76799. private _step;
  76800. private _lastPointerDownID;
  76801. protected _effectiveBarOffset: number;
  76802. protected _renderLeft: number;
  76803. protected _renderTop: number;
  76804. protected _renderWidth: number;
  76805. protected _renderHeight: number;
  76806. protected _backgroundBoxLength: number;
  76807. protected _backgroundBoxThickness: number;
  76808. protected _effectiveThumbThickness: number;
  76809. /** BABYLON.Observable raised when the sldier value changes */
  76810. onValueChangedObservable: BABYLON.Observable<number>;
  76811. /** Gets or sets a boolean indicating if the thumb must be rendered */
  76812. get displayThumb(): boolean;
  76813. set displayThumb(value: boolean);
  76814. /** Gets or sets a step to apply to values (0 by default) */
  76815. get step(): number;
  76816. set step(value: number);
  76817. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  76818. get barOffset(): string | number;
  76819. /** Gets main bar offset in pixels*/
  76820. get barOffsetInPixels(): number;
  76821. set barOffset(value: string | number);
  76822. /** Gets or sets thumb width */
  76823. get thumbWidth(): string | number;
  76824. /** Gets thumb width in pixels */
  76825. get thumbWidthInPixels(): number;
  76826. set thumbWidth(value: string | number);
  76827. /** Gets or sets minimum value */
  76828. get minimum(): number;
  76829. set minimum(value: number);
  76830. /** Gets or sets maximum value */
  76831. get maximum(): number;
  76832. set maximum(value: number);
  76833. /** Gets or sets current value */
  76834. get value(): number;
  76835. set value(value: number);
  76836. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  76837. get isVertical(): boolean;
  76838. set isVertical(value: boolean);
  76839. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  76840. get isThumbClamped(): boolean;
  76841. set isThumbClamped(value: boolean);
  76842. /**
  76843. * Creates a new BaseSlider
  76844. * @param name defines the control name
  76845. */
  76846. constructor(name?: string | undefined);
  76847. protected _getTypeName(): string;
  76848. protected _getThumbPosition(): number;
  76849. protected _getThumbThickness(type: string): number;
  76850. protected _prepareRenderingData(type: string): void;
  76851. private _pointerIsDown;
  76852. /** @hidden */
  76853. protected _updateValueFromPointer(x: number, y: number): void;
  76854. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76855. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76856. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76857. }
  76858. }
  76859. declare module BABYLON.GUI {
  76860. /**
  76861. * Class used to create slider controls
  76862. */
  76863. export class Slider extends BaseSlider {
  76864. name?: string | undefined;
  76865. private _background;
  76866. private _borderColor;
  76867. private _isThumbCircle;
  76868. protected _displayValueBar: boolean;
  76869. /** Gets or sets a boolean indicating if the value bar must be rendered */
  76870. get displayValueBar(): boolean;
  76871. set displayValueBar(value: boolean);
  76872. /** Gets or sets border color */
  76873. get borderColor(): string;
  76874. set borderColor(value: string);
  76875. /** Gets or sets background color */
  76876. get background(): string;
  76877. set background(value: string);
  76878. /** Gets or sets a boolean indicating if the thumb should be round or square */
  76879. get isThumbCircle(): boolean;
  76880. set isThumbCircle(value: boolean);
  76881. /**
  76882. * Creates a new Slider
  76883. * @param name defines the control name
  76884. */
  76885. constructor(name?: string | undefined);
  76886. protected _getTypeName(): string;
  76887. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76888. }
  76889. }
  76890. declare module BABYLON.GUI {
  76891. /** Class used to create a RadioGroup
  76892. * which contains groups of radio buttons
  76893. */
  76894. export class SelectorGroup {
  76895. /** name of SelectorGroup */
  76896. name: string;
  76897. private _groupPanel;
  76898. private _selectors;
  76899. private _groupHeader;
  76900. /**
  76901. * Creates a new SelectorGroup
  76902. * @param name of group, used as a group heading
  76903. */
  76904. constructor(
  76905. /** name of SelectorGroup */
  76906. name: string);
  76907. /** Gets the groupPanel of the SelectorGroup */
  76908. get groupPanel(): StackPanel;
  76909. /** Gets the selectors array */
  76910. get selectors(): StackPanel[];
  76911. /** Gets and sets the group header */
  76912. get header(): string;
  76913. set header(label: string);
  76914. /** @hidden */
  76915. private _addGroupHeader;
  76916. /** @hidden*/
  76917. _getSelector(selectorNb: number): StackPanel | undefined;
  76918. /** Removes the selector at the given position
  76919. * @param selectorNb the position of the selector within the group
  76920. */
  76921. removeSelector(selectorNb: number): void;
  76922. }
  76923. /** Class used to create a CheckboxGroup
  76924. * which contains groups of checkbox buttons
  76925. */
  76926. export class CheckboxGroup extends SelectorGroup {
  76927. /** Adds a checkbox as a control
  76928. * @param text is the label for the selector
  76929. * @param func is the function called when the Selector is checked
  76930. * @param checked is true when Selector is checked
  76931. */
  76932. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  76933. /** @hidden */
  76934. _setSelectorLabel(selectorNb: number, label: string): void;
  76935. /** @hidden */
  76936. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76937. /** @hidden */
  76938. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76939. /** @hidden */
  76940. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76941. }
  76942. /** Class used to create a RadioGroup
  76943. * which contains groups of radio buttons
  76944. */
  76945. export class RadioGroup extends SelectorGroup {
  76946. private _selectNb;
  76947. /** Adds a radio button as a control
  76948. * @param label is the label for the selector
  76949. * @param func is the function called when the Selector is checked
  76950. * @param checked is true when Selector is checked
  76951. */
  76952. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  76953. /** @hidden */
  76954. _setSelectorLabel(selectorNb: number, label: string): void;
  76955. /** @hidden */
  76956. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76957. /** @hidden */
  76958. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76959. /** @hidden */
  76960. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76961. }
  76962. /** Class used to create a SliderGroup
  76963. * which contains groups of slider buttons
  76964. */
  76965. export class SliderGroup extends SelectorGroup {
  76966. /**
  76967. * Adds a slider to the SelectorGroup
  76968. * @param label is the label for the SliderBar
  76969. * @param func is the function called when the Slider moves
  76970. * @param unit is a string describing the units used, eg degrees or metres
  76971. * @param min is the minimum value for the Slider
  76972. * @param max is the maximum value for the Slider
  76973. * @param value is the start value for the Slider between min and max
  76974. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  76975. */
  76976. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  76977. /** @hidden */
  76978. _setSelectorLabel(selectorNb: number, label: string): void;
  76979. /** @hidden */
  76980. _setSelectorLabelColor(selectorNb: number, color: string): void;
  76981. /** @hidden */
  76982. _setSelectorButtonColor(selectorNb: number, color: string): void;
  76983. /** @hidden */
  76984. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  76985. }
  76986. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  76987. * @see http://doc.babylonjs.com/how_to/selector
  76988. */
  76989. export class SelectionPanel extends Rectangle {
  76990. /** name of SelectionPanel */
  76991. name: string;
  76992. /** an array of SelectionGroups */
  76993. groups: SelectorGroup[];
  76994. private _panel;
  76995. private _buttonColor;
  76996. private _buttonBackground;
  76997. private _headerColor;
  76998. private _barColor;
  76999. private _barHeight;
  77000. private _spacerHeight;
  77001. private _labelColor;
  77002. private _groups;
  77003. private _bars;
  77004. /**
  77005. * Creates a new SelectionPanel
  77006. * @param name of SelectionPanel
  77007. * @param groups is an array of SelectionGroups
  77008. */
  77009. constructor(
  77010. /** name of SelectionPanel */
  77011. name: string,
  77012. /** an array of SelectionGroups */
  77013. groups?: SelectorGroup[]);
  77014. protected _getTypeName(): string;
  77015. /** Gets or sets the headerColor */
  77016. get headerColor(): string;
  77017. set headerColor(color: string);
  77018. private _setHeaderColor;
  77019. /** Gets or sets the button color */
  77020. get buttonColor(): string;
  77021. set buttonColor(color: string);
  77022. private _setbuttonColor;
  77023. /** Gets or sets the label color */
  77024. get labelColor(): string;
  77025. set labelColor(color: string);
  77026. private _setLabelColor;
  77027. /** Gets or sets the button background */
  77028. get buttonBackground(): string;
  77029. set buttonBackground(color: string);
  77030. private _setButtonBackground;
  77031. /** Gets or sets the color of separator bar */
  77032. get barColor(): string;
  77033. set barColor(color: string);
  77034. private _setBarColor;
  77035. /** Gets or sets the height of separator bar */
  77036. get barHeight(): string;
  77037. set barHeight(value: string);
  77038. private _setBarHeight;
  77039. /** Gets or sets the height of spacers*/
  77040. get spacerHeight(): string;
  77041. set spacerHeight(value: string);
  77042. private _setSpacerHeight;
  77043. /** Adds a bar between groups */
  77044. private _addSpacer;
  77045. /** Add a group to the selection panel
  77046. * @param group is the selector group to add
  77047. */
  77048. addGroup(group: SelectorGroup): void;
  77049. /** Remove the group from the given position
  77050. * @param groupNb is the position of the group in the list
  77051. */
  77052. removeGroup(groupNb: number): void;
  77053. /** Change a group header label
  77054. * @param label is the new group header label
  77055. * @param groupNb is the number of the group to relabel
  77056. * */
  77057. setHeaderName(label: string, groupNb: number): void;
  77058. /** Change selector label to the one given
  77059. * @param label is the new selector label
  77060. * @param groupNb is the number of the groupcontaining the selector
  77061. * @param selectorNb is the number of the selector within a group to relabel
  77062. * */
  77063. relabel(label: string, groupNb: number, selectorNb: number): void;
  77064. /** For a given group position remove the selector at the given position
  77065. * @param groupNb is the number of the group to remove the selector from
  77066. * @param selectorNb is the number of the selector within the group
  77067. */
  77068. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77069. /** For a given group position of correct type add a checkbox button
  77070. * @param groupNb is the number of the group to remove the selector from
  77071. * @param label is the label for the selector
  77072. * @param func is the function called when the Selector is checked
  77073. * @param checked is true when Selector is checked
  77074. */
  77075. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77076. /** For a given group position of correct type add a radio button
  77077. * @param groupNb is the number of the group to remove the selector from
  77078. * @param label is the label for the selector
  77079. * @param func is the function called when the Selector is checked
  77080. * @param checked is true when Selector is checked
  77081. */
  77082. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77083. /**
  77084. * For a given slider group add a slider
  77085. * @param groupNb is the number of the group to add the slider to
  77086. * @param label is the label for the Slider
  77087. * @param func is the function called when the Slider moves
  77088. * @param unit is a string describing the units used, eg degrees or metres
  77089. * @param min is the minimum value for the Slider
  77090. * @param max is the maximum value for the Slider
  77091. * @param value is the start value for the Slider between min and max
  77092. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77093. */
  77094. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77095. }
  77096. }
  77097. declare module BABYLON.GUI {
  77098. /**
  77099. * Class used to hold a the container for ScrollViewer
  77100. * @hidden
  77101. */
  77102. export class _ScrollViewerWindow extends Container {
  77103. parentClientWidth: number;
  77104. parentClientHeight: number;
  77105. private _freezeControls;
  77106. private _parentMeasure;
  77107. private _oldLeft;
  77108. private _oldTop;
  77109. get freezeControls(): boolean;
  77110. set freezeControls(value: boolean);
  77111. private _bucketWidth;
  77112. private _bucketHeight;
  77113. private _buckets;
  77114. private _bucketLen;
  77115. get bucketWidth(): number;
  77116. get bucketHeight(): number;
  77117. setBucketSizes(width: number, height: number): void;
  77118. private _useBuckets;
  77119. private _makeBuckets;
  77120. private _dispatchInBuckets;
  77121. private _updateMeasures;
  77122. private _updateChildrenMeasures;
  77123. private _restoreMeasures;
  77124. /**
  77125. * Creates a new ScrollViewerWindow
  77126. * @param name of ScrollViewerWindow
  77127. */
  77128. constructor(name?: string);
  77129. protected _getTypeName(): string;
  77130. /** @hidden */
  77131. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77132. /** @hidden */
  77133. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77134. private _scrollChildren;
  77135. private _scrollChildrenWithBuckets;
  77136. /** @hidden */
  77137. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77138. protected _postMeasure(): void;
  77139. }
  77140. }
  77141. declare module BABYLON.GUI {
  77142. /**
  77143. * Class used to create slider controls
  77144. */
  77145. export class ScrollBar extends BaseSlider {
  77146. name?: string | undefined;
  77147. private _background;
  77148. private _borderColor;
  77149. private _tempMeasure;
  77150. /** Gets or sets border color */
  77151. get borderColor(): string;
  77152. set borderColor(value: string);
  77153. /** Gets or sets background color */
  77154. get background(): string;
  77155. set background(value: string);
  77156. /**
  77157. * Creates a new Slider
  77158. * @param name defines the control name
  77159. */
  77160. constructor(name?: string | undefined);
  77161. protected _getTypeName(): string;
  77162. protected _getThumbThickness(): number;
  77163. _draw(context: CanvasRenderingContext2D): void;
  77164. private _first;
  77165. private _originX;
  77166. private _originY;
  77167. /** @hidden */
  77168. protected _updateValueFromPointer(x: number, y: number): void;
  77169. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77170. }
  77171. }
  77172. declare module BABYLON.GUI {
  77173. /**
  77174. * Class used to create slider controls
  77175. */
  77176. export class ImageScrollBar extends BaseSlider {
  77177. name?: string | undefined;
  77178. private _backgroundBaseImage;
  77179. private _backgroundImage;
  77180. private _thumbImage;
  77181. private _thumbBaseImage;
  77182. private _thumbLength;
  77183. private _thumbHeight;
  77184. private _barImageHeight;
  77185. private _tempMeasure;
  77186. /** Number of 90° rotation to apply on the images when in vertical mode */
  77187. num90RotationInVerticalMode: number;
  77188. /**
  77189. * Gets or sets the image used to render the background for horizontal bar
  77190. */
  77191. get backgroundImage(): Image;
  77192. set backgroundImage(value: Image);
  77193. /**
  77194. * Gets or sets the image used to render the thumb
  77195. */
  77196. get thumbImage(): Image;
  77197. set thumbImage(value: Image);
  77198. /**
  77199. * Gets or sets the length of the thumb
  77200. */
  77201. get thumbLength(): number;
  77202. set thumbLength(value: number);
  77203. /**
  77204. * Gets or sets the height of the thumb
  77205. */
  77206. get thumbHeight(): number;
  77207. set thumbHeight(value: number);
  77208. /**
  77209. * Gets or sets the height of the bar image
  77210. */
  77211. get barImageHeight(): number;
  77212. set barImageHeight(value: number);
  77213. /**
  77214. * Creates a new ImageScrollBar
  77215. * @param name defines the control name
  77216. */
  77217. constructor(name?: string | undefined);
  77218. protected _getTypeName(): string;
  77219. protected _getThumbThickness(): number;
  77220. _draw(context: CanvasRenderingContext2D): void;
  77221. private _first;
  77222. private _originX;
  77223. private _originY;
  77224. /** @hidden */
  77225. protected _updateValueFromPointer(x: number, y: number): void;
  77226. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77227. }
  77228. }
  77229. declare module BABYLON.GUI {
  77230. /**
  77231. * Class used to hold a viewer window and sliders in a grid
  77232. */
  77233. export class ScrollViewer extends Rectangle {
  77234. private _grid;
  77235. private _horizontalBarSpace;
  77236. private _verticalBarSpace;
  77237. private _dragSpace;
  77238. private _horizontalBar;
  77239. private _verticalBar;
  77240. private _barColor;
  77241. private _barBackground;
  77242. private _barImage;
  77243. private _horizontalBarImage;
  77244. private _verticalBarImage;
  77245. private _barBackgroundImage;
  77246. private _horizontalBarBackgroundImage;
  77247. private _verticalBarBackgroundImage;
  77248. private _barSize;
  77249. private _window;
  77250. private _pointerIsOver;
  77251. private _wheelPrecision;
  77252. private _onWheelObserver;
  77253. private _clientWidth;
  77254. private _clientHeight;
  77255. private _useImageBar;
  77256. private _thumbLength;
  77257. private _thumbHeight;
  77258. private _barImageHeight;
  77259. private _horizontalBarImageHeight;
  77260. private _verticalBarImageHeight;
  77261. private _oldWindowContentsWidth;
  77262. private _oldWindowContentsHeight;
  77263. /**
  77264. * Gets the horizontal scrollbar
  77265. */
  77266. get horizontalBar(): ScrollBar | ImageScrollBar;
  77267. /**
  77268. * Gets the vertical scrollbar
  77269. */
  77270. get verticalBar(): ScrollBar | ImageScrollBar;
  77271. /**
  77272. * Adds a new control to the current container
  77273. * @param control defines the control to add
  77274. * @returns the current container
  77275. */
  77276. addControl(control: BABYLON.Nullable<Control>): Container;
  77277. /**
  77278. * Removes a control from the current container
  77279. * @param control defines the control to remove
  77280. * @returns the current container
  77281. */
  77282. removeControl(control: Control): Container;
  77283. /** Gets the list of children */
  77284. get children(): Control[];
  77285. _flagDescendantsAsMatrixDirty(): void;
  77286. /**
  77287. * Freezes or unfreezes the controls in the window.
  77288. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77289. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77290. */
  77291. get freezeControls(): boolean;
  77292. set freezeControls(value: boolean);
  77293. /** Gets the bucket width */
  77294. get bucketWidth(): number;
  77295. /** Gets the bucket height */
  77296. get bucketHeight(): number;
  77297. /**
  77298. * Sets the bucket sizes.
  77299. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77300. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77301. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77302. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77303. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77304. * used), that's why it is not enabled by default.
  77305. * @param width width of the bucket
  77306. * @param height height of the bucket
  77307. */
  77308. setBucketSizes(width: number, height: number): void;
  77309. private _forceHorizontalBar;
  77310. private _forceVerticalBar;
  77311. /**
  77312. * Forces the horizontal scroll bar to be displayed
  77313. */
  77314. get forceHorizontalBar(): boolean;
  77315. set forceHorizontalBar(value: boolean);
  77316. /**
  77317. * Forces the vertical scroll bar to be displayed
  77318. */
  77319. get forceVerticalBar(): boolean;
  77320. set forceVerticalBar(value: boolean);
  77321. /**
  77322. * Creates a new ScrollViewer
  77323. * @param name of ScrollViewer
  77324. */
  77325. constructor(name?: string, isImageBased?: boolean);
  77326. /** Reset the scroll viewer window to initial size */
  77327. resetWindow(): void;
  77328. protected _getTypeName(): string;
  77329. private _buildClientSizes;
  77330. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77331. protected _postMeasure(): void;
  77332. /**
  77333. * Gets or sets the mouse wheel precision
  77334. * from 0 to 1 with a default value of 0.05
  77335. * */
  77336. get wheelPrecision(): number;
  77337. set wheelPrecision(value: number);
  77338. /** Gets or sets the scroll bar container background color */
  77339. get scrollBackground(): string;
  77340. set scrollBackground(color: string);
  77341. /** Gets or sets the bar color */
  77342. get barColor(): string;
  77343. set barColor(color: string);
  77344. /** Gets or sets the bar image */
  77345. get thumbImage(): Image;
  77346. set thumbImage(value: Image);
  77347. /** Gets or sets the horizontal bar image */
  77348. get horizontalThumbImage(): Image;
  77349. set horizontalThumbImage(value: Image);
  77350. /** Gets or sets the vertical bar image */
  77351. get verticalThumbImage(): Image;
  77352. set verticalThumbImage(value: Image);
  77353. /** Gets or sets the size of the bar */
  77354. get barSize(): number;
  77355. set barSize(value: number);
  77356. /** Gets or sets the length of the thumb */
  77357. get thumbLength(): number;
  77358. set thumbLength(value: number);
  77359. /** Gets or sets the height of the thumb */
  77360. get thumbHeight(): number;
  77361. set thumbHeight(value: number);
  77362. /** Gets or sets the height of the bar image */
  77363. get barImageHeight(): number;
  77364. set barImageHeight(value: number);
  77365. /** Gets or sets the height of the horizontal bar image */
  77366. get horizontalBarImageHeight(): number;
  77367. set horizontalBarImageHeight(value: number);
  77368. /** Gets or sets the height of the vertical bar image */
  77369. get verticalBarImageHeight(): number;
  77370. set verticalBarImageHeight(value: number);
  77371. /** Gets or sets the bar background */
  77372. get barBackground(): string;
  77373. set barBackground(color: string);
  77374. /** Gets or sets the bar background image */
  77375. get barImage(): Image;
  77376. set barImage(value: Image);
  77377. /** Gets or sets the horizontal bar background image */
  77378. get horizontalBarImage(): Image;
  77379. set horizontalBarImage(value: Image);
  77380. /** Gets or sets the vertical bar background image */
  77381. get verticalBarImage(): Image;
  77382. set verticalBarImage(value: Image);
  77383. private _setWindowPosition;
  77384. /** @hidden */
  77385. private _updateScroller;
  77386. _link(host: AdvancedDynamicTexture): void;
  77387. /** @hidden */
  77388. private _addBar;
  77389. /** @hidden */
  77390. private _attachWheel;
  77391. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77392. /** Releases associated resources */
  77393. dispose(): void;
  77394. }
  77395. }
  77396. declare module BABYLON.GUI {
  77397. /** Class used to render a grid */
  77398. export class DisplayGrid extends Control {
  77399. name?: string | undefined;
  77400. private _cellWidth;
  77401. private _cellHeight;
  77402. private _minorLineTickness;
  77403. private _minorLineColor;
  77404. private _majorLineTickness;
  77405. private _majorLineColor;
  77406. private _majorLineFrequency;
  77407. private _background;
  77408. private _displayMajorLines;
  77409. private _displayMinorLines;
  77410. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  77411. get displayMinorLines(): boolean;
  77412. set displayMinorLines(value: boolean);
  77413. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  77414. get displayMajorLines(): boolean;
  77415. set displayMajorLines(value: boolean);
  77416. /** Gets or sets background color (Black by default) */
  77417. get background(): string;
  77418. set background(value: string);
  77419. /** Gets or sets the width of each cell (20 by default) */
  77420. get cellWidth(): number;
  77421. set cellWidth(value: number);
  77422. /** Gets or sets the height of each cell (20 by default) */
  77423. get cellHeight(): number;
  77424. set cellHeight(value: number);
  77425. /** Gets or sets the tickness of minor lines (1 by default) */
  77426. get minorLineTickness(): number;
  77427. set minorLineTickness(value: number);
  77428. /** Gets or sets the color of minor lines (DarkGray by default) */
  77429. get minorLineColor(): string;
  77430. set minorLineColor(value: string);
  77431. /** Gets or sets the tickness of major lines (2 by default) */
  77432. get majorLineTickness(): number;
  77433. set majorLineTickness(value: number);
  77434. /** Gets or sets the color of major lines (White by default) */
  77435. get majorLineColor(): string;
  77436. set majorLineColor(value: string);
  77437. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  77438. get majorLineFrequency(): number;
  77439. set majorLineFrequency(value: number);
  77440. /**
  77441. * Creates a new GridDisplayRectangle
  77442. * @param name defines the control name
  77443. */
  77444. constructor(name?: string | undefined);
  77445. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77446. protected _getTypeName(): string;
  77447. }
  77448. }
  77449. declare module BABYLON.GUI {
  77450. /**
  77451. * Class used to create slider controls based on images
  77452. */
  77453. export class ImageBasedSlider extends BaseSlider {
  77454. name?: string | undefined;
  77455. private _backgroundImage;
  77456. private _thumbImage;
  77457. private _valueBarImage;
  77458. private _tempMeasure;
  77459. get displayThumb(): boolean;
  77460. set displayThumb(value: boolean);
  77461. /**
  77462. * Gets or sets the image used to render the background
  77463. */
  77464. get backgroundImage(): Image;
  77465. set backgroundImage(value: Image);
  77466. /**
  77467. * Gets or sets the image used to render the value bar
  77468. */
  77469. get valueBarImage(): Image;
  77470. set valueBarImage(value: Image);
  77471. /**
  77472. * Gets or sets the image used to render the thumb
  77473. */
  77474. get thumbImage(): Image;
  77475. set thumbImage(value: Image);
  77476. /**
  77477. * Creates a new ImageBasedSlider
  77478. * @param name defines the control name
  77479. */
  77480. constructor(name?: string | undefined);
  77481. protected _getTypeName(): string;
  77482. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77483. }
  77484. }
  77485. declare module BABYLON.GUI {
  77486. /**
  77487. * Forcing an export so that this code will execute
  77488. * @hidden
  77489. */
  77490. const name = "Statics";
  77491. }
  77492. declare module BABYLON.GUI {
  77493. /**
  77494. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  77495. */
  77496. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  77497. /**
  77498. * Define the instrumented AdvancedDynamicTexture.
  77499. */
  77500. texture: AdvancedDynamicTexture;
  77501. private _captureRenderTime;
  77502. private _renderTime;
  77503. private _captureLayoutTime;
  77504. private _layoutTime;
  77505. private _onBeginRenderObserver;
  77506. private _onEndRenderObserver;
  77507. private _onBeginLayoutObserver;
  77508. private _onEndLayoutObserver;
  77509. /**
  77510. * Gets the perf counter used to capture render time
  77511. */
  77512. get renderTimeCounter(): BABYLON.PerfCounter;
  77513. /**
  77514. * Gets the perf counter used to capture layout time
  77515. */
  77516. get layoutTimeCounter(): BABYLON.PerfCounter;
  77517. /**
  77518. * Enable or disable the render time capture
  77519. */
  77520. get captureRenderTime(): boolean;
  77521. set captureRenderTime(value: boolean);
  77522. /**
  77523. * Enable or disable the layout time capture
  77524. */
  77525. get captureLayoutTime(): boolean;
  77526. set captureLayoutTime(value: boolean);
  77527. /**
  77528. * Instantiates a new advanced dynamic texture instrumentation.
  77529. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  77530. * @param texture Defines the AdvancedDynamicTexture to instrument
  77531. */
  77532. constructor(
  77533. /**
  77534. * Define the instrumented AdvancedDynamicTexture.
  77535. */
  77536. texture: AdvancedDynamicTexture);
  77537. /**
  77538. * Dispose and release associated resources.
  77539. */
  77540. dispose(): void;
  77541. }
  77542. }
  77543. declare module BABYLON.GUI {
  77544. /**
  77545. * Class used to load GUI via XML.
  77546. */
  77547. export class XmlLoader {
  77548. private _nodes;
  77549. private _nodeTypes;
  77550. private _isLoaded;
  77551. private _objectAttributes;
  77552. private _parentClass;
  77553. /**
  77554. * Create a new xml loader
  77555. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  77556. */
  77557. constructor(parentClass?: null);
  77558. private _getChainElement;
  77559. private _getClassAttribute;
  77560. private _createGuiElement;
  77561. private _parseGrid;
  77562. private _parseElement;
  77563. private _prepareSourceElement;
  77564. private _parseElementsFromSource;
  77565. private _parseXml;
  77566. /**
  77567. * Gets if the loading has finished.
  77568. * @returns whether the loading has finished or not
  77569. */
  77570. isLoaded(): boolean;
  77571. /**
  77572. * Gets a loaded node / control by id.
  77573. * @param id the Controls id set in the xml
  77574. * @returns element of type Control
  77575. */
  77576. getNodeById(id: string): any;
  77577. /**
  77578. * Gets all loaded nodes / controls
  77579. * @returns Array of controls
  77580. */
  77581. getNodes(): any;
  77582. /**
  77583. * Initiates the xml layout loading
  77584. * @param xmlFile defines the xml layout to load
  77585. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  77586. * @param callback defines the callback called on layout load.
  77587. */
  77588. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  77589. }
  77590. }
  77591. declare module BABYLON.GUI {
  77592. /**
  77593. * Class used to create containers for controls
  77594. */
  77595. export class Container3D extends Control3D {
  77596. private _blockLayout;
  77597. /**
  77598. * Gets the list of child controls
  77599. */
  77600. protected _children: Control3D[];
  77601. /**
  77602. * Gets the list of child controls
  77603. */
  77604. get children(): Array<Control3D>;
  77605. /**
  77606. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  77607. * This is helpful to optimize layout operation when adding multiple children in a row
  77608. */
  77609. get blockLayout(): boolean;
  77610. set blockLayout(value: boolean);
  77611. /**
  77612. * Creates a new container
  77613. * @param name defines the container name
  77614. */
  77615. constructor(name?: string);
  77616. /**
  77617. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  77618. * @returns the current container
  77619. */
  77620. updateLayout(): Container3D;
  77621. /**
  77622. * Gets a boolean indicating if the given control is in the children of this control
  77623. * @param control defines the control to check
  77624. * @returns true if the control is in the child list
  77625. */
  77626. containsControl(control: Control3D): boolean;
  77627. /**
  77628. * Adds a control to the children of this control
  77629. * @param control defines the control to add
  77630. * @returns the current container
  77631. */
  77632. addControl(control: Control3D): Container3D;
  77633. /**
  77634. * This function will be called everytime a new control is added
  77635. */
  77636. protected _arrangeChildren(): void;
  77637. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77638. /**
  77639. * Removes a control from the children of this control
  77640. * @param control defines the control to remove
  77641. * @returns the current container
  77642. */
  77643. removeControl(control: Control3D): Container3D;
  77644. protected _getTypeName(): string;
  77645. /**
  77646. * Releases all associated resources
  77647. */
  77648. dispose(): void;
  77649. /** Control rotation will remain unchanged */
  77650. static readonly UNSET_ORIENTATION: number;
  77651. /** Control will rotate to make it look at sphere central axis */
  77652. static readonly FACEORIGIN_ORIENTATION: number;
  77653. /** Control will rotate to make it look back at sphere central axis */
  77654. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  77655. /** Control will rotate to look at z axis (0, 0, 1) */
  77656. static readonly FACEFORWARD_ORIENTATION: number;
  77657. /** Control will rotate to look at negative z axis (0, 0, -1) */
  77658. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  77659. }
  77660. }
  77661. declare module BABYLON.GUI {
  77662. /**
  77663. * Class used to manage 3D user interface
  77664. * @see http://doc.babylonjs.com/how_to/gui3d
  77665. */
  77666. export class GUI3DManager implements BABYLON.IDisposable {
  77667. private _scene;
  77668. private _sceneDisposeObserver;
  77669. private _utilityLayer;
  77670. private _rootContainer;
  77671. private _pointerObserver;
  77672. private _pointerOutObserver;
  77673. /** @hidden */
  77674. _lastPickedControl: Control3D;
  77675. /** @hidden */
  77676. _lastControlOver: {
  77677. [pointerId: number]: Control3D;
  77678. };
  77679. /** @hidden */
  77680. _lastControlDown: {
  77681. [pointerId: number]: Control3D;
  77682. };
  77683. /**
  77684. * BABYLON.Observable raised when the point picked by the pointer events changed
  77685. */
  77686. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  77687. /** @hidden */
  77688. _sharedMaterials: {
  77689. [key: string]: BABYLON.Material;
  77690. };
  77691. /** Gets the hosting scene */
  77692. get scene(): BABYLON.Scene;
  77693. /** Gets associated utility layer */
  77694. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  77695. /**
  77696. * Creates a new GUI3DManager
  77697. * @param scene
  77698. */
  77699. constructor(scene?: BABYLON.Scene);
  77700. private _handlePointerOut;
  77701. private _doPicking;
  77702. /**
  77703. * Gets the root container
  77704. */
  77705. get rootContainer(): Container3D;
  77706. /**
  77707. * Gets a boolean indicating if the given control is in the root child list
  77708. * @param control defines the control to check
  77709. * @returns true if the control is in the root child list
  77710. */
  77711. containsControl(control: Control3D): boolean;
  77712. /**
  77713. * Adds a control to the root child list
  77714. * @param control defines the control to add
  77715. * @returns the current manager
  77716. */
  77717. addControl(control: Control3D): GUI3DManager;
  77718. /**
  77719. * Removes a control from the root child list
  77720. * @param control defines the control to remove
  77721. * @returns the current container
  77722. */
  77723. removeControl(control: Control3D): GUI3DManager;
  77724. /**
  77725. * Releases all associated resources
  77726. */
  77727. dispose(): void;
  77728. }
  77729. }
  77730. declare module BABYLON.GUI {
  77731. /**
  77732. * Class used to transport BABYLON.Vector3 information for pointer events
  77733. */
  77734. export class Vector3WithInfo extends BABYLON.Vector3 {
  77735. /** defines the current mouse button index */
  77736. buttonIndex: number;
  77737. /**
  77738. * Creates a new Vector3WithInfo
  77739. * @param source defines the vector3 data to transport
  77740. * @param buttonIndex defines the current mouse button index
  77741. */
  77742. constructor(source: BABYLON.Vector3,
  77743. /** defines the current mouse button index */
  77744. buttonIndex?: number);
  77745. }
  77746. }
  77747. declare module BABYLON.GUI {
  77748. /**
  77749. * Class used as base class for controls
  77750. */
  77751. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  77752. /** Defines the control name */
  77753. name?: string | undefined;
  77754. /** @hidden */
  77755. _host: GUI3DManager;
  77756. private _node;
  77757. private _downCount;
  77758. private _enterCount;
  77759. private _downPointerIds;
  77760. private _isVisible;
  77761. /** Gets or sets the control position in world space */
  77762. get position(): BABYLON.Vector3;
  77763. set position(value: BABYLON.Vector3);
  77764. /** Gets or sets the control scaling in world space */
  77765. get scaling(): BABYLON.Vector3;
  77766. set scaling(value: BABYLON.Vector3);
  77767. /** Callback used to start pointer enter animation */
  77768. pointerEnterAnimation: () => void;
  77769. /** Callback used to start pointer out animation */
  77770. pointerOutAnimation: () => void;
  77771. /** Callback used to start pointer down animation */
  77772. pointerDownAnimation: () => void;
  77773. /** Callback used to start pointer up animation */
  77774. pointerUpAnimation: () => void;
  77775. /**
  77776. * An event triggered when the pointer move over the control
  77777. */
  77778. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  77779. /**
  77780. * An event triggered when the pointer move out of the control
  77781. */
  77782. onPointerOutObservable: BABYLON.Observable<Control3D>;
  77783. /**
  77784. * An event triggered when the pointer taps the control
  77785. */
  77786. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  77787. /**
  77788. * An event triggered when pointer is up
  77789. */
  77790. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  77791. /**
  77792. * An event triggered when a control is clicked on (with a mouse)
  77793. */
  77794. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  77795. /**
  77796. * An event triggered when pointer enters the control
  77797. */
  77798. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  77799. /**
  77800. * Gets or sets the parent container
  77801. */
  77802. parent: BABYLON.Nullable<Container3D>;
  77803. private _behaviors;
  77804. /**
  77805. * Gets the list of attached behaviors
  77806. * @see http://doc.babylonjs.com/features/behaviour
  77807. */
  77808. get behaviors(): BABYLON.Behavior<Control3D>[];
  77809. /**
  77810. * Attach a behavior to the control
  77811. * @see http://doc.babylonjs.com/features/behaviour
  77812. * @param behavior defines the behavior to attach
  77813. * @returns the current control
  77814. */
  77815. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77816. /**
  77817. * Remove an attached behavior
  77818. * @see http://doc.babylonjs.com/features/behaviour
  77819. * @param behavior defines the behavior to attach
  77820. * @returns the current control
  77821. */
  77822. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  77823. /**
  77824. * Gets an attached behavior by name
  77825. * @param name defines the name of the behavior to look for
  77826. * @see http://doc.babylonjs.com/features/behaviour
  77827. * @returns null if behavior was not found else the requested behavior
  77828. */
  77829. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  77830. /** Gets or sets a boolean indicating if the control is visible */
  77831. get isVisible(): boolean;
  77832. set isVisible(value: boolean);
  77833. /**
  77834. * Creates a new control
  77835. * @param name defines the control name
  77836. */
  77837. constructor(
  77838. /** Defines the control name */
  77839. name?: string | undefined);
  77840. /**
  77841. * Gets a string representing the class name
  77842. */
  77843. get typeName(): string;
  77844. /**
  77845. * Get the current class name of the control.
  77846. * @returns current class name
  77847. */
  77848. getClassName(): string;
  77849. protected _getTypeName(): string;
  77850. /**
  77851. * Gets the transform node used by this control
  77852. */
  77853. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  77854. /**
  77855. * Gets the mesh used to render this control
  77856. */
  77857. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77858. /**
  77859. * Link the control as child of the given node
  77860. * @param node defines the node to link to. Use null to unlink the control
  77861. * @returns the current control
  77862. */
  77863. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  77864. /** @hidden **/
  77865. _prepareNode(scene: BABYLON.Scene): void;
  77866. /**
  77867. * Node creation.
  77868. * Can be overriden by children
  77869. * @param scene defines the scene where the node must be attached
  77870. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  77871. */
  77872. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  77873. /**
  77874. * Affect a material to the given mesh
  77875. * @param mesh defines the mesh which will represent the control
  77876. */
  77877. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77878. /** @hidden */
  77879. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  77880. /** @hidden */
  77881. _onPointerEnter(target: Control3D): boolean;
  77882. /** @hidden */
  77883. _onPointerOut(target: Control3D): void;
  77884. /** @hidden */
  77885. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77886. /** @hidden */
  77887. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77888. /** @hidden */
  77889. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77890. /** @hidden */
  77891. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  77892. /** @hidden */
  77893. _disposeNode(): void;
  77894. /**
  77895. * Releases all associated resources
  77896. */
  77897. dispose(): void;
  77898. }
  77899. }
  77900. declare module BABYLON.GUI {
  77901. /**
  77902. * Class used as a root to all buttons
  77903. */
  77904. export class AbstractButton3D extends Control3D {
  77905. /**
  77906. * Creates a new button
  77907. * @param name defines the control name
  77908. */
  77909. constructor(name?: string);
  77910. protected _getTypeName(): string;
  77911. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77912. }
  77913. }
  77914. declare module BABYLON.GUI {
  77915. /**
  77916. * Class used to create a button in 3D
  77917. */
  77918. export class Button3D extends AbstractButton3D {
  77919. /** @hidden */
  77920. protected _currentMaterial: BABYLON.Material;
  77921. private _facadeTexture;
  77922. private _content;
  77923. private _contentResolution;
  77924. private _contentScaleRatio;
  77925. /**
  77926. * Gets or sets the texture resolution used to render content (512 by default)
  77927. */
  77928. get contentResolution(): BABYLON.int;
  77929. set contentResolution(value: BABYLON.int);
  77930. /**
  77931. * Gets or sets the texture scale ratio used to render content (2 by default)
  77932. */
  77933. get contentScaleRatio(): number;
  77934. set contentScaleRatio(value: number);
  77935. protected _disposeFacadeTexture(): void;
  77936. protected _resetContent(): void;
  77937. /**
  77938. * Creates a new button
  77939. * @param name defines the control name
  77940. */
  77941. constructor(name?: string);
  77942. /**
  77943. * Gets or sets the GUI 2D content used to display the button's facade
  77944. */
  77945. get content(): Control;
  77946. set content(value: Control);
  77947. /**
  77948. * Apply the facade texture (created from the content property).
  77949. * This function can be overloaded by child classes
  77950. * @param facadeTexture defines the AdvancedDynamicTexture to use
  77951. */
  77952. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  77953. protected _getTypeName(): string;
  77954. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  77955. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  77956. /**
  77957. * Releases all associated resources
  77958. */
  77959. dispose(): void;
  77960. }
  77961. }
  77962. declare module BABYLON.GUI {
  77963. /**
  77964. * Abstract class used to create a container panel deployed on the surface of a volume
  77965. */
  77966. export abstract class VolumeBasedPanel extends Container3D {
  77967. private _columns;
  77968. private _rows;
  77969. private _rowThenColum;
  77970. private _orientation;
  77971. protected _cellWidth: number;
  77972. protected _cellHeight: number;
  77973. /**
  77974. * Gets or sets the distance between elements
  77975. */
  77976. margin: number;
  77977. /**
  77978. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  77979. * | Value | Type | Description |
  77980. * | ----- | ----------------------------------- | ----------- |
  77981. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  77982. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  77983. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  77984. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  77985. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  77986. */
  77987. get orientation(): number;
  77988. set orientation(value: number);
  77989. /**
  77990. * Gets or sets the number of columns requested (10 by default).
  77991. * The panel will automatically compute the number of rows based on number of child controls.
  77992. */
  77993. get columns(): BABYLON.int;
  77994. set columns(value: BABYLON.int);
  77995. /**
  77996. * Gets or sets a the number of rows requested.
  77997. * The panel will automatically compute the number of columns based on number of child controls.
  77998. */
  77999. get rows(): BABYLON.int;
  78000. set rows(value: BABYLON.int);
  78001. /**
  78002. * Creates new VolumeBasedPanel
  78003. */
  78004. constructor();
  78005. protected _arrangeChildren(): void;
  78006. /** Child classes must implement this function to provide correct control positioning */
  78007. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78008. /** Child classes can implement this function to provide additional processing */
  78009. protected _finalProcessing(): void;
  78010. }
  78011. }
  78012. declare module BABYLON.GUI {
  78013. /**
  78014. * Class used to create a container panel deployed on the surface of a cylinder
  78015. */
  78016. export class CylinderPanel extends VolumeBasedPanel {
  78017. private _radius;
  78018. /**
  78019. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78020. */
  78021. get radius(): BABYLON.float;
  78022. set radius(value: BABYLON.float);
  78023. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78024. private _cylindricalMapping;
  78025. }
  78026. }
  78027. declare module BABYLON.GUI {
  78028. /** @hidden */
  78029. export var fluentVertexShader: {
  78030. name: string;
  78031. shader: string;
  78032. };
  78033. }
  78034. declare module BABYLON.GUI {
  78035. /** @hidden */
  78036. export var fluentPixelShader: {
  78037. name: string;
  78038. shader: string;
  78039. };
  78040. }
  78041. declare module BABYLON.GUI {
  78042. /** @hidden */
  78043. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78044. INNERGLOW: boolean;
  78045. BORDER: boolean;
  78046. HOVERLIGHT: boolean;
  78047. TEXTURE: boolean;
  78048. constructor();
  78049. }
  78050. /**
  78051. * Class used to render controls with fluent desgin
  78052. */
  78053. export class FluentMaterial extends BABYLON.PushMaterial {
  78054. /**
  78055. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78056. */
  78057. innerGlowColorIntensity: number;
  78058. /**
  78059. * Gets or sets the inner glow color (white by default)
  78060. */
  78061. innerGlowColor: BABYLON.Color3;
  78062. /**
  78063. * Gets or sets alpha value (default is 1.0)
  78064. */
  78065. alpha: number;
  78066. /**
  78067. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78068. */
  78069. albedoColor: BABYLON.Color3;
  78070. /**
  78071. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78072. */
  78073. renderBorders: boolean;
  78074. /**
  78075. * Gets or sets border width (default is 0.5)
  78076. */
  78077. borderWidth: number;
  78078. /**
  78079. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78080. */
  78081. edgeSmoothingValue: number;
  78082. /**
  78083. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78084. */
  78085. borderMinValue: number;
  78086. /**
  78087. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78088. */
  78089. renderHoverLight: boolean;
  78090. /**
  78091. * Gets or sets the radius used to render the hover light (default is 1.0)
  78092. */
  78093. hoverRadius: number;
  78094. /**
  78095. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78096. */
  78097. hoverColor: BABYLON.Color4;
  78098. /**
  78099. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78100. */
  78101. hoverPosition: BABYLON.Vector3;
  78102. private _albedoTexture;
  78103. /** Gets or sets the texture to use for albedo color */
  78104. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78105. /**
  78106. * Creates a new Fluent material
  78107. * @param name defines the name of the material
  78108. * @param scene defines the hosting scene
  78109. */
  78110. constructor(name: string, scene: BABYLON.Scene);
  78111. needAlphaBlending(): boolean;
  78112. needAlphaTesting(): boolean;
  78113. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78114. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78115. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78116. getActiveTextures(): BABYLON.BaseTexture[];
  78117. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78118. dispose(forceDisposeEffect?: boolean): void;
  78119. clone(name: string): FluentMaterial;
  78120. serialize(): any;
  78121. getClassName(): string;
  78122. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78123. }
  78124. }
  78125. declare module BABYLON.GUI {
  78126. /**
  78127. * Class used to create a holographic button in 3D
  78128. */
  78129. export class HolographicButton extends Button3D {
  78130. private _backPlate;
  78131. private _textPlate;
  78132. private _frontPlate;
  78133. private _text;
  78134. private _imageUrl;
  78135. private _shareMaterials;
  78136. private _frontMaterial;
  78137. private _backMaterial;
  78138. private _plateMaterial;
  78139. private _pickedPointObserver;
  78140. private _tooltipFade;
  78141. private _tooltipTextBlock;
  78142. private _tooltipTexture;
  78143. private _tooltipMesh;
  78144. private _tooltipHoverObserver;
  78145. private _tooltipOutObserver;
  78146. private _disposeTooltip;
  78147. /**
  78148. * Rendering ground id of all the mesh in the button
  78149. */
  78150. set renderingGroupId(id: number);
  78151. get renderingGroupId(): number;
  78152. /**
  78153. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78154. */
  78155. set tooltipText(text: BABYLON.Nullable<string>);
  78156. get tooltipText(): BABYLON.Nullable<string>;
  78157. /**
  78158. * Gets or sets text for the button
  78159. */
  78160. get text(): string;
  78161. set text(value: string);
  78162. /**
  78163. * Gets or sets the image url for the button
  78164. */
  78165. get imageUrl(): string;
  78166. set imageUrl(value: string);
  78167. /**
  78168. * Gets the back material used by this button
  78169. */
  78170. get backMaterial(): FluentMaterial;
  78171. /**
  78172. * Gets the front material used by this button
  78173. */
  78174. get frontMaterial(): FluentMaterial;
  78175. /**
  78176. * Gets the plate material used by this button
  78177. */
  78178. get plateMaterial(): BABYLON.StandardMaterial;
  78179. /**
  78180. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78181. */
  78182. get shareMaterials(): boolean;
  78183. /**
  78184. * Creates a new button
  78185. * @param name defines the control name
  78186. */
  78187. constructor(name?: string, shareMaterials?: boolean);
  78188. protected _getTypeName(): string;
  78189. private _rebuildContent;
  78190. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78191. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78192. private _createBackMaterial;
  78193. private _createFrontMaterial;
  78194. private _createPlateMaterial;
  78195. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78196. /**
  78197. * Releases all associated resources
  78198. */
  78199. dispose(): void;
  78200. }
  78201. }
  78202. declare module BABYLON.GUI {
  78203. /**
  78204. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78205. */
  78206. export class MeshButton3D extends Button3D {
  78207. /** @hidden */
  78208. protected _currentMesh: BABYLON.Mesh;
  78209. /**
  78210. * Creates a new 3D button based on a mesh
  78211. * @param mesh mesh to become a 3D button
  78212. * @param name defines the control name
  78213. */
  78214. constructor(mesh: BABYLON.Mesh, name?: string);
  78215. protected _getTypeName(): string;
  78216. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78217. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78218. }
  78219. }
  78220. declare module BABYLON.GUI {
  78221. /**
  78222. * Class used to create a container panel deployed on the surface of a plane
  78223. */
  78224. export class PlanePanel extends VolumeBasedPanel {
  78225. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78226. }
  78227. }
  78228. declare module BABYLON.GUI {
  78229. /**
  78230. * Class used to create a container panel where items get randomized planar mapping
  78231. */
  78232. export class ScatterPanel extends VolumeBasedPanel {
  78233. private _iteration;
  78234. /**
  78235. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78236. */
  78237. get iteration(): BABYLON.float;
  78238. set iteration(value: BABYLON.float);
  78239. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78240. private _scatterMapping;
  78241. protected _finalProcessing(): void;
  78242. }
  78243. }
  78244. declare module BABYLON.GUI {
  78245. /**
  78246. * Class used to create a container panel deployed on the surface of a sphere
  78247. */
  78248. export class SpherePanel extends VolumeBasedPanel {
  78249. private _radius;
  78250. /**
  78251. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78252. */
  78253. get radius(): BABYLON.float;
  78254. set radius(value: BABYLON.float);
  78255. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78256. private _sphericalMapping;
  78257. }
  78258. }
  78259. declare module BABYLON.GUI {
  78260. /**
  78261. * Class used to create a stack panel in 3D on XY plane
  78262. */
  78263. export class StackPanel3D extends Container3D {
  78264. private _isVertical;
  78265. /**
  78266. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78267. */
  78268. get isVertical(): boolean;
  78269. set isVertical(value: boolean);
  78270. /**
  78271. * Gets or sets the distance between elements
  78272. */
  78273. margin: number;
  78274. /**
  78275. * Creates new StackPanel
  78276. * @param isVertical
  78277. */
  78278. constructor(isVertical?: boolean);
  78279. protected _arrangeChildren(): void;
  78280. }
  78281. }
  78282. declare module BABYLON {
  78283. /**
  78284. * Configuration for glTF validation
  78285. */
  78286. export interface IGLTFValidationConfiguration {
  78287. /**
  78288. * The url of the glTF validator.
  78289. */
  78290. url: string;
  78291. }
  78292. /**
  78293. * glTF validation
  78294. */
  78295. export class GLTFValidation {
  78296. /**
  78297. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78298. */
  78299. static Configuration: IGLTFValidationConfiguration;
  78300. private static _LoadScriptPromise;
  78301. /**
  78302. * Validate a glTF asset using the glTF-Validator.
  78303. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78304. * @param rootUrl The root url for the glTF
  78305. * @param fileName The file name for the glTF
  78306. * @param getExternalResource The callback to get external resources for the glTF validator
  78307. * @returns A promise that resolves with the glTF validation results once complete
  78308. */
  78309. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78310. }
  78311. }
  78312. declare module BABYLON {
  78313. /**
  78314. * Mode that determines the coordinate system to use.
  78315. */
  78316. export enum GLTFLoaderCoordinateSystemMode {
  78317. /**
  78318. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78319. */
  78320. AUTO = 0,
  78321. /**
  78322. * Sets the useRightHandedSystem flag on the scene.
  78323. */
  78324. FORCE_RIGHT_HANDED = 1
  78325. }
  78326. /**
  78327. * Mode that determines what animations will start.
  78328. */
  78329. export enum GLTFLoaderAnimationStartMode {
  78330. /**
  78331. * No animation will start.
  78332. */
  78333. NONE = 0,
  78334. /**
  78335. * The first animation will start.
  78336. */
  78337. FIRST = 1,
  78338. /**
  78339. * All animations will start.
  78340. */
  78341. ALL = 2
  78342. }
  78343. /**
  78344. * Interface that contains the data for the glTF asset.
  78345. */
  78346. export interface IGLTFLoaderData {
  78347. /**
  78348. * The object that represents the glTF JSON.
  78349. */
  78350. json: Object;
  78351. /**
  78352. * The BIN chunk of a binary glTF.
  78353. */
  78354. bin: Nullable<IDataBuffer>;
  78355. }
  78356. /**
  78357. * Interface for extending the loader.
  78358. */
  78359. export interface IGLTFLoaderExtension {
  78360. /**
  78361. * The name of this extension.
  78362. */
  78363. readonly name: string;
  78364. /**
  78365. * Defines whether this extension is enabled.
  78366. */
  78367. enabled: boolean;
  78368. /**
  78369. * Defines the order of this extension.
  78370. * The loader sorts the extensions using these values when loading.
  78371. */
  78372. order?: number;
  78373. }
  78374. /**
  78375. * Loader state.
  78376. */
  78377. export enum GLTFLoaderState {
  78378. /**
  78379. * The asset is loading.
  78380. */
  78381. LOADING = 0,
  78382. /**
  78383. * The asset is ready for rendering.
  78384. */
  78385. READY = 1,
  78386. /**
  78387. * The asset is completely loaded.
  78388. */
  78389. COMPLETE = 2
  78390. }
  78391. /** @hidden */
  78392. export interface IImportMeshAsyncOutput {
  78393. meshes: AbstractMesh[];
  78394. particleSystems: IParticleSystem[];
  78395. skeletons: Skeleton[];
  78396. animationGroups: AnimationGroup[];
  78397. lights: Light[];
  78398. transformNodes: TransformNode[];
  78399. }
  78400. /** @hidden */
  78401. export interface IGLTFLoader extends IDisposable {
  78402. readonly state: Nullable<GLTFLoaderState>;
  78403. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78404. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  78405. }
  78406. /**
  78407. * File loader for loading glTF files into a scene.
  78408. */
  78409. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78410. /** @hidden */
  78411. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78412. /** @hidden */
  78413. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  78414. /**
  78415. * Raised when the asset has been parsed
  78416. */
  78417. onParsedObservable: Observable<IGLTFLoaderData>;
  78418. private _onParsedObserver;
  78419. /**
  78420. * Raised when the asset has been parsed
  78421. */
  78422. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  78423. /**
  78424. * 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.
  78425. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  78426. * Defaults to true.
  78427. * @hidden
  78428. */
  78429. static IncrementalLoading: boolean;
  78430. /**
  78431. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  78432. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  78433. * @hidden
  78434. */
  78435. static HomogeneousCoordinates: boolean;
  78436. /**
  78437. * The coordinate system mode. Defaults to AUTO.
  78438. */
  78439. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  78440. /**
  78441. * The animation start mode. Defaults to FIRST.
  78442. */
  78443. animationStartMode: GLTFLoaderAnimationStartMode;
  78444. /**
  78445. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  78446. */
  78447. compileMaterials: boolean;
  78448. /**
  78449. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  78450. */
  78451. useClipPlane: boolean;
  78452. /**
  78453. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  78454. */
  78455. compileShadowGenerators: boolean;
  78456. /**
  78457. * Defines if the Alpha blended materials are only applied as coverage.
  78458. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  78459. * If true, no extra effects are applied to transparent pixels.
  78460. */
  78461. transparencyAsCoverage: boolean;
  78462. /**
  78463. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  78464. * Enabling will disable offline support and glTF validator.
  78465. * Defaults to false.
  78466. */
  78467. useRangeRequests: boolean;
  78468. /**
  78469. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  78470. */
  78471. createInstances: boolean;
  78472. /**
  78473. * Function called before loading a url referenced by the asset.
  78474. */
  78475. preprocessUrlAsync: (url: string) => Promise<string>;
  78476. /**
  78477. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78478. */
  78479. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  78480. private _onMeshLoadedObserver;
  78481. /**
  78482. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  78483. */
  78484. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  78485. /**
  78486. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  78487. */
  78488. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  78489. private _onTextureLoadedObserver;
  78490. /**
  78491. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  78492. */
  78493. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  78494. /**
  78495. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  78496. */
  78497. readonly onMaterialLoadedObservable: Observable<Material>;
  78498. private _onMaterialLoadedObserver;
  78499. /**
  78500. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  78501. */
  78502. set onMaterialLoaded(callback: (material: Material) => void);
  78503. /**
  78504. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  78505. */
  78506. readonly onCameraLoadedObservable: Observable<Camera>;
  78507. private _onCameraLoadedObserver;
  78508. /**
  78509. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  78510. */
  78511. set onCameraLoaded(callback: (camera: Camera) => void);
  78512. /**
  78513. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  78514. * For assets with LODs, raised when all of the LODs are complete.
  78515. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78516. */
  78517. readonly onCompleteObservable: Observable<void>;
  78518. private _onCompleteObserver;
  78519. /**
  78520. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  78521. * For assets with LODs, raised when all of the LODs are complete.
  78522. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  78523. */
  78524. set onComplete(callback: () => void);
  78525. /**
  78526. * Observable raised when an error occurs.
  78527. */
  78528. readonly onErrorObservable: Observable<any>;
  78529. private _onErrorObserver;
  78530. /**
  78531. * Callback raised when an error occurs.
  78532. */
  78533. set onError(callback: (reason: any) => void);
  78534. /**
  78535. * Observable raised after the loader is disposed.
  78536. */
  78537. readonly onDisposeObservable: Observable<void>;
  78538. private _onDisposeObserver;
  78539. /**
  78540. * Callback raised after the loader is disposed.
  78541. */
  78542. set onDispose(callback: () => void);
  78543. /**
  78544. * Observable raised after a loader extension is created.
  78545. * Set additional options for a loader extension in this event.
  78546. */
  78547. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  78548. private _onExtensionLoadedObserver;
  78549. /**
  78550. * Callback raised after a loader extension is created.
  78551. */
  78552. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  78553. /**
  78554. * Defines if the loader logging is enabled.
  78555. */
  78556. get loggingEnabled(): boolean;
  78557. set loggingEnabled(value: boolean);
  78558. /**
  78559. * Defines if the loader should capture performance counters.
  78560. */
  78561. get capturePerformanceCounters(): boolean;
  78562. set capturePerformanceCounters(value: boolean);
  78563. /**
  78564. * Defines if the loader should validate the asset.
  78565. */
  78566. validate: boolean;
  78567. /**
  78568. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  78569. */
  78570. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  78571. private _onValidatedObserver;
  78572. /**
  78573. * Callback raised after a loader extension is created.
  78574. */
  78575. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  78576. private _loader;
  78577. /**
  78578. * Name of the loader ("gltf")
  78579. */
  78580. name: string;
  78581. /** @hidden */
  78582. extensions: ISceneLoaderPluginExtensions;
  78583. /**
  78584. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  78585. */
  78586. dispose(): void;
  78587. /** @hidden */
  78588. _clear(): void;
  78589. /** @hidden */
  78590. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78591. /** @hidden */
  78592. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  78593. /** @hidden */
  78594. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78595. meshes: AbstractMesh[];
  78596. particleSystems: IParticleSystem[];
  78597. skeletons: Skeleton[];
  78598. animationGroups: AnimationGroup[];
  78599. }>;
  78600. /** @hidden */
  78601. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78602. /** @hidden */
  78603. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  78604. /** @hidden */
  78605. canDirectLoad(data: string): boolean;
  78606. /** @hidden */
  78607. directLoad(scene: Scene, data: string): any;
  78608. /**
  78609. * The callback that allows custom handling of the root url based on the response url.
  78610. * @param rootUrl the original root url
  78611. * @param responseURL the response url if available
  78612. * @returns the new root url
  78613. */
  78614. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  78615. /** @hidden */
  78616. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  78617. /**
  78618. * The loader state or null if the loader is not active.
  78619. */
  78620. get loaderState(): Nullable<GLTFLoaderState>;
  78621. /**
  78622. * Returns a promise that resolves when the asset is completely loaded.
  78623. * @returns a promise that resolves when the asset is completely loaded.
  78624. */
  78625. whenCompleteAsync(): Promise<void>;
  78626. private _validate;
  78627. private _getLoader;
  78628. private _parseJson;
  78629. private _unpackBinaryAsync;
  78630. private _unpackBinaryV1Async;
  78631. private _unpackBinaryV2Async;
  78632. private static _parseVersion;
  78633. private static _compareVersion;
  78634. private static readonly _logSpaces;
  78635. private _logIndentLevel;
  78636. private _loggingEnabled;
  78637. /** @hidden */
  78638. _log: (message: string) => void;
  78639. /** @hidden */
  78640. _logOpen(message: string): void;
  78641. /** @hidden */
  78642. _logClose(): void;
  78643. private _logEnabled;
  78644. private _logDisabled;
  78645. private _capturePerformanceCounters;
  78646. /** @hidden */
  78647. _startPerformanceCounter: (counterName: string) => void;
  78648. /** @hidden */
  78649. _endPerformanceCounter: (counterName: string) => void;
  78650. private _startPerformanceCounterEnabled;
  78651. private _startPerformanceCounterDisabled;
  78652. private _endPerformanceCounterEnabled;
  78653. private _endPerformanceCounterDisabled;
  78654. }
  78655. }
  78656. declare module BABYLON.GLTF1 {
  78657. /**
  78658. * Enums
  78659. * @hidden
  78660. */
  78661. export enum EComponentType {
  78662. BYTE = 5120,
  78663. UNSIGNED_BYTE = 5121,
  78664. SHORT = 5122,
  78665. UNSIGNED_SHORT = 5123,
  78666. FLOAT = 5126
  78667. }
  78668. /** @hidden */
  78669. export enum EShaderType {
  78670. FRAGMENT = 35632,
  78671. VERTEX = 35633
  78672. }
  78673. /** @hidden */
  78674. export enum EParameterType {
  78675. BYTE = 5120,
  78676. UNSIGNED_BYTE = 5121,
  78677. SHORT = 5122,
  78678. UNSIGNED_SHORT = 5123,
  78679. INT = 5124,
  78680. UNSIGNED_INT = 5125,
  78681. FLOAT = 5126,
  78682. FLOAT_VEC2 = 35664,
  78683. FLOAT_VEC3 = 35665,
  78684. FLOAT_VEC4 = 35666,
  78685. INT_VEC2 = 35667,
  78686. INT_VEC3 = 35668,
  78687. INT_VEC4 = 35669,
  78688. BOOL = 35670,
  78689. BOOL_VEC2 = 35671,
  78690. BOOL_VEC3 = 35672,
  78691. BOOL_VEC4 = 35673,
  78692. FLOAT_MAT2 = 35674,
  78693. FLOAT_MAT3 = 35675,
  78694. FLOAT_MAT4 = 35676,
  78695. SAMPLER_2D = 35678
  78696. }
  78697. /** @hidden */
  78698. export enum ETextureWrapMode {
  78699. CLAMP_TO_EDGE = 33071,
  78700. MIRRORED_REPEAT = 33648,
  78701. REPEAT = 10497
  78702. }
  78703. /** @hidden */
  78704. export enum ETextureFilterType {
  78705. NEAREST = 9728,
  78706. LINEAR = 9728,
  78707. NEAREST_MIPMAP_NEAREST = 9984,
  78708. LINEAR_MIPMAP_NEAREST = 9985,
  78709. NEAREST_MIPMAP_LINEAR = 9986,
  78710. LINEAR_MIPMAP_LINEAR = 9987
  78711. }
  78712. /** @hidden */
  78713. export enum ETextureFormat {
  78714. ALPHA = 6406,
  78715. RGB = 6407,
  78716. RGBA = 6408,
  78717. LUMINANCE = 6409,
  78718. LUMINANCE_ALPHA = 6410
  78719. }
  78720. /** @hidden */
  78721. export enum ECullingType {
  78722. FRONT = 1028,
  78723. BACK = 1029,
  78724. FRONT_AND_BACK = 1032
  78725. }
  78726. /** @hidden */
  78727. export enum EBlendingFunction {
  78728. ZERO = 0,
  78729. ONE = 1,
  78730. SRC_COLOR = 768,
  78731. ONE_MINUS_SRC_COLOR = 769,
  78732. DST_COLOR = 774,
  78733. ONE_MINUS_DST_COLOR = 775,
  78734. SRC_ALPHA = 770,
  78735. ONE_MINUS_SRC_ALPHA = 771,
  78736. DST_ALPHA = 772,
  78737. ONE_MINUS_DST_ALPHA = 773,
  78738. CONSTANT_COLOR = 32769,
  78739. ONE_MINUS_CONSTANT_COLOR = 32770,
  78740. CONSTANT_ALPHA = 32771,
  78741. ONE_MINUS_CONSTANT_ALPHA = 32772,
  78742. SRC_ALPHA_SATURATE = 776
  78743. }
  78744. /** @hidden */
  78745. export interface IGLTFProperty {
  78746. extensions?: {
  78747. [key: string]: any;
  78748. };
  78749. extras?: Object;
  78750. }
  78751. /** @hidden */
  78752. export interface IGLTFChildRootProperty extends IGLTFProperty {
  78753. name?: string;
  78754. }
  78755. /** @hidden */
  78756. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  78757. bufferView: string;
  78758. byteOffset: number;
  78759. byteStride: number;
  78760. count: number;
  78761. type: string;
  78762. componentType: EComponentType;
  78763. max?: number[];
  78764. min?: number[];
  78765. name?: string;
  78766. }
  78767. /** @hidden */
  78768. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  78769. buffer: string;
  78770. byteOffset: number;
  78771. byteLength: number;
  78772. byteStride: number;
  78773. target?: number;
  78774. }
  78775. /** @hidden */
  78776. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  78777. uri: string;
  78778. byteLength?: number;
  78779. type?: string;
  78780. }
  78781. /** @hidden */
  78782. export interface IGLTFShader extends IGLTFChildRootProperty {
  78783. uri: string;
  78784. type: EShaderType;
  78785. }
  78786. /** @hidden */
  78787. export interface IGLTFProgram extends IGLTFChildRootProperty {
  78788. attributes: string[];
  78789. fragmentShader: string;
  78790. vertexShader: string;
  78791. }
  78792. /** @hidden */
  78793. export interface IGLTFTechniqueParameter {
  78794. type: number;
  78795. count?: number;
  78796. semantic?: string;
  78797. node?: string;
  78798. value?: number | boolean | string | Array<any>;
  78799. source?: string;
  78800. babylonValue?: any;
  78801. }
  78802. /** @hidden */
  78803. export interface IGLTFTechniqueCommonProfile {
  78804. lightingModel: string;
  78805. texcoordBindings: Object;
  78806. parameters?: Array<any>;
  78807. }
  78808. /** @hidden */
  78809. export interface IGLTFTechniqueStatesFunctions {
  78810. blendColor?: number[];
  78811. blendEquationSeparate?: number[];
  78812. blendFuncSeparate?: number[];
  78813. colorMask: boolean[];
  78814. cullFace: number[];
  78815. }
  78816. /** @hidden */
  78817. export interface IGLTFTechniqueStates {
  78818. enable: number[];
  78819. functions: IGLTFTechniqueStatesFunctions;
  78820. }
  78821. /** @hidden */
  78822. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  78823. parameters: {
  78824. [key: string]: IGLTFTechniqueParameter;
  78825. };
  78826. program: string;
  78827. attributes: {
  78828. [key: string]: string;
  78829. };
  78830. uniforms: {
  78831. [key: string]: string;
  78832. };
  78833. states: IGLTFTechniqueStates;
  78834. }
  78835. /** @hidden */
  78836. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  78837. technique?: string;
  78838. values: string[];
  78839. }
  78840. /** @hidden */
  78841. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  78842. attributes: {
  78843. [key: string]: string;
  78844. };
  78845. indices: string;
  78846. material: string;
  78847. mode?: number;
  78848. }
  78849. /** @hidden */
  78850. export interface IGLTFMesh extends IGLTFChildRootProperty {
  78851. primitives: IGLTFMeshPrimitive[];
  78852. }
  78853. /** @hidden */
  78854. export interface IGLTFImage extends IGLTFChildRootProperty {
  78855. uri: string;
  78856. }
  78857. /** @hidden */
  78858. export interface IGLTFSampler extends IGLTFChildRootProperty {
  78859. magFilter?: number;
  78860. minFilter?: number;
  78861. wrapS?: number;
  78862. wrapT?: number;
  78863. }
  78864. /** @hidden */
  78865. export interface IGLTFTexture extends IGLTFChildRootProperty {
  78866. sampler: string;
  78867. source: string;
  78868. format?: ETextureFormat;
  78869. internalFormat?: ETextureFormat;
  78870. target?: number;
  78871. type?: number;
  78872. babylonTexture?: Texture;
  78873. }
  78874. /** @hidden */
  78875. export interface IGLTFAmbienLight {
  78876. color?: number[];
  78877. }
  78878. /** @hidden */
  78879. export interface IGLTFDirectionalLight {
  78880. color?: number[];
  78881. }
  78882. /** @hidden */
  78883. export interface IGLTFPointLight {
  78884. color?: number[];
  78885. constantAttenuation?: number;
  78886. linearAttenuation?: number;
  78887. quadraticAttenuation?: number;
  78888. }
  78889. /** @hidden */
  78890. export interface IGLTFSpotLight {
  78891. color?: number[];
  78892. constantAttenuation?: number;
  78893. fallOfAngle?: number;
  78894. fallOffExponent?: number;
  78895. linearAttenuation?: number;
  78896. quadraticAttenuation?: number;
  78897. }
  78898. /** @hidden */
  78899. export interface IGLTFLight extends IGLTFChildRootProperty {
  78900. type: string;
  78901. }
  78902. /** @hidden */
  78903. export interface IGLTFCameraOrthographic {
  78904. xmag: number;
  78905. ymag: number;
  78906. zfar: number;
  78907. znear: number;
  78908. }
  78909. /** @hidden */
  78910. export interface IGLTFCameraPerspective {
  78911. aspectRatio: number;
  78912. yfov: number;
  78913. zfar: number;
  78914. znear: number;
  78915. }
  78916. /** @hidden */
  78917. export interface IGLTFCamera extends IGLTFChildRootProperty {
  78918. type: string;
  78919. }
  78920. /** @hidden */
  78921. export interface IGLTFAnimationChannelTarget {
  78922. id: string;
  78923. path: string;
  78924. }
  78925. /** @hidden */
  78926. export interface IGLTFAnimationChannel {
  78927. sampler: string;
  78928. target: IGLTFAnimationChannelTarget;
  78929. }
  78930. /** @hidden */
  78931. export interface IGLTFAnimationSampler {
  78932. input: string;
  78933. output: string;
  78934. interpolation?: string;
  78935. }
  78936. /** @hidden */
  78937. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  78938. channels?: IGLTFAnimationChannel[];
  78939. parameters?: {
  78940. [key: string]: string;
  78941. };
  78942. samplers?: {
  78943. [key: string]: IGLTFAnimationSampler;
  78944. };
  78945. }
  78946. /** @hidden */
  78947. export interface IGLTFNodeInstanceSkin {
  78948. skeletons: string[];
  78949. skin: string;
  78950. meshes: string[];
  78951. }
  78952. /** @hidden */
  78953. export interface IGLTFSkins extends IGLTFChildRootProperty {
  78954. bindShapeMatrix: number[];
  78955. inverseBindMatrices: string;
  78956. jointNames: string[];
  78957. babylonSkeleton?: Skeleton;
  78958. }
  78959. /** @hidden */
  78960. export interface IGLTFNode extends IGLTFChildRootProperty {
  78961. camera?: string;
  78962. children: string[];
  78963. skin?: string;
  78964. jointName?: string;
  78965. light?: string;
  78966. matrix: number[];
  78967. mesh?: string;
  78968. meshes?: string[];
  78969. rotation?: number[];
  78970. scale?: number[];
  78971. translation?: number[];
  78972. babylonNode?: Node;
  78973. }
  78974. /** @hidden */
  78975. export interface IGLTFScene extends IGLTFChildRootProperty {
  78976. nodes: string[];
  78977. }
  78978. /** @hidden */
  78979. export interface IGLTFRuntime {
  78980. extensions: {
  78981. [key: string]: any;
  78982. };
  78983. accessors: {
  78984. [key: string]: IGLTFAccessor;
  78985. };
  78986. buffers: {
  78987. [key: string]: IGLTFBuffer;
  78988. };
  78989. bufferViews: {
  78990. [key: string]: IGLTFBufferView;
  78991. };
  78992. meshes: {
  78993. [key: string]: IGLTFMesh;
  78994. };
  78995. lights: {
  78996. [key: string]: IGLTFLight;
  78997. };
  78998. cameras: {
  78999. [key: string]: IGLTFCamera;
  79000. };
  79001. nodes: {
  79002. [key: string]: IGLTFNode;
  79003. };
  79004. images: {
  79005. [key: string]: IGLTFImage;
  79006. };
  79007. textures: {
  79008. [key: string]: IGLTFTexture;
  79009. };
  79010. shaders: {
  79011. [key: string]: IGLTFShader;
  79012. };
  79013. programs: {
  79014. [key: string]: IGLTFProgram;
  79015. };
  79016. samplers: {
  79017. [key: string]: IGLTFSampler;
  79018. };
  79019. techniques: {
  79020. [key: string]: IGLTFTechnique;
  79021. };
  79022. materials: {
  79023. [key: string]: IGLTFMaterial;
  79024. };
  79025. animations: {
  79026. [key: string]: IGLTFAnimation;
  79027. };
  79028. skins: {
  79029. [key: string]: IGLTFSkins;
  79030. };
  79031. currentScene?: Object;
  79032. scenes: {
  79033. [key: string]: IGLTFScene;
  79034. };
  79035. extensionsUsed: string[];
  79036. extensionsRequired?: string[];
  79037. buffersCount: number;
  79038. shaderscount: number;
  79039. scene: Scene;
  79040. rootUrl: string;
  79041. loadedBufferCount: number;
  79042. loadedBufferViews: {
  79043. [name: string]: ArrayBufferView;
  79044. };
  79045. loadedShaderCount: number;
  79046. importOnlyMeshes: boolean;
  79047. importMeshesNames?: string[];
  79048. dummyNodes: Node[];
  79049. forAssetContainer: boolean;
  79050. }
  79051. /** @hidden */
  79052. export interface INodeToRoot {
  79053. bone: Bone;
  79054. node: IGLTFNode;
  79055. id: string;
  79056. }
  79057. /** @hidden */
  79058. export interface IJointNode {
  79059. node: IGLTFNode;
  79060. id: string;
  79061. }
  79062. }
  79063. declare module BABYLON.GLTF1 {
  79064. /**
  79065. * Utils functions for GLTF
  79066. * @hidden
  79067. */
  79068. export class GLTFUtils {
  79069. /**
  79070. * Sets the given "parameter" matrix
  79071. * @param scene: the Scene object
  79072. * @param source: the source node where to pick the matrix
  79073. * @param parameter: the GLTF technique parameter
  79074. * @param uniformName: the name of the shader's uniform
  79075. * @param shaderMaterial: the shader material
  79076. */
  79077. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79078. /**
  79079. * Sets the given "parameter" matrix
  79080. * @param shaderMaterial: the shader material
  79081. * @param uniform: the name of the shader's uniform
  79082. * @param value: the value of the uniform
  79083. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79084. */
  79085. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79086. /**
  79087. * Returns the wrap mode of the texture
  79088. * @param mode: the mode value
  79089. */
  79090. static GetWrapMode(mode: number): number;
  79091. /**
  79092. * Returns the byte stride giving an accessor
  79093. * @param accessor: the GLTF accessor objet
  79094. */
  79095. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79096. /**
  79097. * Returns the texture filter mode giving a mode value
  79098. * @param mode: the filter mode value
  79099. */
  79100. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79101. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79102. /**
  79103. * Returns a buffer from its accessor
  79104. * @param gltfRuntime: the GLTF runtime
  79105. * @param accessor: the GLTF accessor
  79106. */
  79107. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79108. /**
  79109. * Decodes a buffer view into a string
  79110. * @param view: the buffer view
  79111. */
  79112. static DecodeBufferToText(view: ArrayBufferView): string;
  79113. /**
  79114. * Returns the default material of gltf. Related to
  79115. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79116. * @param scene: the Babylon.js scene
  79117. */
  79118. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79119. private static _DefaultMaterial;
  79120. }
  79121. }
  79122. declare module BABYLON.GLTF1 {
  79123. /**
  79124. * Implementation of the base glTF spec
  79125. * @hidden
  79126. */
  79127. export class GLTFLoaderBase {
  79128. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79129. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79130. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79131. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79132. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79133. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79134. }
  79135. /**
  79136. * glTF V1 Loader
  79137. * @hidden
  79138. */
  79139. export class GLTFLoader implements IGLTFLoader {
  79140. static Extensions: {
  79141. [name: string]: GLTFLoaderExtension;
  79142. };
  79143. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79144. state: Nullable<GLTFLoaderState>;
  79145. dispose(): void;
  79146. private _importMeshAsync;
  79147. /**
  79148. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79149. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79150. * @param scene the scene the meshes should be added to
  79151. * @param forAssetContainer defines if the entities must be stored in the scene
  79152. * @param data gltf data containing information of the meshes in a loaded file
  79153. * @param rootUrl root url to load from
  79154. * @param onProgress event that fires when loading progress has occured
  79155. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79156. */
  79157. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79158. private _loadAsync;
  79159. /**
  79160. * Imports all objects from a loaded gltf file and adds them to the scene
  79161. * @param scene the scene the objects should be added to
  79162. * @param data gltf data containing information of the meshes in a loaded file
  79163. * @param rootUrl root url to load from
  79164. * @param onProgress event that fires when loading progress has occured
  79165. * @returns a promise which completes when objects have been loaded to the scene
  79166. */
  79167. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  79168. private _loadShadersAsync;
  79169. private _loadBuffersAsync;
  79170. private _createNodes;
  79171. }
  79172. /** @hidden */
  79173. export abstract class GLTFLoaderExtension {
  79174. private _name;
  79175. constructor(name: string);
  79176. get name(): string;
  79177. /**
  79178. * Defines an override for loading the runtime
  79179. * Return true to stop further extensions from loading the runtime
  79180. */
  79181. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79182. /**
  79183. * Defines an onverride for creating gltf runtime
  79184. * Return true to stop further extensions from creating the runtime
  79185. */
  79186. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79187. /**
  79188. * Defines an override for loading buffers
  79189. * Return true to stop further extensions from loading this buffer
  79190. */
  79191. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79192. /**
  79193. * Defines an override for loading texture buffers
  79194. * Return true to stop further extensions from loading this texture data
  79195. */
  79196. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79197. /**
  79198. * Defines an override for creating textures
  79199. * Return true to stop further extensions from loading this texture
  79200. */
  79201. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79202. /**
  79203. * Defines an override for loading shader strings
  79204. * Return true to stop further extensions from loading this shader data
  79205. */
  79206. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79207. /**
  79208. * Defines an override for loading materials
  79209. * Return true to stop further extensions from loading this material
  79210. */
  79211. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79212. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79213. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79214. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79215. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79216. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79217. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79218. private static LoadTextureBufferAsync;
  79219. private static CreateTextureAsync;
  79220. private static ApplyExtensions;
  79221. }
  79222. }
  79223. declare module BABYLON.GLTF1 {
  79224. /** @hidden */
  79225. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79226. private _bin;
  79227. constructor();
  79228. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79229. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79230. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79231. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79232. }
  79233. }
  79234. declare module BABYLON.GLTF1 {
  79235. /** @hidden */
  79236. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79237. constructor();
  79238. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79239. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79240. private _loadTexture;
  79241. }
  79242. }
  79243. declare module BABYLON.GLTF2.Loader {
  79244. /**
  79245. * Loader interface with an index field.
  79246. */
  79247. export interface IArrayItem {
  79248. /**
  79249. * The index of this item in the array.
  79250. */
  79251. index: number;
  79252. }
  79253. /**
  79254. * Loader interface with additional members.
  79255. */
  79256. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79257. /** @hidden */
  79258. _data?: Promise<ArrayBufferView>;
  79259. /** @hidden */
  79260. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79261. }
  79262. /**
  79263. * Loader interface with additional members.
  79264. */
  79265. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79266. }
  79267. /** @hidden */
  79268. export interface _IAnimationSamplerData {
  79269. input: Float32Array;
  79270. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79271. output: Float32Array;
  79272. }
  79273. /**
  79274. * Loader interface with additional members.
  79275. */
  79276. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79277. /** @hidden */
  79278. _data?: Promise<_IAnimationSamplerData>;
  79279. }
  79280. /**
  79281. * Loader interface with additional members.
  79282. */
  79283. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79284. channels: IAnimationChannel[];
  79285. samplers: IAnimationSampler[];
  79286. /** @hidden */
  79287. _babylonAnimationGroup?: AnimationGroup;
  79288. }
  79289. /**
  79290. * Loader interface with additional members.
  79291. */
  79292. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79293. /** @hidden */
  79294. _data?: Promise<ArrayBufferView>;
  79295. }
  79296. /**
  79297. * Loader interface with additional members.
  79298. */
  79299. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79300. /** @hidden */
  79301. _data?: Promise<ArrayBufferView>;
  79302. /** @hidden */
  79303. _babylonBuffer?: Promise<Buffer>;
  79304. }
  79305. /**
  79306. * Loader interface with additional members.
  79307. */
  79308. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79309. }
  79310. /**
  79311. * Loader interface with additional members.
  79312. */
  79313. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79314. /** @hidden */
  79315. _data?: Promise<ArrayBufferView>;
  79316. }
  79317. /**
  79318. * Loader interface with additional members.
  79319. */
  79320. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79321. }
  79322. /**
  79323. * Loader interface with additional members.
  79324. */
  79325. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79326. }
  79327. /**
  79328. * Loader interface with additional members.
  79329. */
  79330. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79331. baseColorTexture?: ITextureInfo;
  79332. metallicRoughnessTexture?: ITextureInfo;
  79333. }
  79334. /**
  79335. * Loader interface with additional members.
  79336. */
  79337. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79338. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79339. normalTexture?: IMaterialNormalTextureInfo;
  79340. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79341. emissiveTexture?: ITextureInfo;
  79342. /** @hidden */
  79343. _data?: {
  79344. [babylonDrawMode: number]: {
  79345. babylonMaterial: Material;
  79346. babylonMeshes: AbstractMesh[];
  79347. promise: Promise<void>;
  79348. };
  79349. };
  79350. }
  79351. /**
  79352. * Loader interface with additional members.
  79353. */
  79354. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79355. primitives: IMeshPrimitive[];
  79356. }
  79357. /**
  79358. * Loader interface with additional members.
  79359. */
  79360. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79361. /** @hidden */
  79362. _instanceData?: {
  79363. babylonSourceMesh: Mesh;
  79364. promise: Promise<any>;
  79365. };
  79366. }
  79367. /**
  79368. * Loader interface with additional members.
  79369. */
  79370. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79371. /**
  79372. * The parent glTF node.
  79373. */
  79374. parent?: INode;
  79375. /** @hidden */
  79376. _babylonTransformNode?: TransformNode;
  79377. /** @hidden */
  79378. _primitiveBabylonMeshes?: AbstractMesh[];
  79379. /** @hidden */
  79380. _babylonBones?: Bone[];
  79381. /** @hidden */
  79382. _numMorphTargets?: number;
  79383. }
  79384. /** @hidden */
  79385. export interface _ISamplerData {
  79386. noMipMaps: boolean;
  79387. samplingMode: number;
  79388. wrapU: number;
  79389. wrapV: number;
  79390. }
  79391. /**
  79392. * Loader interface with additional members.
  79393. */
  79394. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  79395. /** @hidden */
  79396. _data?: _ISamplerData;
  79397. }
  79398. /**
  79399. * Loader interface with additional members.
  79400. */
  79401. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  79402. }
  79403. /**
  79404. * Loader interface with additional members.
  79405. */
  79406. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  79407. /** @hidden */
  79408. _data?: {
  79409. babylonSkeleton: Skeleton;
  79410. promise: Promise<void>;
  79411. };
  79412. }
  79413. /**
  79414. * Loader interface with additional members.
  79415. */
  79416. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  79417. }
  79418. /**
  79419. * Loader interface with additional members.
  79420. */
  79421. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  79422. }
  79423. /**
  79424. * Loader interface with additional members.
  79425. */
  79426. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  79427. accessors?: IAccessor[];
  79428. animations?: IAnimation[];
  79429. buffers?: IBuffer[];
  79430. bufferViews?: IBufferView[];
  79431. cameras?: ICamera[];
  79432. images?: IImage[];
  79433. materials?: IMaterial[];
  79434. meshes?: IMesh[];
  79435. nodes?: INode[];
  79436. samplers?: ISampler[];
  79437. scenes?: IScene[];
  79438. skins?: ISkin[];
  79439. textures?: ITexture[];
  79440. }
  79441. }
  79442. declare module BABYLON.GLTF2 {
  79443. /**
  79444. * Interface for a glTF loader extension.
  79445. */
  79446. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  79447. /**
  79448. * Called after the loader state changes to LOADING.
  79449. */
  79450. onLoading?(): void;
  79451. /**
  79452. * Called after the loader state changes to READY.
  79453. */
  79454. onReady?(): void;
  79455. /**
  79456. * Define this method to modify the default behavior when loading scenes.
  79457. * @param context The context when loading the asset
  79458. * @param scene The glTF scene property
  79459. * @returns A promise that resolves when the load is complete or null if not handled
  79460. */
  79461. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  79462. /**
  79463. * Define this method to modify the default behavior when loading nodes.
  79464. * @param context The context when loading the asset
  79465. * @param node The glTF node property
  79466. * @param assign A function called synchronously after parsing the glTF properties
  79467. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  79468. */
  79469. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79470. /**
  79471. * Define this method to modify the default behavior when loading cameras.
  79472. * @param context The context when loading the asset
  79473. * @param camera The glTF camera property
  79474. * @param assign A function called synchronously after parsing the glTF properties
  79475. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  79476. */
  79477. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  79478. /**
  79479. * @hidden
  79480. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  79481. * @param context The context when loading the asset
  79482. * @param primitive The glTF mesh primitive property
  79483. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  79484. */
  79485. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79486. /**
  79487. * @hidden
  79488. * Define this method to modify the default behavior when loading data for mesh primitives.
  79489. * @param context The context when loading the asset
  79490. * @param name The mesh name when loading the asset
  79491. * @param node The glTF node when loading the asset
  79492. * @param mesh The glTF mesh when loading the asset
  79493. * @param primitive The glTF mesh primitive property
  79494. * @param assign A function called synchronously after parsing the glTF properties
  79495. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79496. */
  79497. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  79498. /**
  79499. * @hidden
  79500. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  79501. * @param context The context when loading the asset
  79502. * @param material The glTF material property
  79503. * @param assign A function called synchronously after parsing the glTF properties
  79504. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  79505. */
  79506. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  79507. /**
  79508. * Define this method to modify the default behavior when creating materials.
  79509. * @param context The context when loading the asset
  79510. * @param material The glTF material property
  79511. * @param babylonDrawMode The draw mode for the Babylon material
  79512. * @returns The Babylon material or null if not handled
  79513. */
  79514. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  79515. /**
  79516. * Define this method to modify the default behavior when loading material properties.
  79517. * @param context The context when loading the asset
  79518. * @param material The glTF material property
  79519. * @param babylonMaterial The Babylon material
  79520. * @returns A promise that resolves when the load is complete or null if not handled
  79521. */
  79522. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  79523. /**
  79524. * Define this method to modify the default behavior when loading texture infos.
  79525. * @param context The context when loading the asset
  79526. * @param textureInfo The glTF texture info property
  79527. * @param assign A function called synchronously after parsing the glTF properties
  79528. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79529. */
  79530. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79531. /**
  79532. * @hidden
  79533. * Define this method to modify the default behavior when loading textures.
  79534. * @param context The context when loading the asset
  79535. * @param texture The glTF texture property
  79536. * @param assign A function called synchronously after parsing the glTF properties
  79537. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  79538. */
  79539. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  79540. /**
  79541. * Define this method to modify the default behavior when loading animations.
  79542. * @param context The context when loading the asset
  79543. * @param animation The glTF animation property
  79544. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  79545. */
  79546. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  79547. /**
  79548. * @hidden
  79549. * Define this method to modify the default behavior when loading skins.
  79550. * @param context The context when loading the asset
  79551. * @param node The glTF node property
  79552. * @param skin The glTF skin property
  79553. * @returns A promise that resolves when the load is complete or null if not handled
  79554. */
  79555. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  79556. /**
  79557. * @hidden
  79558. * Define this method to modify the default behavior when loading uris.
  79559. * @param context The context when loading the asset
  79560. * @param property The glTF property associated with the uri
  79561. * @param uri The uri to load
  79562. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79563. */
  79564. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  79565. /**
  79566. * Define this method to modify the default behavior when loading buffer views.
  79567. * @param context The context when loading the asset
  79568. * @param bufferView The glTF buffer view property
  79569. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79570. */
  79571. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  79572. /**
  79573. * Define this method to modify the default behavior when loading buffers.
  79574. * @param context The context when loading the asset
  79575. * @param buffer The glTF buffer property
  79576. * @param byteOffset The byte offset to load
  79577. * @param byteLength The byte length to load
  79578. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  79579. */
  79580. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  79581. }
  79582. }
  79583. declare module BABYLON.GLTF2 {
  79584. /**
  79585. * Helper class for working with arrays when loading the glTF asset
  79586. */
  79587. export class ArrayItem {
  79588. /**
  79589. * Gets an item from the given array.
  79590. * @param context The context when loading the asset
  79591. * @param array The array to get the item from
  79592. * @param index The index to the array
  79593. * @returns The array item
  79594. */
  79595. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  79596. /**
  79597. * Assign an `index` field to each item of the given array.
  79598. * @param array The array of items
  79599. */
  79600. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  79601. }
  79602. /**
  79603. * The glTF 2.0 loader
  79604. */
  79605. export class GLTFLoader implements IGLTFLoader {
  79606. /** @hidden */
  79607. _completePromises: Promise<any>[];
  79608. /** @hidden */
  79609. _forAssetContainer: boolean;
  79610. /** Storage */
  79611. _babylonLights: Light[];
  79612. /** @hidden */
  79613. _disableInstancedMesh: number;
  79614. private _disposed;
  79615. private _parent;
  79616. private _state;
  79617. private _extensions;
  79618. private _rootUrl;
  79619. private _fileName;
  79620. private _uniqueRootUrl;
  79621. private _gltf;
  79622. private _bin;
  79623. private _babylonScene;
  79624. private _rootBabylonMesh;
  79625. private _defaultBabylonMaterialData;
  79626. private _progressCallback?;
  79627. private _requests;
  79628. private static _RegisteredExtensions;
  79629. /**
  79630. * The default glTF sampler.
  79631. */
  79632. static readonly DefaultSampler: ISampler;
  79633. /**
  79634. * Registers a loader extension.
  79635. * @param name The name of the loader extension.
  79636. * @param factory The factory function that creates the loader extension.
  79637. */
  79638. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  79639. /**
  79640. * Unregisters a loader extension.
  79641. * @param name The name of the loader extension.
  79642. * @returns A boolean indicating whether the extension has been unregistered
  79643. */
  79644. static UnregisterExtension(name: string): boolean;
  79645. /**
  79646. * The loader state.
  79647. */
  79648. get state(): Nullable<GLTFLoaderState>;
  79649. /**
  79650. * The object that represents the glTF JSON.
  79651. */
  79652. get gltf(): IGLTF;
  79653. /**
  79654. * The BIN chunk of a binary glTF.
  79655. */
  79656. get bin(): Nullable<IDataBuffer>;
  79657. /**
  79658. * The parent file loader.
  79659. */
  79660. get parent(): GLTFFileLoader;
  79661. /**
  79662. * The Babylon scene when loading the asset.
  79663. */
  79664. get babylonScene(): Scene;
  79665. /**
  79666. * The root Babylon mesh when loading the asset.
  79667. */
  79668. get rootBabylonMesh(): Mesh;
  79669. /** @hidden */
  79670. constructor(parent: GLTFFileLoader);
  79671. /** @hidden */
  79672. dispose(): void;
  79673. /** @hidden */
  79674. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  79675. /** @hidden */
  79676. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79677. private _loadAsync;
  79678. private _loadData;
  79679. private _setupData;
  79680. private _loadExtensions;
  79681. private _checkExtensions;
  79682. private _setState;
  79683. private _createRootNode;
  79684. /**
  79685. * Loads a glTF scene.
  79686. * @param context The context when loading the asset
  79687. * @param scene The glTF scene property
  79688. * @returns A promise that resolves when the load is complete
  79689. */
  79690. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  79691. private _forEachPrimitive;
  79692. private _getMeshes;
  79693. private _getTransformNodes;
  79694. private _getSkeletons;
  79695. private _getAnimationGroups;
  79696. private _startAnimations;
  79697. /**
  79698. * Loads a glTF node.
  79699. * @param context The context when loading the asset
  79700. * @param node The glTF node property
  79701. * @param assign A function called synchronously after parsing the glTF properties
  79702. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  79703. */
  79704. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  79705. private _loadMeshAsync;
  79706. /**
  79707. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  79708. * @param context The context when loading the asset
  79709. * @param name The mesh name when loading the asset
  79710. * @param node The glTF node when loading the asset
  79711. * @param mesh The glTF mesh when loading the asset
  79712. * @param primitive The glTF mesh primitive property
  79713. * @param assign A function called synchronously after parsing the glTF properties
  79714. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  79715. */
  79716. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  79717. private _loadVertexDataAsync;
  79718. private _createMorphTargets;
  79719. private _loadMorphTargetsAsync;
  79720. private _loadMorphTargetVertexDataAsync;
  79721. private static _LoadTransform;
  79722. private _loadSkinAsync;
  79723. private _loadBones;
  79724. private _loadBone;
  79725. private _loadSkinInverseBindMatricesDataAsync;
  79726. private _updateBoneMatrices;
  79727. private _getNodeMatrix;
  79728. /**
  79729. * Loads a glTF camera.
  79730. * @param context The context when loading the asset
  79731. * @param camera The glTF camera property
  79732. * @param assign A function called synchronously after parsing the glTF properties
  79733. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  79734. */
  79735. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  79736. private _loadAnimationsAsync;
  79737. /**
  79738. * Loads a glTF animation.
  79739. * @param context The context when loading the asset
  79740. * @param animation The glTF animation property
  79741. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  79742. */
  79743. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  79744. /**
  79745. * @hidden Loads a glTF animation channel.
  79746. * @param context The context when loading the asset
  79747. * @param animationContext The context of the animation when loading the asset
  79748. * @param animation The glTF animation property
  79749. * @param channel The glTF animation channel property
  79750. * @param babylonAnimationGroup The babylon animation group property
  79751. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  79752. * @returns A void promise when the channel load is complete
  79753. */
  79754. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  79755. private _loadAnimationSamplerAsync;
  79756. private _loadBufferAsync;
  79757. /**
  79758. * Loads a glTF buffer view.
  79759. * @param context The context when loading the asset
  79760. * @param bufferView The glTF buffer view property
  79761. * @returns A promise that resolves with the loaded data when the load is complete
  79762. */
  79763. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  79764. private _loadAccessorAsync;
  79765. /** @hidden */
  79766. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  79767. private _loadIndicesAccessorAsync;
  79768. private _loadVertexBufferViewAsync;
  79769. private _loadVertexAccessorAsync;
  79770. private _loadMaterialMetallicRoughnessPropertiesAsync;
  79771. /** @hidden */
  79772. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  79773. private _createDefaultMaterial;
  79774. /**
  79775. * Creates a Babylon material from a glTF material.
  79776. * @param context The context when loading the asset
  79777. * @param material The glTF material property
  79778. * @param babylonDrawMode The draw mode for the Babylon material
  79779. * @returns The Babylon material
  79780. */
  79781. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  79782. /**
  79783. * Loads properties from a glTF material into a Babylon material.
  79784. * @param context The context when loading the asset
  79785. * @param material The glTF material property
  79786. * @param babylonMaterial The Babylon material
  79787. * @returns A promise that resolves when the load is complete
  79788. */
  79789. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79790. /**
  79791. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  79792. * @param context The context when loading the asset
  79793. * @param material The glTF material property
  79794. * @param babylonMaterial The Babylon material
  79795. * @returns A promise that resolves when the load is complete
  79796. */
  79797. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  79798. /**
  79799. * Loads the alpha properties from a glTF material into a Babylon material.
  79800. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  79801. * @param context The context when loading the asset
  79802. * @param material The glTF material property
  79803. * @param babylonMaterial The Babylon material
  79804. */
  79805. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  79806. /**
  79807. * Loads a glTF texture info.
  79808. * @param context The context when loading the asset
  79809. * @param textureInfo The glTF texture info property
  79810. * @param assign A function called synchronously after parsing the glTF properties
  79811. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  79812. */
  79813. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79814. /** @hidden */
  79815. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79816. /** @hidden */
  79817. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  79818. private _loadSampler;
  79819. /**
  79820. * Loads a glTF image.
  79821. * @param context The context when loading the asset
  79822. * @param image The glTF image property
  79823. * @returns A promise that resolves with the loaded data when the load is complete
  79824. */
  79825. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  79826. /**
  79827. * Loads a glTF uri.
  79828. * @param context The context when loading the asset
  79829. * @param property The glTF property associated with the uri
  79830. * @param uri The base64 or relative uri
  79831. * @returns A promise that resolves with the loaded data when the load is complete
  79832. */
  79833. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  79834. private _onProgress;
  79835. /**
  79836. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  79837. * @param babylonObject the Babylon object with metadata
  79838. * @param pointer the JSON pointer
  79839. */
  79840. static AddPointerMetadata(babylonObject: {
  79841. metadata: any;
  79842. }, pointer: string): void;
  79843. private static _GetTextureWrapMode;
  79844. private static _GetTextureSamplingMode;
  79845. private static _GetTypedArrayConstructor;
  79846. private static _GetTypedArray;
  79847. private static _GetNumComponents;
  79848. private static _ValidateUri;
  79849. private static _GetDrawMode;
  79850. private _compileMaterialsAsync;
  79851. private _compileShadowGeneratorsAsync;
  79852. private _forEachExtensions;
  79853. private _applyExtensions;
  79854. private _extensionsOnLoading;
  79855. private _extensionsOnReady;
  79856. private _extensionsLoadSceneAsync;
  79857. private _extensionsLoadNodeAsync;
  79858. private _extensionsLoadCameraAsync;
  79859. private _extensionsLoadVertexDataAsync;
  79860. private _extensionsLoadMeshPrimitiveAsync;
  79861. private _extensionsLoadMaterialAsync;
  79862. private _extensionsCreateMaterial;
  79863. private _extensionsLoadMaterialPropertiesAsync;
  79864. private _extensionsLoadTextureInfoAsync;
  79865. private _extensionsLoadTextureAsync;
  79866. private _extensionsLoadAnimationAsync;
  79867. private _extensionsLoadSkinAsync;
  79868. private _extensionsLoadUriAsync;
  79869. private _extensionsLoadBufferViewAsync;
  79870. private _extensionsLoadBufferAsync;
  79871. /**
  79872. * Helper method called by a loader extension to load an glTF extension.
  79873. * @param context The context when loading the asset
  79874. * @param property The glTF property to load the extension from
  79875. * @param extensionName The name of the extension to load
  79876. * @param actionAsync The action to run
  79877. * @returns The promise returned by actionAsync or null if the extension does not exist
  79878. */
  79879. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79880. /**
  79881. * Helper method called by a loader extension to load a glTF extra.
  79882. * @param context The context when loading the asset
  79883. * @param property The glTF property to load the extra from
  79884. * @param extensionName The name of the extension to load
  79885. * @param actionAsync The action to run
  79886. * @returns The promise returned by actionAsync or null if the extra does not exist
  79887. */
  79888. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  79889. /**
  79890. * Checks for presence of an extension.
  79891. * @param name The name of the extension to check
  79892. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  79893. */
  79894. isExtensionUsed(name: string): boolean;
  79895. /**
  79896. * Increments the indentation level and logs a message.
  79897. * @param message The message to log
  79898. */
  79899. logOpen(message: string): void;
  79900. /**
  79901. * Decrements the indentation level.
  79902. */
  79903. logClose(): void;
  79904. /**
  79905. * Logs a message
  79906. * @param message The message to log
  79907. */
  79908. log(message: string): void;
  79909. /**
  79910. * Starts a performance counter.
  79911. * @param counterName The name of the performance counter
  79912. */
  79913. startPerformanceCounter(counterName: string): void;
  79914. /**
  79915. * Ends a performance counter.
  79916. * @param counterName The name of the performance counter
  79917. */
  79918. endPerformanceCounter(counterName: string): void;
  79919. }
  79920. }
  79921. declare module BABYLON.GLTF2.Loader.Extensions {
  79922. /**
  79923. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  79924. */
  79925. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  79926. /**
  79927. * The name of this extension.
  79928. */
  79929. readonly name: string;
  79930. /**
  79931. * Defines whether this extension is enabled.
  79932. */
  79933. enabled: boolean;
  79934. private _loader;
  79935. private _lights?;
  79936. /** @hidden */
  79937. constructor(loader: GLTFLoader);
  79938. /** @hidden */
  79939. dispose(): void;
  79940. /** @hidden */
  79941. onLoading(): void;
  79942. /** @hidden */
  79943. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  79944. private _loadLightAsync;
  79945. }
  79946. }
  79947. declare module BABYLON.GLTF2.Loader.Extensions {
  79948. /**
  79949. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  79950. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  79951. * !!! Experimental Extension Subject to Changes !!!
  79952. */
  79953. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  79954. /**
  79955. * The name of this extension.
  79956. */
  79957. readonly name: string;
  79958. /**
  79959. * Defines whether this extension is enabled.
  79960. */
  79961. enabled: boolean;
  79962. private _loader;
  79963. /** @hidden */
  79964. constructor(loader: GLTFLoader);
  79965. /** @hidden */
  79966. dispose(): void;
  79967. /** @hidden */
  79968. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  79969. }
  79970. }
  79971. declare module BABYLON.GLTF2.Loader.Extensions {
  79972. /**
  79973. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  79974. */
  79975. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  79976. /**
  79977. * The name of this extension.
  79978. */
  79979. readonly name: string;
  79980. /**
  79981. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  79982. */
  79983. dracoCompression?: DracoCompression;
  79984. /**
  79985. * Defines whether this extension is enabled.
  79986. */
  79987. enabled: boolean;
  79988. private _loader;
  79989. /** @hidden */
  79990. constructor(loader: GLTFLoader);
  79991. /** @hidden */
  79992. dispose(): void;
  79993. /** @hidden */
  79994. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  79995. }
  79996. }
  79997. declare module BABYLON.GLTF2.Loader.Extensions {
  79998. /**
  79999. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80000. */
  80001. export class KHR_lights implements IGLTFLoaderExtension {
  80002. /**
  80003. * The name of this extension.
  80004. */
  80005. readonly name: string;
  80006. /**
  80007. * Defines whether this extension is enabled.
  80008. */
  80009. enabled: boolean;
  80010. private _loader;
  80011. private _lights?;
  80012. /** @hidden */
  80013. constructor(loader: GLTFLoader);
  80014. /** @hidden */
  80015. dispose(): void;
  80016. /** @hidden */
  80017. onLoading(): void;
  80018. /** @hidden */
  80019. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80020. }
  80021. }
  80022. declare module BABYLON.GLTF2.Loader.Extensions {
  80023. /**
  80024. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80025. */
  80026. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80027. /**
  80028. * The name of this extension.
  80029. */
  80030. readonly name: string;
  80031. /**
  80032. * Defines whether this extension is enabled.
  80033. */
  80034. enabled: boolean;
  80035. /**
  80036. * Defines a number that determines the order the extensions are applied.
  80037. */
  80038. order: number;
  80039. private _loader;
  80040. /** @hidden */
  80041. constructor(loader: GLTFLoader);
  80042. /** @hidden */
  80043. dispose(): void;
  80044. /** @hidden */
  80045. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80046. private _loadSpecularGlossinessPropertiesAsync;
  80047. }
  80048. }
  80049. declare module BABYLON.GLTF2.Loader.Extensions {
  80050. /**
  80051. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80052. */
  80053. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80054. /**
  80055. * The name of this extension.
  80056. */
  80057. readonly name: string;
  80058. /**
  80059. * Defines whether this extension is enabled.
  80060. */
  80061. enabled: boolean;
  80062. /**
  80063. * Defines a number that determines the order the extensions are applied.
  80064. */
  80065. order: number;
  80066. private _loader;
  80067. /** @hidden */
  80068. constructor(loader: GLTFLoader);
  80069. /** @hidden */
  80070. dispose(): void;
  80071. /** @hidden */
  80072. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80073. private _loadUnlitPropertiesAsync;
  80074. }
  80075. }
  80076. declare module BABYLON.GLTF2.Loader.Extensions {
  80077. /**
  80078. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80079. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80080. * !!! Experimental Extension Subject to Changes !!!
  80081. */
  80082. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80083. /**
  80084. * The name of this extension.
  80085. */
  80086. readonly name: string;
  80087. /**
  80088. * Defines whether this extension is enabled.
  80089. */
  80090. enabled: boolean;
  80091. /**
  80092. * Defines a number that determines the order the extensions are applied.
  80093. */
  80094. order: number;
  80095. private _loader;
  80096. /** @hidden */
  80097. constructor(loader: GLTFLoader);
  80098. /** @hidden */
  80099. dispose(): void;
  80100. /** @hidden */
  80101. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80102. private _loadClearCoatPropertiesAsync;
  80103. }
  80104. }
  80105. declare module BABYLON.GLTF2.Loader.Extensions {
  80106. /**
  80107. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80108. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80109. * !!! Experimental Extension Subject to Changes !!!
  80110. */
  80111. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80112. /**
  80113. * The name of this extension.
  80114. */
  80115. readonly name: string;
  80116. /**
  80117. * Defines whether this extension is enabled.
  80118. */
  80119. enabled: boolean;
  80120. /**
  80121. * Defines a number that determines the order the extensions are applied.
  80122. */
  80123. order: number;
  80124. private _loader;
  80125. /** @hidden */
  80126. constructor(loader: GLTFLoader);
  80127. /** @hidden */
  80128. dispose(): void;
  80129. /** @hidden */
  80130. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80131. private _loadSheenPropertiesAsync;
  80132. }
  80133. }
  80134. declare module BABYLON.GLTF2.Loader.Extensions {
  80135. /**
  80136. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80137. * !!! Experimental Extension Subject to Changes !!!
  80138. */
  80139. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80140. /**
  80141. * The name of this extension.
  80142. */
  80143. readonly name: string;
  80144. /**
  80145. * Defines whether this extension is enabled.
  80146. */
  80147. enabled: boolean;
  80148. /**
  80149. * Defines a number that determines the order the extensions are applied.
  80150. */
  80151. order: number;
  80152. private _loader;
  80153. /** @hidden */
  80154. constructor(loader: GLTFLoader);
  80155. /** @hidden */
  80156. dispose(): void;
  80157. /** @hidden */
  80158. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80159. private _loadSpecularPropertiesAsync;
  80160. }
  80161. }
  80162. declare module BABYLON.GLTF2.Loader.Extensions {
  80163. /**
  80164. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80165. * !!! Experimental Extension Subject to Changes !!!
  80166. */
  80167. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80168. /**
  80169. * Default ior Value from the spec.
  80170. */
  80171. private static readonly _DEFAULT_IOR;
  80172. /**
  80173. * The name of this extension.
  80174. */
  80175. readonly name: string;
  80176. /**
  80177. * Defines whether this extension is enabled.
  80178. */
  80179. enabled: boolean;
  80180. /**
  80181. * Defines a number that determines the order the extensions are applied.
  80182. */
  80183. order: number;
  80184. private _loader;
  80185. /** @hidden */
  80186. constructor(loader: GLTFLoader);
  80187. /** @hidden */
  80188. dispose(): void;
  80189. /** @hidden */
  80190. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80191. private _loadIorPropertiesAsync;
  80192. }
  80193. }
  80194. declare module BABYLON.GLTF2.Loader.Extensions {
  80195. /**
  80196. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80197. * !!! Experimental Extension Subject to Changes !!!
  80198. */
  80199. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80200. /**
  80201. * The name of this extension.
  80202. */
  80203. readonly name: string;
  80204. /**
  80205. * Defines whether this extension is enabled.
  80206. */
  80207. enabled: boolean;
  80208. private _loader;
  80209. /**
  80210. * The default variant name.
  80211. */
  80212. defaultVariant: string | undefined;
  80213. private _tagsToMap;
  80214. /** @hidden */
  80215. constructor(loader: GLTFLoader);
  80216. /** @hidden */
  80217. dispose(): void;
  80218. /**
  80219. * Return a list of available variants for this asset.
  80220. * @returns {string[]}
  80221. */
  80222. getVariants(): string[];
  80223. /**
  80224. * Select a variant by providing a list of variant tag names.
  80225. *
  80226. * @param {(string | string[])} variantName
  80227. */
  80228. selectVariant(variantName: string | string[]): void;
  80229. /**
  80230. * Select a variant by providing a single variant tag.
  80231. *
  80232. * @param {string} variantName
  80233. */
  80234. selectVariantTag(variantName: string): void;
  80235. /** @hidden */
  80236. onLoading(): void;
  80237. /** @hidden */
  80238. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80239. }
  80240. }
  80241. declare module BABYLON.GLTF2.Loader.Extensions {
  80242. /**
  80243. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80244. * !!! Experimental Extension Subject to Changes !!!
  80245. */
  80246. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80247. /**
  80248. * The name of this extension.
  80249. */
  80250. readonly name: string;
  80251. /**
  80252. * Defines whether this extension is enabled.
  80253. */
  80254. enabled: boolean;
  80255. /**
  80256. * Defines a number that determines the order the extensions are applied.
  80257. */
  80258. order: number;
  80259. private _loader;
  80260. /** @hidden */
  80261. constructor(loader: GLTFLoader);
  80262. /** @hidden */
  80263. dispose(): void;
  80264. /** @hidden */
  80265. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80266. private _loadTransparentPropertiesAsync;
  80267. }
  80268. }
  80269. declare module BABYLON.GLTF2.Loader.Extensions {
  80270. /**
  80271. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80272. */
  80273. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80274. /**
  80275. * The name of this extension.
  80276. */
  80277. readonly name: string;
  80278. /**
  80279. * Defines whether this extension is enabled.
  80280. */
  80281. enabled: boolean;
  80282. /** @hidden */
  80283. constructor(loader: GLTFLoader);
  80284. /** @hidden */
  80285. dispose(): void;
  80286. }
  80287. }
  80288. declare module BABYLON.GLTF2.Loader.Extensions {
  80289. /**
  80290. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80291. * !!! Experimental Extension Subject to Changes !!!
  80292. */
  80293. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80294. /** The name of this extension. */
  80295. readonly name: string;
  80296. /** Defines whether this extension is enabled. */
  80297. enabled: boolean;
  80298. private _loader;
  80299. /** @hidden */
  80300. constructor(loader: GLTFLoader);
  80301. /** @hidden */
  80302. dispose(): void;
  80303. /** @hidden */
  80304. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80305. }
  80306. }
  80307. declare module BABYLON.GLTF2.Loader.Extensions {
  80308. /**
  80309. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80310. */
  80311. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80312. /**
  80313. * The name of this extension.
  80314. */
  80315. readonly name: string;
  80316. /**
  80317. * Defines whether this extension is enabled.
  80318. */
  80319. enabled: boolean;
  80320. private _loader;
  80321. /** @hidden */
  80322. constructor(loader: GLTFLoader);
  80323. /** @hidden */
  80324. dispose(): void;
  80325. /** @hidden */
  80326. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80327. }
  80328. }
  80329. declare module BABYLON.GLTF2.Loader.Extensions {
  80330. /**
  80331. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80332. * !!! Experimental Extension Subject to Changes !!!
  80333. */
  80334. export class KHR_xmp implements IGLTFLoaderExtension {
  80335. /**
  80336. * The name of this extension.
  80337. */
  80338. readonly name: string;
  80339. /**
  80340. * Defines whether this extension is enabled.
  80341. */
  80342. enabled: boolean;
  80343. /**
  80344. * Defines a number that determines the order the extensions are applied.
  80345. */
  80346. order: number;
  80347. private _loader;
  80348. /** @hidden */
  80349. constructor(loader: GLTFLoader);
  80350. /** @hidden */
  80351. dispose(): void;
  80352. /**
  80353. * Called after the loader state changes to LOADING.
  80354. */
  80355. onLoading(): void;
  80356. }
  80357. }
  80358. declare module BABYLON.GLTF2.Loader.Extensions {
  80359. /**
  80360. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80361. */
  80362. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80363. /**
  80364. * The name of this extension.
  80365. */
  80366. readonly name: string;
  80367. /**
  80368. * Defines whether this extension is enabled.
  80369. */
  80370. enabled: boolean;
  80371. private _loader;
  80372. private _clips;
  80373. private _emitters;
  80374. /** @hidden */
  80375. constructor(loader: GLTFLoader);
  80376. /** @hidden */
  80377. dispose(): void;
  80378. /** @hidden */
  80379. onLoading(): void;
  80380. /** @hidden */
  80381. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80382. /** @hidden */
  80383. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80384. /** @hidden */
  80385. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80386. private _loadClipAsync;
  80387. private _loadEmitterAsync;
  80388. private _getEventAction;
  80389. private _loadAnimationEventAsync;
  80390. }
  80391. }
  80392. declare module BABYLON.GLTF2.Loader.Extensions {
  80393. /**
  80394. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  80395. */
  80396. export class MSFT_lod implements IGLTFLoaderExtension {
  80397. /**
  80398. * The name of this extension.
  80399. */
  80400. readonly name: string;
  80401. /**
  80402. * Defines whether this extension is enabled.
  80403. */
  80404. enabled: boolean;
  80405. /**
  80406. * Defines a number that determines the order the extensions are applied.
  80407. */
  80408. order: number;
  80409. /**
  80410. * Maximum number of LODs to load, starting from the lowest LOD.
  80411. */
  80412. maxLODsToLoad: number;
  80413. /**
  80414. * Observable raised when all node 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. onNodeLODsLoadedObservable: Observable<number>;
  80419. /**
  80420. * Observable raised when all material LODs of one level are loaded.
  80421. * The event data is the index of the loaded LOD starting from zero.
  80422. * Dispose the loader to cancel the loading of the next level of LODs.
  80423. */
  80424. onMaterialLODsLoadedObservable: Observable<number>;
  80425. private _loader;
  80426. private _nodeIndexLOD;
  80427. private _nodeSignalLODs;
  80428. private _nodePromiseLODs;
  80429. private _materialIndexLOD;
  80430. private _materialSignalLODs;
  80431. private _materialPromiseLODs;
  80432. private _indexLOD;
  80433. private _bufferLODs;
  80434. /** @hidden */
  80435. constructor(loader: GLTFLoader);
  80436. /** @hidden */
  80437. dispose(): void;
  80438. /** @hidden */
  80439. onReady(): void;
  80440. /** @hidden */
  80441. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80442. /** @hidden */
  80443. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80444. /** @hidden */
  80445. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80446. /** @hidden */
  80447. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80448. /** @hidden */
  80449. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80450. private _loadBufferLOD;
  80451. /**
  80452. * Gets an array of LOD properties from lowest to highest.
  80453. */
  80454. private _getLODs;
  80455. private _disposeTransformNode;
  80456. private _disposeMaterials;
  80457. }
  80458. }
  80459. declare module BABYLON.GLTF2.Loader.Extensions {
  80460. /** @hidden */
  80461. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  80462. readonly name: string;
  80463. enabled: boolean;
  80464. private _loader;
  80465. constructor(loader: GLTFLoader);
  80466. dispose(): void;
  80467. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80468. }
  80469. }
  80470. declare module BABYLON.GLTF2.Loader.Extensions {
  80471. /** @hidden */
  80472. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  80473. readonly name: string;
  80474. enabled: boolean;
  80475. private _loader;
  80476. constructor(loader: GLTFLoader);
  80477. dispose(): void;
  80478. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80479. }
  80480. }
  80481. declare module BABYLON.GLTF2.Loader.Extensions {
  80482. /**
  80483. * Store glTF extras (if present) in BJS objects' metadata
  80484. */
  80485. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  80486. /**
  80487. * The name of this extension.
  80488. */
  80489. readonly name: string;
  80490. /**
  80491. * Defines whether this extension is enabled.
  80492. */
  80493. enabled: boolean;
  80494. private _loader;
  80495. private _assignExtras;
  80496. /** @hidden */
  80497. constructor(loader: GLTFLoader);
  80498. /** @hidden */
  80499. dispose(): void;
  80500. /** @hidden */
  80501. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80502. /** @hidden */
  80503. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80504. /** @hidden */
  80505. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80506. }
  80507. }
  80508. declare module BABYLON {
  80509. /**
  80510. * Class reading and parsing the MTL file bundled with the obj file.
  80511. */
  80512. export class MTLFileLoader {
  80513. /**
  80514. * Invert Y-Axis of referenced textures on load
  80515. */
  80516. static INVERT_TEXTURE_Y: boolean;
  80517. /**
  80518. * All material loaded from the mtl will be set here
  80519. */
  80520. materials: StandardMaterial[];
  80521. /**
  80522. * This function will read the mtl file and create each material described inside
  80523. * This function could be improve by adding :
  80524. * -some component missing (Ni, Tf...)
  80525. * -including the specific options available
  80526. *
  80527. * @param scene defines the scene the material will be created in
  80528. * @param data defines the mtl data to parse
  80529. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  80530. * @param forAssetContainer defines if the material should be registered in the scene
  80531. */
  80532. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  80533. /**
  80534. * Gets the texture for the material.
  80535. *
  80536. * If the material is imported from input file,
  80537. * We sanitize the url to ensure it takes the textre from aside the material.
  80538. *
  80539. * @param rootUrl The root url to load from
  80540. * @param value The value stored in the mtl
  80541. * @return The Texture
  80542. */
  80543. private static _getTexture;
  80544. }
  80545. }
  80546. declare module BABYLON {
  80547. /**
  80548. * Options for loading OBJ/MTL files
  80549. */
  80550. type MeshLoadOptions = {
  80551. /**
  80552. * Defines if UVs are optimized by default during load.
  80553. */
  80554. OptimizeWithUV: boolean;
  80555. /**
  80556. * Defines custom scaling of UV coordinates of loaded meshes.
  80557. */
  80558. UVScaling: Vector2;
  80559. /**
  80560. * Invert model on y-axis (does a model scaling inversion)
  80561. */
  80562. InvertY: boolean;
  80563. /**
  80564. * Invert Y-Axis of referenced textures on load
  80565. */
  80566. InvertTextureY: boolean;
  80567. /**
  80568. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80569. */
  80570. ImportVertexColors: boolean;
  80571. /**
  80572. * Compute the normals for the model, even if normals are present in the file.
  80573. */
  80574. ComputeNormals: boolean;
  80575. /**
  80576. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80577. */
  80578. SkipMaterials: boolean;
  80579. /**
  80580. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80581. */
  80582. MaterialLoadingFailsSilently: boolean;
  80583. };
  80584. /**
  80585. * OBJ file type loader.
  80586. * This is a babylon scene loader plugin.
  80587. */
  80588. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80589. /**
  80590. * Defines if UVs are optimized by default during load.
  80591. */
  80592. static OPTIMIZE_WITH_UV: boolean;
  80593. /**
  80594. * Invert model on y-axis (does a model scaling inversion)
  80595. */
  80596. static INVERT_Y: boolean;
  80597. /**
  80598. * Invert Y-Axis of referenced textures on load
  80599. */
  80600. static get INVERT_TEXTURE_Y(): boolean;
  80601. static set INVERT_TEXTURE_Y(value: boolean);
  80602. /**
  80603. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  80604. */
  80605. static IMPORT_VERTEX_COLORS: boolean;
  80606. /**
  80607. * Compute the normals for the model, even if normals are present in the file.
  80608. */
  80609. static COMPUTE_NORMALS: boolean;
  80610. /**
  80611. * Defines custom scaling of UV coordinates of loaded meshes.
  80612. */
  80613. static UV_SCALING: Vector2;
  80614. /**
  80615. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  80616. */
  80617. static SKIP_MATERIALS: boolean;
  80618. /**
  80619. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  80620. *
  80621. * Defaults to true for backwards compatibility.
  80622. */
  80623. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  80624. /**
  80625. * Defines the name of the plugin.
  80626. */
  80627. name: string;
  80628. /**
  80629. * Defines the extension the plugin is able to load.
  80630. */
  80631. extensions: string;
  80632. /** @hidden */
  80633. obj: RegExp;
  80634. /** @hidden */
  80635. group: RegExp;
  80636. /** @hidden */
  80637. mtllib: RegExp;
  80638. /** @hidden */
  80639. usemtl: RegExp;
  80640. /** @hidden */
  80641. smooth: RegExp;
  80642. /** @hidden */
  80643. vertexPattern: RegExp;
  80644. /** @hidden */
  80645. normalPattern: RegExp;
  80646. /** @hidden */
  80647. uvPattern: RegExp;
  80648. /** @hidden */
  80649. facePattern1: RegExp;
  80650. /** @hidden */
  80651. facePattern2: RegExp;
  80652. /** @hidden */
  80653. facePattern3: RegExp;
  80654. /** @hidden */
  80655. facePattern4: RegExp;
  80656. /** @hidden */
  80657. facePattern5: RegExp;
  80658. private _forAssetContainer;
  80659. private _meshLoadOptions;
  80660. /**
  80661. * Creates loader for .OBJ files
  80662. *
  80663. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  80664. */
  80665. constructor(meshLoadOptions?: MeshLoadOptions);
  80666. private static get currentMeshLoadOptions();
  80667. /**
  80668. * Calls synchronously the MTL file attached to this obj.
  80669. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  80670. * Without this function materials are not displayed in the first frame (but displayed after).
  80671. * In consequence it is impossible to get material information in your HTML file
  80672. *
  80673. * @param url The URL of the MTL file
  80674. * @param rootUrl
  80675. * @param onSuccess Callback function to be called when the MTL file is loaded
  80676. * @private
  80677. */
  80678. private _loadMTL;
  80679. /**
  80680. * Instantiates a OBJ file loader plugin.
  80681. * @returns the created plugin
  80682. */
  80683. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  80684. /**
  80685. * If the data string can be loaded directly.
  80686. *
  80687. * @param data string containing the file data
  80688. * @returns if the data can be loaded directly
  80689. */
  80690. canDirectLoad(data: string): boolean;
  80691. /**
  80692. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  80693. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80694. * @param scene the scene the meshes should be added to
  80695. * @param data the OBJ data to load
  80696. * @param rootUrl root url to load from
  80697. * @param onProgress event that fires when loading progress has occured
  80698. * @param fileName Defines the name of the file to load
  80699. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80700. */
  80701. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80702. meshes: AbstractMesh[];
  80703. particleSystems: IParticleSystem[];
  80704. skeletons: Skeleton[];
  80705. animationGroups: AnimationGroup[];
  80706. }>;
  80707. /**
  80708. * Imports all objects from the loaded OBJ data and adds them to the scene
  80709. * @param scene the scene the objects should be added to
  80710. * @param data the OBJ data to load
  80711. * @param rootUrl root url to load from
  80712. * @param onProgress event that fires when loading progress has occured
  80713. * @param fileName Defines the name of the file to load
  80714. * @returns a promise which completes when objects have been loaded to the scene
  80715. */
  80716. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80717. /**
  80718. * Load into an asset container.
  80719. * @param scene The scene to load into
  80720. * @param data The data to import
  80721. * @param rootUrl The root url for scene and resources
  80722. * @param onProgress The callback when the load progresses
  80723. * @param fileName Defines the name of the file to load
  80724. * @returns The loaded asset container
  80725. */
  80726. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80727. /**
  80728. * Read the OBJ file and create an Array of meshes.
  80729. * Each mesh contains all information given by the OBJ and the MTL file.
  80730. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  80731. *
  80732. * @param meshesNames
  80733. * @param scene Scene The scene where are displayed the data
  80734. * @param data String The content of the obj file
  80735. * @param rootUrl String The path to the folder
  80736. * @returns Array<AbstractMesh>
  80737. * @private
  80738. */
  80739. private _parseSolid;
  80740. }
  80741. }
  80742. declare module BABYLON {
  80743. /**
  80744. * STL file type loader.
  80745. * This is a babylon scene loader plugin.
  80746. */
  80747. export class STLFileLoader implements ISceneLoaderPlugin {
  80748. /** @hidden */
  80749. solidPattern: RegExp;
  80750. /** @hidden */
  80751. facetsPattern: RegExp;
  80752. /** @hidden */
  80753. normalPattern: RegExp;
  80754. /** @hidden */
  80755. vertexPattern: RegExp;
  80756. /**
  80757. * Defines the name of the plugin.
  80758. */
  80759. name: string;
  80760. /**
  80761. * Defines the extensions the stl loader is able to load.
  80762. * force data to come in as an ArrayBuffer
  80763. * we'll convert to string if it looks like it's an ASCII .stl
  80764. */
  80765. extensions: ISceneLoaderPluginExtensions;
  80766. /**
  80767. * Import meshes into a scene.
  80768. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  80769. * @param scene The scene to import into
  80770. * @param data The data to import
  80771. * @param rootUrl The root url for scene and resources
  80772. * @param meshes The meshes array to import into
  80773. * @param particleSystems The particle systems array to import into
  80774. * @param skeletons The skeletons array to import into
  80775. * @param onError The callback when import fails
  80776. * @returns True if successful or false otherwise
  80777. */
  80778. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  80779. /**
  80780. * Load into a scene.
  80781. * @param scene The scene to load into
  80782. * @param data The data to import
  80783. * @param rootUrl The root url for scene and resources
  80784. * @param onError The callback when import fails
  80785. * @returns true if successful or false otherwise
  80786. */
  80787. load(scene: Scene, data: any, rootUrl: string): boolean;
  80788. /**
  80789. * Load into an asset container.
  80790. * @param scene The scene to load into
  80791. * @param data The data to import
  80792. * @param rootUrl The root url for scene and resources
  80793. * @param onError The callback when import fails
  80794. * @returns The loaded asset container
  80795. */
  80796. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  80797. private _isBinary;
  80798. private _parseBinary;
  80799. private _parseASCII;
  80800. }
  80801. }
  80802. declare module BABYLON {
  80803. /**
  80804. * Class for generating OBJ data from a Babylon scene.
  80805. */
  80806. export class OBJExport {
  80807. /**
  80808. * Exports the geometry of a Mesh array in .OBJ file format (text)
  80809. * @param mesh defines the list of meshes to serialize
  80810. * @param materials defines if materials should be exported
  80811. * @param matlibname defines the name of the associated mtl file
  80812. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  80813. * @returns the OBJ content
  80814. */
  80815. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  80816. /**
  80817. * Exports the material(s) of a mesh in .MTL file format (text)
  80818. * @param mesh defines the mesh to extract the material from
  80819. * @returns the mtl content
  80820. */
  80821. static MTL(mesh: Mesh): string;
  80822. }
  80823. }
  80824. declare module BABYLON {
  80825. /** @hidden */
  80826. export var __IGLTFExporterExtension: number;
  80827. /**
  80828. * Interface for extending the exporter
  80829. * @hidden
  80830. */
  80831. export interface IGLTFExporterExtension {
  80832. /**
  80833. * The name of this extension
  80834. */
  80835. readonly name: string;
  80836. /**
  80837. * Defines whether this extension is enabled
  80838. */
  80839. enabled: boolean;
  80840. /**
  80841. * Defines whether this extension is required
  80842. */
  80843. required: boolean;
  80844. }
  80845. }
  80846. declare module BABYLON.GLTF2.Exporter {
  80847. /** @hidden */
  80848. export var __IGLTFExporterExtensionV2: number;
  80849. /**
  80850. * Interface for a glTF exporter extension
  80851. * @hidden
  80852. */
  80853. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  80854. /**
  80855. * Define this method to modify the default behavior before exporting a texture
  80856. * @param context The context when loading the asset
  80857. * @param babylonTexture The Babylon.js texture
  80858. * @param mimeType The mime-type of the generated image
  80859. * @returns A promise that resolves with the exported texture
  80860. */
  80861. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  80862. /**
  80863. * Define this method to get notified when a texture info is created
  80864. * @param context The context when loading the asset
  80865. * @param textureInfo The glTF texture info
  80866. * @param babylonTexture The Babylon.js texture
  80867. */
  80868. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  80869. /**
  80870. * Define this method to modify the default behavior when exporting texture info
  80871. * @param context The context when loading the asset
  80872. * @param meshPrimitive glTF mesh primitive
  80873. * @param babylonSubMesh Babylon submesh
  80874. * @param binaryWriter glTF serializer binary writer instance
  80875. * @returns nullable IMeshPrimitive promise
  80876. */
  80877. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  80878. /**
  80879. * Define this method to modify the default behavior when exporting a node
  80880. * @param context The context when exporting the node
  80881. * @param node glTF node
  80882. * @param babylonNode BabylonJS node
  80883. * @returns nullable INode promise
  80884. */
  80885. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80886. [key: number]: number;
  80887. }): Promise<Nullable<INode>>;
  80888. /**
  80889. * Define this method to modify the default behavior when exporting a material
  80890. * @param material glTF material
  80891. * @param babylonMaterial BabylonJS material
  80892. * @returns nullable IMaterial promise
  80893. */
  80894. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  80895. /**
  80896. * Define this method to return additional textures to export from a material
  80897. * @param material glTF material
  80898. * @param babylonMaterial BabylonJS material
  80899. * @returns List of textures
  80900. */
  80901. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80902. /** Gets a boolean indicating that this extension was used */
  80903. wasUsed: boolean;
  80904. /** Gets a boolean indicating that this extension is required for the file to work */
  80905. required: boolean;
  80906. /**
  80907. * Called after the exporter state changes to EXPORTING
  80908. */
  80909. onExporting?(): void;
  80910. }
  80911. }
  80912. declare module BABYLON.GLTF2.Exporter {
  80913. /**
  80914. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  80915. * @hidden
  80916. */
  80917. export class _GLTFMaterialExporter {
  80918. /**
  80919. * Represents the dielectric specular values for R, G and B
  80920. */
  80921. private static readonly _DielectricSpecular;
  80922. /**
  80923. * Allows the maximum specular power to be defined for material calculations
  80924. */
  80925. private static readonly _MaxSpecularPower;
  80926. /**
  80927. * Mapping to store textures
  80928. */
  80929. private _textureMap;
  80930. /**
  80931. * Numeric tolerance value
  80932. */
  80933. private static readonly _Epsilon;
  80934. /**
  80935. * Reference to the glTF Exporter
  80936. */
  80937. private _exporter;
  80938. constructor(exporter: _Exporter);
  80939. /**
  80940. * Specifies if two colors are approximately equal in value
  80941. * @param color1 first color to compare to
  80942. * @param color2 second color to compare to
  80943. * @param epsilon threshold value
  80944. */
  80945. private static FuzzyEquals;
  80946. /**
  80947. * Gets the materials from a Babylon scene and converts them to glTF materials
  80948. * @param scene babylonjs scene
  80949. * @param mimeType texture mime type
  80950. * @param images array of images
  80951. * @param textures array of textures
  80952. * @param materials array of materials
  80953. * @param imageData mapping of texture names to base64 textures
  80954. * @param hasTextureCoords specifies if texture coordinates are present on the material
  80955. */
  80956. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  80957. /**
  80958. * Makes a copy of the glTF material without the texture parameters
  80959. * @param originalMaterial original glTF material
  80960. * @returns glTF material without texture parameters
  80961. */
  80962. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  80963. /**
  80964. * Specifies if the material has any texture parameters present
  80965. * @param material glTF Material
  80966. * @returns boolean specifying if texture parameters are present
  80967. */
  80968. _hasTexturesPresent(material: IMaterial): boolean;
  80969. /**
  80970. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  80971. * @param babylonStandardMaterial
  80972. * @returns glTF Metallic Roughness Material representation
  80973. */
  80974. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  80975. /**
  80976. * Computes the metallic factor
  80977. * @param diffuse diffused value
  80978. * @param specular specular value
  80979. * @param oneMinusSpecularStrength one minus the specular strength
  80980. * @returns metallic value
  80981. */
  80982. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  80983. /**
  80984. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  80985. * @param glTFMaterial glTF material
  80986. * @param babylonMaterial Babylon material
  80987. */
  80988. private static _SetAlphaMode;
  80989. /**
  80990. * Converts a Babylon Standard Material to a glTF Material
  80991. * @param babylonStandardMaterial BJS Standard Material
  80992. * @param mimeType mime type to use for the textures
  80993. * @param images array of glTF image interfaces
  80994. * @param textures array of glTF texture interfaces
  80995. * @param materials array of glTF material interfaces
  80996. * @param imageData map of image file name to data
  80997. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  80998. */
  80999. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81000. private _finishMaterial;
  81001. /**
  81002. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81003. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81004. * @param mimeType mime type to use for the textures
  81005. * @param images array of glTF image interfaces
  81006. * @param textures array of glTF texture interfaces
  81007. * @param materials array of glTF material interfaces
  81008. * @param imageData map of image file name to data
  81009. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81010. */
  81011. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81012. /**
  81013. * Converts an image typed array buffer to a base64 image
  81014. * @param buffer typed array buffer
  81015. * @param width width of the image
  81016. * @param height height of the image
  81017. * @param mimeType mimetype of the image
  81018. * @returns base64 image string
  81019. */
  81020. private _createBase64FromCanvasAsync;
  81021. /**
  81022. * Generates a white texture based on the specified width and height
  81023. * @param width width of the texture in pixels
  81024. * @param height height of the texture in pixels
  81025. * @param scene babylonjs scene
  81026. * @returns white texture
  81027. */
  81028. private _createWhiteTexture;
  81029. /**
  81030. * 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
  81031. * @param texture1 first texture to resize
  81032. * @param texture2 second texture to resize
  81033. * @param scene babylonjs scene
  81034. * @returns resized textures or null
  81035. */
  81036. private _resizeTexturesToSameDimensions;
  81037. /**
  81038. * Converts an array of pixels to a Float32Array
  81039. * Throws an error if the pixel format is not supported
  81040. * @param pixels - array buffer containing pixel values
  81041. * @returns Float32 of pixels
  81042. */
  81043. private _convertPixelArrayToFloat32;
  81044. /**
  81045. * Convert Specular Glossiness Textures to Metallic Roughness
  81046. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81047. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81048. * @param diffuseTexture texture used to store diffuse information
  81049. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81050. * @param factors specular glossiness material factors
  81051. * @param mimeType the mime type to use for the texture
  81052. * @returns pbr metallic roughness interface or null
  81053. */
  81054. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81055. /**
  81056. * Converts specular glossiness material properties to metallic roughness
  81057. * @param specularGlossiness interface with specular glossiness material properties
  81058. * @returns interface with metallic roughness material properties
  81059. */
  81060. private _convertSpecularGlossinessToMetallicRoughness;
  81061. /**
  81062. * Calculates the surface reflectance, independent of lighting conditions
  81063. * @param color Color source to calculate brightness from
  81064. * @returns number representing the perceived brightness, or zero if color is undefined
  81065. */
  81066. private _getPerceivedBrightness;
  81067. /**
  81068. * Returns the maximum color component value
  81069. * @param color
  81070. * @returns maximum color component value, or zero if color is null or undefined
  81071. */
  81072. private _getMaxComponent;
  81073. /**
  81074. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81075. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81076. * @param mimeType mime type to use for the textures
  81077. * @param images array of glTF image interfaces
  81078. * @param textures array of glTF texture interfaces
  81079. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81080. * @param imageData map of image file name to data
  81081. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81082. * @returns glTF PBR Metallic Roughness factors
  81083. */
  81084. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81085. private _getGLTFTextureSampler;
  81086. private _getGLTFTextureWrapMode;
  81087. private _getGLTFTextureWrapModesSampler;
  81088. /**
  81089. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81090. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81091. * @param mimeType mime type to use for the textures
  81092. * @param images array of glTF image interfaces
  81093. * @param textures array of glTF texture interfaces
  81094. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81095. * @param imageData map of image file name to data
  81096. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81097. * @returns glTF PBR Metallic Roughness factors
  81098. */
  81099. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81100. /**
  81101. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81102. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81103. * @param mimeType mime type to use for the textures
  81104. * @param images array of glTF image interfaces
  81105. * @param textures array of glTF texture interfaces
  81106. * @param materials array of glTF material interfaces
  81107. * @param imageData map of image file name to data
  81108. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81109. */
  81110. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81111. private setMetallicRoughnessPbrMaterial;
  81112. private getPixelsFromTexture;
  81113. /**
  81114. * Extracts a texture from a Babylon texture into file data and glTF data
  81115. * @param babylonTexture Babylon texture to extract
  81116. * @param mimeType Mime Type of the babylonTexture
  81117. * @return glTF texture info, or null if the texture format is not supported
  81118. */
  81119. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81120. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81121. /**
  81122. * Builds a texture from base64 string
  81123. * @param base64Texture base64 texture string
  81124. * @param baseTextureName Name to use for the texture
  81125. * @param mimeType image mime type for the texture
  81126. * @param images array of images
  81127. * @param textures array of textures
  81128. * @param imageData map of image data
  81129. * @returns glTF texture info, or null if the texture format is not supported
  81130. */
  81131. private _getTextureInfoFromBase64;
  81132. }
  81133. }
  81134. declare module BABYLON {
  81135. /**
  81136. * Class for holding and downloading glTF file data
  81137. */
  81138. export class GLTFData {
  81139. /**
  81140. * Object which contains the file name as the key and its data as the value
  81141. */
  81142. glTFFiles: {
  81143. [fileName: string]: string | Blob;
  81144. };
  81145. /**
  81146. * Initializes the glTF file object
  81147. */
  81148. constructor();
  81149. /**
  81150. * Downloads the glTF data as files based on their names and data
  81151. */
  81152. downloadFiles(): void;
  81153. }
  81154. }
  81155. declare module BABYLON {
  81156. /**
  81157. * Holds a collection of exporter options and parameters
  81158. */
  81159. export interface IExportOptions {
  81160. /**
  81161. * Function which indicates whether a babylon node should be exported or not
  81162. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81163. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81164. */
  81165. shouldExportNode?(node: Node): boolean;
  81166. /**
  81167. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81168. * @param metadata source metadata to read from
  81169. * @returns the data to store to glTF node extras
  81170. */
  81171. metadataSelector?(metadata: any): any;
  81172. /**
  81173. * The sample rate to bake animation curves
  81174. */
  81175. animationSampleRate?: number;
  81176. /**
  81177. * Begin serialization without waiting for the scene to be ready
  81178. */
  81179. exportWithoutWaitingForScene?: boolean;
  81180. /**
  81181. * Indicates if coordinate system swapping root nodes should be included in export
  81182. */
  81183. includeCoordinateSystemConversionNodes?: boolean;
  81184. }
  81185. /**
  81186. * Class for generating glTF data from a Babylon scene.
  81187. */
  81188. export class GLTF2Export {
  81189. /**
  81190. * Exports the geometry of the scene to .gltf file format asynchronously
  81191. * @param scene Babylon scene with scene hierarchy information
  81192. * @param filePrefix File prefix to use when generating the glTF file
  81193. * @param options Exporter options
  81194. * @returns Returns an object with a .gltf file and associates texture names
  81195. * as keys and their data and paths as values
  81196. */
  81197. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81198. private static _PreExportAsync;
  81199. private static _PostExportAsync;
  81200. /**
  81201. * Exports the geometry of the scene to .glb file format asychronously
  81202. * @param scene Babylon scene with scene hierarchy information
  81203. * @param filePrefix File prefix to use when generating glb file
  81204. * @param options Exporter options
  81205. * @returns Returns an object with a .glb filename as key and data as value
  81206. */
  81207. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81208. }
  81209. }
  81210. declare module BABYLON.GLTF2.Exporter {
  81211. /**
  81212. * @hidden
  81213. */
  81214. export class _GLTFUtilities {
  81215. /**
  81216. * Creates a buffer view based on the supplied arguments
  81217. * @param bufferIndex index value of the specified buffer
  81218. * @param byteOffset byte offset value
  81219. * @param byteLength byte length of the bufferView
  81220. * @param byteStride byte distance between conequential elements
  81221. * @param name name of the buffer view
  81222. * @returns bufferView for glTF
  81223. */
  81224. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81225. /**
  81226. * Creates an accessor based on the supplied arguments
  81227. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81228. * @param name The name of the accessor
  81229. * @param type The type of the accessor
  81230. * @param componentType The datatype of components in the attribute
  81231. * @param count The number of attributes referenced by this accessor
  81232. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81233. * @param min Minimum value of each component in this attribute
  81234. * @param max Maximum value of each component in this attribute
  81235. * @returns accessor for glTF
  81236. */
  81237. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81238. /**
  81239. * Calculates the minimum and maximum values of an array of position floats
  81240. * @param positions Positions array of a mesh
  81241. * @param vertexStart Starting vertex offset to calculate min and max values
  81242. * @param vertexCount Number of vertices to check for min and max values
  81243. * @returns min number array and max number array
  81244. */
  81245. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81246. min: number[];
  81247. max: number[];
  81248. };
  81249. /**
  81250. * Converts a new right-handed Vector3
  81251. * @param vector vector3 array
  81252. * @returns right-handed Vector3
  81253. */
  81254. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81255. /**
  81256. * Converts a Vector3 to right-handed
  81257. * @param vector Vector3 to convert to right-handed
  81258. */
  81259. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81260. /**
  81261. * Converts a three element number array to right-handed
  81262. * @param vector number array to convert to right-handed
  81263. */
  81264. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81265. /**
  81266. * Converts a new right-handed Vector3
  81267. * @param vector vector3 array
  81268. * @returns right-handed Vector3
  81269. */
  81270. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81271. /**
  81272. * Converts a Vector3 to right-handed
  81273. * @param vector Vector3 to convert to right-handed
  81274. */
  81275. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81276. /**
  81277. * Converts a three element number array to right-handed
  81278. * @param vector number array to convert to right-handed
  81279. */
  81280. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81281. /**
  81282. * Converts a Vector4 to right-handed
  81283. * @param vector Vector4 to convert to right-handed
  81284. */
  81285. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81286. /**
  81287. * Converts a Vector4 to right-handed
  81288. * @param vector Vector4 to convert to right-handed
  81289. */
  81290. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81291. /**
  81292. * Converts a Quaternion to right-handed
  81293. * @param quaternion Source quaternion to convert to right-handed
  81294. */
  81295. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81296. /**
  81297. * Converts a Quaternion to right-handed
  81298. * @param quaternion Source quaternion to convert to right-handed
  81299. */
  81300. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81301. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81302. }
  81303. }
  81304. declare module BABYLON.GLTF2.Exporter {
  81305. /**
  81306. * Converts Babylon Scene into glTF 2.0.
  81307. * @hidden
  81308. */
  81309. export class _Exporter {
  81310. /**
  81311. * Stores the glTF to export
  81312. */
  81313. _glTF: IGLTF;
  81314. /**
  81315. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81316. */
  81317. _bufferViews: IBufferView[];
  81318. /**
  81319. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81320. */
  81321. _accessors: IAccessor[];
  81322. /**
  81323. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81324. */
  81325. _nodes: INode[];
  81326. /**
  81327. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81328. */
  81329. private _scenes;
  81330. /**
  81331. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81332. */
  81333. private _meshes;
  81334. /**
  81335. * Stores all the generated material information, which represents the appearance of each primitive
  81336. */
  81337. _materials: IMaterial[];
  81338. _materialMap: {
  81339. [materialID: number]: number;
  81340. };
  81341. /**
  81342. * Stores all the generated texture information, which is referenced by glTF materials
  81343. */
  81344. _textures: ITexture[];
  81345. /**
  81346. * Stores all the generated image information, which is referenced by glTF textures
  81347. */
  81348. _images: IImage[];
  81349. /**
  81350. * Stores all the texture samplers
  81351. */
  81352. _samplers: ISampler[];
  81353. /**
  81354. * Stores all the generated animation samplers, which is referenced by glTF animations
  81355. */
  81356. /**
  81357. * Stores the animations for glTF models
  81358. */
  81359. private _animations;
  81360. /**
  81361. * Stores the total amount of bytes stored in the glTF buffer
  81362. */
  81363. private _totalByteLength;
  81364. /**
  81365. * Stores a reference to the Babylon scene containing the source geometry and material information
  81366. */
  81367. _babylonScene: Scene;
  81368. /**
  81369. * Stores a map of the image data, where the key is the file name and the value
  81370. * is the image data
  81371. */
  81372. _imageData: {
  81373. [fileName: string]: {
  81374. data: Uint8Array;
  81375. mimeType: ImageMimeType;
  81376. };
  81377. };
  81378. /**
  81379. * Stores a map of the unique id of a node to its index in the node array
  81380. */
  81381. _nodeMap: {
  81382. [key: number]: number;
  81383. };
  81384. /**
  81385. * Specifies if the source Babylon scene was left handed, and needed conversion.
  81386. */
  81387. _convertToRightHandedSystem: boolean;
  81388. /**
  81389. * Specifies if a Babylon node should be converted to right-handed on export
  81390. */
  81391. _convertToRightHandedSystemMap: {
  81392. [nodeId: number]: boolean;
  81393. };
  81394. _includeCoordinateSystemConversionNodes: boolean;
  81395. /**
  81396. * Baked animation sample rate
  81397. */
  81398. private _animationSampleRate;
  81399. private _options;
  81400. private _localEngine;
  81401. _glTFMaterialExporter: _GLTFMaterialExporter;
  81402. private _extensions;
  81403. private static _ExtensionNames;
  81404. private static _ExtensionFactories;
  81405. private _applyExtension;
  81406. private _applyExtensions;
  81407. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  81408. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  81409. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81410. [key: number]: number;
  81411. }): Promise<Nullable<INode>>;
  81412. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  81413. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  81414. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81415. private _forEachExtensions;
  81416. private _extensionsOnExporting;
  81417. /**
  81418. * Load glTF serializer extensions
  81419. */
  81420. private _loadExtensions;
  81421. /**
  81422. * Creates a glTF Exporter instance, which can accept optional exporter options
  81423. * @param babylonScene Babylon scene object
  81424. * @param options Options to modify the behavior of the exporter
  81425. */
  81426. constructor(babylonScene: Scene, options?: IExportOptions);
  81427. dispose(): void;
  81428. /**
  81429. * Registers a glTF exporter extension
  81430. * @param name Name of the extension to export
  81431. * @param factory The factory function that creates the exporter extension
  81432. */
  81433. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  81434. /**
  81435. * Un-registers an exporter extension
  81436. * @param name The name fo the exporter extension
  81437. * @returns A boolean indicating whether the extension has been un-registered
  81438. */
  81439. static UnregisterExtension(name: string): boolean;
  81440. /**
  81441. * Lazy load a local engine
  81442. */
  81443. _getLocalEngine(): Engine;
  81444. private reorderIndicesBasedOnPrimitiveMode;
  81445. /**
  81446. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  81447. * clock-wise during export to glTF
  81448. * @param submesh BabylonJS submesh
  81449. * @param primitiveMode Primitive mode of the mesh
  81450. * @param sideOrientation the winding order of the submesh
  81451. * @param vertexBufferKind The type of vertex attribute
  81452. * @param meshAttributeArray The vertex attribute data
  81453. * @param byteOffset The offset to the binary data
  81454. * @param binaryWriter The binary data for the glTF file
  81455. * @param convertToRightHandedSystem Converts the values to right-handed
  81456. */
  81457. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  81458. /**
  81459. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  81460. * clock-wise during export to glTF
  81461. * @param submesh BabylonJS submesh
  81462. * @param primitiveMode Primitive mode of the mesh
  81463. * @param sideOrientation the winding order of the submesh
  81464. * @param vertexBufferKind The type of vertex attribute
  81465. * @param meshAttributeArray The vertex attribute data
  81466. * @param byteOffset The offset to the binary data
  81467. * @param binaryWriter The binary data for the glTF file
  81468. * @param convertToRightHandedSystem Converts the values to right-handed
  81469. */
  81470. private reorderTriangleFillMode;
  81471. /**
  81472. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  81473. * clock-wise during export to glTF
  81474. * @param submesh BabylonJS submesh
  81475. * @param primitiveMode Primitive mode of the mesh
  81476. * @param sideOrientation the winding order of the submesh
  81477. * @param vertexBufferKind The type of vertex attribute
  81478. * @param meshAttributeArray The vertex attribute data
  81479. * @param byteOffset The offset to the binary data
  81480. * @param binaryWriter The binary data for the glTF file
  81481. * @param convertToRightHandedSystem Converts the values to right-handed
  81482. */
  81483. private reorderTriangleStripDrawMode;
  81484. /**
  81485. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  81486. * clock-wise during export to glTF
  81487. * @param submesh BabylonJS submesh
  81488. * @param primitiveMode Primitive mode of the mesh
  81489. * @param sideOrientation the winding order of the submesh
  81490. * @param vertexBufferKind The type of vertex attribute
  81491. * @param meshAttributeArray The vertex attribute data
  81492. * @param byteOffset The offset to the binary data
  81493. * @param binaryWriter The binary data for the glTF file
  81494. * @param convertToRightHandedSystem Converts the values to right-handed
  81495. */
  81496. private reorderTriangleFanMode;
  81497. /**
  81498. * Writes the vertex attribute data to binary
  81499. * @param vertices The vertices to write to the binary writer
  81500. * @param byteOffset The offset into the binary writer to overwrite binary data
  81501. * @param vertexAttributeKind The vertex attribute type
  81502. * @param meshAttributeArray The vertex attribute data
  81503. * @param binaryWriter The writer containing the binary data
  81504. * @param convertToRightHandedSystem Converts the values to right-handed
  81505. */
  81506. private writeVertexAttributeData;
  81507. /**
  81508. * Writes mesh attribute data to a data buffer
  81509. * Returns the bytelength of the data
  81510. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  81511. * @param meshAttributeArray Array containing the attribute data
  81512. * @param binaryWriter The buffer to write the binary data to
  81513. * @param indices Used to specify the order of the vertex data
  81514. * @param convertToRightHandedSystem Converts the values to right-handed
  81515. */
  81516. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  81517. /**
  81518. * Generates glTF json data
  81519. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  81520. * @param glTFPrefix Text to use when prefixing a glTF file
  81521. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  81522. * @returns json data as string
  81523. */
  81524. private generateJSON;
  81525. /**
  81526. * Generates data for .gltf and .bin files based on the glTF prefix string
  81527. * @param glTFPrefix Text to use when prefixing a glTF file
  81528. * @param dispose Dispose the exporter
  81529. * @returns GLTFData with glTF file data
  81530. */
  81531. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81532. /**
  81533. * Creates a binary buffer for glTF
  81534. * @returns array buffer for binary data
  81535. */
  81536. private _generateBinaryAsync;
  81537. /**
  81538. * Pads the number to a multiple of 4
  81539. * @param num number to pad
  81540. * @returns padded number
  81541. */
  81542. private _getPadding;
  81543. /**
  81544. * @hidden
  81545. */
  81546. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  81547. /**
  81548. * Sets the TRS for each node
  81549. * @param node glTF Node for storing the transformation data
  81550. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  81551. * @param convertToRightHandedSystem Converts the values to right-handed
  81552. */
  81553. private setNodeTransformation;
  81554. private getVertexBufferFromMesh;
  81555. /**
  81556. * Creates a bufferview based on the vertices type for the Babylon mesh
  81557. * @param kind Indicates the type of vertices data
  81558. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  81559. * @param binaryWriter The buffer to write the bufferview data to
  81560. * @param convertToRightHandedSystem Converts the values to right-handed
  81561. */
  81562. private createBufferViewKind;
  81563. /**
  81564. * The primitive mode of the Babylon mesh
  81565. * @param babylonMesh The BabylonJS mesh
  81566. */
  81567. private getMeshPrimitiveMode;
  81568. /**
  81569. * Sets the primitive mode of the glTF mesh primitive
  81570. * @param meshPrimitive glTF mesh primitive
  81571. * @param primitiveMode The primitive mode
  81572. */
  81573. private setPrimitiveMode;
  81574. /**
  81575. * Sets the vertex attribute accessor based of the glTF mesh primitive
  81576. * @param meshPrimitive glTF mesh primitive
  81577. * @param attributeKind vertex attribute
  81578. * @returns boolean specifying if uv coordinates are present
  81579. */
  81580. private setAttributeKind;
  81581. /**
  81582. * Sets data for the primitive attributes of each submesh
  81583. * @param mesh glTF Mesh object to store the primitive attribute information
  81584. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  81585. * @param binaryWriter Buffer to write the attribute data to
  81586. * @param convertToRightHandedSystem Converts the values to right-handed
  81587. */
  81588. private setPrimitiveAttributesAsync;
  81589. /**
  81590. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  81591. * @param node The node to check
  81592. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  81593. */
  81594. private isBabylonCoordinateSystemConvertingNode;
  81595. /**
  81596. * Creates a glTF scene based on the array of meshes
  81597. * Returns the the total byte offset
  81598. * @param babylonScene Babylon scene to get the mesh data from
  81599. * @param binaryWriter Buffer to write binary data to
  81600. */
  81601. private createSceneAsync;
  81602. /**
  81603. * Creates a mapping of Node unique id to node index and handles animations
  81604. * @param babylonScene Babylon Scene
  81605. * @param nodes Babylon transform nodes
  81606. * @param binaryWriter Buffer to write binary data to
  81607. * @returns Node mapping of unique id to index
  81608. */
  81609. private createNodeMapAndAnimationsAsync;
  81610. /**
  81611. * Creates a glTF node from a Babylon mesh
  81612. * @param babylonMesh Source Babylon mesh
  81613. * @param binaryWriter Buffer for storing geometry data
  81614. * @param convertToRightHandedSystem Converts the values to right-handed
  81615. * @param nodeMap Node mapping of unique id to glTF node index
  81616. * @returns glTF node
  81617. */
  81618. private createNodeAsync;
  81619. }
  81620. /**
  81621. * @hidden
  81622. *
  81623. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  81624. */
  81625. export class _BinaryWriter {
  81626. /**
  81627. * Array buffer which stores all binary data
  81628. */
  81629. private _arrayBuffer;
  81630. /**
  81631. * View of the array buffer
  81632. */
  81633. private _dataView;
  81634. /**
  81635. * byte offset of data in array buffer
  81636. */
  81637. private _byteOffset;
  81638. /**
  81639. * Initialize binary writer with an initial byte length
  81640. * @param byteLength Initial byte length of the array buffer
  81641. */
  81642. constructor(byteLength: number);
  81643. /**
  81644. * Resize the array buffer to the specified byte length
  81645. * @param byteLength
  81646. */
  81647. private resizeBuffer;
  81648. /**
  81649. * Get an array buffer with the length of the byte offset
  81650. * @returns ArrayBuffer resized to the byte offset
  81651. */
  81652. getArrayBuffer(): ArrayBuffer;
  81653. /**
  81654. * Get the byte offset of the array buffer
  81655. * @returns byte offset
  81656. */
  81657. getByteOffset(): number;
  81658. /**
  81659. * Stores an UInt8 in the array buffer
  81660. * @param entry
  81661. * @param byteOffset If defined, specifies where to set the value as an offset.
  81662. */
  81663. setUInt8(entry: number, byteOffset?: number): void;
  81664. /**
  81665. * Gets an UInt32 in the array buffer
  81666. * @param entry
  81667. * @param byteOffset If defined, specifies where to set the value as an offset.
  81668. */
  81669. getUInt32(byteOffset: number): number;
  81670. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81671. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  81672. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81673. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  81674. /**
  81675. * Stores a Float32 in the array buffer
  81676. * @param entry
  81677. */
  81678. setFloat32(entry: number, byteOffset?: number): void;
  81679. /**
  81680. * Stores an UInt32 in the array buffer
  81681. * @param entry
  81682. * @param byteOffset If defined, specifies where to set the value as an offset.
  81683. */
  81684. setUInt32(entry: number, byteOffset?: number): void;
  81685. }
  81686. }
  81687. declare module BABYLON.GLTF2.Exporter {
  81688. /**
  81689. * @hidden
  81690. * Interface to store animation data.
  81691. */
  81692. export interface _IAnimationData {
  81693. /**
  81694. * Keyframe data.
  81695. */
  81696. inputs: number[];
  81697. /**
  81698. * Value data.
  81699. */
  81700. outputs: number[][];
  81701. /**
  81702. * Animation interpolation data.
  81703. */
  81704. samplerInterpolation: AnimationSamplerInterpolation;
  81705. /**
  81706. * Minimum keyframe value.
  81707. */
  81708. inputsMin: number;
  81709. /**
  81710. * Maximum keyframe value.
  81711. */
  81712. inputsMax: number;
  81713. }
  81714. /**
  81715. * @hidden
  81716. */
  81717. export interface _IAnimationInfo {
  81718. /**
  81719. * The target channel for the animation
  81720. */
  81721. animationChannelTargetPath: AnimationChannelTargetPath;
  81722. /**
  81723. * The glTF accessor type for the data.
  81724. */
  81725. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  81726. /**
  81727. * Specifies if quaternions should be used.
  81728. */
  81729. useQuaternion: boolean;
  81730. }
  81731. /**
  81732. * @hidden
  81733. * Utility class for generating glTF animation data from BabylonJS.
  81734. */
  81735. export class _GLTFAnimation {
  81736. /**
  81737. * @ignore
  81738. *
  81739. * Creates glTF channel animation from BabylonJS animation.
  81740. * @param babylonTransformNode - BabylonJS mesh.
  81741. * @param animation - animation.
  81742. * @param animationChannelTargetPath - The target animation channel.
  81743. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  81744. * @param useQuaternion - Specifies if quaternions are used.
  81745. * @returns nullable IAnimationData
  81746. */
  81747. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  81748. private static _DeduceAnimationInfo;
  81749. /**
  81750. * @ignore
  81751. * Create node animations from the transform node animations
  81752. * @param babylonNode
  81753. * @param runtimeGLTFAnimation
  81754. * @param idleGLTFAnimations
  81755. * @param nodeMap
  81756. * @param nodes
  81757. * @param binaryWriter
  81758. * @param bufferViews
  81759. * @param accessors
  81760. * @param convertToRightHandedSystem
  81761. * @param animationSampleRate
  81762. */
  81763. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  81764. [key: number]: number;
  81765. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  81766. /**
  81767. * @ignore
  81768. * Create node animations from the animation groups
  81769. * @param babylonScene
  81770. * @param glTFAnimations
  81771. * @param nodeMap
  81772. * @param nodes
  81773. * @param binaryWriter
  81774. * @param bufferViews
  81775. * @param accessors
  81776. * @param convertToRightHandedSystemMap
  81777. * @param animationSampleRate
  81778. */
  81779. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  81780. [key: number]: number;
  81781. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  81782. [nodeId: number]: boolean;
  81783. }, animationSampleRate: number): void;
  81784. private static AddAnimation;
  81785. /**
  81786. * Create a baked animation
  81787. * @param babylonTransformNode BabylonJS mesh
  81788. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  81789. * @param animationChannelTargetPath animation target channel
  81790. * @param minFrame minimum animation frame
  81791. * @param maxFrame maximum animation frame
  81792. * @param fps frames per second of the animation
  81793. * @param inputs input key frames of the animation
  81794. * @param outputs output key frame data of the animation
  81795. * @param convertToRightHandedSystem converts the values to right-handed
  81796. * @param useQuaternion specifies if quaternions should be used
  81797. */
  81798. private static _CreateBakedAnimation;
  81799. private static _ConvertFactorToVector3OrQuaternion;
  81800. private static _SetInterpolatedValue;
  81801. /**
  81802. * Creates linear animation from the animation key frames
  81803. * @param babylonTransformNode BabylonJS mesh
  81804. * @param animation BabylonJS animation
  81805. * @param animationChannelTargetPath The target animation channel
  81806. * @param frameDelta The difference between the last and first frame of the animation
  81807. * @param inputs Array to store the key frame times
  81808. * @param outputs Array to store the key frame data
  81809. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81810. * @param useQuaternion Specifies if quaternions are used in the animation
  81811. */
  81812. private static _CreateLinearOrStepAnimation;
  81813. /**
  81814. * Creates cubic spline animation from the animation key frames
  81815. * @param babylonTransformNode BabylonJS mesh
  81816. * @param animation BabylonJS animation
  81817. * @param animationChannelTargetPath The target animation channel
  81818. * @param frameDelta The difference between the last and first frame of the animation
  81819. * @param inputs Array to store the key frame times
  81820. * @param outputs Array to store the key frame data
  81821. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  81822. * @param useQuaternion Specifies if quaternions are used in the animation
  81823. */
  81824. private static _CreateCubicSplineAnimation;
  81825. private static _GetBasePositionRotationOrScale;
  81826. /**
  81827. * Adds a key frame value
  81828. * @param keyFrame
  81829. * @param animation
  81830. * @param outputs
  81831. * @param animationChannelTargetPath
  81832. * @param basePositionRotationOrScale
  81833. * @param convertToRightHandedSystem
  81834. * @param useQuaternion
  81835. */
  81836. private static _AddKeyframeValue;
  81837. /**
  81838. * Determine the interpolation based on the key frames
  81839. * @param keyFrames
  81840. * @param animationChannelTargetPath
  81841. * @param useQuaternion
  81842. */
  81843. private static _DeduceInterpolation;
  81844. /**
  81845. * Adds an input tangent or output tangent to the output data
  81846. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  81847. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  81848. * @param outputs The animation data by keyframe
  81849. * @param animationChannelTargetPath The target animation channel
  81850. * @param interpolation The interpolation type
  81851. * @param keyFrame The key frame with the animation data
  81852. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  81853. * @param useQuaternion Specifies if quaternions are used
  81854. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  81855. */
  81856. private static AddSplineTangent;
  81857. /**
  81858. * Get the minimum and maximum key frames' frame values
  81859. * @param keyFrames animation key frames
  81860. * @returns the minimum and maximum key frame value
  81861. */
  81862. private static calculateMinMaxKeyFrames;
  81863. }
  81864. }
  81865. declare module BABYLON.GLTF2.Exporter {
  81866. /** @hidden */
  81867. export var textureTransformPixelShader: {
  81868. name: string;
  81869. shader: string;
  81870. };
  81871. }
  81872. declare module BABYLON.GLTF2.Exporter.Extensions {
  81873. /**
  81874. * @hidden
  81875. */
  81876. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  81877. private _recordedTextures;
  81878. /** Name of this extension */
  81879. readonly name: string;
  81880. /** Defines whether this extension is enabled */
  81881. enabled: boolean;
  81882. /** Defines whether this extension is required */
  81883. required: boolean;
  81884. /** Reference to the glTF exporter */
  81885. private _wasUsed;
  81886. constructor(exporter: _Exporter);
  81887. dispose(): void;
  81888. /** @hidden */
  81889. get wasUsed(): boolean;
  81890. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81891. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  81892. /**
  81893. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  81894. * @param babylonTexture
  81895. * @param offset
  81896. * @param rotation
  81897. * @param scale
  81898. * @param scene
  81899. */
  81900. private _textureTransformTextureAsync;
  81901. }
  81902. }
  81903. declare module BABYLON.GLTF2.Exporter.Extensions {
  81904. /**
  81905. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  81906. */
  81907. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  81908. /** The name of this extension. */
  81909. readonly name: string;
  81910. /** Defines whether this extension is enabled. */
  81911. enabled: boolean;
  81912. /** Defines whether this extension is required */
  81913. required: boolean;
  81914. /** Reference to the glTF exporter */
  81915. private _exporter;
  81916. private _lights;
  81917. /** @hidden */
  81918. constructor(exporter: _Exporter);
  81919. /** @hidden */
  81920. dispose(): void;
  81921. /** @hidden */
  81922. get wasUsed(): boolean;
  81923. /** @hidden */
  81924. onExporting(): void;
  81925. /**
  81926. * Define this method to modify the default behavior when exporting a node
  81927. * @param context The context when exporting the node
  81928. * @param node glTF node
  81929. * @param babylonNode BabylonJS node
  81930. * @param nodeMap Node mapping of unique id to glTF node index
  81931. * @returns nullable INode promise
  81932. */
  81933. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81934. [key: number]: number;
  81935. }): Promise<Nullable<INode>>;
  81936. }
  81937. }
  81938. declare module BABYLON.GLTF2.Exporter.Extensions {
  81939. /**
  81940. * @hidden
  81941. */
  81942. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  81943. /** Name of this extension */
  81944. readonly name: string;
  81945. /** Defines whether this extension is enabled */
  81946. enabled: boolean;
  81947. /** Defines whether this extension is required */
  81948. required: boolean;
  81949. /** Reference to the glTF exporter */
  81950. private _textureInfos;
  81951. private _exportedTextures;
  81952. private _wasUsed;
  81953. constructor(exporter: _Exporter);
  81954. dispose(): void;
  81955. /** @hidden */
  81956. get wasUsed(): boolean;
  81957. private _getTextureIndex;
  81958. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  81959. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81960. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  81961. }
  81962. }
  81963. declare module BABYLON {
  81964. /**
  81965. * Class for generating STL data from a Babylon scene.
  81966. */
  81967. export class STLExport {
  81968. /**
  81969. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  81970. * @param meshes list defines the mesh to serialize
  81971. * @param download triggers the automatic download of the file.
  81972. * @param fileName changes the downloads fileName.
  81973. * @param binary changes the STL to a binary type.
  81974. * @param isLittleEndian toggle for binary type exporter.
  81975. * @returns the STL as UTF8 string
  81976. */
  81977. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  81978. }
  81979. }
  81980. declare module "babylonjs-gltf2interface" {
  81981. export = BABYLON.GLTF2;
  81982. }
  81983. /**
  81984. * Module for glTF 2.0 Interface
  81985. */
  81986. declare module BABYLON.GLTF2 {
  81987. /**
  81988. * The datatype of the components in the attribute
  81989. */
  81990. const enum AccessorComponentType {
  81991. /**
  81992. * Byte
  81993. */
  81994. BYTE = 5120,
  81995. /**
  81996. * Unsigned Byte
  81997. */
  81998. UNSIGNED_BYTE = 5121,
  81999. /**
  82000. * Short
  82001. */
  82002. SHORT = 5122,
  82003. /**
  82004. * Unsigned Short
  82005. */
  82006. UNSIGNED_SHORT = 5123,
  82007. /**
  82008. * Unsigned Int
  82009. */
  82010. UNSIGNED_INT = 5125,
  82011. /**
  82012. * Float
  82013. */
  82014. FLOAT = 5126,
  82015. }
  82016. /**
  82017. * Specifies if the attirbute is a scalar, vector, or matrix
  82018. */
  82019. const enum AccessorType {
  82020. /**
  82021. * Scalar
  82022. */
  82023. SCALAR = "SCALAR",
  82024. /**
  82025. * Vector2
  82026. */
  82027. VEC2 = "VEC2",
  82028. /**
  82029. * Vector3
  82030. */
  82031. VEC3 = "VEC3",
  82032. /**
  82033. * Vector4
  82034. */
  82035. VEC4 = "VEC4",
  82036. /**
  82037. * Matrix2x2
  82038. */
  82039. MAT2 = "MAT2",
  82040. /**
  82041. * Matrix3x3
  82042. */
  82043. MAT3 = "MAT3",
  82044. /**
  82045. * Matrix4x4
  82046. */
  82047. MAT4 = "MAT4",
  82048. }
  82049. /**
  82050. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82051. */
  82052. const enum AnimationChannelTargetPath {
  82053. /**
  82054. * Translation
  82055. */
  82056. TRANSLATION = "translation",
  82057. /**
  82058. * Rotation
  82059. */
  82060. ROTATION = "rotation",
  82061. /**
  82062. * Scale
  82063. */
  82064. SCALE = "scale",
  82065. /**
  82066. * Weights
  82067. */
  82068. WEIGHTS = "weights",
  82069. }
  82070. /**
  82071. * Interpolation algorithm
  82072. */
  82073. const enum AnimationSamplerInterpolation {
  82074. /**
  82075. * The animated values are linearly interpolated between keyframes
  82076. */
  82077. LINEAR = "LINEAR",
  82078. /**
  82079. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82080. */
  82081. STEP = "STEP",
  82082. /**
  82083. * The animation's interpolation is computed using a cubic spline with specified tangents
  82084. */
  82085. CUBICSPLINE = "CUBICSPLINE",
  82086. }
  82087. /**
  82088. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82089. */
  82090. const enum CameraType {
  82091. /**
  82092. * A perspective camera containing properties to create a perspective projection matrix
  82093. */
  82094. PERSPECTIVE = "perspective",
  82095. /**
  82096. * An orthographic camera containing properties to create an orthographic projection matrix
  82097. */
  82098. ORTHOGRAPHIC = "orthographic",
  82099. }
  82100. /**
  82101. * The mime-type of the image
  82102. */
  82103. const enum ImageMimeType {
  82104. /**
  82105. * JPEG Mime-type
  82106. */
  82107. JPEG = "image/jpeg",
  82108. /**
  82109. * PNG Mime-type
  82110. */
  82111. PNG = "image/png",
  82112. }
  82113. /**
  82114. * The alpha rendering mode of the material
  82115. */
  82116. const enum MaterialAlphaMode {
  82117. /**
  82118. * The alpha value is ignored and the rendered output is fully opaque
  82119. */
  82120. OPAQUE = "OPAQUE",
  82121. /**
  82122. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82123. */
  82124. MASK = "MASK",
  82125. /**
  82126. * 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)
  82127. */
  82128. BLEND = "BLEND",
  82129. }
  82130. /**
  82131. * The type of the primitives to render
  82132. */
  82133. const enum MeshPrimitiveMode {
  82134. /**
  82135. * Points
  82136. */
  82137. POINTS = 0,
  82138. /**
  82139. * Lines
  82140. */
  82141. LINES = 1,
  82142. /**
  82143. * Line Loop
  82144. */
  82145. LINE_LOOP = 2,
  82146. /**
  82147. * Line Strip
  82148. */
  82149. LINE_STRIP = 3,
  82150. /**
  82151. * Triangles
  82152. */
  82153. TRIANGLES = 4,
  82154. /**
  82155. * Triangle Strip
  82156. */
  82157. TRIANGLE_STRIP = 5,
  82158. /**
  82159. * Triangle Fan
  82160. */
  82161. TRIANGLE_FAN = 6,
  82162. }
  82163. /**
  82164. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82165. */
  82166. const enum TextureMagFilter {
  82167. /**
  82168. * Nearest
  82169. */
  82170. NEAREST = 9728,
  82171. /**
  82172. * Linear
  82173. */
  82174. LINEAR = 9729,
  82175. }
  82176. /**
  82177. * Minification filter. All valid values correspond to WebGL enums
  82178. */
  82179. const enum TextureMinFilter {
  82180. /**
  82181. * Nearest
  82182. */
  82183. NEAREST = 9728,
  82184. /**
  82185. * Linear
  82186. */
  82187. LINEAR = 9729,
  82188. /**
  82189. * Nearest Mip-Map Nearest
  82190. */
  82191. NEAREST_MIPMAP_NEAREST = 9984,
  82192. /**
  82193. * Linear Mipmap Nearest
  82194. */
  82195. LINEAR_MIPMAP_NEAREST = 9985,
  82196. /**
  82197. * Nearest Mipmap Linear
  82198. */
  82199. NEAREST_MIPMAP_LINEAR = 9986,
  82200. /**
  82201. * Linear Mipmap Linear
  82202. */
  82203. LINEAR_MIPMAP_LINEAR = 9987,
  82204. }
  82205. /**
  82206. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82207. */
  82208. const enum TextureWrapMode {
  82209. /**
  82210. * Clamp to Edge
  82211. */
  82212. CLAMP_TO_EDGE = 33071,
  82213. /**
  82214. * Mirrored Repeat
  82215. */
  82216. MIRRORED_REPEAT = 33648,
  82217. /**
  82218. * Repeat
  82219. */
  82220. REPEAT = 10497,
  82221. }
  82222. /**
  82223. * glTF Property
  82224. */
  82225. interface IProperty {
  82226. /**
  82227. * Dictionary object with extension-specific objects
  82228. */
  82229. extensions?: {
  82230. [key: string]: any;
  82231. };
  82232. /**
  82233. * Application-Specific data
  82234. */
  82235. extras?: any;
  82236. }
  82237. /**
  82238. * glTF Child of Root Property
  82239. */
  82240. interface IChildRootProperty extends IProperty {
  82241. /**
  82242. * The user-defined name of this object
  82243. */
  82244. name?: string;
  82245. }
  82246. /**
  82247. * Indices of those attributes that deviate from their initialization value
  82248. */
  82249. interface IAccessorSparseIndices extends IProperty {
  82250. /**
  82251. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82252. */
  82253. bufferView: number;
  82254. /**
  82255. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82256. */
  82257. byteOffset?: number;
  82258. /**
  82259. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82260. */
  82261. componentType: AccessorComponentType;
  82262. }
  82263. /**
  82264. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82265. */
  82266. interface IAccessorSparseValues extends IProperty {
  82267. /**
  82268. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82269. */
  82270. bufferView: number;
  82271. /**
  82272. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82273. */
  82274. byteOffset?: number;
  82275. }
  82276. /**
  82277. * Sparse storage of attributes that deviate from their initialization value
  82278. */
  82279. interface IAccessorSparse extends IProperty {
  82280. /**
  82281. * The number of attributes encoded in this sparse accessor
  82282. */
  82283. count: number;
  82284. /**
  82285. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82286. */
  82287. indices: IAccessorSparseIndices;
  82288. /**
  82289. * 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
  82290. */
  82291. values: IAccessorSparseValues;
  82292. }
  82293. /**
  82294. * 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
  82295. */
  82296. interface IAccessor extends IChildRootProperty {
  82297. /**
  82298. * The index of the bufferview
  82299. */
  82300. bufferView?: number;
  82301. /**
  82302. * The offset relative to the start of the bufferView in bytes
  82303. */
  82304. byteOffset?: number;
  82305. /**
  82306. * The datatype of components in the attribute
  82307. */
  82308. componentType: AccessorComponentType;
  82309. /**
  82310. * Specifies whether integer data values should be normalized
  82311. */
  82312. normalized?: boolean;
  82313. /**
  82314. * The number of attributes referenced by this accessor
  82315. */
  82316. count: number;
  82317. /**
  82318. * Specifies if the attribute is a scalar, vector, or matrix
  82319. */
  82320. type: AccessorType;
  82321. /**
  82322. * Maximum value of each component in this attribute
  82323. */
  82324. max?: number[];
  82325. /**
  82326. * Minimum value of each component in this attribute
  82327. */
  82328. min?: number[];
  82329. /**
  82330. * Sparse storage of attributes that deviate from their initialization value
  82331. */
  82332. sparse?: IAccessorSparse;
  82333. }
  82334. /**
  82335. * Targets an animation's sampler at a node's property
  82336. */
  82337. interface IAnimationChannel extends IProperty {
  82338. /**
  82339. * The index of a sampler in this animation used to compute the value for the target
  82340. */
  82341. sampler: number;
  82342. /**
  82343. * The index of the node and TRS property to target
  82344. */
  82345. target: IAnimationChannelTarget;
  82346. }
  82347. /**
  82348. * The index of the node and TRS property that an animation channel targets
  82349. */
  82350. interface IAnimationChannelTarget extends IProperty {
  82351. /**
  82352. * The index of the node to target
  82353. */
  82354. node: number;
  82355. /**
  82356. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82357. */
  82358. path: AnimationChannelTargetPath;
  82359. }
  82360. /**
  82361. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82362. */
  82363. interface IAnimationSampler extends IProperty {
  82364. /**
  82365. * The index of an accessor containing keyframe input values, e.g., time
  82366. */
  82367. input: number;
  82368. /**
  82369. * Interpolation algorithm
  82370. */
  82371. interpolation?: AnimationSamplerInterpolation;
  82372. /**
  82373. * The index of an accessor, containing keyframe output values
  82374. */
  82375. output: number;
  82376. }
  82377. /**
  82378. * A keyframe animation
  82379. */
  82380. interface IAnimation extends IChildRootProperty {
  82381. /**
  82382. * An array of channels, each of which targets an animation's sampler at a node's property
  82383. */
  82384. channels: IAnimationChannel[];
  82385. /**
  82386. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  82387. */
  82388. samplers: IAnimationSampler[];
  82389. }
  82390. /**
  82391. * Metadata about the glTF asset
  82392. */
  82393. interface IAsset extends IChildRootProperty {
  82394. /**
  82395. * A copyright message suitable for display to credit the content creator
  82396. */
  82397. copyright?: string;
  82398. /**
  82399. * Tool that generated this glTF model. Useful for debugging
  82400. */
  82401. generator?: string;
  82402. /**
  82403. * The glTF version that this asset targets
  82404. */
  82405. version: string;
  82406. /**
  82407. * The minimum glTF version that this asset targets
  82408. */
  82409. minVersion?: string;
  82410. }
  82411. /**
  82412. * A buffer points to binary geometry, animation, or skins
  82413. */
  82414. interface IBuffer extends IChildRootProperty {
  82415. /**
  82416. * 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
  82417. */
  82418. uri?: string;
  82419. /**
  82420. * The length of the buffer in bytes
  82421. */
  82422. byteLength: number;
  82423. }
  82424. /**
  82425. * A view into a buffer generally representing a subset of the buffer
  82426. */
  82427. interface IBufferView extends IChildRootProperty {
  82428. /**
  82429. * The index of the buffer
  82430. */
  82431. buffer: number;
  82432. /**
  82433. * The offset into the buffer in bytes
  82434. */
  82435. byteOffset?: number;
  82436. /**
  82437. * The lenth of the bufferView in bytes
  82438. */
  82439. byteLength: number;
  82440. /**
  82441. * The stride, in bytes
  82442. */
  82443. byteStride?: number;
  82444. }
  82445. /**
  82446. * An orthographic camera containing properties to create an orthographic projection matrix
  82447. */
  82448. interface ICameraOrthographic extends IProperty {
  82449. /**
  82450. * The floating-point horizontal magnification of the view. Must not be zero
  82451. */
  82452. xmag: number;
  82453. /**
  82454. * The floating-point vertical magnification of the view. Must not be zero
  82455. */
  82456. ymag: number;
  82457. /**
  82458. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  82459. */
  82460. zfar: number;
  82461. /**
  82462. * The floating-point distance to the near clipping plane
  82463. */
  82464. znear: number;
  82465. }
  82466. /**
  82467. * A perspective camera containing properties to create a perspective projection matrix
  82468. */
  82469. interface ICameraPerspective extends IProperty {
  82470. /**
  82471. * The floating-point aspect ratio of the field of view
  82472. */
  82473. aspectRatio?: number;
  82474. /**
  82475. * The floating-point vertical field of view in radians
  82476. */
  82477. yfov: number;
  82478. /**
  82479. * The floating-point distance to the far clipping plane
  82480. */
  82481. zfar?: number;
  82482. /**
  82483. * The floating-point distance to the near clipping plane
  82484. */
  82485. znear: number;
  82486. }
  82487. /**
  82488. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82489. */
  82490. interface ICamera extends IChildRootProperty {
  82491. /**
  82492. * An orthographic camera containing properties to create an orthographic projection matrix
  82493. */
  82494. orthographic?: ICameraOrthographic;
  82495. /**
  82496. * A perspective camera containing properties to create a perspective projection matrix
  82497. */
  82498. perspective?: ICameraPerspective;
  82499. /**
  82500. * Specifies if the camera uses a perspective or orthographic projection
  82501. */
  82502. type: CameraType;
  82503. }
  82504. /**
  82505. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  82506. */
  82507. interface IImage extends IChildRootProperty {
  82508. /**
  82509. * 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
  82510. */
  82511. uri?: string;
  82512. /**
  82513. * The image's MIME type
  82514. */
  82515. mimeType?: ImageMimeType;
  82516. /**
  82517. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  82518. */
  82519. bufferView?: number;
  82520. }
  82521. /**
  82522. * Material Normal Texture Info
  82523. */
  82524. interface IMaterialNormalTextureInfo extends ITextureInfo {
  82525. /**
  82526. * The scalar multiplier applied to each normal vector of the normal texture
  82527. */
  82528. scale?: number;
  82529. }
  82530. /**
  82531. * Material Occlusion Texture Info
  82532. */
  82533. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  82534. /**
  82535. * A scalar multiplier controlling the amount of occlusion applied
  82536. */
  82537. strength?: number;
  82538. }
  82539. /**
  82540. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  82541. */
  82542. interface IMaterialPbrMetallicRoughness {
  82543. /**
  82544. * The material's base color factor
  82545. */
  82546. baseColorFactor?: number[];
  82547. /**
  82548. * The base color texture
  82549. */
  82550. baseColorTexture?: ITextureInfo;
  82551. /**
  82552. * The metalness of the material
  82553. */
  82554. metallicFactor?: number;
  82555. /**
  82556. * The roughness of the material
  82557. */
  82558. roughnessFactor?: number;
  82559. /**
  82560. * The metallic-roughness texture
  82561. */
  82562. metallicRoughnessTexture?: ITextureInfo;
  82563. }
  82564. /**
  82565. * The material appearance of a primitive
  82566. */
  82567. interface IMaterial extends IChildRootProperty {
  82568. /**
  82569. * 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
  82570. */
  82571. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82572. /**
  82573. * The normal map texture
  82574. */
  82575. normalTexture?: IMaterialNormalTextureInfo;
  82576. /**
  82577. * The occlusion map texture
  82578. */
  82579. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82580. /**
  82581. * The emissive map texture
  82582. */
  82583. emissiveTexture?: ITextureInfo;
  82584. /**
  82585. * 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
  82586. */
  82587. emissiveFactor?: number[];
  82588. /**
  82589. * The alpha rendering mode of the material
  82590. */
  82591. alphaMode?: MaterialAlphaMode;
  82592. /**
  82593. * The alpha cutoff value of the material
  82594. */
  82595. alphaCutoff?: number;
  82596. /**
  82597. * Specifies whether the material is double sided
  82598. */
  82599. doubleSided?: boolean;
  82600. }
  82601. /**
  82602. * Geometry to be rendered with the given material
  82603. */
  82604. interface IMeshPrimitive extends IProperty {
  82605. /**
  82606. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  82607. */
  82608. attributes: {
  82609. [name: string]: number;
  82610. };
  82611. /**
  82612. * The index of the accessor that contains the indices
  82613. */
  82614. indices?: number;
  82615. /**
  82616. * The index of the material to apply to this primitive when rendering
  82617. */
  82618. material?: number;
  82619. /**
  82620. * The type of primitives to render. All valid values correspond to WebGL enums
  82621. */
  82622. mode?: MeshPrimitiveMode;
  82623. /**
  82624. * 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
  82625. */
  82626. targets?: {
  82627. [name: string]: number;
  82628. }[];
  82629. }
  82630. /**
  82631. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  82632. */
  82633. interface IMesh extends IChildRootProperty {
  82634. /**
  82635. * An array of primitives, each defining geometry to be rendered with a material
  82636. */
  82637. primitives: IMeshPrimitive[];
  82638. /**
  82639. * Array of weights to be applied to the Morph Targets
  82640. */
  82641. weights?: number[];
  82642. }
  82643. /**
  82644. * A node in the node hierarchy
  82645. */
  82646. interface INode extends IChildRootProperty {
  82647. /**
  82648. * The index of the camera referenced by this node
  82649. */
  82650. camera?: number;
  82651. /**
  82652. * The indices of this node's children
  82653. */
  82654. children?: number[];
  82655. /**
  82656. * The index of the skin referenced by this node
  82657. */
  82658. skin?: number;
  82659. /**
  82660. * A floating-point 4x4 transformation matrix stored in column-major order
  82661. */
  82662. matrix?: number[];
  82663. /**
  82664. * The index of the mesh in this node
  82665. */
  82666. mesh?: number;
  82667. /**
  82668. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  82669. */
  82670. rotation?: number[];
  82671. /**
  82672. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  82673. */
  82674. scale?: number[];
  82675. /**
  82676. * The node's translation along the x, y, and z axes
  82677. */
  82678. translation?: number[];
  82679. /**
  82680. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  82681. */
  82682. weights?: number[];
  82683. }
  82684. /**
  82685. * Texture sampler properties for filtering and wrapping modes
  82686. */
  82687. interface ISampler extends IChildRootProperty {
  82688. /**
  82689. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82690. */
  82691. magFilter?: TextureMagFilter;
  82692. /**
  82693. * Minification filter. All valid values correspond to WebGL enums
  82694. */
  82695. minFilter?: TextureMinFilter;
  82696. /**
  82697. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82698. */
  82699. wrapS?: TextureWrapMode;
  82700. /**
  82701. * T (V) wrapping mode. All valid values correspond to WebGL enums
  82702. */
  82703. wrapT?: TextureWrapMode;
  82704. }
  82705. /**
  82706. * The root nodes of a scene
  82707. */
  82708. interface IScene extends IChildRootProperty {
  82709. /**
  82710. * The indices of each root node
  82711. */
  82712. nodes: number[];
  82713. }
  82714. /**
  82715. * Joints and matrices defining a skin
  82716. */
  82717. interface ISkin extends IChildRootProperty {
  82718. /**
  82719. * 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
  82720. */
  82721. inverseBindMatrices?: number;
  82722. /**
  82723. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  82724. */
  82725. skeleton?: number;
  82726. /**
  82727. * 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)
  82728. */
  82729. joints: number[];
  82730. }
  82731. /**
  82732. * A texture and its sampler
  82733. */
  82734. interface ITexture extends IChildRootProperty {
  82735. /**
  82736. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  82737. */
  82738. sampler?: number;
  82739. /**
  82740. * The index of the image used by this texture
  82741. */
  82742. source: number;
  82743. }
  82744. /**
  82745. * Reference to a texture
  82746. */
  82747. interface ITextureInfo extends IProperty {
  82748. /**
  82749. * The index of the texture
  82750. */
  82751. index: number;
  82752. /**
  82753. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  82754. */
  82755. texCoord?: number;
  82756. }
  82757. /**
  82758. * The root object for a glTF asset
  82759. */
  82760. interface IGLTF extends IProperty {
  82761. /**
  82762. * An array of accessors. An accessor is a typed view into a bufferView
  82763. */
  82764. accessors?: IAccessor[];
  82765. /**
  82766. * An array of keyframe animations
  82767. */
  82768. animations?: IAnimation[];
  82769. /**
  82770. * Metadata about the glTF asset
  82771. */
  82772. asset: IAsset;
  82773. /**
  82774. * An array of buffers. A buffer points to binary geometry, animation, or skins
  82775. */
  82776. buffers?: IBuffer[];
  82777. /**
  82778. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  82779. */
  82780. bufferViews?: IBufferView[];
  82781. /**
  82782. * An array of cameras
  82783. */
  82784. cameras?: ICamera[];
  82785. /**
  82786. * Names of glTF extensions used somewhere in this asset
  82787. */
  82788. extensionsUsed?: string[];
  82789. /**
  82790. * Names of glTF extensions required to properly load this asset
  82791. */
  82792. extensionsRequired?: string[];
  82793. /**
  82794. * An array of images. An image defines data used to create a texture
  82795. */
  82796. images?: IImage[];
  82797. /**
  82798. * An array of materials. A material defines the appearance of a primitive
  82799. */
  82800. materials?: IMaterial[];
  82801. /**
  82802. * An array of meshes. A mesh is a set of primitives to be rendered
  82803. */
  82804. meshes?: IMesh[];
  82805. /**
  82806. * An array of nodes
  82807. */
  82808. nodes?: INode[];
  82809. /**
  82810. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  82811. */
  82812. samplers?: ISampler[];
  82813. /**
  82814. * The index of the default scene
  82815. */
  82816. scene?: number;
  82817. /**
  82818. * An array of scenes
  82819. */
  82820. scenes?: IScene[];
  82821. /**
  82822. * An array of skins. A skin is defined by joints and matrices
  82823. */
  82824. skins?: ISkin[];
  82825. /**
  82826. * An array of textures
  82827. */
  82828. textures?: ITexture[];
  82829. }
  82830. /**
  82831. * The glTF validation results
  82832. * @ignore
  82833. */
  82834. interface IGLTFValidationResults {
  82835. info: {
  82836. generator: string;
  82837. hasAnimations: boolean;
  82838. hasDefaultScene: boolean;
  82839. hasMaterials: boolean;
  82840. hasMorphTargets: boolean;
  82841. hasSkins: boolean;
  82842. hasTextures: boolean;
  82843. maxAttributesUsed: number;
  82844. primitivesCount: number
  82845. };
  82846. issues: {
  82847. messages: Array<string>;
  82848. numErrors: number;
  82849. numHints: number;
  82850. numInfos: number;
  82851. numWarnings: number;
  82852. truncated: boolean
  82853. };
  82854. mimeType: string;
  82855. uri: string;
  82856. validatedAt: string;
  82857. validatorVersion: string;
  82858. }
  82859. /**
  82860. * The glTF validation options
  82861. */
  82862. interface IGLTFValidationOptions {
  82863. /** Uri to use */
  82864. uri?: string;
  82865. /** Function used to load external resources */
  82866. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  82867. /** Boolean indicating that we need to validate accessor data */
  82868. validateAccessorData?: boolean;
  82869. /** max number of issues allowed */
  82870. maxIssues?: number;
  82871. /** Ignored issues */
  82872. ignoredIssues?: Array<string>;
  82873. /** Value to override severy settings */
  82874. severityOverrides?: Object;
  82875. }
  82876. /**
  82877. * The glTF validator object
  82878. * @ignore
  82879. */
  82880. interface IGLTFValidator {
  82881. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82882. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  82883. }
  82884. }
  82885. declare module BABYLON {
  82886. /** @hidden */
  82887. export var cellPixelShader: {
  82888. name: string;
  82889. shader: string;
  82890. };
  82891. }
  82892. declare module BABYLON {
  82893. /** @hidden */
  82894. export var cellVertexShader: {
  82895. name: string;
  82896. shader: string;
  82897. };
  82898. }
  82899. declare module BABYLON {
  82900. export class CellMaterial extends BABYLON.PushMaterial {
  82901. private _diffuseTexture;
  82902. diffuseTexture: BABYLON.BaseTexture;
  82903. diffuseColor: BABYLON.Color3;
  82904. _computeHighLevel: boolean;
  82905. computeHighLevel: boolean;
  82906. private _disableLighting;
  82907. disableLighting: boolean;
  82908. private _maxSimultaneousLights;
  82909. maxSimultaneousLights: number;
  82910. constructor(name: string, scene: BABYLON.Scene);
  82911. needAlphaBlending(): boolean;
  82912. needAlphaTesting(): boolean;
  82913. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82914. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82915. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82916. getAnimatables(): BABYLON.IAnimatable[];
  82917. getActiveTextures(): BABYLON.BaseTexture[];
  82918. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82919. dispose(forceDisposeEffect?: boolean): void;
  82920. getClassName(): string;
  82921. clone(name: string): CellMaterial;
  82922. serialize(): any;
  82923. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  82924. }
  82925. }
  82926. declare module BABYLON {
  82927. export class CustomShaderStructure {
  82928. FragmentStore: string;
  82929. VertexStore: string;
  82930. constructor();
  82931. }
  82932. export class ShaderSpecialParts {
  82933. constructor();
  82934. Fragment_Begin: string;
  82935. Fragment_Definitions: string;
  82936. Fragment_MainBegin: string;
  82937. Fragment_Custom_Diffuse: string;
  82938. Fragment_Before_Lights: string;
  82939. Fragment_Before_Fog: string;
  82940. Fragment_Custom_Alpha: string;
  82941. Fragment_Before_FragColor: string;
  82942. Vertex_Begin: string;
  82943. Vertex_Definitions: string;
  82944. Vertex_MainBegin: string;
  82945. Vertex_Before_PositionUpdated: string;
  82946. Vertex_Before_NormalUpdated: string;
  82947. Vertex_After_WorldPosComputed: string;
  82948. Vertex_MainEnd: string;
  82949. }
  82950. export class CustomMaterial extends BABYLON.StandardMaterial {
  82951. static ShaderIndexer: number;
  82952. CustomParts: ShaderSpecialParts;
  82953. _isCreatedShader: boolean;
  82954. _createdShaderName: string;
  82955. _customUniform: string[];
  82956. _newUniforms: string[];
  82957. _newUniformInstances: {
  82958. [name: string]: any;
  82959. };
  82960. _newSamplerInstances: {
  82961. [name: string]: BABYLON.Texture;
  82962. };
  82963. _customAttributes: string[];
  82964. FragmentShader: string;
  82965. VertexShader: string;
  82966. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  82967. ReviewUniform(name: string, arr: string[]): string[];
  82968. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  82969. constructor(name: string, scene: BABYLON.Scene);
  82970. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  82971. AddAttribute(name: string): CustomMaterial;
  82972. Fragment_Begin(shaderPart: string): CustomMaterial;
  82973. Fragment_Definitions(shaderPart: string): CustomMaterial;
  82974. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  82975. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  82976. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  82977. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  82978. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  82979. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  82980. Vertex_Begin(shaderPart: string): CustomMaterial;
  82981. Vertex_Definitions(shaderPart: string): CustomMaterial;
  82982. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  82983. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  82984. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  82985. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  82986. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  82987. }
  82988. }
  82989. declare module BABYLON {
  82990. export class ShaderAlebdoParts {
  82991. constructor();
  82992. Fragment_Begin: string;
  82993. Fragment_Definitions: string;
  82994. Fragment_MainBegin: string;
  82995. Fragment_Custom_Albedo: string;
  82996. Fragment_Before_Lights: string;
  82997. Fragment_Custom_MetallicRoughness: string;
  82998. Fragment_Custom_MicroSurface: string;
  82999. Fragment_Before_Fog: string;
  83000. Fragment_Custom_Alpha: string;
  83001. Fragment_Before_FragColor: string;
  83002. Vertex_Begin: string;
  83003. Vertex_Definitions: string;
  83004. Vertex_MainBegin: string;
  83005. Vertex_Before_PositionUpdated: string;
  83006. Vertex_Before_NormalUpdated: string;
  83007. Vertex_After_WorldPosComputed: string;
  83008. Vertex_MainEnd: string;
  83009. }
  83010. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  83011. static ShaderIndexer: number;
  83012. CustomParts: ShaderAlebdoParts;
  83013. _isCreatedShader: boolean;
  83014. _createdShaderName: string;
  83015. _customUniform: string[];
  83016. _newUniforms: string[];
  83017. _newUniformInstances: {
  83018. [name: string]: any;
  83019. };
  83020. _newSamplerInstances: {
  83021. [name: string]: BABYLON.Texture;
  83022. };
  83023. _customAttributes: string[];
  83024. FragmentShader: string;
  83025. VertexShader: string;
  83026. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83027. ReviewUniform(name: string, arr: string[]): string[];
  83028. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83029. constructor(name: string, scene: BABYLON.Scene);
  83030. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83031. AddAttribute(name: string): PBRCustomMaterial;
  83032. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83033. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83034. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83035. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83036. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83037. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83038. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83039. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83040. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83041. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83042. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83043. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83044. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83045. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83046. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83047. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83048. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83049. }
  83050. }
  83051. declare module BABYLON {
  83052. /** @hidden */
  83053. export var firePixelShader: {
  83054. name: string;
  83055. shader: string;
  83056. };
  83057. }
  83058. declare module BABYLON {
  83059. /** @hidden */
  83060. export var fireVertexShader: {
  83061. name: string;
  83062. shader: string;
  83063. };
  83064. }
  83065. declare module BABYLON {
  83066. export class FireMaterial extends BABYLON.PushMaterial {
  83067. private _diffuseTexture;
  83068. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83069. private _distortionTexture;
  83070. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83071. private _opacityTexture;
  83072. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83073. diffuseColor: BABYLON.Color3;
  83074. speed: number;
  83075. private _scaledDiffuse;
  83076. private _lastTime;
  83077. constructor(name: string, scene: BABYLON.Scene);
  83078. needAlphaBlending(): boolean;
  83079. needAlphaTesting(): boolean;
  83080. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83081. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83082. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83083. getAnimatables(): BABYLON.IAnimatable[];
  83084. getActiveTextures(): BABYLON.BaseTexture[];
  83085. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83086. getClassName(): string;
  83087. dispose(forceDisposeEffect?: boolean): void;
  83088. clone(name: string): FireMaterial;
  83089. serialize(): any;
  83090. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83091. }
  83092. }
  83093. declare module BABYLON {
  83094. /** @hidden */
  83095. export var furPixelShader: {
  83096. name: string;
  83097. shader: string;
  83098. };
  83099. }
  83100. declare module BABYLON {
  83101. /** @hidden */
  83102. export var furVertexShader: {
  83103. name: string;
  83104. shader: string;
  83105. };
  83106. }
  83107. declare module BABYLON {
  83108. export class FurMaterial extends BABYLON.PushMaterial {
  83109. private _diffuseTexture;
  83110. diffuseTexture: BABYLON.BaseTexture;
  83111. private _heightTexture;
  83112. heightTexture: BABYLON.BaseTexture;
  83113. diffuseColor: BABYLON.Color3;
  83114. furLength: number;
  83115. furAngle: number;
  83116. furColor: BABYLON.Color3;
  83117. furOffset: number;
  83118. furSpacing: number;
  83119. furGravity: BABYLON.Vector3;
  83120. furSpeed: number;
  83121. furDensity: number;
  83122. furOcclusion: number;
  83123. furTexture: BABYLON.DynamicTexture;
  83124. private _disableLighting;
  83125. disableLighting: boolean;
  83126. private _maxSimultaneousLights;
  83127. maxSimultaneousLights: number;
  83128. highLevelFur: boolean;
  83129. _meshes: BABYLON.AbstractMesh[];
  83130. private _furTime;
  83131. constructor(name: string, scene: BABYLON.Scene);
  83132. get furTime(): number;
  83133. set furTime(furTime: number);
  83134. needAlphaBlending(): boolean;
  83135. needAlphaTesting(): boolean;
  83136. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83137. updateFur(): void;
  83138. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83139. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83140. getAnimatables(): BABYLON.IAnimatable[];
  83141. getActiveTextures(): BABYLON.BaseTexture[];
  83142. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83143. dispose(forceDisposeEffect?: boolean): void;
  83144. clone(name: string): FurMaterial;
  83145. serialize(): any;
  83146. getClassName(): string;
  83147. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  83148. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  83149. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  83150. }
  83151. }
  83152. declare module BABYLON {
  83153. /** @hidden */
  83154. export var gradientPixelShader: {
  83155. name: string;
  83156. shader: string;
  83157. };
  83158. }
  83159. declare module BABYLON {
  83160. /** @hidden */
  83161. export var gradientVertexShader: {
  83162. name: string;
  83163. shader: string;
  83164. };
  83165. }
  83166. declare module BABYLON {
  83167. export class GradientMaterial extends BABYLON.PushMaterial {
  83168. private _maxSimultaneousLights;
  83169. maxSimultaneousLights: number;
  83170. topColor: BABYLON.Color3;
  83171. topColorAlpha: number;
  83172. bottomColor: BABYLON.Color3;
  83173. bottomColorAlpha: number;
  83174. offset: number;
  83175. scale: number;
  83176. smoothness: number;
  83177. private _disableLighting;
  83178. disableLighting: boolean;
  83179. constructor(name: string, scene: BABYLON.Scene);
  83180. needAlphaBlending(): boolean;
  83181. needAlphaTesting(): boolean;
  83182. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83183. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83184. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83185. getAnimatables(): BABYLON.IAnimatable[];
  83186. dispose(forceDisposeEffect?: boolean): void;
  83187. clone(name: string): GradientMaterial;
  83188. serialize(): any;
  83189. getClassName(): string;
  83190. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  83191. }
  83192. }
  83193. declare module BABYLON {
  83194. /** @hidden */
  83195. export var gridPixelShader: {
  83196. name: string;
  83197. shader: string;
  83198. };
  83199. }
  83200. declare module BABYLON {
  83201. /** @hidden */
  83202. export var gridVertexShader: {
  83203. name: string;
  83204. shader: string;
  83205. };
  83206. }
  83207. declare module BABYLON {
  83208. /**
  83209. * The grid materials allows you to wrap any shape with a grid.
  83210. * Colors are customizable.
  83211. */
  83212. export class GridMaterial extends BABYLON.PushMaterial {
  83213. /**
  83214. * Main color of the grid (e.g. between lines)
  83215. */
  83216. mainColor: BABYLON.Color3;
  83217. /**
  83218. * Color of the grid lines.
  83219. */
  83220. lineColor: BABYLON.Color3;
  83221. /**
  83222. * The scale of the grid compared to unit.
  83223. */
  83224. gridRatio: number;
  83225. /**
  83226. * Allows setting an offset for the grid lines.
  83227. */
  83228. gridOffset: BABYLON.Vector3;
  83229. /**
  83230. * The frequency of thicker lines.
  83231. */
  83232. majorUnitFrequency: number;
  83233. /**
  83234. * The visibility of minor units in the grid.
  83235. */
  83236. minorUnitVisibility: number;
  83237. /**
  83238. * The grid opacity outside of the lines.
  83239. */
  83240. opacity: number;
  83241. /**
  83242. * Determine RBG output is premultiplied by alpha value.
  83243. */
  83244. preMultiplyAlpha: boolean;
  83245. private _opacityTexture;
  83246. opacityTexture: BABYLON.BaseTexture;
  83247. private _gridControl;
  83248. /**
  83249. * constructor
  83250. * @param name The name given to the material in order to identify it afterwards.
  83251. * @param scene The scene the material is used in.
  83252. */
  83253. constructor(name: string, scene: BABYLON.Scene);
  83254. /**
  83255. * Returns wehter or not the grid requires alpha blending.
  83256. */
  83257. needAlphaBlending(): boolean;
  83258. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83259. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83260. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83261. /**
  83262. * Dispose the material and its associated resources.
  83263. * @param forceDisposeEffect will also dispose the used effect when true
  83264. */
  83265. dispose(forceDisposeEffect?: boolean): void;
  83266. clone(name: string): GridMaterial;
  83267. serialize(): any;
  83268. getClassName(): string;
  83269. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  83270. }
  83271. }
  83272. declare module BABYLON {
  83273. /** @hidden */
  83274. export var lavaPixelShader: {
  83275. name: string;
  83276. shader: string;
  83277. };
  83278. }
  83279. declare module BABYLON {
  83280. /** @hidden */
  83281. export var lavaVertexShader: {
  83282. name: string;
  83283. shader: string;
  83284. };
  83285. }
  83286. declare module BABYLON {
  83287. export class LavaMaterial extends BABYLON.PushMaterial {
  83288. private _diffuseTexture;
  83289. diffuseTexture: BABYLON.BaseTexture;
  83290. noiseTexture: BABYLON.BaseTexture;
  83291. fogColor: BABYLON.Color3;
  83292. speed: number;
  83293. movingSpeed: number;
  83294. lowFrequencySpeed: number;
  83295. fogDensity: number;
  83296. private _lastTime;
  83297. diffuseColor: BABYLON.Color3;
  83298. private _disableLighting;
  83299. disableLighting: boolean;
  83300. private _unlit;
  83301. unlit: boolean;
  83302. private _maxSimultaneousLights;
  83303. maxSimultaneousLights: number;
  83304. private _scaledDiffuse;
  83305. constructor(name: string, scene: BABYLON.Scene);
  83306. needAlphaBlending(): boolean;
  83307. needAlphaTesting(): boolean;
  83308. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83309. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83310. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83311. getAnimatables(): BABYLON.IAnimatable[];
  83312. getActiveTextures(): BABYLON.BaseTexture[];
  83313. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83314. dispose(forceDisposeEffect?: boolean): void;
  83315. clone(name: string): LavaMaterial;
  83316. serialize(): any;
  83317. getClassName(): string;
  83318. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  83319. }
  83320. }
  83321. declare module BABYLON {
  83322. /** @hidden */
  83323. export var mixPixelShader: {
  83324. name: string;
  83325. shader: string;
  83326. };
  83327. }
  83328. declare module BABYLON {
  83329. /** @hidden */
  83330. export var mixVertexShader: {
  83331. name: string;
  83332. shader: string;
  83333. };
  83334. }
  83335. declare module BABYLON {
  83336. export class MixMaterial extends BABYLON.PushMaterial {
  83337. /**
  83338. * Mix textures
  83339. */
  83340. private _mixTexture1;
  83341. mixTexture1: BABYLON.BaseTexture;
  83342. private _mixTexture2;
  83343. mixTexture2: BABYLON.BaseTexture;
  83344. /**
  83345. * Diffuse textures
  83346. */
  83347. private _diffuseTexture1;
  83348. diffuseTexture1: BABYLON.Texture;
  83349. private _diffuseTexture2;
  83350. diffuseTexture2: BABYLON.Texture;
  83351. private _diffuseTexture3;
  83352. diffuseTexture3: BABYLON.Texture;
  83353. private _diffuseTexture4;
  83354. diffuseTexture4: BABYLON.Texture;
  83355. private _diffuseTexture5;
  83356. diffuseTexture5: BABYLON.Texture;
  83357. private _diffuseTexture6;
  83358. diffuseTexture6: BABYLON.Texture;
  83359. private _diffuseTexture7;
  83360. diffuseTexture7: BABYLON.Texture;
  83361. private _diffuseTexture8;
  83362. diffuseTexture8: BABYLON.Texture;
  83363. /**
  83364. * Uniforms
  83365. */
  83366. diffuseColor: BABYLON.Color3;
  83367. specularColor: BABYLON.Color3;
  83368. specularPower: number;
  83369. private _disableLighting;
  83370. disableLighting: boolean;
  83371. private _maxSimultaneousLights;
  83372. maxSimultaneousLights: number;
  83373. constructor(name: string, scene: BABYLON.Scene);
  83374. needAlphaBlending(): boolean;
  83375. needAlphaTesting(): boolean;
  83376. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83377. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83378. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83379. getAnimatables(): BABYLON.IAnimatable[];
  83380. getActiveTextures(): BABYLON.BaseTexture[];
  83381. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83382. dispose(forceDisposeEffect?: boolean): void;
  83383. clone(name: string): MixMaterial;
  83384. serialize(): any;
  83385. getClassName(): string;
  83386. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  83387. }
  83388. }
  83389. declare module BABYLON {
  83390. /** @hidden */
  83391. export var normalPixelShader: {
  83392. name: string;
  83393. shader: string;
  83394. };
  83395. }
  83396. declare module BABYLON {
  83397. /** @hidden */
  83398. export var normalVertexShader: {
  83399. name: string;
  83400. shader: string;
  83401. };
  83402. }
  83403. declare module BABYLON {
  83404. export class NormalMaterial extends BABYLON.PushMaterial {
  83405. private _diffuseTexture;
  83406. diffuseTexture: BABYLON.BaseTexture;
  83407. diffuseColor: BABYLON.Color3;
  83408. private _disableLighting;
  83409. disableLighting: boolean;
  83410. private _maxSimultaneousLights;
  83411. maxSimultaneousLights: number;
  83412. constructor(name: string, scene: BABYLON.Scene);
  83413. needAlphaBlending(): boolean;
  83414. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  83415. needAlphaTesting(): boolean;
  83416. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83417. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83418. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83419. getAnimatables(): BABYLON.IAnimatable[];
  83420. getActiveTextures(): BABYLON.BaseTexture[];
  83421. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83422. dispose(forceDisposeEffect?: boolean): void;
  83423. clone(name: string): NormalMaterial;
  83424. serialize(): any;
  83425. getClassName(): string;
  83426. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  83427. }
  83428. }
  83429. declare module BABYLON {
  83430. /** @hidden */
  83431. export var shadowOnlyPixelShader: {
  83432. name: string;
  83433. shader: string;
  83434. };
  83435. }
  83436. declare module BABYLON {
  83437. /** @hidden */
  83438. export var shadowOnlyVertexShader: {
  83439. name: string;
  83440. shader: string;
  83441. };
  83442. }
  83443. declare module BABYLON {
  83444. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  83445. private _activeLight;
  83446. private _needAlphaBlending;
  83447. constructor(name: string, scene: BABYLON.Scene);
  83448. shadowColor: BABYLON.Color3;
  83449. needAlphaBlending(): boolean;
  83450. needAlphaTesting(): boolean;
  83451. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83452. get activeLight(): BABYLON.IShadowLight;
  83453. set activeLight(light: BABYLON.IShadowLight);
  83454. private _getFirstShadowLightForMesh;
  83455. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83456. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83457. clone(name: string): ShadowOnlyMaterial;
  83458. serialize(): any;
  83459. getClassName(): string;
  83460. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  83461. }
  83462. }
  83463. declare module BABYLON {
  83464. /** @hidden */
  83465. export var simplePixelShader: {
  83466. name: string;
  83467. shader: string;
  83468. };
  83469. }
  83470. declare module BABYLON {
  83471. /** @hidden */
  83472. export var simpleVertexShader: {
  83473. name: string;
  83474. shader: string;
  83475. };
  83476. }
  83477. declare module BABYLON {
  83478. export class SimpleMaterial extends BABYLON.PushMaterial {
  83479. private _diffuseTexture;
  83480. diffuseTexture: BABYLON.BaseTexture;
  83481. diffuseColor: BABYLON.Color3;
  83482. private _disableLighting;
  83483. disableLighting: boolean;
  83484. private _maxSimultaneousLights;
  83485. maxSimultaneousLights: number;
  83486. constructor(name: string, scene: BABYLON.Scene);
  83487. needAlphaBlending(): boolean;
  83488. needAlphaTesting(): boolean;
  83489. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83490. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83491. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83492. getAnimatables(): BABYLON.IAnimatable[];
  83493. getActiveTextures(): BABYLON.BaseTexture[];
  83494. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83495. dispose(forceDisposeEffect?: boolean): void;
  83496. clone(name: string): SimpleMaterial;
  83497. serialize(): any;
  83498. getClassName(): string;
  83499. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  83500. }
  83501. }
  83502. declare module BABYLON {
  83503. /** @hidden */
  83504. export var skyPixelShader: {
  83505. name: string;
  83506. shader: string;
  83507. };
  83508. }
  83509. declare module BABYLON {
  83510. /** @hidden */
  83511. export var skyVertexShader: {
  83512. name: string;
  83513. shader: string;
  83514. };
  83515. }
  83516. declare module BABYLON {
  83517. /**
  83518. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  83519. * @see https://doc.babylonjs.com/extensions/sky
  83520. */
  83521. export class SkyMaterial extends BABYLON.PushMaterial {
  83522. /**
  83523. * Defines the overall luminance of sky in interval ]0, 1[.
  83524. */
  83525. luminance: number;
  83526. /**
  83527. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  83528. */
  83529. turbidity: number;
  83530. /**
  83531. * Defines the sky appearance (light intensity).
  83532. */
  83533. rayleigh: number;
  83534. /**
  83535. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  83536. */
  83537. mieCoefficient: number;
  83538. /**
  83539. * Defines the amount of haze particles following the Mie scattering theory.
  83540. */
  83541. mieDirectionalG: number;
  83542. /**
  83543. * Defines the distance of the sun according to the active scene camera.
  83544. */
  83545. distance: number;
  83546. /**
  83547. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  83548. * "inclined".
  83549. */
  83550. inclination: number;
  83551. /**
  83552. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  83553. * an object direction and a reference direction.
  83554. */
  83555. azimuth: number;
  83556. /**
  83557. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  83558. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  83559. */
  83560. sunPosition: BABYLON.Vector3;
  83561. /**
  83562. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  83563. * .sunPosition property.
  83564. */
  83565. useSunPosition: boolean;
  83566. /**
  83567. * Defines an offset vector used to get a horizon offset.
  83568. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  83569. */
  83570. cameraOffset: BABYLON.Vector3;
  83571. private _cameraPosition;
  83572. /**
  83573. * Instantiates a new sky material.
  83574. * This material allows to create dynamic and texture free
  83575. * effects for skyboxes by taking care of the atmosphere state.
  83576. * @see https://doc.babylonjs.com/extensions/sky
  83577. * @param name Define the name of the material in the scene
  83578. * @param scene Define the scene the material belong to
  83579. */
  83580. constructor(name: string, scene: BABYLON.Scene);
  83581. /**
  83582. * Specifies if the material will require alpha blending
  83583. * @returns a boolean specifying if alpha blending is needed
  83584. */
  83585. needAlphaBlending(): boolean;
  83586. /**
  83587. * Specifies if this material should be rendered in alpha test mode
  83588. * @returns false as the sky material doesn't need alpha testing.
  83589. */
  83590. needAlphaTesting(): boolean;
  83591. /**
  83592. * Get the texture used for alpha test purpose.
  83593. * @returns null as the sky material has no texture.
  83594. */
  83595. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83596. /**
  83597. * Get if the submesh is ready to be used and all its information available.
  83598. * Child classes can use it to update shaders
  83599. * @param mesh defines the mesh to check
  83600. * @param subMesh defines which submesh to check
  83601. * @param useInstances specifies that instances should be used
  83602. * @returns a boolean indicating that the submesh is ready or not
  83603. */
  83604. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83605. /**
  83606. * Binds the submesh to this material by preparing the effect and shader to draw
  83607. * @param world defines the world transformation matrix
  83608. * @param mesh defines the mesh containing the submesh
  83609. * @param subMesh defines the submesh to bind the material to
  83610. */
  83611. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83612. /**
  83613. * Get the list of animatables in the material.
  83614. * @returns the list of animatables object used in the material
  83615. */
  83616. getAnimatables(): BABYLON.IAnimatable[];
  83617. /**
  83618. * Disposes the material
  83619. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  83620. */
  83621. dispose(forceDisposeEffect?: boolean): void;
  83622. /**
  83623. * Makes a duplicate of the material, and gives it a new name
  83624. * @param name defines the new name for the duplicated material
  83625. * @returns the cloned material
  83626. */
  83627. clone(name: string): SkyMaterial;
  83628. /**
  83629. * Serializes this material in a JSON representation
  83630. * @returns the serialized material object
  83631. */
  83632. serialize(): any;
  83633. /**
  83634. * Gets the current class name of the material e.g. "SkyMaterial"
  83635. * Mainly use in serialization.
  83636. * @returns the class name
  83637. */
  83638. getClassName(): string;
  83639. /**
  83640. * Creates a sky material from parsed material data
  83641. * @param source defines the JSON representation of the material
  83642. * @param scene defines the hosting scene
  83643. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  83644. * @returns a new sky material
  83645. */
  83646. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  83647. }
  83648. }
  83649. declare module BABYLON {
  83650. /** @hidden */
  83651. export var terrainPixelShader: {
  83652. name: string;
  83653. shader: string;
  83654. };
  83655. }
  83656. declare module BABYLON {
  83657. /** @hidden */
  83658. export var terrainVertexShader: {
  83659. name: string;
  83660. shader: string;
  83661. };
  83662. }
  83663. declare module BABYLON {
  83664. export class TerrainMaterial extends BABYLON.PushMaterial {
  83665. private _mixTexture;
  83666. mixTexture: BABYLON.BaseTexture;
  83667. private _diffuseTexture1;
  83668. diffuseTexture1: BABYLON.Texture;
  83669. private _diffuseTexture2;
  83670. diffuseTexture2: BABYLON.Texture;
  83671. private _diffuseTexture3;
  83672. diffuseTexture3: BABYLON.Texture;
  83673. private _bumpTexture1;
  83674. bumpTexture1: BABYLON.Texture;
  83675. private _bumpTexture2;
  83676. bumpTexture2: BABYLON.Texture;
  83677. private _bumpTexture3;
  83678. bumpTexture3: BABYLON.Texture;
  83679. diffuseColor: BABYLON.Color3;
  83680. specularColor: BABYLON.Color3;
  83681. specularPower: number;
  83682. private _disableLighting;
  83683. disableLighting: boolean;
  83684. private _maxSimultaneousLights;
  83685. maxSimultaneousLights: number;
  83686. constructor(name: string, scene: BABYLON.Scene);
  83687. needAlphaBlending(): boolean;
  83688. needAlphaTesting(): boolean;
  83689. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83690. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83691. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83692. getAnimatables(): BABYLON.IAnimatable[];
  83693. getActiveTextures(): BABYLON.BaseTexture[];
  83694. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83695. dispose(forceDisposeEffect?: boolean): void;
  83696. clone(name: string): TerrainMaterial;
  83697. serialize(): any;
  83698. getClassName(): string;
  83699. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  83700. }
  83701. }
  83702. declare module BABYLON {
  83703. /** @hidden */
  83704. export var triplanarPixelShader: {
  83705. name: string;
  83706. shader: string;
  83707. };
  83708. }
  83709. declare module BABYLON {
  83710. /** @hidden */
  83711. export var triplanarVertexShader: {
  83712. name: string;
  83713. shader: string;
  83714. };
  83715. }
  83716. declare module BABYLON {
  83717. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  83718. mixTexture: BABYLON.BaseTexture;
  83719. private _diffuseTextureX;
  83720. diffuseTextureX: BABYLON.BaseTexture;
  83721. private _diffuseTextureY;
  83722. diffuseTextureY: BABYLON.BaseTexture;
  83723. private _diffuseTextureZ;
  83724. diffuseTextureZ: BABYLON.BaseTexture;
  83725. private _normalTextureX;
  83726. normalTextureX: BABYLON.BaseTexture;
  83727. private _normalTextureY;
  83728. normalTextureY: BABYLON.BaseTexture;
  83729. private _normalTextureZ;
  83730. normalTextureZ: BABYLON.BaseTexture;
  83731. tileSize: number;
  83732. diffuseColor: BABYLON.Color3;
  83733. specularColor: BABYLON.Color3;
  83734. specularPower: number;
  83735. private _disableLighting;
  83736. disableLighting: boolean;
  83737. private _maxSimultaneousLights;
  83738. maxSimultaneousLights: number;
  83739. constructor(name: string, scene: BABYLON.Scene);
  83740. needAlphaBlending(): boolean;
  83741. needAlphaTesting(): boolean;
  83742. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83743. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83744. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83745. getAnimatables(): BABYLON.IAnimatable[];
  83746. getActiveTextures(): BABYLON.BaseTexture[];
  83747. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83748. dispose(forceDisposeEffect?: boolean): void;
  83749. clone(name: string): TriPlanarMaterial;
  83750. serialize(): any;
  83751. getClassName(): string;
  83752. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  83753. }
  83754. }
  83755. declare module BABYLON {
  83756. /** @hidden */
  83757. export var waterPixelShader: {
  83758. name: string;
  83759. shader: string;
  83760. };
  83761. }
  83762. declare module BABYLON {
  83763. /** @hidden */
  83764. export var waterVertexShader: {
  83765. name: string;
  83766. shader: string;
  83767. };
  83768. }
  83769. declare module BABYLON {
  83770. export class WaterMaterial extends BABYLON.PushMaterial {
  83771. renderTargetSize: BABYLON.Vector2;
  83772. private _bumpTexture;
  83773. bumpTexture: BABYLON.BaseTexture;
  83774. diffuseColor: BABYLON.Color3;
  83775. specularColor: BABYLON.Color3;
  83776. specularPower: number;
  83777. private _disableLighting;
  83778. disableLighting: boolean;
  83779. private _maxSimultaneousLights;
  83780. maxSimultaneousLights: number;
  83781. /**
  83782. * @param {number}: Represents the wind force
  83783. */
  83784. windForce: number;
  83785. /**
  83786. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  83787. */
  83788. windDirection: BABYLON.Vector2;
  83789. /**
  83790. * @param {number}: Wave height, represents the height of the waves
  83791. */
  83792. waveHeight: number;
  83793. /**
  83794. * @param {number}: Bump height, represents the bump height related to the bump map
  83795. */
  83796. bumpHeight: number;
  83797. /**
  83798. * @param {boolean}: Add a smaller moving bump to less steady waves.
  83799. */
  83800. private _bumpSuperimpose;
  83801. bumpSuperimpose: boolean;
  83802. /**
  83803. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  83804. */
  83805. private _fresnelSeparate;
  83806. fresnelSeparate: boolean;
  83807. /**
  83808. * @param {boolean}: bump Waves modify the reflection.
  83809. */
  83810. private _bumpAffectsReflection;
  83811. bumpAffectsReflection: boolean;
  83812. /**
  83813. * @param {number}: The water color blended with the refraction (near)
  83814. */
  83815. waterColor: BABYLON.Color3;
  83816. /**
  83817. * @param {number}: The blend factor related to the water color
  83818. */
  83819. colorBlendFactor: number;
  83820. /**
  83821. * @param {number}: The water color blended with the reflection (far)
  83822. */
  83823. waterColor2: BABYLON.Color3;
  83824. /**
  83825. * @param {number}: The blend factor related to the water color (reflection, far)
  83826. */
  83827. colorBlendFactor2: number;
  83828. /**
  83829. * @param {number}: Represents the maximum length of a wave
  83830. */
  83831. waveLength: number;
  83832. /**
  83833. * @param {number}: Defines the waves speed
  83834. */
  83835. waveSpeed: number;
  83836. /**
  83837. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  83838. * will avoid calculating useless pixels in the pixel shader of the water material.
  83839. */
  83840. disableClipPlane: boolean;
  83841. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  83842. private _mesh;
  83843. private _refractionRTT;
  83844. private _reflectionRTT;
  83845. private _reflectionTransform;
  83846. private _lastTime;
  83847. private _lastDeltaTime;
  83848. private _useLogarithmicDepth;
  83849. private _waitingRenderList;
  83850. private _imageProcessingConfiguration;
  83851. private _imageProcessingObserver;
  83852. /**
  83853. * Gets a boolean indicating that current material needs to register RTT
  83854. */
  83855. get hasRenderTargetTextures(): boolean;
  83856. /**
  83857. * Constructor
  83858. */
  83859. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  83860. get useLogarithmicDepth(): boolean;
  83861. set useLogarithmicDepth(value: boolean);
  83862. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83863. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  83864. addToRenderList(node: any): void;
  83865. enableRenderTargets(enable: boolean): void;
  83866. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  83867. get renderTargetsEnabled(): boolean;
  83868. needAlphaBlending(): boolean;
  83869. needAlphaTesting(): boolean;
  83870. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83871. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83872. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83873. private _createRenderTargets;
  83874. getAnimatables(): BABYLON.IAnimatable[];
  83875. getActiveTextures(): BABYLON.BaseTexture[];
  83876. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83877. dispose(forceDisposeEffect?: boolean): void;
  83878. clone(name: string): WaterMaterial;
  83879. serialize(): any;
  83880. getClassName(): string;
  83881. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  83882. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  83883. }
  83884. }
  83885. declare module BABYLON {
  83886. /** @hidden */
  83887. export var asciiartPixelShader: {
  83888. name: string;
  83889. shader: string;
  83890. };
  83891. }
  83892. declare module BABYLON {
  83893. /**
  83894. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  83895. *
  83896. * It basically takes care rendering the font front the given font size to a texture.
  83897. * This is used later on in the postprocess.
  83898. */
  83899. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  83900. private _font;
  83901. private _text;
  83902. private _charSize;
  83903. /**
  83904. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  83905. */
  83906. get charSize(): number;
  83907. /**
  83908. * Create a new instance of the Ascii Art FontTexture class
  83909. * @param name the name of the texture
  83910. * @param font the font to use, use the W3C CSS notation
  83911. * @param text the caracter set to use in the rendering.
  83912. * @param scene the scene that owns the texture
  83913. */
  83914. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  83915. /**
  83916. * Gets the max char width of a font.
  83917. * @param font the font to use, use the W3C CSS notation
  83918. * @return the max char width
  83919. */
  83920. private getFontWidth;
  83921. /**
  83922. * Gets the max char height of a font.
  83923. * @param font the font to use, use the W3C CSS notation
  83924. * @return the max char height
  83925. */
  83926. private getFontHeight;
  83927. /**
  83928. * Clones the current AsciiArtTexture.
  83929. * @return the clone of the texture.
  83930. */
  83931. clone(): AsciiArtFontTexture;
  83932. /**
  83933. * Parses a json object representing the texture and returns an instance of it.
  83934. * @param source the source JSON representation
  83935. * @param scene the scene to create the texture for
  83936. * @return the parsed texture
  83937. */
  83938. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  83939. }
  83940. /**
  83941. * Option available in the Ascii Art Post Process.
  83942. */
  83943. export interface IAsciiArtPostProcessOptions {
  83944. /**
  83945. * The font to use following the w3c font definition.
  83946. */
  83947. font?: string;
  83948. /**
  83949. * The character set to use in the postprocess.
  83950. */
  83951. characterSet?: string;
  83952. /**
  83953. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83954. * This number is defined between 0 and 1;
  83955. */
  83956. mixToTile?: number;
  83957. /**
  83958. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83959. * This number is defined between 0 and 1;
  83960. */
  83961. mixToNormal?: number;
  83962. }
  83963. /**
  83964. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  83965. *
  83966. * Simmply add it to your scene and let the nerd that lives in you have fun.
  83967. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  83968. */
  83969. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  83970. /**
  83971. * The font texture used to render the char in the post process.
  83972. */
  83973. private _asciiArtFontTexture;
  83974. /**
  83975. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  83976. * This number is defined between 0 and 1;
  83977. */
  83978. mixToTile: number;
  83979. /**
  83980. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  83981. * This number is defined between 0 and 1;
  83982. */
  83983. mixToNormal: number;
  83984. /**
  83985. * Instantiates a new Ascii Art Post Process.
  83986. * @param name the name to give to the postprocess
  83987. * @camera the camera to apply the post process to.
  83988. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  83989. */
  83990. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  83991. }
  83992. }
  83993. declare module BABYLON {
  83994. /** @hidden */
  83995. export var digitalrainPixelShader: {
  83996. name: string;
  83997. shader: string;
  83998. };
  83999. }
  84000. declare module BABYLON {
  84001. /**
  84002. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  84003. *
  84004. * It basically takes care rendering the font front the given font size to a texture.
  84005. * This is used later on in the postprocess.
  84006. */
  84007. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  84008. private _font;
  84009. private _text;
  84010. private _charSize;
  84011. /**
  84012. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84013. */
  84014. get charSize(): number;
  84015. /**
  84016. * Create a new instance of the Digital Rain FontTexture class
  84017. * @param name the name of the texture
  84018. * @param font the font to use, use the W3C CSS notation
  84019. * @param text the caracter set to use in the rendering.
  84020. * @param scene the scene that owns the texture
  84021. */
  84022. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84023. /**
  84024. * Gets the max char width of a font.
  84025. * @param font the font to use, use the W3C CSS notation
  84026. * @return the max char width
  84027. */
  84028. private getFontWidth;
  84029. /**
  84030. * Gets the max char height of a font.
  84031. * @param font the font to use, use the W3C CSS notation
  84032. * @return the max char height
  84033. */
  84034. private getFontHeight;
  84035. /**
  84036. * Clones the current DigitalRainFontTexture.
  84037. * @return the clone of the texture.
  84038. */
  84039. clone(): DigitalRainFontTexture;
  84040. /**
  84041. * Parses a json object representing the texture and returns an instance of it.
  84042. * @param source the source JSON representation
  84043. * @param scene the scene to create the texture for
  84044. * @return the parsed texture
  84045. */
  84046. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84047. }
  84048. /**
  84049. * Option available in the Digital Rain Post Process.
  84050. */
  84051. export interface IDigitalRainPostProcessOptions {
  84052. /**
  84053. * The font to use following the w3c font definition.
  84054. */
  84055. font?: string;
  84056. /**
  84057. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84058. * This number is defined between 0 and 1;
  84059. */
  84060. mixToTile?: number;
  84061. /**
  84062. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84063. * This number is defined between 0 and 1;
  84064. */
  84065. mixToNormal?: number;
  84066. }
  84067. /**
  84068. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84069. *
  84070. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84071. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84072. */
  84073. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84074. /**
  84075. * The font texture used to render the char in the post process.
  84076. */
  84077. private _digitalRainFontTexture;
  84078. /**
  84079. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84080. * This number is defined between 0 and 1;
  84081. */
  84082. mixToTile: number;
  84083. /**
  84084. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84085. * This number is defined between 0 and 1;
  84086. */
  84087. mixToNormal: number;
  84088. /**
  84089. * Instantiates a new Digital Rain Post Process.
  84090. * @param name the name to give to the postprocess
  84091. * @camera the camera to apply the post process to.
  84092. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84093. */
  84094. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84095. }
  84096. }
  84097. declare module BABYLON {
  84098. /** @hidden */
  84099. export var brickProceduralTexturePixelShader: {
  84100. name: string;
  84101. shader: string;
  84102. };
  84103. }
  84104. declare module BABYLON {
  84105. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  84106. private _numberOfBricksHeight;
  84107. private _numberOfBricksWidth;
  84108. private _jointColor;
  84109. private _brickColor;
  84110. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84111. updateShaderUniforms(): void;
  84112. get numberOfBricksHeight(): number;
  84113. set numberOfBricksHeight(value: number);
  84114. get numberOfBricksWidth(): number;
  84115. set numberOfBricksWidth(value: number);
  84116. get jointColor(): BABYLON.Color3;
  84117. set jointColor(value: BABYLON.Color3);
  84118. get brickColor(): BABYLON.Color3;
  84119. set brickColor(value: BABYLON.Color3);
  84120. /**
  84121. * Serializes this brick procedural texture
  84122. * @returns a serialized brick procedural texture object
  84123. */
  84124. serialize(): any;
  84125. /**
  84126. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  84127. * @param parsedTexture defines parsed texture data
  84128. * @param scene defines the current scene
  84129. * @param rootUrl defines the root URL containing brick procedural texture information
  84130. * @returns a parsed Brick Procedural BABYLON.Texture
  84131. */
  84132. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  84133. }
  84134. }
  84135. declare module BABYLON {
  84136. /** @hidden */
  84137. export var cloudProceduralTexturePixelShader: {
  84138. name: string;
  84139. shader: string;
  84140. };
  84141. }
  84142. declare module BABYLON {
  84143. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  84144. private _skyColor;
  84145. private _cloudColor;
  84146. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84147. updateShaderUniforms(): void;
  84148. get skyColor(): BABYLON.Color4;
  84149. set skyColor(value: BABYLON.Color4);
  84150. get cloudColor(): BABYLON.Color4;
  84151. set cloudColor(value: BABYLON.Color4);
  84152. /**
  84153. * Serializes this cloud procedural texture
  84154. * @returns a serialized cloud procedural texture object
  84155. */
  84156. serialize(): any;
  84157. /**
  84158. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  84159. * @param parsedTexture defines parsed texture data
  84160. * @param scene defines the current scene
  84161. * @param rootUrl defines the root URL containing cloud procedural texture information
  84162. * @returns a parsed Cloud Procedural BABYLON.Texture
  84163. */
  84164. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  84165. }
  84166. }
  84167. declare module BABYLON {
  84168. /** @hidden */
  84169. export var fireProceduralTexturePixelShader: {
  84170. name: string;
  84171. shader: string;
  84172. };
  84173. }
  84174. declare module BABYLON {
  84175. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  84176. private _time;
  84177. private _speed;
  84178. private _autoGenerateTime;
  84179. private _fireColors;
  84180. private _alphaThreshold;
  84181. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84182. updateShaderUniforms(): void;
  84183. render(useCameraPostProcess?: boolean): void;
  84184. static get PurpleFireColors(): BABYLON.Color3[];
  84185. static get GreenFireColors(): BABYLON.Color3[];
  84186. static get RedFireColors(): BABYLON.Color3[];
  84187. static get BlueFireColors(): BABYLON.Color3[];
  84188. get autoGenerateTime(): boolean;
  84189. set autoGenerateTime(value: boolean);
  84190. get fireColors(): BABYLON.Color3[];
  84191. set fireColors(value: BABYLON.Color3[]);
  84192. get time(): number;
  84193. set time(value: number);
  84194. get speed(): BABYLON.Vector2;
  84195. set speed(value: BABYLON.Vector2);
  84196. get alphaThreshold(): number;
  84197. set alphaThreshold(value: number);
  84198. /**
  84199. * Serializes this fire procedural texture
  84200. * @returns a serialized fire procedural texture object
  84201. */
  84202. serialize(): any;
  84203. /**
  84204. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  84205. * @param parsedTexture defines parsed texture data
  84206. * @param scene defines the current scene
  84207. * @param rootUrl defines the root URL containing fire procedural texture information
  84208. * @returns a parsed Fire Procedural BABYLON.Texture
  84209. */
  84210. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  84211. }
  84212. }
  84213. declare module BABYLON {
  84214. /** @hidden */
  84215. export var grassProceduralTexturePixelShader: {
  84216. name: string;
  84217. shader: string;
  84218. };
  84219. }
  84220. declare module BABYLON {
  84221. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  84222. private _grassColors;
  84223. private _groundColor;
  84224. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84225. updateShaderUniforms(): void;
  84226. get grassColors(): BABYLON.Color3[];
  84227. set grassColors(value: BABYLON.Color3[]);
  84228. get groundColor(): BABYLON.Color3;
  84229. set groundColor(value: BABYLON.Color3);
  84230. /**
  84231. * Serializes this grass procedural texture
  84232. * @returns a serialized grass procedural texture object
  84233. */
  84234. serialize(): any;
  84235. /**
  84236. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  84237. * @param parsedTexture defines parsed texture data
  84238. * @param scene defines the current scene
  84239. * @param rootUrl defines the root URL containing grass procedural texture information
  84240. * @returns a parsed Grass Procedural BABYLON.Texture
  84241. */
  84242. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  84243. }
  84244. }
  84245. declare module BABYLON {
  84246. /** @hidden */
  84247. export var marbleProceduralTexturePixelShader: {
  84248. name: string;
  84249. shader: string;
  84250. };
  84251. }
  84252. declare module BABYLON {
  84253. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  84254. private _numberOfTilesHeight;
  84255. private _numberOfTilesWidth;
  84256. private _amplitude;
  84257. private _jointColor;
  84258. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84259. updateShaderUniforms(): void;
  84260. get numberOfTilesHeight(): number;
  84261. set numberOfTilesHeight(value: number);
  84262. get amplitude(): number;
  84263. set amplitude(value: number);
  84264. get numberOfTilesWidth(): number;
  84265. set numberOfTilesWidth(value: number);
  84266. get jointColor(): BABYLON.Color3;
  84267. set jointColor(value: BABYLON.Color3);
  84268. /**
  84269. * Serializes this marble procedural texture
  84270. * @returns a serialized marble procedural texture object
  84271. */
  84272. serialize(): any;
  84273. /**
  84274. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  84275. * @param parsedTexture defines parsed texture data
  84276. * @param scene defines the current scene
  84277. * @param rootUrl defines the root URL containing marble procedural texture information
  84278. * @returns a parsed Marble Procedural BABYLON.Texture
  84279. */
  84280. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  84281. }
  84282. }
  84283. declare module BABYLON {
  84284. /** @hidden */
  84285. export var normalMapProceduralTexturePixelShader: {
  84286. name: string;
  84287. shader: string;
  84288. };
  84289. }
  84290. declare module BABYLON {
  84291. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  84292. private _baseTexture;
  84293. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84294. updateShaderUniforms(): void;
  84295. render(useCameraPostProcess?: boolean): void;
  84296. resize(size: any, generateMipMaps: any): void;
  84297. get baseTexture(): BABYLON.Texture;
  84298. set baseTexture(texture: BABYLON.Texture);
  84299. /**
  84300. * Serializes this normal map procedural texture
  84301. * @returns a serialized normal map procedural texture object
  84302. */
  84303. serialize(): any;
  84304. /**
  84305. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  84306. * @param parsedTexture defines parsed texture data
  84307. * @param scene defines the current scene
  84308. * @param rootUrl defines the root URL containing normal map procedural texture information
  84309. * @returns a parsed Normal Map Procedural BABYLON.Texture
  84310. */
  84311. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  84312. }
  84313. }
  84314. declare module BABYLON {
  84315. /** @hidden */
  84316. export var perlinNoiseProceduralTexturePixelShader: {
  84317. name: string;
  84318. shader: string;
  84319. };
  84320. }
  84321. declare module BABYLON {
  84322. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  84323. time: number;
  84324. timeScale: number;
  84325. translationSpeed: number;
  84326. private _currentTranslation;
  84327. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84328. updateShaderUniforms(): void;
  84329. render(useCameraPostProcess?: boolean): void;
  84330. resize(size: any, generateMipMaps: any): void;
  84331. /**
  84332. * Serializes this perlin noise procedural texture
  84333. * @returns a serialized perlin noise procedural texture object
  84334. */
  84335. serialize(): any;
  84336. /**
  84337. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  84338. * @param parsedTexture defines parsed texture data
  84339. * @param scene defines the current scene
  84340. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  84341. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  84342. */
  84343. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  84344. }
  84345. }
  84346. declare module BABYLON {
  84347. /** @hidden */
  84348. export var roadProceduralTexturePixelShader: {
  84349. name: string;
  84350. shader: string;
  84351. };
  84352. }
  84353. declare module BABYLON {
  84354. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  84355. private _roadColor;
  84356. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84357. updateShaderUniforms(): void;
  84358. get roadColor(): BABYLON.Color3;
  84359. set roadColor(value: BABYLON.Color3);
  84360. /**
  84361. * Serializes this road procedural texture
  84362. * @returns a serialized road procedural texture object
  84363. */
  84364. serialize(): any;
  84365. /**
  84366. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  84367. * @param parsedTexture defines parsed texture data
  84368. * @param scene defines the current scene
  84369. * @param rootUrl defines the root URL containing road procedural texture information
  84370. * @returns a parsed Road Procedural BABYLON.Texture
  84371. */
  84372. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  84373. }
  84374. }
  84375. declare module BABYLON {
  84376. /** @hidden */
  84377. export var starfieldProceduralTexturePixelShader: {
  84378. name: string;
  84379. shader: string;
  84380. };
  84381. }
  84382. declare module BABYLON {
  84383. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  84384. private _time;
  84385. private _alpha;
  84386. private _beta;
  84387. private _zoom;
  84388. private _formuparam;
  84389. private _stepsize;
  84390. private _tile;
  84391. private _brightness;
  84392. private _darkmatter;
  84393. private _distfading;
  84394. private _saturation;
  84395. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84396. updateShaderUniforms(): void;
  84397. get time(): number;
  84398. set time(value: number);
  84399. get alpha(): number;
  84400. set alpha(value: number);
  84401. get beta(): number;
  84402. set beta(value: number);
  84403. get formuparam(): number;
  84404. set formuparam(value: number);
  84405. get stepsize(): number;
  84406. set stepsize(value: number);
  84407. get zoom(): number;
  84408. set zoom(value: number);
  84409. get tile(): number;
  84410. set tile(value: number);
  84411. get brightness(): number;
  84412. set brightness(value: number);
  84413. get darkmatter(): number;
  84414. set darkmatter(value: number);
  84415. get distfading(): number;
  84416. set distfading(value: number);
  84417. get saturation(): number;
  84418. set saturation(value: number);
  84419. /**
  84420. * Serializes this starfield procedural texture
  84421. * @returns a serialized starfield procedural texture object
  84422. */
  84423. serialize(): any;
  84424. /**
  84425. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  84426. * @param parsedTexture defines parsed texture data
  84427. * @param scene defines the current scene
  84428. * @param rootUrl defines the root URL containing startfield procedural texture information
  84429. * @returns a parsed Starfield Procedural BABYLON.Texture
  84430. */
  84431. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  84432. }
  84433. }
  84434. declare module BABYLON {
  84435. /** @hidden */
  84436. export var woodProceduralTexturePixelShader: {
  84437. name: string;
  84438. shader: string;
  84439. };
  84440. }
  84441. declare module BABYLON {
  84442. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  84443. private _ampScale;
  84444. private _woodColor;
  84445. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  84446. updateShaderUniforms(): void;
  84447. get ampScale(): number;
  84448. set ampScale(value: number);
  84449. get woodColor(): BABYLON.Color3;
  84450. set woodColor(value: BABYLON.Color3);
  84451. /**
  84452. * Serializes this wood procedural texture
  84453. * @returns a serialized wood procedural texture object
  84454. */
  84455. serialize(): any;
  84456. /**
  84457. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  84458. * @param parsedTexture defines parsed texture data
  84459. * @param scene defines the current scene
  84460. * @param rootUrl defines the root URL containing wood procedural texture information
  84461. * @returns a parsed Wood Procedural BABYLON.Texture
  84462. */
  84463. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  84464. }
  84465. }